stl_read

PURPOSE ^

STL_READ Read in an stl file and output an EIDORS model struct

SYNOPSIS ^

function mdl = stl_read(fname)

DESCRIPTION ^

STL_READ  Read in an stl file and output an EIDORS model struct
 This function is a wrapper for the Matlab Central contribution by 
 Adam H. Aitkenhead called READ_stl from "Mesh voxelization"
 http://www.mathworks.de/matlabcentral/fileexchange/27390-mesh-voxelisation

 See also stl_write

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function mdl = stl_read(fname)
0002 %STL_READ  Read in an stl file and output an EIDORS model struct
0003 % This function is a wrapper for the Matlab Central contribution by
0004 % Adam H. Aitkenhead called READ_stl from "Mesh voxelization"
0005 % http://www.mathworks.de/matlabcentral/fileexchange/27390-mesh-voxelisation
0006 %
0007 % See also stl_write
0008 
0009 % Copyright 2013 Bartłomiej Grychtol
0010 % License: GPL version 2 or 3
0011 % $Id: stl_read.m 5112 2015-06-14 13:00:41Z aadler $
0012 
0013 if ischar(fname) && strcmp(fname, 'UNIT_TEST'), do_unit_test; return, end
0014 
0015 [V] = READ_stl(fname);
0016 N = reshape(shiftdim(V,1),3,[])';
0017 [nodes m n] = unique(N,'rows');
0018 mdl.nodes = nodes;
0019 mdl.elems = reshape(n',3,[])';
0020 mdl.type  = 'fwd_model'; % sort of
0021 mdl.boundary = mdl.elems;
0022 
0023 
0024 function do_unit_test
0025    a = [
0026    -0.8981   -0.7492   -0.2146    0.3162    0.7935    0.9615    0.6751    0.0565   -0.3635   -0.9745
0027     0.1404    0.5146    0.3504    0.5069    0.2702   -0.2339   -0.8677   -0.6997   -0.8563   -0.4668 ]';
0028 fmdl = ng_mk_extruded_model({2,{a,0.5*a,0.2*a},1},[],[]);
0029 
0030 fv.faces    = find_boundary(fmdl);
0031 fv.vertices = fmdl.nodes;
0032 stl_write(fv, 'test.stl');
0033 mdl = stl_read('test.stl');
0034 show_fem(mdl)
0035 delete('test.stl');
0036 
0037

Generated on Wed 21-Jun-2017 09:29:07 by m2html © 2005