[node,elem]=readsmf(fname) read simple model format (SMF) author: Qianqian Fang, <q.fang at neu.edu> date: 2007/11/21 input: fname: name of the SMF data file output: node: node coordinates of the mesh elem: list of elements of the mesh -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0001 function [node,elem]=readsmf(fname) 0002 % 0003 % [node,elem]=readsmf(fname) 0004 % 0005 % read simple model format (SMF) 0006 % 0007 % author: Qianqian Fang, <q.fang at neu.edu> 0008 % date: 2007/11/21 0009 % 0010 % input: 0011 % fname: name of the SMF data file 0012 % 0013 % output: 0014 % node: node coordinates of the mesh 0015 % elem: list of elements of the mesh 0016 % 0017 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) 0018 % 0019 node=[]; 0020 elem=[]; 0021 fid=fopen(fname,'rt'); 0022 while(~feof(fid)) 0023 line=fgetl(fid); 0024 if(line(1)=='v') 0025 dd=sscanf(line,'v %f %f %f'); 0026 if(length(dd)==3) 0027 node=[node;dd]; 0028 end 0029 elseif(line(1)=='f') 0030 dd=sscanf(line,'f %d %d %d'); 0031 if(length(dd)==3) 0032 elem=[elem;dd]; 0033 end 0034 end 0035 end 0036 fclose(fid); 0037 node=reshape(node,3,length(node)/3)'; 0038 elem=reshape(elem,3,length(elem)/3)';