Over 1000 faces when importing stl file to matlab

조회 수: 4 (최근 30일)
yonatan s
yonatan s 2017년 5월 6일
답변: DGM 2025년 4월 4일
hello, ive prepared a simple crater shape object (after creating it in autocad i rescaled it using mattercontrol slicer software), and exported it to matlab. when i look at the object properties (in matlab) it has about 1800 faces , 2700 edges and 900 vertices, which make it impossible to work with. i only need one face and one edge.
is there anything i can do in matlab to fix this? thanks
  댓글 수: 2
DGM
DGM 2025년 4월 3일
It's not possible to create any valid surface geometry with one face with one edge. A triangle has three edges.
Walter Roberson
Walter Roberson 2025년 4월 3일
At the very least there would have to be one face for the outside boundary. But if that is the only face, then the result would be a flat surface, contrary to the fact that it is intended to be a "crater shape". We have a contradiction, so asking for only one face is unreasonable.

댓글을 달려면 로그인하십시오.

답변 (1개)

DGM
DGM 2025년 4월 4일
I thought about this one, and maybe there's an answer. Maybe we're not talking about "faces" as in getting individual triangles or quads, but isolating surface regions of an object. Something like this:
unzip minbasesaddle.stl.zip % needed for the forum
% a 30x30 lofted surface with minimal base layer geometry
% this compares well to the described properties
% 904 vertices
% 1804 faces
% 2706 edges
T = stlread('minbasesaddle.stl');
% display it using patch()
patch('faces',T.ConnectivityList,'vertices',T.Points, ...
'facecolor','w','edgecolor','k');
view(3); camlight; view(10,33)
axis equal; grid on
xlabel('X'); ylabel('Y'); zlabel('Z')
% get only the top surface
V = T.Points;
F = T.ConnectivityList;
goodverts = V(:,3) > 0.1;
[F V] = prunebadverts(F,V,goodverts);
% display it using patch()
figure
patch('faces',F,'vertices',V,'facecolor','w','edgecolor','k');
view(3); camlight; view(10,33)
axis equal; grid on
xlabel('X'); ylabel('Y'); zlabel('Z')
function [F V] = prunebadverts(F,V,goodverts)
% Given a mask specifying which vertices are good,
% discard bad vertices and all faces which reference them.
% If no mask is given, get rid of vertices with NaN z-value.
% Remap face indices when done
if nargin == 2
goodverts = find(~isnan(V(:,3)));
else
goodverts = find(goodverts);
end
goodfaces = all(ismember(F,goodverts),2);
F = F(goodfaces,:); % get rid of junk faces
map = zeros(size(V,1),1); % remap vertex indices
map(goodverts) = 1:numel(goodverts);
V = V(goodverts,:); % get rid of junk vertices
F = map(F); % remap faces to match new vertex list
end
That said, even if we're talking about this as a region, it still has four "edges". Maybe OP had something cylindrical?

카테고리

Help CenterFile Exchange에서 STL (STereoLithography)에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by