Home > vbmeg > external > iso2mesh > savemedit.m

savemedit

PURPOSE ^

SYNOPSIS ^

function savemedit(node,face,elem,fname)

DESCRIPTION ^

 savemedit(node,face,elem,fname)

 save a surface or tetrahedral mesh to Medit format

 author: Qianqian Fang, <q.fang at neu.edu>
 date: 2010/10/30

 input:
      node: input, surface node list, dimension (nn,3 or 4)
      face: input, surface face element list, dimension (be,3 or 4)
      elem: input, tetrahedral element list, dimension (ne,4 or 5)
      fname: output file name

 -- 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 savemedit(node,face,elem,fname)
0002 %
0003 % savemedit(node,face,elem,fname)
0004 %
0005 % save a surface or tetrahedral mesh to Medit format
0006 %
0007 % author: Qianqian Fang, <q.fang at neu.edu>
0008 % date: 2010/10/30
0009 %
0010 % input:
0011 %      node: input, surface node list, dimension (nn,3 or 4)
0012 %      face: input, surface face element list, dimension (be,3 or 4)
0013 %      elem: input, tetrahedral element list, dimension (ne,4 or 5)
0014 %      fname: output file name
0015 %
0016 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0017 %
0018 
0019 fid=fopen(fname,'wt');
0020 if(fid==-1)
0021     error('You do not have permission to save mesh files.');
0022 end
0023 
0024 fprintf(fid,'# Generated by iso2mesh: http://iso2mesh.sf.net\n');
0025 fprintf(fid,'MeshVersionFormatted\t1\nDimension\t3\n');
0026 
0027 if(~isempty(node))
0028   if(size(node,2)<=3) node(1,4)=0; end
0029   fprintf(fid,'Vertices\t%d\n',size(node,1));
0030   fprintf(fid,'%e\t%e\t%e\t%.0f\n',node(:,1:4)');
0031 end
0032 
0033 if(~isempty(face))
0034   if(size(face,2)<=3) face(1,4)=0; end
0035   fprintf(fid,'Triangles\t%d\n',size(face,1));
0036   fprintf(fid,'%d\t%d\t%d\t%d\n',face(:,1:4)');
0037 end
0038 
0039 if(~isempty(elem))
0040   if(size(elem,2)<=4) elem(1,5)=0; end
0041   fprintf(fid,'Tetrahedra\t%d\n',size(elem,1));
0042   fprintf(fid,'%d\t%d\t%d\t%d\t%d\n',elem(:,1:5)');
0043 end
0044 
0045 fprintf(fid,'End');
0046 
0047 fclose(fid);

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