-
Notifications
You must be signed in to change notification settings - Fork 5
/
save_fstri.m
34 lines (28 loc) · 698 Bytes
/
save_fstri.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
function [] = save_fstri(filename,points,faces,normals)
% SAVE_TRI Save FreeSurfer ASCII .tri file
%
% SYNTAX
% [] = SAVE_FSTRI(FILENAME,POINTS,FACES,NORMALS)
%
%
%
% Created by Alexandre Gramfort on 2008-03-09.
% Copyright (c) 2007-2011 Alexandre Gramfort. All rights reserved.
%
me = 'SAVE_FSTRI';
if nargin == 0
eval(['help ',lower(me)])
return
end
if nargin<4 | isempty(normals)
normals = mesh_normals(points,faces);
end
fid = fopen(filename,'w');
npoints = size(points,1);
nfaces = size(faces,1);
fprintf(fid,'%g\n',npoints);
fprintf(fid,'%g %g %g %g %g %g\n',[points, normals]');
fprintf(fid,'%g\n',nfaces);
fprintf(fid,'%g %g %g\n',faces');
fclose(fid);
end