How to convert from 2D polygons (vtkPolydata) to a 3D volumen

How to convert from 2D polygons (vtkPolydata) to a 3D volumen?
Check the following image:

For simple cases (contours are approximately parallel, no branching, no holes or keyholes, smooth capping is not needed, etc.) then vtkRuledSurfaceFilter may be usable to create a closed surface, convert that to stencil and that to a volume. In case that all the previous conditions are met and also spacing between each contour is exactly the same and they are exactly parallel then you can rasterize each contour using vtkImageStencilRaster.

There is a robust implementation available in Slicer’s segment converter, which supports keyholes, branching, smooth end-capping, etc. developed for converting DICOM RT structure sets to closed surfaces (and volumes). See a short paper, implementation, and a related discussion.