.stl file generation with multiple tetrahedron inside cube
10 views (last 30 days)
Show older comments
i used command stlwrite but got the error
"Error using stlwrite (line 33)
Tetrahedron triangulation is not supported. "
i m trying to use this function but dont understand mistake or concept .
the variable has been uploaded .using 2nd function of stl export i get only triangle not tetra hedrons
e.g
i=1;
a=A{i};
DT3 = delaunayTriangulation(a);
nodes_file =DT3.Points ;
triangles_file=DT3.ConnectivityList ;
STL_file_name='abc.stl';
solid='defg';
[normalized_normal_vectors]=STL_Export(nodes_file, triangles_file, STL_file_name,solid);.
how to make the .stl file of tetrahedron ?
the resutls i get ..not tetrahedron but only triangles ?

0 Comments
Answers (1)
DGM
on 7 Oct 2025 at 22:18
An STL file represents a triangular mesh, not a tetrahedral mesh. Accordingly, the built-in encoder and FEX #20922 will return an error if given a tetra/quad mesh. FEX #24400 will instead create a file full of jumbled useless garbage because it's a buggy mess.
Unless you have a better definition of the requirements, just use the convex hull of the vertices. Either use convhull(), or if you need the DT object for other purposes, you could use the freeBoundary() method on it to get the hull instead.
% as given
load matlab.mat
for k = 1:numel(A)
% get the surface of the convex hull
V = A{k};
F = convhull(A{k});
% write it
fname = sprintf('test_%03d.stl',k);
stlwrite(triangulation(F,V),fname)
% visualize it
patch('faces',F,'vertices',V,'facecolor','none','edgecolor','k');
view(3); view(-30,47);
axis equal; grid on; hold on
end
In this example A(end) contains a list of vertices which define the unit cube seen above. All the others are irregular clusters of vertices.
0 Comments
See Also
Categories
Find more on Geometry and Mesh in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!