1 function nrbexport (nurbs, filename)
4 % NRBEXPORT: export NURBS geometries to a format compatible with the one used in GeoPDEs (version 0.6).
8 % nrbexport (nurbs, filename);
12 % nurbs : NURBS curve, surface or volume, see nrbmak.
13 % filename : name of the output file.
18 % The data of the nurbs structure is written in the file, in a format
19 % that can be read by GeoPDEs.
21 % Copyright (C) 2011 Rafael Vazquez
23 % This program is free software: you can redistribute it and/or modify
24 % it under the terms of the GNU General Public License as published by
25 % the Free Software Foundation, either version 2 of the License, or
26 % (at your option) any later version.
28 % This program is distributed in the hope that it will be useful,
29 % but WITHOUT ANY WARRANTY; without even the implied warranty of
30 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 % GNU General Public License for more details.
33 % You should have received a copy of the GNU General Public License
34 % along with this program. If not, see <http://www.gnu.org/licenses/>.
36 fid = fopen (filename, 'w');
38 error ('nrbexport: cannot open file %s', filename);
41 ndim = numel (nurbs(1).order);
42 npatch = numel (nurbs);
43 fprintf (fid, '%s\n', '# nurbs mesh v.0.7');
44 fprintf (fid, '%s\n', '#');
45 fprintf (fid, '%s\n', ['# ' date]);
46 fprintf (fid, '%s\n', '#');
48 fprintf (fid, '%2i', ndim, 1);
51 fprintf (fid, '%s %i', 'PATCH', iptc);
53 fprintf (fid, '%2i', nurbs(iptc).order-1);
55 fprintf (fid, '%2i', nurbs(iptc).number);
58 fprintf (fid, '%1.7f ', nurbs(iptc).knots{ii});
64 fprintf (fid, '%1.15f ', nurbs(iptc).coefs(ii,:,:));
67 fprintf (fid, '%1.15f ', nurbs(iptc).coefs(4,:,:));
71 fprintf (fid, '%1.15f ', nurbs(iptc).coefs(ii,:,:,:));
74 fprintf (fid, '%1.15f ', nurbs(iptc).coefs(4,:,:,:));