-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathsavetetgennode.m
35 lines (33 loc) · 908 Bytes
/
savetetgennode.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
function savetetgennode(node, fname)
%
% savetetgennode(node,fname)
%
% save a mesh node list to tetgen .node format
%
% author: Qianqian Fang, <q.fang at neu.edu>
%
% input:
% node: node coordinates, dimension (nn,3)
% columns beyound the 3rd column are treated as
% markers and attributes associated with the node
% fname: output file name
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%
hasprop = 0;
attrstr = '';
markers = '';
fid = fopen(fname, 'wt');
if (fid == 0)
error(['can not write to file ' fname]);
end
if (size(node, 2) >= 5)
hasprop = size(node, 2) - 4;
attrstr = repmat('%e ', 1, hasprop);
end
if (size(node, 2) >= 4)
markers = '%d';
end
fprintf(fid, '%d %d %d %d\n', size(node, 1), 3, hasprop, size(node, 2) >= 4);
fprintf(fid, ['%d %e %e %e ' attrstr markers '\n'], [(1:size(node, 1))' - 1 node]');
fclose(fid);