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

2 次查看(过去 30 天)

采纳的回答

MathWorks Support Team
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