How to generate volume mesh from CAD surface mesh

420 views
Skip to first unread message

Yang Lu

unread,
Dec 2, 2011, 8:36:36 AM12/2/11
to iso2mes...@googlegroups.com
Hello Dr. Fang

I am new at Iso2mesh.
My question is how to generate volume mesh from a surface mesh. The
surface mesh is made by triangles.
Please see the attached screen shot and VRML format file.
This is a irregular shape particle included in a cube box.
Particle surface is represented by hundreds of triangles and the cube
box is also composed by triangles.
Can I use iso2mesh to create tetrahedral elements from the triangle
mesh? Thanks.

Kind Regards

Yang

particle-1.png
particle-1.wrl

Qianqian Fang

unread,
Dec 2, 2011, 3:43:34 PM12/2/11
to iso2mes...@googlegroups.com, Yang Lu

hi Yang

You first need to manually copy/edit the node coordinates
and triangle indices from your wrl file and create
an OFF format mesh file based on the specification
[1]. Then you can load your surface to iso2mesh with
readoff.m and produce volumetric mesh with s2m.

Alternatively, you can download and install meshlab [2],
load your wrl and save as off. Then you should be able
to process it in iso2mesh.

currently iso2mesh can only save simple meshes
to a VRML file, but a parser is not available yet.

Qianqian


[1] http://people.sc.fsu.edu/~jburkardt/data/off/off.html
[2] http://meshlab.sourceforge.net/

>
> Kind Regards
>
> Yang
>

The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

Yang Lu

unread,
Dec 2, 2011, 9:04:48 PM12/2/11
to Qianqian Fang, iso2mes...@googlegroups.com
Hi Qianqian

Thank you very much for your quick response.
According to your guidance, I have convert the wrl file to a OFF file
using Meshlab. The OFF file is attached.

Now my question is:
The bounding box is made by 12 very big triangles.
May I remesh the bounding box to more smaller triangles and then
generate volume mesh based on these finer surface mesh?
If yes. How to do it in iso2mesh?
Yesterday, I tried to mesh it in Amira. However, Amira was stucked by
error notices: unclosed face and surface normal problem. Will iso2mesh
encounter these problems?

Kind Regards


Yang

--
Stay on top of everything new and different, both inside and around
High Performance Computing and Multiscale Modeling technology ~~~

particle-1.off

Qianqian Fang

unread,
Dec 3, 2011, 12:09:07 AM12/3/11
to Yang Lu, iso2mes...@googlegroups.com
On 12/02/2011 09:04 PM, Yang Lu wrote:
> Hi Qianqian
>
> Thank you very much for your quick response.
> According to your guidance, I have convert the wrl file to a OFF file
> using Meshlab. The OFF file is attached.

I suggest you giving iso2mesh a try based on my previous email.
If you get any problem, I can help you to fix it.

> Now my question is:
> The bounding box is made by 12 very big triangles.
> May I remesh the bounding box to more smaller triangles and then
> generate volume mesh based on these finer surface mesh?
> If yes. How to do it in iso2mesh?

again, you have to try it and see the results first.

surf2mesh has a parameter to add bounding box, so,
having it in the input surface is not really necessary.

> Yesterday, I tried to mesh it in Amira. However, Amira was stucked by
> error notices: unclosed face and surface normal problem. Will iso2mesh
> encounter these problems?

please run it to find out.

Qianqian

Yang Lu

unread,
Dec 4, 2011, 2:21:38 PM12/4/11
to Qianqian Fang, iso2mes...@googlegroups.com
Hi Qianqian

Thank you for your suggestion.
I tried to import .off using readoff.m.
However, it pops up with following error:

>> [node,elem]=readoff('particle-1.off')
??? Index exceeds matrix dimensions.

Error in ==> readoff at 34
elem=round(elem(:,2:3))+1;


Can you please help me fix this problem? Thanks.

Yang

On Sat, Dec 3, 2011 at 12:09 AM, Qianqian Fang

--

Qianqian Fang

unread,
Dec 4, 2011, 8:32:32 PM12/4/11
to Yang Lu, iso2mes...@googlegroups.com
On 12/04/2011 02:21 PM, Yang Lu wrote:
> Hi Qianqian
>
> Thank you for your suggestion.
> I tried to import .off using readoff.m.
> However, it pops up with following error:
>
>>> [node,elem]=readoff('particle-1.off')
> ??? Index exceeds matrix dimensions.
>
> Error in ==> readoff at 34
> elem=round(elem(:,2:3))+1;
>
> Can you please help me fix this problem? Thanks.

please update your iso2mesh to the latest version via SVN:
http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?Download#Anonymous_SVN_Access

or you can update your readoff.m script with this one:
http://iso2mesh.svn.sourceforge.net/viewvc/iso2mesh?view=revision&revision=330

what happened was that your OFF is not a plain OFF, but
one with colors (that's why the first line is COFF). the
old version of readoff does not support this type of file.

I tried your data with the new script, it worked ok.

when you feed the node/elem data to s2m, do remember
to use only the first 3 columns of node array, because other
columns are color data.

Qianqian

Yang Lu

unread,
Dec 4, 2011, 11:33:06 PM12/4/11
to Qianqian Fang, iso2mes...@googlegroups.com
Hi Qianqian

With the new readoff.m, I can input the node and element information
successfully. Thanks.
Then I proceed to the surface to mesh and visualization part. Here are
the errors I encountered:

1. I tried to plot the cut cross view the tetrahedral mesh. So I tried
qmeshcut.m. And get the following error notice:

>> qmeshcut(elem,node,[0 1 0],[0 0 0;2 2 2;3 4 5])
??? Undefined function or variable "edges".

Error in ==> qmeshcut at 57
edgemask=sum(asign(edges),2);

2. According to your suggestions, I only use the first 3 columns of
node array when I feed the node/elem data to s2m.

[node,elem,face]=s2m(no(:,1:3),el,0.8,10);

However, there are a few warnings:

generating tetrahedral mesh from closed surfaces ...
resampling surface mesh ...
Warning: File not found or permission denied
> In deletemeshfile at 20
In meshresample>domeshsimplify at 45
In meshresample at 23
In surf2mesh at 45
In s2m at 16
In test_surf2mesh_singleparticle at 40
max face ratio=0.800000
edge index number 0
mesh simplificaton in progress ...


Edges collected: 0
Edges proccessed: 0
Edges collapsed: 0

Edges not collapsed due to topological constrians: 0
Edge not collapsed due to cost computation constrians: 0
Edge not collapsed due to placement computation constrians: 0

Finished...
0 edges removed.
0 final edges.
Warning: Your input mesh contains topological defects, and the mesh resampling
utility aborted during processing. Now iso2mesh is trying to repair
your mesh with
meshcheckrepair. You can also call this manually before passing your mesh to
meshresample.
> In meshresample at 26
In surf2mesh at 45
In s2m at 16
In test_surf2mesh_singleparticle at 40


INFO- Loaded 3482 vertices and 6960 faces.
Saving Manifold Oriented Triangulation ...
WARNING- Some triangles have been reversed to achieve orientation.
Warning: File not found or permission denied
> In deletemeshfile at 20
In meshresample>domeshsimplify at 45
In meshresample at 31
In surf2mesh at 45
In s2m at 16
In test_surf2mesh_singleparticle at 40
max face ratio=0.800000
edge index number 20880
mesh simplificaton in progress ...


Edges collected: 10440
Edges proccessed: 697
Edges collapsed: 696

Edges not collapsed due to topological constrians: 0
Edge not collapsed due to cost computation constrians: 0
Edge not collapsed due to placement computation constrians: 0

Finished...
2088 edges removed.
8352 final edges.
creating volumetric mesh from a surface mesh ...

WARNING: the license for "tetgen" is non-free and does not permit
commercial use.
Please use the "cgalmesh" or "cgalpoly" options where free-software is desired.
is fix volume=1 maxvol=10.000000
Opening C:\DOCUME~1\luyang02\LOCALS~1\Temp\iso2mesh-luyang02\post_vmesh.poly.
Constructing Delaunay tetrahedralization.
Delaunay seconds: 0.359
Creating surface mesh.
Perturbing vertices.
Delaunizing segments.
Constraining facets.
Segment and facet seconds: 0.453
Removing unwanted tetrahedra.
Hole seconds: 0.016
Repairing mesh.
Repair seconds: 0
Adding Steiner points to enforce quality.
Quality seconds: 2.219
Optimizing mesh.
Optimize seconds: 0.359

Writing C:\DOCUME~1\luyang02\LOCALS~1\Temp\iso2mesh-luyang02\post_vmesh.1.node.
Writing C:\DOCUME~1\luyang02\LOCALS~1\Temp\iso2mesh-luyang02\post_vmesh.1.ele.
Writing C:\DOCUME~1\luyang02\LOCALS~1\Temp\iso2mesh-luyang02\post_vmesh.1.face.

Output seconds: 0.375
Total running seconds: 3.781

Statistics:

Input points: 2786
Input facets: 5568
Input segments: 8352
Input holes: 0
Input regions: 0

Mesh points: 7894
Mesh tetrahedra: 33607
Mesh triangles: 72148
Mesh subfaces: 9868
Mesh subsegments: 10502

volume mesh generation is complete


3. Then I tried to save generated tetrahedral mesh to wrl and using
the savevrml function:

savevrml(node,face,'fname.wrl');

Subsequently, I tried to visualize the fname.wrl using a free software
Paraview. And I got the following error notice. I think there is
something wrong with the mesh information written in fname.wrl.


ERROR: In C:\berk\ReleaseBuilds\ParaView3\VTK\Filtering\vtkDemandDrivenPipeline.cxx,
line 726
vtkStreamingDemandDrivenPipeline (0732AC80): Input port 0 of algorithm
vtkAppendPolyData(072A6060) has 0 connections but is not optional.


ERROR: In C:\berk\ReleaseBuilds\ParaView3\VTK\Filtering\vtkDemandDrivenPipeline.cxx,
line 726
vtkStreamingDemandDrivenPipeline (05119EC0): Input port 0 of algorithm
vtkAppendPolyData(07263CB0) has 0 connections but is not optional.


Can you please help me fix the above mentioned 3 problems? Thank you very much.

Kind Regards

Yang

when you feed the node/elem data to s2m, do remember
to use only the first 3 columns of node array, because other
columns are color data.

--

Qianqian Fang

unread,
Dec 5, 2011, 9:12:30 AM12/5/11
to Yang Lu, iso2mes...@googlegroups.com
On 12/04/2011 11:33 PM, Yang Lu wrote:
> 1. I tried to plot the cut cross view the tetrahedral mesh. So I tried
> qmeshcut.m. And get the following error notice:
>
>>> qmeshcut(elem,node,[0 1 0],[0 0 0;2 2 2;3 4 5])
> ??? Undefined function or variable "edges".
>
> Error in ==> qmeshcut at 57
> edgemask=sum(asign(edges),2);

hi Yang

the "value" parameter should be a vector of the same length as node.


> 2. According to your suggestions, I only use the first 3 columns of
> node array when I feed the node/elem data to s2m.
>
> [node,elem,face]=s2m(no(:,1:3),el,0.8,10);
>
> However, there are a few warnings:

I ran your data with the latest SVN code, the permission deny
warning did not show up. Please upgrade your iso2mesh to the
latest svn version if you want to try it yourself.

Other than that, everything else looks normal.

> 3. Then I tried to save generated tetrahedral mesh to wrl and using
> the savevrml function:
>
> savevrml(node,face,'fname.wrl');


the vrml output from savevrml was only tested against
Blender (an open-source modeling tool, http://www.blender.org/).
I don't know the format required by Paraview. You
may have to ask in Paraviewer's mailing list to find out.

Qianqian

Yang Lu

unread,
Dec 5, 2011, 11:25:48 AM12/5/11
to Qianqian Fang, iso2mes...@googlegroups.com
Hi Qianqian

1. I just updated the iso2mesh latest version from SVN.
Then I tried to generate mesh. But got new problems as follow:


>> [no,el]=readoff('particle-1.off');
>> [node,elem,face]=s2m(no(:,1:3),el,0.8,10);


generating tetrahedral mesh from closed surfaces ...
resampling surface mesh ...

max face ratio=0.800000
edge index number 0
mesh simplificaton in progress ...


Edges collected: 0
Edges proccessed: 0
Edges collapsed: 0

Edges not collapsed due to topological constrians: 0
Edge not collapsed due to cost computation constrians: 0
Edge not collapsed due to placement computation constrians: 0

Finished...
0 edges removed.
0 final edges.

??? Error using ==> strtrim
Input should be a string or a cell array of strings.

Error in ==> readoff>nonemptyline at 60
end

Error in ==> readoff at 25
line=nonemptyline(fid);

Error in ==> meshresample>domeshsimplify at 47
[node,elem]=readoff(mwpath('post_remesh.off'));

Error in ==> meshresample at 23
[node,elem]=domeshsimplify(v,f,keepratio);

Error in ==> surf2mesh at 45
[no,el]=meshresample(v(:,1:3),f(:,1:3),keepratio);

Error in ==> s2m at 25
[node,elem,face]=surf2mesh(v,f,p0,p1,keepratio,maxvol,[],[]);

2. the "value" parameter should be a vector of the same length as node.
I don't know why such a long vector is needed in mesh cut-cross view.

Can you let me try the command you used? I think a replication of what
you have done is a better way than my own.

Kind Regards

Yang

--

Qianqian Fang

unread,
Dec 5, 2011, 11:42:28 AM12/5/11
to iso2mes...@googlegroups.com
On 12/05/2011 11:15 AM, Yang Lu wrote:
> Hi Qianqian
>
> 1. I just updated the iso2mesh latest version from SVN.
> Then I tried to generate mesh. But got new problems as follow:
>
>
>>> [no,el]=readoff('particle-1.off');
>>> [node,elem,face]=s2m(no(:,1:3),el,0.8,10);


I tried your commands on matlab 7.4 and 7.11
as well as octave 3.2, they all ran just fine.


> 2. the "value" parameter should be a vector of the same length as node.
> I don't know why such a long vector is needed in mesh cut-cross view.

because qmeshcut does more than slicing a mesh, it
also interpolate the values on the nodes along the cut.
If you don't need this feature, just set it to ones(size(node(:,1)))

Qianqian

>
> Can you let me try the command you used? I think a replication of what
> you have done is a better way than my own.
>
> Kind Regards
>
> Yang
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

Yang Lu

unread,
Dec 5, 2011, 1:22:21 PM12/5/11
to iso2mes...@googlegroups.com, Qianqian Fang
Hi Qianqian

To make sure that I installed isomesh correctly, I downloaded the
latest version from SVN. (The latest update was made on two weeks ago.
)
After I install it, I tried to run every sample scripts in your sample folder.
It's strange most of the samples runs fine, except
'demo_refine_spherebox_mesh.m'.
The last part of the interactive message denotes:

volume mesh generation is complete

Warning: File not found or permission denied
> In deletemeshfile at 20
In meshresample>domeshsimplify at 45
In meshresample at 23

In demo_refine_spherebox_mesh at 63
max face ratio=0.200000


edge index number 0
mesh simplificaton in progress ...


Edges collected: 0
Edges proccessed: 0
Edges collapsed: 0

Edges not collapsed due to topological constrians: 0
Edge not collapsed due to cost computation constrians: 0
Edge not collapsed due to placement computation constrians: 0

Finished...
0 edges removed.
0 final edges.

??? Error using ==> strtrim
Input should be a string or a cell array of strings.

Error in ==> readoff>nonemptyline at 60
end

Error in ==> readoff at 25
line=nonemptyline(fid);

Error in ==> meshresample>domeshsimplify at 47
[node,elem]=readoff(mwpath('post_remesh.off'));

Error in ==> meshresample at 23
[node,elem]=domeshsimplify(v,f,keepratio);

Error in ==> demo_refine_spherebox_mesh at 63
[no2,el2]=meshresample(no,el,0.2); % down sample the sphere mesh

The error message also happens in running my script


[no,el]=readoff('particle-1.off');
[node,elem,face]=s2m(no(:,1:3),el,0.8,10);

However, when I change 0.8 to 1.0, it runs fine
[node,elem,face]=s2m(no(:,1:3),el,1.0,10);

Can you help me figure out the problem? Does that mean some file can't be found?

Kind Regards

Yang


On Mon, Dec 5, 2011 at 11:42 AM, Qianqian Fang

> --
> You received this message because you are subscribed to the Google Groups
> "iso2mesh-users" group.
> To post to this group, send email to iso2mes...@googlegroups.com.
> To unsubscribe from this group, send email to
> iso2mesh-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/iso2mesh-users?hl=en.

Yang Lu

unread,
Dec 5, 2011, 2:54:19 PM12/5/11
to iso2mes...@googlegroups.com, Qianqian Fang
Hi Qianqian
I found a file I/O problem. Can you help me figure it out? Thanks.


WARNING: the license for "tetgen" is non-free and does not permit
commercial use.
Please use the "cgalmesh" or "cgalpoly" options where free-software is desired.

is fix volume=1 maxvol=8.000000
Opening C:\DOCUME~1\yanglu\LOCALS~1\Temp\iso2mesh-yanglu\demo_sph3_post_vmesh.poly.
Opening C:\DOCUME~1\yanglu\LOCALS~1\Temp\iso2mesh-yanglu\demo_sph3_post_vmesh.mtr.
Opening C:\DOCUME~1\yanglu\LOCALS~1\Temp\iso2mesh-yanglu\demo_sph3_post_vmesh.b.node.
File I/O Error: Cannot access file
C:\DOCUME~1\yanglu\LOCALS~1\Temp\iso2mesh-yanglu\demo_sph3_post_vmesh.b.node.
Constructing Delaunay tetrahedralization.
Delaunay seconds: 0.046
Duplicating background mesh.
Background mesh reconstruct seconds: 0


Creating surface mesh.
Perturbing vertices.
Delaunizing segments.
Constraining facets.

Segment and facet seconds: 0.032
Removing unwanted tetrahedra.
Spreading regional attributes.
Hole seconds: 0


Repairing mesh.
Repair seconds: 0

Size interpolating seconds: 0.015


Adding Steiner points to enforce quality.

Quality seconds: 6.782
Optimizing mesh.
Optimize seconds: 0.453

Writing C:\DOCUME~1\yanglu\LOCALS~1\Temp\iso2mesh-yanglu\demo_sph3_post_vmesh.1.node.
Writing C:\DOCUME~1\yanglu\LOCALS~1\Temp\iso2mesh-yanglu\demo_sph3_post_vmesh.1.ele.
Writing C:\DOCUME~1\yanglu\LOCALS~1\Temp\iso2mesh-yanglu\demo_sph3_post_vmesh.1.face.


Kind Regards

Yang

Qianqian Fang

unread,
Dec 5, 2011, 3:29:53 PM12/5/11
to Yang Lu, iso2mes...@googlegroups.com
On 12/05/2011 02:54 PM, Yang Lu wrote:
> Hi Qianqian
> I found a file I/O problem. Can you help me figure it out? Thanks.

That is not an error although it does read like one. It is
indeed a warning. ".node" file is not used in this case,
and tetgen ignored it safely. As far as I can tell, tetgen
succeeded in this case.

Qianqian

Qianqian Fang

unread,
Dec 5, 2011, 6:21:00 PM12/5/11
to Yang Lu, iso2mes...@googlegroups.com
On 12/05/2011 04:46 PM, Yang Lu wrote:
Hi Qianqian

1. I just trimed the redundant 4 columns of color data. Here is the
running results from old readoff.m.
Are those warnings "Warning: File not found or permission denied" good?

the warning is not supposed to be there. If you have
experience with matlab, I would like you to debug this
by setting a break point in the line causing this warning.

2. Then I try "qmeshcut.m". And got the following errors:
qmeshcut(elem,node,ones(size(node(:,1))),[0 1 3 1])
??? Error using ==> times
Matrix dimensions must agree.


what's the size of your node? do you know if the plane
will have an intersection with the volume?


Error in ==> qmeshcut at 72
    dist=sum( (co.*node)' )+d;


Kind Regards


by the way, I think I fixed the strtrim error you got earlier, see

http://iso2mesh.svn.sourceforge.net/viewvc/iso2mesh?view=revision&revision=331


Qianqian


PS: I added CC to iso2mesh-users list for documenting the
solutions.
Reply all
Reply to author
Forward
0 new messages