Home > matGeom > meshes3d > writeMesh_stl.m

writeMesh_stl

PURPOSE ^

WRITEMESH_STL Write mesh data in the STL format.

SYNOPSIS ^

function writeMesh_stl(fileName, vertices, faces, varargin)

DESCRIPTION ^

WRITEMESH_STL Write mesh data in the STL format.

   writeMesh_stl(FNAME, VERTICES, FACES)

   writeMesh_stl(FNAME, MESH)

   writeMesh_stl(FNAME, VERTICES, FACES, ...) see stlwrite for additonal
   options

   Example
   mesh = cylinderMesh([60 50 40 10 20 30 5], 1);
   writeMesh_stl('Cylinder.stl', mesh, 'bin');

   References
   Wrapper function for MATLAB's build-in stlwrite.

   See also
   meshes3d, writeMesh, writeMesh_off, writeMesh_ply

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function writeMesh_stl(fileName, vertices, faces, varargin)
0002 %WRITEMESH_STL Write mesh data in the STL format.
0003 %
0004 %   writeMesh_stl(FNAME, VERTICES, FACES)
0005 %
0006 %   writeMesh_stl(FNAME, MESH)
0007 %
0008 %   writeMesh_stl(FNAME, VERTICES, FACES, ...) see stlwrite for additonal
0009 %   options
0010 %
0011 %   Example
0012 %   mesh = cylinderMesh([60 50 40 10 20 30 5], 1);
0013 %   writeMesh_stl('Cylinder.stl', mesh, 'bin');
0014 %
0015 %   References
0016 %   Wrapper function for MATLAB's build-in stlwrite.
0017 %
0018 %   See also
0019 %   meshes3d, writeMesh, writeMesh_off, writeMesh_ply
0020 
0021 % ------
0022 % Author: oqilipo
0023 % Created: 2021-02-13, using Matlab 9.9.0.1538559 (R2020b)
0024 % Copyright 2021
0025 
0026 %% Check inputs
0027 if ~ischar(fileName)
0028     error('First argument must contain the name of the file');
0029 end
0030 
0031 % optionnaly parses data
0032 if isstruct(vertices)
0033     if nargin > 2
0034         varargin = [{faces} varargin{:}];
0035     end
0036     faces = vertices.faces;
0037     vertices = vertices.vertices;
0038 end
0039 
0040 %% Write STL
0041 TR = triangulation(faces, vertices);
0042 stlwrite(TR,fileName, varargin{:})
0043 
0044 end

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019