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

1 view (last 30 days)
Why are "freeBoundary" surface meshes from tetrahedrons not oriented consistently?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 20 May 2022
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.

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!