Showing revision 1

Getting Started with iso2mesh

Despite that iso2mesh provides a rich collection of mesh-related functions, such as edge extraction, disconnected surface component extraction etc, the core functionalities, i.e. creating volumetric meshes from surfaces or binary image stacks, are very straightforward to use. A minimum step to perform such tasks only requires about 3 to 5 lines of matlab code. You can find some examples from the sample/ directory. In this page, we summarize the overall work-flow of this toolbox.

To outline a simple meshing session, let's assume you have a 3D image array, named "mydata", saved in a file called mydata.mat. Variable mydata can be any 3D image, a MRI/CT scan or a simple binary mask produced by your own command. Here are the commands you need to produce a volumetric FEM mesh from this volume:

 load mydata.mat
                            1:size(mydata,3), 5, 100, 1,'cgalsurf');
 % or use the short form:
 % [node,elem,face]=v2m(mydata>0,0.5,5,100);
 % be careful, the last column of face is a label, should not be used for plotting, same for elem

The first line loads the data to your current session. The second line calls an iso2mesh function, 'vol2mesh' to make a volumetric mesh from this data array. The first argument, "mydata>0" , is to convert mydata to a binary array (by thresholding at 0); the 2nd, 3rd and 4th arguments specify the sub-volume from the array to be used for the meshing, in this case, we used the full volume; the 5th argument, 5, represent the size (in voxel unit) of the triangular mesh on the surface of the object - the smaller this number, the more triangles to represent the object surface; the 6th argument, 100, denotes the maximum volumetric element volume, which essential set the density of the tetrahedral mesh; the 7th argument, 1, is a flag meaning that we will perform automatic mesh validation & repairing during the meshing process, it will be turned off when set to 0; we suggest use 1 for most of your mesh generation; the last argument specifies the mesh generation method, two methods are available: 'cgalsurf' - use CGAL surface mesher (constrained Delaunay tetrahedralization) to extract surface mesh, and 'simplify' - produce voxel-based surface mesh and then resample to a coarser mesh.

There are 3 outputs from vol2mesh command:

  • node: the node coordinates for the generated volumetric mesh, with dimension of NN x 3, with each column being x, y and z, respectively.
  • elem: the tetrahedral element info, with a dimension of NE x 4; each row represents an element, and each column are the node indices of each corner of the tetrahedron
  • face: triangular surface element info, with a dimension of NS x 4,;the first 3 columns are the node indices of each corner of the triangle, and the last column is a flag to identify its mapping to the original surface id.
Powered by Habitat