Showing revision 1.0

Frequently asked questions about iso2mesh

1. I am getting a "Two subfaces ... are found intersecting each other" error, what should I do?
2. After mesh generation, the plotted surface looked messed up, what was wrong?
3. Matlab complains about imread, imclose or imfill missing
4. iso2mesh failed when writing files to disk
5. When displaying the surface produced by iso2mesh with OpenGL, there are lot of holes, how to fix this?

1. I am getting a "Two subfaces ... are found intersecting each other" error, what should I do?

This is the most frequently encountered problem using this toolbox. There are three possible causes of this error:

1. the volume you are trying to mesh contains regions having shared boundary segments

This is most likely happening when you see the above error message. Try to plot your volume slice by slice, and pay attention to any voxels whose neighbors have more than 2 different values. If you do see these type of voxels (junctions), unfortunately, iso2mesh can not handle this situation at this point. Here are two possible temporary work-arounds:
  1. if there are not many junction voxels, you may want to manually edit your image and disconnect the regions that share the same boundary and make sure all the sub-regions are either completely disjointed, or completely enclosed by another.
  2. merge the regions that have shared boundaries, and mesh the resulting merged volume; after you get the tetrahedra, compute the centroid of each element in the merged domain (identified by their labels), and map them back to your original segmented image; determine the original region id using the voxel containing the centroids.

If you have any better suggestions to enable iso2mesh to handle this situation, please let me know.

2. you are using 'simplify' method to mesh a complex domain

There are two possible methods for volume-to-surface conversion, 'simplify' and 'cgalsurf'. The second method always returns a well-posed surface where no self-intersecting elements present; however, the 'simplify' approach does not. The default method for vol2mesh/vol2surf (v2m/v2s) is 'cgalsurf'. If you have to use 'simplify', you may have to experiment different surface densities for the surface extraction. You may lucky enough to find a working configuration, but very likely, you may not. Please use 'cgalsurf' option whenever possible.

3. your surface mesh is too coarse and intersects the enclosed surfaces

The mesh extraction will represent the region boundaries by a sheet of triangles. Near sharp edges, this representation may generate a rounded edge and does not exactly preserve the shape of the original domain. If you happen to mesh a thin layer of material, the resulting surface may intersect each other at sharp edges if your surface element is too big. Please use a small opt.radbound value to run the mesh generation again.

2. After mesh generation, the plotted surface looked messed up, what was wrong?

It is very likely you incorrectly used the output variables. The output of vol2mesh or surf2mesh include elem: the tetrahedral element indices, and face: the surface triangle indices. But be careful, both of these two arrays have an additional column. The last column is a label field, indicating the origin (sub-region) of the elements. You should never use the last columns of these two arrays for plotting. To make a correct surface plot, you should use something like
 trisurf(face(:,1:3),node(:,1),node(:,2),node(:,3));
and don't use the full face array as the first parameter.

3. Matlab complains about imread, imclose or imfill missing

Under the sample/ directory, demo_vol2mesh_ex2.m requires imread, which is a build-in function in matlab, but not in octave. You have to install octave-image via apt-get or yum first. In example demo_vol2mesh_ex3.m, functions imclose and imfill are needed. These two functions can only be found in matlab's image processing toolbox. If you don't have this toolbox installed (of course, it is not free), you can simply pass this example. For octave, unfortunately, these functions do not exist yet, and hopefully someone can fill them in soon.

4. iso2mesh failed when writing files to disk

If you are working on a multi-user workstation, and multiple users were using iso2mesh, some temporary files may have a conflict in read/write permission under /tmp directory. If user A runs iso2mesh first, and user B will get this error, because iso2mesh fails to create the temporary files as it does not have the permissions to overwrite those files created by A. To solve this issue, please define your own temporary folder, or set your session id, you can find more info at Advanced page.

5. When displaying the surface produced by iso2mesh with OpenGL, there are lot of holes, how to fix this?

The node orders in the output surface mesh are random, some are oriented clockwise, some are counter-clockwise. This will make OpenGL, or OpenGL based applications, render the surface with different materials. To correct this, you can simply call
 [newnode,newface]=meshcheckrepair(node,face); 
and the new surface: [newnode,newface] will have consistent orientation. Again, be careful if you are using the face output from vol2surf/v2s, it has an extra column. You only need to use the first 3 columns in the face array.
Powered by Habitat