Anyone who's an expert on faces and vertices could help ? I feel I could use ismember and filter like this but it's going to take ages before re-ordering everything....maybe there's some magic trick function available ?
Issue connectivity faces with isosurface
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Walter Roberson
el 18 de Oct. de 2023
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.
Respuestas (1)
Fabio Freschi
el 15 de Oct. de 2023
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)
2 comentarios
Fabio Freschi
el 17 de Oct. de 2023
I don't think it is possible to have that property for a generic mesh, if you want to label all triangles
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!