contour plot of a 3D Solid Object
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I imported the .stl file like this
fv = stlread('EXAMPLE.stl');
patch(fv,'FaceColor', [0.8 0.8 1.0], ...
'EdgeColor', 'none', ...
'FaceLighting', 'gouraud', ...
'AmbientStrength', 0.15);
grid off
hold on
axis equal
But I can't create the outline of the solid object. Anyone know how I can do?
For example the sphere in the figure

0 commentaires
Réponses (1)
Shadaab Siddiqie
le 18 Nov 2020
You can create outlines only on the edges not on a curved surface. For more information refer STL File Import.
3 commentaires
DGM
le 14 Juil 2025
Modifié(e) : DGM
le 14 Juil 2025
OP wound up in this scenario because of this exact same bad advice. OP was trying to simply import and plot an STL file, but everyone keeps trying to sell the PDE toolbox, which by your own admission, won't accomplish what they asked for.
MATLAB has stlread() and stlwrite() and triplot() and all sorts of tools. Why do those tools even exist if the staff just keep trying to recommend that canonical STL import is done with the PDE toolbox?
I'm basing my interpretation of the question on the sum of both of these threads. Here's an answer to what appears to be the question:
unzip stepholecube.stl.zip % for the forum
% this is FEX #22409 or one of its derivatives,
% none of which are complete decoders, and you don't need one
% unless you're running R2018a or newer anyway.
% even if you were, you would want FEX #51200 instead.
%fv = stlread('stepholecube.stl');
% just use the built-in decoder you already have.
% it's a bit annoying that it only supports
% one type of output format, but at least it's complete.
T = stlread('stepholecube.stl');
% here is _a_ set of setup parameters for patch()
patch('faces',T.ConnectivityList, ...
'vertices',T.Points, ...
'FaceColor',[0.8 0.8 1.0], ... % choose something
'EdgeColor','k', ... % but pick an edge color that gives contrast
'FaceLighting','flat'); % if you want edges to be clearly visible
view(3); view(-21,47); camlight % a little bit of light can help
axis equal; grid on
What appears acceptable may vary with model complexity, but in my opinion, if you want to see the edges for some reason, it helps to stay simple with lighting/shading settings so as to not reduce visual clarity. On the other side, as your model gets more complex, you might want to hide the edges so that they don't end up obscuring the surface completely. In that case, light and shadow start becoming more visually important.
If it wasn't about just the edges of the triangulation, but the actual level curves or perhaps other feature edges of a particular object, that would have needed to have been clarified. Again, I'm responding to the theme of both threads, not just the specific words in the question title.
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
