0001 function [node,elem,face]=readtetgen(fstub)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
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
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
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