Why are "freeBoundary" surface meshes from tetrahedrons not oriented consistently?

조회 수: 2 (최근 30일)
Why are "freeBoundary" surface meshes from tetrahedrons not oriented consistently?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2022년 5월 20일
The triangles returned from the "freeBoundary" function inherit the orientation of the tetrahedrons they originally belonged to.
Orientation of the tetrahedrons is correct when:
(v12 x v13) * v14 > 0
where
vij is the vector between Points i and j : Pj - Pi
i.e. the mathematical volume of the tetrahedron is positive.
Preprocessing the tetrahedrons fixes the inconsistently oriented mesh.
A function to achieve this for an incoming tetrahedron triangulation is:
function [triRet, reversed] = repairTet(tri)
%repair tetrahedron definition
% reverse the tetrahedron connectivity definition when they are
% defined inconsistently
nTetra=size(tri.ConnectivityList,1);
volumes=zeros(nTetra,1); % allocation
for j=1:nTetra
pts=tri.Points(tri.ConnectivityList(j,:),:);
vecs=pts(2:4,:)-pts(1,:);
volumes(j)=1/6*cross(vecs(1,:),vecs(2,:))*(vecs(3,:)');
end
% identify wrongly defined tetrahedrons
reversed=(volumes<0);
temp=tri.ConnectivityList(reversed,:);
tNew=tri.ConnectivityList;
tNew(reversed,:)=temp(:,[1 2 4 3]); % notice the swapping of columns
% create the new tetrahedrons (members of triangulations are read-only)
triRet=triangulation(tNew,tri.Points);
end
The surface mesh returned from the "freeBoundary" function then contains outwards pointing normal vectors.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by