apply marching cube on unstructured grid with vtk voxel cells

I am trying to use a vtkMarchingCubes algo on a Unstructuredgrid data. The problem i am facing is vtkMarchingCubes only work with vtkImageData.
ERROR:root:Input for connection index 0 on input port index 0 for algorithm vtkMarchingCubes(0000018CC55BA9A0) is of type vtkUnstructuredGrid, but a vtkImageData is required.
Do you have anyalternativ?
Thanks a lot to take the time to answer me.

Use vtkContourFilter

Is it possible to smooth an Unstructured grid without extracting the surface? Because all of the filters I use only extract the outer surface and the inside of the geometry is lost. But I want to smooth only the boundary of my data while conserving the inside, like in the picture.

You can probably use vtkConstrainedSmoothingFilter. You’ll likely have to use a constraint array to control the maximum amount each point can move. Note that allowing only boundary points to move (i.e., be smoothed) while fixing interior points can result in defects in the resulting mesh.

I have this error: AttributeError: module ‘vtkmodules.all’ has no attribute ‘vtkConstrainedSmoothingFilter’

You need a very recent version of VTK


If I understood it right, you basically want to:

  1. Select the cells that are inside of some shell (e.g. a sphere);
  2. Smooth the outermost cells as to coincide with the shell surface.

The second operation can be performed by projecting certain vertexes (those “exposed to the air”) of the outermost cells into the shell surface. If you don’t have a shell surface, you can genereate it ad hoc by using the marching cubes as suggested above.

This is not a trivial operation, but you can start here: data structure - How to smooth a voxel mesh? - Game Development Stack Exchange. Follow the discussion and from there you can get some pointers.

take care,


Hello Mr Schroeder,
when i use vtkDelaunay filter i get this error "vtkDelaunay3D.cxx:522 WARN| vtkDelaunay3D (00000225E6D4E820): 132 degenerate triangles encountered, mesh quality ". Do you know how to fix this error ?


You can use vtkCleanPolyData to post-process the obtained mesh to treat or remove degenerate cells:




the problem is I only work with UnstruncturedGrid not Polydata.



Then I suggest you to review the first stages back in your processing pipeline. Check how the original unstructured grid is being generated/imported and processed. Original data is not supposed to contain degenerate cases. Degenerate cells usually arise after applying some processing to them.

all the best,