Home > vbmeg > external > iso2mesh > savedxf.m

savedxf

PURPOSE ^

SYNOPSIS ^

function savedxf(node,face,elem,fname)

DESCRIPTION ^

 savedxf(node,face,elem,fname)

 save a surface mesh to DXF format

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

 input:
      node: input, surface node list, dimension (nn,3)
      face: input, surface face element list, dimension (be,3)
      elem: input, tetrahedral element list, dimension (ne,4)
      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 savedxf(node,face,elem,fname)
0002 %
0003 % savedxf(node,face,elem,fname)
0004 %
0005 % save a surface mesh to DXF format
0006 %
0007 % author: Qianqian Fang, <q.fang at neu.edu>
0008 % date: 2010/04/25
0009 %
0010 % input:
0011 %      node: input, surface node list, dimension (nn,3)
0012 %      face: input, surface face element list, dimension (be,3)
0013 %      elem: input, tetrahedral element list, dimension (ne,4)
0014 %      fname: output file name
0015 %
0016 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0017 %
0018 
0019 if(nargin==2)
0020    fname=face;
0021    face=[];
0022    elem=[];
0023 end
0024 
0025 if(nargin==3)
0026    fname=elem;
0027    elem=[];
0028 end
0029 
0030 fid=fopen(fname,'wt');
0031 if(fid==-1)
0032     error('You do not have permission to save mesh files.');
0033 end
0034 
0035 fprintf(fid,'0\nSECTION\n2\nHEADER\n0\nENDSEC\n0\nSECTION\n2\nENTITIES\n');
0036 
0037 if(~isempty(face))
0038   fprintf(fid,'0\nPOLYLINE\n66\n1\n8\nI2M\n70\n64\n71\n%d\n72\n%d\n',size(node,1),size(face,1));
0039 end
0040 
0041 if(~isempty(node))
0042   node=node(:,1:3);
0043   fprintf(fid,'0\nVERTEX\n8\nI2M\n10\n%.16f\n20\n%.16f\n30\n%.16f\n70\n192\n',node');
0044 end
0045 
0046 if(~isempty(face))
0047   face=face(:,1:3);
0048   fprintf(fid,'0\nVERTEX\n8\nI2M\n62\n254\n10\n0.0\n20\n0.0\n30\n0.0\n70\n128\n71\n%d\n72\n%d\n73\n%d\n',face');
0049 end
0050 
0051 fprintf(fid,'0\nSEQEND\n0\nENDSEC\n');
0052 
0053 if(~isempty(face))
0054   fprintf(fid,'0\nSECTION\n2\nENTITIES\n0\nINSERT\n8\n1\n2\nMesh\n10\n0.0\n20\n0.0\n30\n0.0\n41\n1.0\n42\n1.0\n43\n1.0\n50\n0.0\n0\nENDSEC\n');
0055 end
0056 
0057 fprintf(fid,'0\nEOF');
0058 
0059 fclose(fid);

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