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, ~, n] = unique(N,'rows');
0018 mdl.nodes = nodes;
0019 mdl.elems = reshape(uint32(n)',3,[])';
0020 same = mdl.elems(:,1) == mdl.elems(:,2) | mdl.elems(:,2) == mdl.elems(:,3) | mdl.elems(:,1) == mdl.elems(:,3);
0021 mdl.elems(same,:) = [];
0022 mdl.boundary = mdl.elems;
0023
0024 [~,name,ext] = fileparts(fname);
0025 mdl = eidors_obj('fwd_model',mdl,'name',[name ext]);
0026
0027
0028 function do_unit_test
0029 a = [
0030 -0.8981 -0.7492 -0.2146 0.3162 0.7935 0.9615 0.6751 0.0565 -0.3635 -0.9745
0031 0.1404 0.5146 0.3504 0.5069 0.2702 -0.2339 -0.8677 -0.6997 -0.8563 -0.4668 ]';
0032 fmdl = ng_mk_extruded_model({2,{a,0.5*a,0.2*a},1},[],[]);
0033
0034 fv.faces = find_boundary(fmdl);
0035 fv.vertices = fmdl.nodes;
0036 stl_write(fv, 'test.stl');
0037 mdl = stl_read('test.stl');
0038 show_fem(mdl)
0039 delete('test.stl');
0040
0041