Home > vbmeg > external > iso2mesh > orderloopedge.m

orderloopedge

PURPOSE ^

SYNOPSIS ^

function newedge=orderloopedge(edge)

DESCRIPTION ^

 [newedge]=orderloopedge(edge)

 order the node list of a simple loop based on connection sequence

 author: Qianqian Fang (fangq <at> nmr.mgh.harvard.edu)
 date:   2008/05

 input: 
        edge: a loop consisted by a sequence of edges, each row 
              is an edge with two integers: start/end node index

 output:
        newedge: reordered edge node list

 -- 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 newedge=orderloopedge(edge)
0002 %
0003 % [newedge]=orderloopedge(edge)
0004 %
0005 % order the node list of a simple loop based on connection sequence
0006 %
0007 % author: Qianqian Fang (fangq <at> nmr.mgh.harvard.edu)
0008 % date:   2008/05
0009 %
0010 % input:
0011 %        edge: a loop consisted by a sequence of edges, each row
0012 %              is an edge with two integers: start/end node index
0013 %
0014 % output:
0015 %        newedge: reordered edge node list
0016 %
0017 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0018 %
0019 
0020 % this subroutine can not process bifercation
0021 
0022 ne=size(edge,1);
0023 newedge=zeros(size(edge));
0024 newedge(1,:)=edge(1,:);
0025 
0026 for i=2:ne
0027   [row,col]=find(edge(i:end,:)==newedge(i-1,2));
0028   if(length(row)==1) % loop node
0029      newedge(i,:)=[newedge(i-1,2),edge(row+i-1,3-col)];
0030      edge([i,row+i-1],:)=edge([row+i-1,i],:);
0031   elseif (length(row)>=2)
0032      error('bifercation is found,exit');
0033   elseif (length(row)==0)
0034      error(['open curve at ' num2str(edge(i-1,2)) ]);
0035   end
0036 end
0037

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