/usr/share/octave/packages/fpl-1.3.5/savevtkvector.m is in octave-fpl 1.3.5-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | ## Copyright (C) 2010 Kurnia Wano, Levente Torok
##.
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##.
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##.
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING. If not, see <http://www.gnu.org/licenses/>.
##
## -*- texinfo -*-
## @deftypefn {Function File} [@var{status}] = savevtkvector (@var{X}, @var{Y}, @var{Z}, @var{filename})
##
## Save a 3-D vector field of components @var{X}, @var{Y}, @var{Z} to the file @var{filename} in VTK format.
##
## This file format is used by Mayavi2 or ParaView for example.
## X, Y and Z should be 3-D arrays of the same
## size, each storing vector components in a given Cartesian direction.
##
## If no write errors occurred, output argument @var{status} is set to 1, otherwise 0.
##
## @seealso{savevtk}
## @end deftypefn
##
## Author: Kurnia Wano, Levente Torok <TorokLev@gmail.com>
## Created: 2010-08-02 matlab version
## Updates: 2010-11-03 octave adoptatoin
## 2011-08-17 remove matlab style short-cicuit operator, indentation, help text
##
function [status] = savevtkvector (X, Y, Z, filename='vtkvector.vtk')
status = 0;
if (nargin < 4), usage ("[status] = savevtkvector (X, Y, Z, filename='vtkvector.vtk')"); endif
if ((size(X) ~= size(Y)) || (size(X) ~= size(Z)))
error ("Error: velocity arrays of unequal size\n");
end
[ny, nx, nz] = size (datax);
xx = 1:size (datax, 2);
yy = 1:size (datax, 1);
zz = 1:size (datax, 3);
datax = datax(:)';
datay = datay(:)';
dataz = dataz(:)';
## Header
if (ischar (filename))
[ fid, msg ] = fopen (fullfile (outputd, filename), 'w');
if ( fid < 1 )
error ("Cannot open the file for saving: %s", msg);
endif
else
usage ("Filename expected for arg # 2");
endif
try
fprintf (fid, '%s\n', '# vtk DataFile Version 3.0');
fprintf (fid, '%s\n', '3D LFF extrapolation');
fprintf (fid, '%s\n', 'ASCII' );
fprintf (fid, '%s\n', 'DATASET RECTILINEAR_GRID');
fprintf (fid, '%s %1.0i %1.0i %1.0i\n', 'DIMENSIONS',nx, ny, nz);
fprintf (fid, '%s %1.0i %s\n', 'X_COORDINATES', nx, 'float');
fprintf (fid, '%1.0i ', xx);
fprintf (fid, '\n%s %1.0i %s\n', 'Y_COORDINATES', ny, 'float');
fprintf (fid, '%1.0i ', yy);
fprintf (fid, '\n%s %1.0i %s\n', 'Z_COORDINATES', nz, 'float');
fprintf (fid, '%1.0i ', zz);
## Data
fprintf (fid, '\n%s %1.0i','POINT_DATA', nx*ny*nz );
fprintf (fid, '\n%s\n', 'VECTORS BFIELD float');
fprintf (fid, '%6.2f %6.2f %6.2f\n', [datax;datay;dataz]);
fclose (fid);
status = 1;
catch
error ("Error writing file %s - disk full?", filename)
end_try_catch
endfunction
|