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.