[elist,nextfront]=advancefront(edges,loop,elen) advance an edge-front on an oriented surface to the next separated by one-element width author: Qianqian Fang, <q.fang at neu.edu> date: 2012/02/09 input: edges: edge list of an oriented surface mesh, must be in CCW order loop: a 2-column array, specifying a closed loop in CCW order elen: node number inside each element, if ignored, elen is set to 3 output: elist: list of triangles that is enclosed between the two edge-fronts nextfront: a new edge loop list representing the next edge-front -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0001 function [elist,nextfront]=advancefront(edges,loop,elen) 0002 % 0003 % [elist,nextfront]=advancefront(edges,loop,elen) 0004 % 0005 % advance an edge-front on an oriented surface to the next separated by 0006 % one-element width 0007 % 0008 % author: Qianqian Fang, <q.fang at neu.edu> 0009 % date: 2012/02/09 0010 % 0011 % input: 0012 % edges: edge list of an oriented surface mesh, must be in CCW order 0013 % loop: a 2-column array, specifying a closed loop in CCW order 0014 % elen: node number inside each element, if ignored, elen is set to 3 0015 % 0016 % output: 0017 % elist: list of triangles that is enclosed between the two 0018 % edge-fronts 0019 % nextfront: a new edge loop list representing the next edge-front 0020 % 0021 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) 0022 % 0023 0024 elist=[]; 0025 nextfront=[]; 0026 0027 if(nargin<3) elen=3; end 0028 0029 [hasedge, loc]=ismember(loop,edges,'rows'); 0030 0031 if(~all(hasedge)) 0032 error('loop edge is not defined in the mesh'); 0033 end 0034 0035 nodenum=size(edges,1)/elen; 0036 0037 elist=unique(mod(loc-1,nodenum))+1; 0038 nextfront=edges(elist,:); 0039 for i=1:elen-1 0040 nextfront=[nextfront;edges(elist+nodenum*i,:)]; 0041 end 0042 nextfront=setdiff(nextfront,loop,'rows'); 0043 0044 % remove reversed edge pairs 0045 [flag,loc]=ismember(nextfront,nextfront(:,[2 1]),'rows'); 0046 id=find(flag); 0047 if(~isempty(id)) 0048 delmark=flag; 0049 delmark(loc(find(loc>0)))=1; 0050 nextfront(find(delmark),:)=[]; 0051 end 0052 nextfront=nextfront(:,[2 1]); % reverse this loop, as it is reversed to the input loop