Why are "freeBoundary" surface meshes from tetrahedrons not oriented consistently?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 20 Mai 2022
Réponse apportée : MathWorks Support Team
le 20 Mai 2022
Why are "freeBoundary" surface meshes from tetrahedrons not oriented consistently?
Réponse acceptée
MathWorks Support Team
le 20 Mai 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.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!