


[newnode,newelem]=mergesurf(node1,elem1,node2,elem2,...)
merge two or more triangular meshes and split intersecting elements
author: Qianqian Fang <fangq at nmr.mgh.harvard.edu>
input:
node: node coordinates, dimension (nn,3)
elem: tetrahedral element or triangle surface (nn,3)
output:
newnode: the node coordinates after merging, dimension (nn,3)
newelem: tetrahedral element or surfaces after merging (nn,4) or (nhn,5)
note: you can call meshcheckrepair for the output newnode and
newelem to remove the duplicated nodes or elements
example:
[node1,face1,elem1]=meshabox([0 0 0],[10 10 10],1,1);
[node2,face2,elem2]=meshasphere([5 5 10],3,0.3,3);
[newnode,newface]=mergemesh(node1,face1,node2,face2);
plotmesh(newnode,newface,'x>5');
-- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)

0001 function [newnode,newelem]=mergesurf(node,elem,varargin) 0002 % 0003 % [newnode,newelem]=mergesurf(node1,elem1,node2,elem2,...) 0004 % 0005 % merge two or more triangular meshes and split intersecting elements 0006 % 0007 % author: Qianqian Fang <fangq at nmr.mgh.harvard.edu> 0008 % 0009 % input: 0010 % node: node coordinates, dimension (nn,3) 0011 % elem: tetrahedral element or triangle surface (nn,3) 0012 % 0013 % output: 0014 % newnode: the node coordinates after merging, dimension (nn,3) 0015 % newelem: tetrahedral element or surfaces after merging (nn,4) or (nhn,5) 0016 % 0017 % note: you can call meshcheckrepair for the output newnode and 0018 % newelem to remove the duplicated nodes or elements 0019 % 0020 % example: 0021 % 0022 % [node1,face1,elem1]=meshabox([0 0 0],[10 10 10],1,1); 0023 % [node2,face2,elem2]=meshasphere([5 5 10],3,0.3,3); 0024 % [newnode,newface]=mergemesh(node1,face1,node2,face2); 0025 % plotmesh(newnode,newface,'x>5'); 0026 % 0027 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) 0028 % 0029 0030 len=length(varargin); 0031 newnode=node; 0032 newelem=elem; 0033 if(len>0 & mod(len,2)~=0) 0034 error('you must give node and element in pairs'); 0035 end 0036 for i=1:2:len 0037 no=varargin{i}; 0038 el=varargin{i+1}; 0039 [newnode,newelem]=surfboolean(newnode,newelem,'all',no,el); 0040 end