# Extract Voxel Information From vtkVoxelModeller

**URL:** https://discourse.vtk.org/t/extract-voxel-information-from-vtkvoxelmodeller/2492
**Category:** Support
**Created:** [January 24, 2020, 1:02pm UTC](https://discourse.vtk.org/t/extract-voxel-information-from-vtkvoxelmodeller/2492 "2020-01-24T13:02:10Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![chris](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://discourse.vtk.org/u/chris)
#### Post date: [January 24, 2020, 1:02pm UTC](https://discourse.vtk.org/t/extract-voxel-information-from-vtkvoxelmodeller/2492/1 "2020-01-24T13:02:10Z")

</div>

Hey at all,

i’m new here and i don’t know if this is the right place for my question. But i googled now for several days and can’t find a solution. So i’m stuck without help …

My task is to (3D)-voxel a simple mesh and get the (x,y,z)-coordinates of all 8 vertices of all of the (3D)-voxels.

So a function like:  
for voxel in vtkVoxelModeller:  
for vertices in voxel:  
return the (x,y,z)-coords of the vertex

Does someone has an idea on how to achiev this.  
The workflow until voxel is no problem and marching cubes with the voxels also works. But i cant find the coords of the voxels …

---

<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: [January 24, 2020, 2:22pm UTC](https://discourse.vtk.org/t/extract-voxel-information-from-vtkvoxelmodeller/2492/2 "2020-01-24T14:22:58Z")

</div>

We usually convert surface meshes (vtkPolyData) to volumes (vtkImageData) using vtkPolyDataToImageStencil (see implementation for example [here](https://github.com/Slicer/Slicer/blob/master/Libs/vtkSegmentationCore/vtkClosedSurfaceToBinaryLabelmapConversionRule.cxx)).

Marching cubes (or the current faster version, fliyng edge filter) converts volume to surface mesh. You can get point coordinates from vtkPolyData using `polydata->GetPoints()->GetPoint(n)`.

---

<div class="post-metadata">

### Author: ![chris](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://discourse.vtk.org/u/chris)
#### Post date: [January 27, 2020, 9:28am UTC](https://discourse.vtk.org/t/extract-voxel-information-from-vtkvoxelmodeller/2492/3 "2020-01-27T09:28:23Z")

</div>

Hey @lassoan,  
thanks for your answer, but unfortunately the answer does not solve my problem.

So as you proposed i converted the surface mesh to a volume mesh. With this volume mesh i can also make the voxelisation. But as I said i need the (x,y,z)-coordinates of all 8 vertices of all of the (3D)-voxels which get generated. It’s not important if it’s a voxeled mesh or a voxeled volume.

The problem with marching cubes is that i can only get a surface mesh of a smoothed surface. But i need the 8 edges of every voxel …

Does someone have an idea?

---

<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: [January 27, 2020, 7:41pm UTC](https://discourse.vtk.org/t/extract-voxel-information-from-vtkvoxelmodeller/2492/4 "2020-01-27T19:41:58Z")

</div>

> [@chris](#):
>
> The problem with marching cubes is that i can only get a surface mesh of a smoothed surface.

For binary image input you will get a “voxelized” (not smoothed) surface. You may also use the [discrete version of marching cubes / flying edges](https://vtk.org/doc/nightly/html/classvtkDiscreteMarchingCubes.html) to enforce this or vtkThreshold+vtkGeometryFilter (as in [cubes example](https://lorensen.github.io/VTKExamples/site/Cxx/Medical/GenerateCubesFromLabels/)).
