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

**URL:** https://discourse.vtk.org/t/how-to-convert-from-2d-polygons-vtkpolydata-to-a-3d-volumen/2175
**Category:** Support
**Created:** [November 28, 2019, 2:47pm UTC](https://discourse.vtk.org/t/how-to-convert-from-2d-polygons-vtkpolydata-to-a-3d-volumen/2175 "2019-11-28T14:47:33Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![vacingforo](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/v/7c8e57/32.png) [@vacingforo](https://discourse.vtk.org/u/vacingforo)
#### Post date: [November 28, 2019, 2:47pm UTC](https://discourse.vtk.org/t/how-to-convert-from-2d-polygons-vtkpolydata-to-a-3d-volumen/2175/1 "2019-11-28T14:47:33Z")

</div>

How to convert from 2D polygons (vtkPolydata) to a 3D volumen?  
Check the following image:  
 ![polygons](https://discourse.vtk.org/uploads/default/original/2X/4/44ff6c29ad028d606a06a3dd95a58adb4ba96a7a.png)

 ![polygon2](https://discourse.vtk.org/uploads/default/original/2X/5/51ebc7edce8a9f3c69946a72d5185b346d0ba664.png)

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [November 28, 2019, 8:47pm UTC](https://discourse.vtk.org/t/how-to-convert-from-2d-polygons-vtkpolydata-to-a-3d-volumen/2175/2 "2019-11-28T20:47:38Z")

</div>

For simple cases (contours are approximately parallel, no branching, no holes or keyholes, smooth capping is not needed, etc.) then [vtkRuledSurfaceFilter](https://vtk.org/doc/nightly/html/classvtkRuledSurfaceFilter.html) 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](https://vtk.org/doc/nightly/html/classvtkImageStencilRaster.html).

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](http://perk.cs.queensu.ca/sites/perkd7.cs.queensu.ca/files/Sunderland2015-manuscript.pdf), [implementation](https://github.com/SlicerRt/SlicerRT/blob/master/DicomRtImportExport/ConversionRules/vtkPlanarContourToClosedSurfaceConversionRule.cxx), and a [related discussion](https://github.com/Radiomics/pyradiomics/issues/515).
