Home > vbmeg > external > iso2mesh > readtetgen.m

readtetgen

PURPOSE ^

SYNOPSIS ^

function [node,elem,face]=readtetgen(fstub)

DESCRIPTION ^

 [node,elem,face]=readtetgen(fstub)

 read tetgen output files

 author: Qianqian Fang, <q.fang at neu.edu>
 date: 2007/11/21

 input:
    fstub: file name stub

 output:
    node: node coordinates of the tetgen mesh
    elem: tetrahedra element list of the tetgen mesh
    face: surface triangles of the tetgen mesh

 -- 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 [node,elem,face]=readtetgen(fstub)
0002 %
0003 % [node,elem,face]=readtetgen(fstub)
0004 %
0005 % read tetgen output files
0006 %
0007 % author: Qianqian Fang, <q.fang at neu.edu>
0008 % date: 2007/11/21
0009 %
0010 % input:
0011 %    fstub: file name stub
0012 %
0013 % output:
0014 %    node: node coordinates of the tetgen mesh
0015 %    elem: tetrahedra element list of the tetgen mesh
0016 %    face: surface triangles of the tetgen mesh
0017 %
0018 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0019 %
0020 
0021 % read node file
0022 fp=fopen([fstub,'.node'],'rt');
0023 if(fp==0) 
0024     error('node file is missing!'); 
0025 end
0026 [dim,count] = fscanf(fp,'%d',4);
0027 if(count<4) error('wrong node file'); end
0028 node=fscanf(fp,'%f',[4,dim(1)]);
0029 idx=node(1,:);
0030 node=node(2:4,:)';
0031 fclose(fp);
0032 
0033 % read element file
0034 fp=fopen([fstub,'.ele'],'rt');
0035 if(fp==0) 
0036         error('elem file is missing!'); 
0037 end
0038 [dim,count] = fscanf(fp,'%d',3);
0039 if(count<3) error('wrong elem file'); end
0040 elem=fscanf(fp,'%d',[dim(2)+dim(3)+1,dim(1)]);
0041 elem=elem';
0042 elem(:,1)=[];
0043 elem(:,1:dim(2))=elem(:,1:dim(2))+(1-idx(1));
0044 fclose(fp);
0045 
0046 % read surface mesh file
0047 fp=fopen([fstub,'.face'],'rt');
0048 if(fp==0)
0049         error('surface data file is missing!');
0050 end
0051 [dim,count] = fscanf(fp,'%d',2);
0052 if(count<2) error('wrong surface file'); end
0053 face=fscanf(fp,'%d',[5,dim(1)]);
0054 face=[face(2:end-1,:)+1;face(end,:)]';
0055 fclose(fp);
0056

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