필터 지우기
필터 지우기

Find discontinuous areas in geometry

조회 수: 4 (최근 30일)
Chenglin Li
Chenglin Li 2023년 6월 9일
댓글: Chenglin Li 2023년 6월 15일
There is an stl file of a concave surface, known the vertices and joint indexes of each face, as well as the normal vectors of each face, to obtain the discontinuous region, that is, the concave face and the vertex information contained in the face, as shown in the figure below.
My idea is to find the concave part by judging that the Angle between the normal vectors of the adjacent faces is less than or equal to 90 degrees, and output the concave faces, but my program outputs all the faces, I don't know why
[VF] = stlread("ASCao.stl");
% normal is for every outward facing normal vector
[normals] = lin_compute_mesh_normal(VF.Points,VF.ConnectivityList);
% %Plot the mesh with the normals:
lin_plot_face_normal(VF.Points,VF.ConnectivityList,normals);
faces = VF.ConnectivityList;
[verticesOnFace] = findVerticesOnFace(2, VF.Points, faces);
% Find the concave face
concaveFaces = [];
for i = 1 : size(VF.ConnectivityList, 1)
% Gets the face ids of the current and adjacent faces
faceId = i;
adjFaceIds = vertexAttachments(faces, faceId);
% Determine whether the current face is recessed
isConcave = false;
for j = 1 : size(adjFaceIds, 2)
if dot(normals(faceId,:), normals(adjFaceIds(j),:)) <= 0
% The Angle between the normal vectors of adjacent faces is less than or equal to 90 degrees
% (that is, both sides are less inclined, and there may be a concave part).
isConcave = true;
break;
end
end
% If the current face is concave, it is added to the result array
if isConcave
concaveFaces = [concaveFaces; faceId];
end
end
% Output the ID of the concave face
disp(concaveFaces);
function [attachments] = vertexAttachments(faces, faceId)
% Computes the face ids of all faces adjacent to the specified face
numFaces = size(faces, 1);
adjFaceIds = [];
faceVertices = faces(faceId,:);
for i = 1 : numFaces
sameVertexCount = 0;
for j = 1 : 3
if ismember(faces(i,j), faceVertices)
sameVertexCount = sameVertexCount + 1;
end
if sameVertexCount == 2
adjFaceIds(end+1) = i;
break;
end
end
end
% Returns the face ID of all faces adjacent to the specified face
attachments = adjFaceIds(adjFaceIds ~= faceId);
end
function [verticesOnFace] = findVerticesOnFace(faceId, vertices, faces)
% Find all vertex coordinates on the specified face ID
faceVertices = faces(faceId,:);
verticesOnFace = [];
for i = 1 : size(vertices, 1)
if ismember(vertices(i,:), vertices(faceVertices,:), 'rows')
verticesOnFace(end+1,:) = vertices(i,:);
end
end
end
  댓글 수: 5
Joel Hottinger
Joel Hottinger 2023년 6월 14일
편집: Joel Hottinger 2023년 6월 14일
What other information do you have about each face? I can't think of any way in which you could determine concavity with only the normal vectors.
I edited my previous comment to show the issue. Imagine the normal vectors are centered on the origin, they would look identical in that case.
Chenglin Li
Chenglin Li 2023년 6월 15일
There's no other information about each face, normal is just a method that I tried, but it's not clear what to do after this method fails.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Geometry and Mesh에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by