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 [node,elem,face]=vol2mesh(mydata>0,1:size(mydata,1),1:size(mydata,2),... 1:size(mydata,3), 5, 100, 1,'cgalsurf'); % or use the short form: % [node,elem,face]=v2m(mydata>0,0.5,5,100); trisurf(face(:,1:3),node(:,1),node(:,2),node(:,3)); % 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: