gmsh_stl2tet

PURPOSE ^

GMSH_STL2TET creates a tetrahedral mesh from an stl file

SYNOPSIS ^

function mdl = gmsh_stl2tet(stlfile, maxh, extra)

DESCRIPTION ^

GMSH_STL2TET creates a tetrahedral mesh from an stl file
 mdl = gmsh_stl2tet(stlfile, maxh, extra) where:
        mdl - EIDORS fwd_model struct
    stlfile - path to stl file
       maxh - maximum edge length (default: coarse mesh)
      extra - extra command line options to gmsh

 NOTE: Only one surface per file is allowed.

 See also CALL_GMSH

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mdl = gmsh_stl2tet(stlfile, maxh, extra)
0002 %GMSH_STL2TET creates a tetrahedral mesh from an stl file
0003 % mdl = gmsh_stl2tet(stlfile, maxh, extra) where:
0004 %        mdl - EIDORS fwd_model struct
0005 %    stlfile - path to stl file
0006 %       maxh - maximum edge length (default: coarse mesh)
0007 %      extra - extra command line options to gmsh
0008 %
0009 % NOTE: Only one surface per file is allowed.
0010 %
0011 % See also CALL_GMSH
0012 
0013 % (C) Bartlomiej Grychtol, 2012.
0014 % $Id: gmsh_stl2tet.m 4132 2013-06-04 10:45:37Z bgrychtol $
0015 
0016 if nargin < 3
0017    extra = [];
0018 end
0019 if nargin > 1 && ~isempty(maxh)
0020    extra = [' -clmax ' num2str(maxh), ' ', extra];
0021 end
0022 
0023 stem = strrep(stlfile,'.stl','');
0024 %TODO: Some of this could be exposed as options (Algorithm, Optimize, ...)
0025 fid = fopen([stem '.geo'],'w');
0026 fprintf(fid,'Merge "%s";\n',stlfile);
0027 fprintf(fid,'Surface Loop(1) = {1};\n');
0028 fprintf(fid,'Volume(1) = {1};\n');
0029 fprintf(fid,'Physical Volume(''object'') = {1};\n');
0030 fprintf(fid,'Mesh.Algorithm3D=4;\n'); %1=delaunay (tetgen) and 4=frontal (netgen)
0031 fprintf(fid,'Mesh.OptimizeNetgen=1;\n');
0032 fclose(fid);
0033 
0034 call_gmsh([stem '.geo'], 3, extra);
0035 
0036 mdl = gmsh_mk_fwd_model([stem '.msh'],[],[],[]);

Generated on Tue 31-Dec-2019 17:03:26 by m2html © 2005