# Convert unstructured grid model to volume

**URL:** <https://discourse.slicer.org/t/convert-unstructured-grid-model-to-volume/3867>\
**Category:** Support\
**Created:** [August 22, 2018, 9:29pm UTC](https://discourse.slicer.org/t/convert-unstructured-grid-model-to-volume/3867 "2018-08-22T21:29:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghnguyen](https://avatars.discourse-cdn.com/v4/letter/g/c6cbf5/32.png) [@ghnguyen](https://discourse.slicer.org/u/ghnguyen)\
**Post date:** [August 22, 2018, 9:29pm UTC](https://discourse.slicer.org/t/convert-unstructured-grid-model-to-volume/3867/1 "2018-08-22T21:29:02Z")

</div>

Hi,  
I tried loading the volumetric mesh (vtkUnstructuredGrid) by using both the interface Load Data as Volume and using “slicer.util.loadVolume(’/path/to/file’)” on the Python interactor to no avail. Slicer simply doesn’t load it up. However, loading it as Model would always work. How do I load it as Volume?

Here’s a sample unstructuredgrid below:

* * *

# vtk DataFile Version 3.0

2D scalar data  
ASCII

DATASET UNSTRUCTURED\_GRID  
POINTS 18 float  
0 0 2  
1 0 2  
1 1 2  
0 1 2  
2 0 2  
3 0 2  
3 1 2  
2 1 2  
4 5 6  
2 2 4  
4 4 4  
6 5 2  
7 2 4  
3 4 2  
2 4 6  
1 3 5  
2 9 8  
8 7 5

CELLS 4 44  
10 0 1 2 8 9 4 5 13 12 11  
10 0 2 3 15 16 4 6 1 17 10  
10 1 4 2 9 10 11 12 13 14 16  
10 9 8 7 6 5 4 3 2 1 0

CELL\_TYPES 4  
24  
24  
24  
24

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 23, 2018, 4:59am UTC](https://discourse.slicer.org/t/convert-unstructured-grid-model-to-volume/3867/2 "2018-08-23T04:59:21Z")

</div>

Surface and volumetric meshes are represented in Slicer as model nodes. You can convert a volumetric mesh to volume by sampling the mesh at each voxel using vtkProbeFilter. Here is a complete example of how to do that: [https://github.com/lassoan/SlicerNotebooks/blob/master/UnstructuredGridToVolume.ipynb](https://github.com/lassoan/SlicerNotebooks/blob/master/UnstructuredGridToVolume.ipynb)

---

<div class="post-metadata">

**Author:** ![ghnguyen](https://avatars.discourse-cdn.com/v4/letter/g/c6cbf5/32.png) [@ghnguyen](https://discourse.slicer.org/u/ghnguyen)\
**Post date:** [August 23, 2018, 3:45pm UTC](https://discourse.slicer.org/t/convert-unstructured-grid-model-to-volume/3867/3 "2018-08-23T15:45:14Z")

</div>

I was able to make it work thanks to your help. One thing I noticed was that the vtkUnstructuredGrid mesh must have CELL\_DATA and POINT\_DATA for Slicer to work correctly. I’m a beginner at vtk in general, so I guess my question would be which part of your code requires those two pieces of data? Or does volumetric mesh in general needs to have those in Slicer? I was able to generate volumes without those in vtkpython on conda and Paraview. Thanks a lot Andras!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 23, 2018, 4:19pm UTC](https://discourse.slicer.org/t/convert-unstructured-grid-model-to-volume/3867/4 "2018-08-23T16:19:12Z")

</div>

Maybe vtkProbeFilter specifically needs cell or point data (I don’t think you need both). You can convert between point and cell data as needed using [vtkPointDataToCellData](https://www.vtk.org/doc/nightly/html/classvtkPointDataToCellData.html) and [vtkCellDataToPointData](https://www.vtk.org/doc/nightly/html/classvtkCellDataToPointData.html).

---

<div class="post-metadata">

**Author:** ![Asees\_Kaur](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/asees_kaur/32/6850_2.png) [@Asees\_Kaur](https://discourse.slicer.org/u/Asees_Kaur)\
**Post date:** [October 2, 2020, 12:37am UTC](https://discourse.slicer.org/t/convert-unstructured-grid-model-to-volume/3867/5 "2020-10-02T00:37:26Z")

</div>

hi this page has been taken down. would you mind reuploading it, im having a similar issue

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 29, 2022, 1:40am UTC](https://discourse.slicer.org/t/convert-unstructured-grid-model-to-volume/3867/6 "2022-01-29T01:40:36Z")

</div>

A post was split to a new topic: [Convert mesh to volume](https://discourse.slicer.org/t/convert-mesh-to-volume/21686)
