facecell=finddisconnsurf(f) subroutine to extract disconnected surfaces from a cluster of surfaces author: Qianqian Fang (fangq@nmr.mgh.harvard.edu) Date: 2008/03/06 input: f: faces defined by node indices for all surface triangles output: facecell: separated disconnected surface node indices -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0001 function facecell=finddisconnsurf(f) 0002 % 0003 % facecell=finddisconnsurf(f) 0004 % 0005 % subroutine to extract disconnected surfaces from a 0006 % cluster of surfaces 0007 % 0008 % author: Qianqian Fang (fangq@nmr.mgh.harvard.edu) 0009 % Date: 2008/03/06 0010 % 0011 % input: 0012 % f: faces defined by node indices for all surface triangles 0013 % 0014 % output: 0015 % facecell: separated disconnected surface node indices 0016 % 0017 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) 0018 % 0019 0020 facecell={}; 0021 subset=[]; 0022 while(~isempty(f)) 0023 idx=reshape(ismember(f,f(1,:)), size(f)); 0024 ii=find(sum(idx,2)); 0025 while(~isempty(ii)) 0026 if(isempty(ii)) break; end 0027 %ii=unique(ii); 0028 subset(end+1:end+length(ii),:)=f(ii,:); 0029 f(ii,:)=[]; 0030 idx=reshape(ismember(f,subset), size(f)); 0031 ii=find(sum(idx,2)); 0032 end 0033 if(~isempty(subset)) 0034 facecell{end+1}=subset; 0035 subset=[]; 0036 end 0037 end