Home > vbmeg > external > iso2mesh > flatsegment.m

flatsegment

PURPOSE ^

SYNOPSIS ^

function mask=flatsegment(node,edge)

DESCRIPTION ^

 mask=flatsegment(node,edge)

 decompose edge loops into flat segments alone arbitrary planes of the bounding box

 author: Qianqian Fang, <q.fang at neu.edu>
 date: 2008/04/08

 this code is fragile: it can not handle curves with many co-linear
 nodes near the corner point

 input:   
    node:  x,y,z coordinates of each node of the mesh
    edge:  input, a single vector separated by NaN, each segment
           is a close-polygon consisted by node IDs 

 output:
    mask:  output, a cell, each element is a close-polygon 
           on x/y/z plane 

 -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mask=flatsegment(node,edge)
0002 %
0003 % mask=flatsegment(node,edge)
0004 %
0005 % decompose edge loops into flat segments alone arbitrary planes of the bounding box
0006 %
0007 % author: Qianqian Fang, <q.fang at neu.edu>
0008 % date: 2008/04/08
0009 %
0010 % this code is fragile: it can not handle curves with many co-linear
0011 % nodes near the corner point
0012 %
0013 % input:
0014 %    node:  x,y,z coordinates of each node of the mesh
0015 %    edge:  input, a single vector separated by NaN, each segment
0016 %           is a close-polygon consisted by node IDs
0017 %
0018 % output:
0019 %    mask:  output, a cell, each element is a close-polygon
0020 %           on x/y/z plane
0021 %
0022 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0023 %
0024 
0025 idx=edge;
0026 nn=length(idx);
0027 val=zeros(nn,1);
0028 for i=1:nn
0029   tet=mod(i:i+3,nn);
0030   tet(find(tet==0))=nn;
0031   val(i)=(abs(det([node(idx(tet),:),ones(4,1)]))>1e-5);
0032 end
0033 
0034 val(end+1:end+2)=val(1:2);
0035 mask={};
0036 oldend=1;
0037 for i=1:nn
0038     if(val(i)==1&val(i+1)==1&val(i+2)==0)
0039             val(i+2)=2;
0040             mask{count}=idx(oldend:i+2);
0041             count=count+1;
0042             oldend=i+2;
0043         else
0044             mask{count}=[idx(oldend:end);mask{1}];
0045             break;
0046         end
0047 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005