I am still in the process of learning ITK/VTK and struggling for a few days to create a mesh with three types (triangle, tetrahedron, and Simplex) of cells from the binary mask volume. I feel that I am doing some mistakes.
What I did is that
I created the surface by following the procedure in this link using marching cubes and setting the parameters as follows:
double isoValue = 0.5; // threshold value
surface->ComputeNormalsOn();
surface->ComputeGradientsOn();
surface->SetValue(0, isoValue); // second value acts as threshold
surface->Update();
and saved the surface in a vtkPolyData
I created the triangle mesh by following the commands in this link.
My question is two-folded:
The surface created using Marching Cube does not look smooth, and the mesh edges and cells also look the same (see the figures). Is this a usual representation of triangle mesh and marching cube? Or should I change any parameter?
@dzenanz Hi Sir, Thanks for introducing CuberilleImageToMeshFilter. I have attached two meshes: 1)CuberilleMesh 2)MarchingCubeMesh, which have been created triangle mesh by using two methods. meshes.zip (2.3 MB)
As you can view the meshes, there is not that much difference between the two meshes in terms of smoothness. I am wondering should I change any parameter for the cuberFilter ? Or if I am doing some mistakes somewhere.
The famous bunny mesh looks smooth and the size of triangles are big. As attached here: bunny_mesh.zip (1.1 MB)
How the size and the number of triangle (or other cell types) in a mesh can affect the mesh processing?
Probably your input mesh is highly anisotropic. Resampling the image to have cubic voxels before segmentation will fix the issue. See some more details in this discussion.
For a smoother mesh, use a b-spline interpolator on the original volume data, not the thresholded volume, as described in the Cuberille Insight Journal article.
@matt.mccormick Thanks a lot Sir. Really appreciate it. This is the thing that needed it. May I ask one more question? What filter type should be used to view the created mesh by Cuberille? Should I convert it to UnstrcuturedGrid in Vtk and visualize using Vtk or can be visualized in ITK?
You can save the mesh with itk::MeshFileWriter, which can save the mesh as a vtkPolyData as a.vtk or other mesh file formats. The files can be read as vtkPolyData with VTK and rendered – this is the data structure VTK uses for rendering. vtkUnstructuredGrid can also be used, but it is converted to vtkPolyData for rendering.
BTW, i used in the past this pure VTK example, eliminates staircase artifacts completely with default parameters, produces very smooth meshes. Just for completeness.