Clipping three-dimensional mesh.

104 views
Skip to first unread message

Julio Sotelo

unread,
Feb 7, 2020, 10:37:32 AM2/7/20
to iso2mesh-users
Dear all,

My name is Julio Sotelo, Ph.D. in Electrical Engineering. I have been worked for several years with iso2mesh, CGAL, TetGen, and other libraries, mainly focused on the processing and visualization of cardiovascular magnetic resonance imaging. I would like to ask you if it is feasible in iso2mesh, generate something similar to the clip tool of  Paraview?. Basically, I automatically select a 2D plane from a 3D volume, then I cut the tetrahedral mesh in the 2D plane automatically selected, then I need to keep the larger part of the cutting process, it is important to leave the cutting part completely flat.

I attach a Paraview example.

Best regards to everyone. 
Clipping Tetrahedral Mesh.PNG

Qianqian Fang

unread,
Feb 7, 2020, 3:30:51 PM2/7/20
to iso2mes...@googlegroups.com, Julio Sotelo

hi Julio

currently, iso2mesh does not directly support slicing a 3D tetrahedral mesh, but it supports slicing a surface mesh via the surfboolean function.

here is an example:

[node1,face1,elem1]=meshasphere([10,10,10],10,1,10);
face1=volface(meshreorient(node1,elem1(:,1:4)));

[node2,face2,elem2]=meshabox([-10 -10 5],[30 30 40],5,1); % make a bounding box above z=5
face2=volface(meshreorient(node2,elem2(:,1:4)));

[no,fc]=surfboolean(node1,face1,'and',node2,face2);
plotmesh(no,fc)

so what you can do is to extract the surface mesh of your original tet mesh using volface, do the slicing using surfboolean, and then recreate the tetrahedral mesh using s2m. The downside of this is that your interior nodes will unlikely to match with your original mesh. Also, the surfboolean function does not guarantee self-intersecting free, so there is also a risk that s2m fails. if the surface is simple, like this example, you must call meshcheckrepair(...,'meshfix') before passing those to s2m.

We do have a function to slice a tetrahedral mesh, named qmeshcut, but it only extracts the intersecting face. It also returns the indices of the intersecting tetrahedral element. I assume with some minor work, we can make it work exactly as Paraview's plot, but one must determine what portion of the element sits above the intersecting plane and create new elements using the intersection nodes.


[cutpos,cutvalue,facedata,eid]=qmeshcut(elem1(:,1:4),node1,node1(:,3),[0 0 5; 0 10 5; 10 0 5]); % slice the spherical tet mesh above above z=5
c0=meshcentroid(node1,elem1);          % get all elements whose centroid is above z=5
idx=setdiff(find(c0(:,3)>5),eid);      % compute all elements that do not intersect with the plane

figure;hold on;
hcut=patch('Faces',facedata,'Vertices',cutpos,'FaceVertexCData',cutvalue,'facecolor','interp'); % plot the cross-section
plotmesh(node1,elem1(idx,:))          
% plot the mesh above the plane
plotmesh(node1,elem1(eid,:),'facecolor','r','facealpha',0.2,'linestyle','none')  % plot the intersecting elements


a screenshot of the above tet-slicing via qmeshcut is attached.

if someone wants to work on an updated qmeshcut that keeps a half-space rather than just the intersection, please let me know, happy to add it to the package.

Qianqian



Best regards to everyone. 
--
You received this message because you are subscribed to the Google Groups "iso2mesh-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iso2mesh-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iso2mesh-users/5e4ca092-2158-4179-af4e-a34c473346c1%40googlegroups.com.


qmeshcut_tet.png

Julio Sotelo

unread,
Feb 8, 2020, 6:07:29 PM2/8/20
to Qianqian Fang, iso2mes...@googlegroups.com
Thank Qianqian, for your quick answer, I hope to try this method in the next weeks. 
Best regard! 
--
Atte.
Julio Sotelo Parraguez
BSc. Biomedical Engineer
MSc. in Biomedical Engineering
MSc. in Engineering
PhD. in Engineering
Post-Doctoral Fellow PUC
Tutor del Diplomado en Resonancia Magnética PUC

Reply all
Reply to author
Forward
0 new messages