0001 function mdl = stl_read(fname)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
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';
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