What code will open .stl files successfully?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
What code will open these .stl files successfully?
The following code was used to open .stl files in Matlab. You will need to download the .stl files found here -> https://www.thingiverse.com/thing:3699999/files
Code:
______________________________________________________________
fv = stlread('Aortic_root_initial_full.stl');
patch(fv,'FaceColor', [0.8 0.8 1.0], ...
'EdgeColor', 'none', ...
'FaceLighting', 'gouraud', ...
'AmbientStrength', 0.15);
% Add a camera light, and tone down the specular highlighting
camlight('headlight');
material('dull');
% Fix the axes scaling, and set a nice view angle
axis('image');
view([-135 35]);
_________________________________________________________________
I receive the following error:
Error using patch
Not enough input arguments.
0 comentarios
Respuestas (1)
Star Strider
el 14 de En. de 2024
Editada: Star Strider
el 14 de En. de 2024
I am having serious problems trying to access that file. (I’ll keep working on it.)
The patch function requires ‘x’, ‘y’, (and optionally ‘z’) coordinates, or 'Faces' and 'Vertices'. The chosen coordinates must enclose a 2D or 3D contour in order to work.
Example —
x = linspace(0, 10, 150).'; % Assume Column Orientation
y = [sin(2*pi*x/10)+2 cos(2*pi*x/10)-2];
figure
patch([x; flip(x)], [y(:,1); flip(y(:,2))], 'r')
Here, the ‘x’ argument traces out a forward-reverse path, as does the ‘y’ coordinate, however for it, two different vectors trace out two different contours.
The patch call in your code only has one provided cordinate, ‘fv’ (that may have the necessary information, however it is only one argument, so if they are available the necessary 'Faces' and 'Vertices' arguments must be extracted from it) and patch needs appropriate data for every object you want it to draw. See the patch documentation section on Specifying Faces and Vertices for those details.
EDIT — Added details.
Uz = unzip('Aortic_root_initial_full.zip');
filename = Uz{1}
[TR,fileformat,attributes,solidID] = stlread(filename);
P = TR.Points;
T = TR.ConnectivityList;
figure
trisurf(T, P(:,1), P(:,2), P(:,3), 'EdgeColor','none')
colormap(turbo)
axis('equal')
view(120,45)
Ax = gca;
Ax.Visible = 'off';
figure
trisurf(T, P(:,1), P(:,2), P(:,3), 'EdgeColor','none')
colormap(turbo)
axis('equal')
view(210,115)
Ax = gca;
Ax.Visible = 'off';
figure
patch('Faces',T, 'Vertices',P, 'FaceColor','r', 'EdgeColor',[1 1 1]*0.2, 'EdgeAlpha',0.5)
view(120,45)
Ax = gca;
Ax.Visible = 'off';
axis('equal')
EDIT — (14 Jan 2024 at 16:36)
After a couple Win 11 crashes, I managed to find the downloaded file and upload it here. I believe what you want is the trisurf plot, however I also provided a patch plot fot you to experiment with.
EDIT — (14 Jan 2024 at 20:48)
Corrected typographical errors, added rotated view showing aortic valve leaves and calcifications.
.
0 comentarios
Ver también
Categorías
Más información sobre Polygons en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



