Hello Everyone.
I have a simple three dimensional vtkImageData object representing a voxelgrid:
If a voxel at an index (i, j, k) is set, the entry is 1 ( voxelImageData[idx(x, y, z)] = 1), if the voxel at this index is not set, then the entry is 0.
I want to convert this voxelgrid (3D-volume) to a regular vtkPolyData-Object (mesh surface) for STL-Export with the vtkStlWriter.
I try to archive this using the vtkMarchingCubes / vtkDiscreteMarchingCubes / vtkFlyingEdges3D - Algorithm:
vtkNew<vtkDiscreteMarchingCubes> surface;
//vtkNew<vtkMarchingCubes> surface;
//vtkNew<vtkFlyingEdges3D> surface;
surface->SetInputData(voxelImage);
surface->ComputeNormalsOn();
surface->SetValue(0, 1.0);
//surface->GenerateValues(1, 1, 1);
surface->Update();
While it succeeds in generating a mesh-surface which represents the surface of the occupied voxels, the resulting mesh-surfaces has holes (mostly axis-parallel surfaces are missing).
For example, given this voxel grid as input:
The output should be simply a cube with all sides closed.
However, this is what i get:
A cube surface, where only half of the sides are closed.
I tried this with a variety of voxel representations and mostly axis parallel surfaces are almost always missing (but there are also additional holes at times.)
What can i do to get a closed surface mesh from a binary voxel grid (labelmap) using vtk?
Thank you very much in advance.