Home > vbmeg > external > iso2mesh > readgts.m

readgts

PURPOSE ^

SYNOPSIS ^

function [node,elem,edges,edgemap]=readgts(fname)

DESCRIPTION ^

 [node,elem,edges,edgemap]=readgts(fname)

 read GNU Triangulated Surface files (GTS)

 author: Qianqian Fang, <q.fang at neu.edu>
 date: 2008/03/28

 input:
    fname: name of the OFF data file

 output:
    node: node coordinates of the mesh
    elem: list of elements of the surface mesh
    edges: the edge list section in the GTS file (optional)
    edgemap: the face section (in terms of edge indices) in the GTS file
             (optional)

 -- 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,edges,edgemap]=readgts(fname)
0002 %
0003 % [node,elem,edges,edgemap]=readgts(fname)
0004 %
0005 % read GNU Triangulated Surface files (GTS)
0006 %
0007 % author: Qianqian Fang, <q.fang at neu.edu>
0008 % date: 2008/03/28
0009 %
0010 % input:
0011 %    fname: name of the OFF data file
0012 %
0013 % output:
0014 %    node: node coordinates of the mesh
0015 %    elem: list of elements of the surface mesh
0016 %    edges: the edge list section in the GTS file (optional)
0017 %    edgemap: the face section (in terms of edge indices) in the GTS file
0018 %             (optional)
0019 %
0020 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0021 %
0022 
0023 node=[];
0024 elem=[];
0025 fid=fopen(fname,'rt');
0026 line=fgetl(fid);
0027 dim=sscanf(line,'%d',3);
0028 node   =fscanf(fid,'%f',[3,dim(1)])';
0029 edges  =fscanf(fid,'%d',[2,dim(2)])';
0030 edgemap=fscanf(fid,'%d',[3,dim(3)])';
0031 fclose(fid);
0032 
0033 edget=edges';
0034 len=size(edgemap,1);
0035 elem=reshape(edget(:,edgemap'),6,len)';
0036 try
0037     for i=1:len
0038       elem(i,1:3)=unique(elem(i,:));
0039     end
0040 catch
0041     error(sprint('invalid GTS face, id=%d\n',i));
0042 end
0043 elem=elem(:,1:3);

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