フィルターのクリア

Find Concave Edges in STL-File

30 ビュー (過去 30 日間)
Timo Schmid
Timo Schmid 2021 年 1 月 19 日
コメント済み: Chris Hooper 2024 年 4 月 3 日 17:13
Hello all,
I am looking for a method to identify concave edges of an STL model which is not too computationally intensive..
The stlread function provides the vertex-coordinates (mx3), faces (nx3) and normals of the faces (nx3)... Where m is the number of all triangle vertices and n is the number of corresponding face-indices.
The edges I want to identify are the ones I marked red (as an example):
I tried different methods which all took ages too compute.
For example I created an Triangulation object using the triangulate function and compared the angle between normals of adjacent faces to further on store their common edge in case of exceeding a treshold - stopped working on this idea because of the sheer amount of calculations needed.
Pseudo Code:
TR = triangulation(faces,x,y,z);
% Compare all faces if they are neighbors
for queryId=1:(size(TR.ConnectivityList,1))
for compId = 1:(size(TR.ConnectivityList,1))
% ID for comparison is not equal to query ID
if queryId ~= compId
% If faces are connected calculate angle between face
% normals
if (TR.isConnected(queryId,compId))
n1 = TR.faceNormal(queryId);
n2 = TR.faceNormal(compId);
theta = acos(dot(n1,n2) / (norm(n1)*norm(n2)));
% Do further calculations here if theta > treshold
end
end
end
end
I also tried using the Triangulation objects property "featureEdges" to extract these edges, but unfortunately it doesn't yield the result I expected (right picture), although it works quite fine for the example (left picture) provided in the function file.
Hope anybody can help me. Thanks!
  2 件のコメント
Alfredo Bagalà
Alfredo Bagalà 2022 年 9 月 14 日
Hi, I have the same problem. Did you find any solution?
ET
ET 2023 年 7 月 15 日
Me too, any solutions?

サインインしてコメントする。

回答 (1 件)

ET
ET 2023 年 7 月 16 日
編集済み: ET 2023 年 7 月 16 日
featureEdges isn't working because the stl files have unique vertices defined for every triangle. This means that every triangle is all alone with no neighbours - so no features to find.
To fix this, you need to remap faces so that neighbouring triangles share vertices.
F = faces;
V = [x,y,z];
% find shared vertices and remap faces
[V2,~,IC] = uniquetol(V,'ByRows',true);
F2 = IC(F);
TR = triangulation(F2,V2);
trisurf(TR,'linestyle','none');
axis equal
grid on
hold all
% Find and plot feature edges
F = featureEdges(TR,pi/4);
x = HR.Points(:,1);
y = HR.Points(:,2);
z = HR.Points(:,3);
plot3(x(F)',y(F)',z(F)','-r','LineWidth',1.5)
  1 件のコメント
Chris Hooper
Chris Hooper 2024 年 4 月 3 日 17:13
Fantastic thanks!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSTL (STereoLithography) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by