[Gmsh] 2D bitmap files to 3D mesh

Kubicek Bernhard Bernhard.Kubicek at ait.ac.at
Tue Mar 30 14:01:53 CEST 2010


You might find this link interesting:
http://www.meshing.at/Spiderhome/Tarantula.html
-----------------------------------
Bernhard Kubicek
Energy Department
Electric Energy Systems

Bitte beachten Sie unsere neuen Kontaktdaten!
Please note our new contact details!

AIT Austrian Institute of Technology
Österreichisches Forschungs- und Prüfzentrum Arsenal Ges.m.b.H.
Giefinggasse 2 | 1210 Vienna | Austria
T +43(0) 50550-6258 | M +43(0) 664 6207748

bernhard.kubicek at ait.ac.at | http://www.ait.ac.at
________________________________________
From: gmsh-bounces at ace20.montefiore.ulg.ac.be [gmsh-bounces at ace20.montefiore.ulg.ac.be] On Behalf Of Fred-Johan Pettersen [fjp.medtek at aerogadget.net]
Sent: Tuesday, March 30, 2010 12:52 PM
To: gmsh at geuz.org
Subject: [Gmsh] 2D bitmap files to 3D mesh

Hi,

I have looked around and found that there is at least two other who tried to do the same as I did [1], that is: read a bunch of images, typically from a CT or similar, where each image represent a slice of a 3D structure, and create a mesh from it.

I'll describe my case in more detail:
The 3D (x,y,z) data is in the format of a bunch of 2D(x,y) image files where each file represent a given z-value. Each datapoint in 3D is called a voxel, and the voxel may be one of around 30 different integers. Each integer value represent a material type. Each material type is typicalled lumped together in smaller or larger lumps.

My dataset has more than 150,000,000 voxels, and is thus a bit on the big side for usage in a FEM-simulator, which is my goal. But the simulator (COMSOL multiphysics) can read Nastran BDF-files, and Gmsh can create such files. So what I want is to read my 2D-files into Gmsh, create a 3D mesh, and then export it to a Nastran file. I might sub-sample the 3D-matrix to produce coarser data, but this doesn' solve my problem by itself. I need a mesh that is rather fine at the surfaces, but the mesh may be much coarser inside the lumps of a given material.

What I have tried so far, and that didn' work very well was this: I wrote a C-program that reads all my 2D-files,and placed them in a 3D array. I then created STL-files (3D surface mesh), one fle for each material type, which I imported successfully into Gmsh, and then created Nastran files. This approach could have worked fine if it wasn't for the fact that there are holes in the "lumps" filled with other materials, and there are places where, for instance, two cubes of the same material (voxels) shares an edge or even only a vertex in 3D space. This isn' handled very well by Gmsh. The method I tried was this:

// Read file 1 and create volume.
Merge "file_1.stl";
Surface Loop(1) = {1};
Volume(1) = {1};

// Mesh settings
Mesh.Format = 31;

Since this didn' work, I am hoping that some of you might know of another way to do what I want.

Regarding the previous postings (se links below), I think the method Gary was asking about was something like this:
for(z=0; z < number_of_2D_files; z++)
Read 2D-file.
Define each area with same value in the 2D-file as a surface (sizes from one pixel to whole file).
Extrude all surfaces along z-axis.
This method is fine if it is possible to do (I need more experienced Gmsh users to comment on this), and if it is possible to merge materials of same type one the z-layer below or above so that we reduce the number of volumes.

I belive that is enough information to understand my problem. Does anybody have a solution?

Best regards,
Fred-Johan Pettersen

[1]:
http://www.geuz.org/pipermail/gmsh/2006/002055.html
http://www.geuz.org/pipermail/gmsh/2008/003183.html
http://www.geuz.org/pipermail/gmsh/2008/003193.html