[openedge,elemid]=surfedge(f) find the edge of an open surface or surface of a volume author: Qianqian Fang, <q.fang at neu.edu> date: 2007/11/21 input: f: input, surface face element list, dimension (be,3) output: openedge: list of edges of the specified surface elemid (optional): the corresponding index of the tetrahedron of an open-edge or triangle, elemid has the same length as openedge. -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0001 function [openedge,elemid]=surfedge(f,varargin) 0002 % 0003 % [openedge,elemid]=surfedge(f) 0004 % 0005 % find the edge of an open surface or surface of a volume 0006 % 0007 % author: Qianqian Fang, <q.fang at neu.edu> 0008 % date: 2007/11/21 0009 % 0010 % input: 0011 % f: input, surface face element list, dimension (be,3) 0012 % 0013 % output: 0014 % openedge: list of edges of the specified surface 0015 % elemid (optional): the corresponding index of the 0016 % tetrahedron of an open-edge or triangle, 0017 % elemid has the same length as openedge. 0018 % 0019 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) 0020 % 0021 0022 if(isempty(f)) 0023 openedge=[]; 0024 return; 0025 end 0026 0027 opt=varargin2struct(varargin{:}); 0028 findjunc=jsonopt('Junction',0,opt); 0029 0030 if(size(f,2)==3) 0031 edges=[f(:,[1,2]); 0032 f(:,[2,3]); 0033 f(:,[3,1])]; % create all the edges 0034 elseif(size(f,2)==4) 0035 edges=[f(:,[1,2,3]); 0036 f(:,[2,1,4]); 0037 f(:,[1,3,4]); 0038 f(:,[2,4,3])]; % create all the edges 0039 else 0040 error('surfedge only supports 2D and 3D elements'); 0041 end 0042 % node4=[f(:,3);f(:,2);f(:,1)]; % node idx concatinated 0043 edgesort=sort(edges,2); 0044 [foo,ix,jx]=unique(edgesort,'rows'); 0045 0046 if(isoctavemesh) 0047 u=unique(jx); 0048 if(size(f,2)==3 && findjunc) 0049 qx=u(hist(jx,u)>2); 0050 else 0051 qx=u(hist(jx,u)==1); 0052 end 0053 else 0054 vec=histc(jx,1:max(jx)); 0055 if(size(f,2)==3 && findjunc) 0056 qx=find(vec>2); 0057 else 0058 qx=find(vec==1); 0059 end 0060 end 0061 openedge=edges(ix(qx),:); 0062 if(nargout>=2) 0063 [elemid, iy]=ind2sub(size(f),ix(qx)); 0064 end 0065 % node4=node4(ix(qx));