Issue connectivity faces with isosurface

4 次查看(过去 30 天)
Hi,
Say I have a gaussian-like function from which I extract the 0.5 isosurface. When I look at the list of faces, I see that the following faces are not necessarily connected i.e. the face(i,:) does not necessarily have two indices in common with the face(i+1,:). Does anyone know an efficient way to order that list in order to get this kind of connectivity property ? Thanks !
Code to see the issue:
x=linspace(-1,1,100);
[X,Y,Z]=meshgrid(x,x,x);
gaus = exp(-(X.^2+Y.^2+Z.^2)/2/0.1^2);
fv = isosurface(X,Y,Z,gaus,0.5);
hold on
for i=1:1:100
p1 = fv.vertices(fv.faces(i,1),:);
p2 = fv.vertices(fv.faces(i,2),:);
p3 = fv.vertices(fv.faces(i,3),:);
plot3([p1(1) p2(1)],[p1(2) p2(2)],[p1(3) p2(3)])
plot3([p1(1) p3(1)],[p1(2) p3(2)],[p1(3) p3(3)])
plot3([p3(1) p2(1)],[p3(2) p2(2)],[p3(3) p2(3)])
pause
end
  7 个评论
Walter Roberson
Walter Roberson 2023-10-18
It appears that isosurface() only produces triangle meshes. If it does not duplicate faces, then possibly that has implications for a traversal order.
Pick a vertex and a starting face. Traverse the three triangles in (say) counter-clockwise order, and then flip "down" to the next level, and traverse in the same order along the bottom of what you had already traversed, then move to the next level and so on.
Ouatehaouks
Ouatehaouks 2023-10-19
what do you mean by level ? If it is the row in faces, I'm not sure this will be sufficient. When one launches my exemple, one can see that triangles appear connected from one another and then at some point it jumps to another region of my sphere which is completely disconnected, so I need to find another level that stays connected and it does not seem to be a matter of counterclockwise to me. Or maybe I misunderstood your point.

请先登录,再进行评论。

回答(1 个)

Fabio Freschi
Fabio Freschi 2023-10-15
Sorting of the faces does not guaratee the property you think exist. If you check, your isosurface is a closed surface: all edges are shared by two triangles
clear all, close all
% your code
x=linspace(-1,1,100);
[X,Y,Z]=meshgrid(x,x,x);
gaus = exp(-(X.^2+Y.^2+Z.^2)/2/0.1^2);
fv = isosurface(X,Y,Z,gaus,0.5);
% plot isosurface (graphic check)
figure, axis equal, view([1 1 1]);
p = patch(fv,'FaceColor','r');
% load data on triangulation class
DT = triangulation(fv.faces,fv.vertices);
% mesh edges
E = edges(DT);
% find triangles attached to edges
tri = edgeAttachments(DT,E);
% check the number of triangels attached to edges
nTri = cellfun(@length,tri);
% check if the all edges are shared by two triangles
all(nTri == 2)
ans = logical
1
  2 个评论
Ouatehaouks
Ouatehaouks 2023-10-17
Thank you for your help. The triangulation seems to be a good way, I did not know you could triangulate a 3D surface, I thought it would connect points in 3D a well...I'm not sure though how to use E and tri to sort fv.faces so that fv.faces(i,:) and fv.faces(i+1,:) have two indices in common ?
Fabio Freschi
Fabio Freschi 2023-10-17
I don't think it is possible to have that property for a generic mesh, if you want to label all triangles

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by