www.pudn.com > AFEM@matlab.rar > putmesh.m, change:2006-10-17,size:1697b


function putmesh(mesh, filename, format, varargin)
% PUTMESH saves the current mesh to a file with designated file name and
% format. 
% 
% USAGE
%    putmesh(mesh, filename, format, varargin)
%
% INPUT 
%       mesh:  current mesh structure
%   filename:  file name you want to use to save mesh and solution
%     format:  picture format 
%              supported format includes ps, eps, ps2, eps2, jpeg, png,
%              etc (see the help of MATLAB command print), default format
%              is "epsc".
%
% Examples
%    putmesh(mesh)
%    putmesh(mesh, 'savedmesh', 'png')
%    putmesh(mesh, 'savedmesh', 'eps', 'tiff', 'r300')
%

% L. Chen & C. Zhang 10-17-2006

%--------------------------------------------------------------------------
% Generate opitional data
%--------------------------------------------------------------------------
if (nargin <= 1), filename = 'meshfile'; end % default file name
if (nargin <= 2), format = 'epsc'; end % default file format

parameters = []; % optional parameters
if (nargin >= 4)
    for i = 1:length(varargin)
        parameters = [parameters, ' -', varargin{i}];
    end
end

%--------------------------------------------------------------------------
% Plot and save mesh
%--------------------------------------------------------------------------
fighandle = figure; hold on
trisurf(mesh.elem,mesh.node(:,1),mesh.node(:,2),zeros(size(mesh.node,1),1));
view(2), axis equal, axis off;
eval(['print', ' -d', format, parameters, ' ', filename]);
close(fighandle);

%--------------------------------------------------------------------------
% End of function PUTMESH
%--------------------------------------------------------------------------