Subtract mesh from other mesh

74 views
Skip to first unread message

Andy Horn

unread,
Jun 25, 2016, 3:27:51 PM6/25/16
to iso2mesh-users
Hello iso2mesh users,

first of all thanks so much for this awesome toolbox!
I am trying to generate a mesh of a box that has tetraeders of four types (e.g. tissue types).
To do so, I'd need to generate a box mesh (mesh A) which is a certain tissue type. I'd like to then subtract a second mesh (mesh B) from this box (resulting in mesh A') and finally concatenate the two meshes (mesh A' + B).
Is this possible somehow?
I know about the function mergemesh. The problem with that is that the intersecting meshes would just be divided. That doesn't work with my problem, unfortunately.

Any help is much appreciated!

Best, Andy

Qianqian Fang

unread,
Jun 25, 2016, 3:37:52 PM6/25/16
to iso2mes...@googlegroups.com
On 6/25/2016 2:24 PM, Andy Horn wrote:
Hello iso2mesh users,

first of all thanks so much for this awesome toolbox!
I am trying to generate a mesh of a box that has tetraeders of four types (e.g. tissue types).
To do so, I'd need to generate a box mesh (mesh A) which is a certain tissue type. I'd like to then subtract a second mesh (mesh B) from this box (resulting in mesh A') and finally concatenate the two meshes (mesh A' + B).
Is this possible somehow?

hi Andy

why don't you create a 2-layer mesh from the start?

if the two layers are brick-shaped, an example can be found here

https://github.com/fangq/mmc/blob/master/mmc/trunk/mmclab/example/demo_sfdi_2layer.m#L22-L34

all you need are the two lines: lines#23 and #34. let me know if
this works for you.

Qianqian

I know about the function mergemesh. The problem with that is that the intersecting meshes would just be divided. That doesn't work with my problem, unfortunately.

Any help is much appreciated!

Best, Andy
--
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 post to this group, send email to iso2mes...@googlegroups.com.
Visit this group at https://groups.google.com/group/iso2mesh-users.
For more options, visit https://groups.google.com/d/optout.

Andy Horn

unread,
Jun 25, 2016, 6:43:16 PM6/25/16
to iso2mesh-users
Dear Qianqian,

thank you so much for your quick reply.
I think this is exactly what I am looking for – i.e. specifying regions. However, in my application, the regions are not brick shaped. In total, I'd have four regions (or layers?), all are a bit complex and the surfaces of them may overlap.
In the final mesh, I'd like region 1 to "win" over region 2, etc. So if there's a surface assigned to layer 1 covering part of the same volume also covered by a surface assigned to layer 2, I'd like the tetrahedrons of the mesh to be part of layer 1 only (and neglect layer 2 for this part of the mesh).
Do you think that's doable?

Formulated in a more specific way, let's say I have a surface describing a brain nucleus and a surface describing an electrode that has been put inside that nucleus. I'd like to generate a unified mesh where the part of the nucleus, in which the electrode sticks, is now also labeled as "electrode", the rest of the nucleus remains "nucleus".

Thank you so much for any help or example of how to do this!

Best, Andy
Message has been deleted
Message has been deleted

Andy Horn

unread,
Jun 25, 2016, 8:06:25 PM6/25/16
to iso2mesh-users
Btw I tried to do it with the attached data.



Data can be visualized using:

figure, patch(fv,'FaceColor','b','FaceAlpha',0.1);

hold on

plot3(c0(:,1),c0(:,2),c0(:,3),'g*');


I'd like to generate a volume mesh of the bounding box:

1,1,1

101,101,150

(which is the box that one can see).


If I run:

    [node,elem]=surf2mesh(fv.vertices,fv.faces,[1,1,1],[101,101,150],1,[],c0);


it only creates a mesh from the box, not from the other structures inside it..


Any help would be much appreciated!


Thanks so much, Andy

data.mat

Andy Horn

unread,
Jun 27, 2016, 11:19:54 AM6/27/16
to iso2mesh-users
Dear QianQian,

I tried to generate a multilayer mesh (see my last post) but it didn't really work.
Do you think you could potentially help me with this?

Thank you so much,

Andy

Qianqian Fang

unread,
Jun 27, 2016, 11:53:45 PM6/27/16
to iso2mes...@googlegroups.com
On 6/27/2016 11:19 AM, Andy Horn wrote:
Dear QianQian,

I tried to generate a multilayer mesh (see my last post) but it didn't really work.
Do you think you could potentially help me with this?

hi Andy

I don't know how you generated the input surface, but I found a lot
of problems.

first, try

[no,fc]=meshcheckrepair(fv.vertices,fv.faces);

you can see all kinds of problems - duplicated nodes/elements, Coincident elements
etc.

More importantly, there is a box surface mesh that is in intersection with the surfaces.
s2m/surf2mesh can not deal with self-interesting surfaces. You will have to
manually fix it and make sure no two triangles that intersect at a position other
than on the edge or a vertex.

Qianqian


Thank you so much,

Andy
Reply all
Reply to author
Forward
0 new messages