Issues merging meshes

108 views
Skip to first unread message

Alex

unread,
Jan 11, 2019, 7:08:04 PM1/11/19
to iso2mesh-users
Hi,

Specs:
Fedora 29
GNU Octave 4.4.1


Problem:
I am looking make a heterogeneous medium that is composed of 3 cylinders (tissue type 1) and a box that surrounds it (tissue type 2), but they share a face on one side. However I am getting an seg fault error when I use surfboolean() to combine them. I saw https://groups.google.com/forum/?hl=en#!msg/iso2mesh-users/CpPIoyTpils/kczvsYjXBgAJ;context-place=forum/iso2mesh-users and tried to change the box and cylinders from having co-planer surfaces i.e. [node4,face4,elem4]=meshabox([-20 -50 0], [80 50 40], 1); ===> [node4,face4,elem4]=meshabox([-20 -50 10], [80 50 40], 1), but with no luck.


Code:

addpath '/var/home/$USER/LabData/Toolboxes/mmc-master/iso2mesh-master';
addpath
'/var/home/$USER/LabData/Toolboxes/mmc-master/matlab';
addpath
'/var/home/$USER/LabData/Toolboxes/mmc-master/mmclab';
clear all
;
close all
;
%################################
% CONTROL FLAGS
%################################
PLOT_CYLINDERS
= true;
%################################
% PROPERTIES OF CYLINDERS
%################################
% Radius
r
= 13/2;               % [mm]
% Height
h
= 20;                 % [mm]
% Distance between cylinders
dx
= 20                         % [mm]
% Position along x
xoffset1
= -5;                   % [mm]
xoffset2
= xoffset1 + dx;       % [mm]
xoffset3
= xoffset2 + dx;       % [mm]

%################################
%   MAKE CYLINDERS
%################################
% Create the three inclusions and merge the meshes.

% Cylinder 1
% Create meshed volume for the first cylinder;
[node1,face1,elem1]=meshacylinder([xoffset1, 0, 0],[xoffset1, 0, h],r);
% Extract longitudinal surface from the meshed cylinder.
[node1,elem1,face1]=surf2mesh(node1,face1,[],[],1,1);
% Remove isolated nodes in the cylinders surface.
[node1,elem1]=removeisolatednode(node1,elem1(:,1:4));
elem1
(:,5) = 1;

% Cylinder 2
[node2,face2,elem2]=meshacylinder([xoffset2,0,0],[xoffset2,0,h],r);
% Extract longitudinal surface from the meshed cylinder.
[node2,elem2,face2]=surf2mesh(node2,face2,[],[],1,1);
% Remove isolated nodes in the cylinders surface.
[node2,elem2]=removeisolatednode(node2,elem2(:,1:4));
elem2
(:,5) = 1;

% Cylinder 3
[node3,face3,elem3]=meshacylinder([xoffset3,0,0],[xoffset3,0,h],r);
% Extract longitudinal surface from the meshed cylinder.
[node3,elem3,face3]=surf2mesh(node3,face3,[],[],1,1);
% Remove isolated nodes in the cylinders surface.
[node3,elem3]=removeisolatednode(node3,elem3(:,1:4));
elem3
(:,5) = 1;

% Merge the three cylinders.
[cnode,celem]=mergemesh(node1,elem1,node2,elem2,node3,elem3);

% If true plot the cylinders
if PLOT_CYLINDERS
  plotmesh
(cnode, celem);
endif

% Add a box and merge with the cylinders.
[node4,face4,elem4]=meshabox([-20 -50 0], [80 50 40], 1);
elem4
(:,5) = 2;
[pnode,pelem]=surfboolean(node4,elem4,'first',cnode,celem); % <==== ERROR
plotmesh
(pnode, pelem);

Error:


>> [pnode,pelem]=surfboolean(node4,elem4,'first',cnode,celem);

sh
: line 1:   165 Segmentation fault      (core dumped) "/var/home/$USER/LabData/Toolboxes/mmc-master/iso2mesh-master/bin/cork.mexa64" -first "/tmp/iso2mesh-$USER/pre_surfbool1.off" "/tmp/iso2mesh-$USER/pre_surfbool2.off" "/tmp/iso2mesh-$USER/post_surfbool.off" -1648335518
error
: surface boolean command failed:
cd
"/tmp/iso2mesh-$USER/" && "/var/home/$USER/LabData/Toolboxes/mmc-master/iso2mesh-master/bin/cork.mexa64" -first "/tmp/iso2mesh-$USER/pre_surfbool1.off" "/tmp/iso2mesh-$USER/pre_surfbool2.off" "/tmp/iso2mesh-$USER/post_surfbool.off" -1648335518
ERROR
:


Shijie Yan

unread,
Jan 14, 2019, 11:53:32 AM1/14/19
to iso2mes...@googlegroups.com
Hi Alex,

I am a student of Dr.Fang. 

I think the reason why the 'surfboolean' failed in your script is because the bottom of the cylinders are overlapped with that of the bounding box. So I extrude the cylinders a little bit and use the 'first' option of 'surfboolean' and it works. Please see attached script and let me know if you have any questions.

FYI: my Specs: Ubuntu 18.04, MATLAB2018a

Best,
Shijie Yan

--
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.
Alex_01_13_2019.m

Alex

unread,
Jan 17, 2019, 3:23:33 PM1/17/19
to iso2mesh-users
Hi Shijie,

Thanks that seems to fix my issues. I just have a couple of clarifying questions. 

%% create volumetric mesh
% use [79,49,39;xoffset1,0,5;xoffset2,0,5;xoffset3,0,5] as region seeds to
% assign the 5th column of elem_final(tissue type),4 tissue types
[node_4type,elem_4type]=surf2mesh(node_all,face_all,[],[],1,10,[79,49,39;offset1,0,5;xoffset2,0,5;xoffset3,0,5]);

For "[79,49,39;..." what do those values relate to? and then for "[...offset1,0,5...]" I am guessing you are using the offset values to center it about the cylinder but then the values for 0 and 5 I a little lost for what those seem to be doing?

Thanks for your help!

Shijie Yan

unread,
Jan 17, 2019, 5:00:49 PM1/17/19
to iso2mes...@googlegroups.com
Hi Alex,

They are seeds for each region (tissue type) you want to define. Please see : https://github.com/fangq/iso2mesh/blob/a4ae65b225daef907c898f8516f5fa16645fc50f/surf2mesh.m#L18

Simply put, region seed is used to differentiate the domain inside and outside of the triangular faces that encloses the seed itself.

Specifically, [79,49,39] is a position enclosed by the triangular faces of the bounding box but outside those of the 3 cylinders. If there are only 2 tissue types (upon your request), one seed for the region outside of those cylinders should be sufficient. 

More seeds can be used if you need more tissue types. For instance, "[...offset1,0,5...]" can be added if you want cylinder #1 has a different tissue type. Position "[...offset1,0,5...]" is just a point randomly chosen as long as it is enclosed by the triangular faces of cylinder #1. 

Best,
Shijie

Alex

unread,
Jan 18, 2019, 10:06:06 AM1/18/19
to iso2mesh-users
Thanks Shijie!

I'll take a closer look at the documentation as well.
Reply all
Reply to author
Forward
0 new messages