forked from fangq/iso2mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
readmedit.m
39 lines (38 loc) · 963 Bytes
/
readmedit.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function [node,elem,face]=readmedit(filename)
%
% [node,elem,face]=readmedit(filename)
%
% read Medit mesh format
%
% author: Qianqian Fang, <q.fang at neu.edu>
%
% input:
% fname: name of the medit data file
%
% output:
% node: node coordinates of the mesh
% elem: list of elements of the mesh
% face: list of surface triangles of the mesh
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%
node=[];
elem=[];
face=[];
fid=fopen(filename,'rt');
while(~feof(fid))
key=fscanf(fid,'%s',1);
if(strcmp(key,'End')) break; end
val=fscanf(fid,'%d',1);
if(strcmp(key,'Vertices'))
node=fscanf(fid,'%f',4*val);
node=reshape(node,[4 val])';
elseif(strcmp(key,'Triangles'))
face=fscanf(fid,'%d',4*val);
face=reshape(face,[4 val])';
elseif(strcmp(key,'Tetrahedra'))
elem=fscanf(fid,'%d',5*val);
elem=reshape(elem,[5 val])';
end
end
fclose(fid);