# Creating uniform rectilinear slice of 3D data

**URL:** https://discourse.vtk.org/t/creating-uniform-rectilinear-slice-of-3d-data/1002
**Category:** Support
**Created:** [May 21, 2019, 7:38pm UTC](https://discourse.vtk.org/t/creating-uniform-rectilinear-slice-of-3d-data/1002 "2019-05-21T19:38:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![philipp](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@philipp](https://discourse.vtk.org/u/philipp)
#### Post date: [May 21, 2019, 7:38pm UTC](https://discourse.vtk.org/t/creating-uniform-rectilinear-slice-of-3d-data/1002/1 "2019-05-21T19:38:39Z")

</div>

Hi,

I need to obtain arbitrary slices of 3D data. I need these slices to be rectilinear and uniform. I figured out that probing it with an appropriate input geometry would do the trick.  
Is there any simple way to create the input geometry from a plane. (Specifying the origin and normal of the plane?)

Greetings,  
Philipp

---

<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: [May 22, 2019, 12:53am UTC](https://discourse.vtk.org/t/creating-uniform-rectilinear-slice-of-3d-data/1002/2 "2019-05-22T00:53:11Z")

</div>

Probably [vtkImageReslice](https://vtk.org/doc/nightly/html/classvtkImageReslice.html) is the most suitable filter for this. You can set the plane orientation and position using [SetResliceAxes](https://vtk.org/doc/nightly/html/classvtkImageReslice.html#abf6a3c4b082085b6b51614f60d0841b3) method.

---

<div class="post-metadata">

### Author: ![philipp](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@philipp](https://discourse.vtk.org/u/philipp)
#### Post date: [May 22, 2019, 2:52pm UTC](https://discourse.vtk.org/t/creating-uniform-rectilinear-slice-of-3d-data/1002/3 "2019-05-22T14:52:30Z")

</div>

I allready tried vtkImageReslice but it does not work. It only works with ImageDataInput. I need an approach that also works with unstructured grids. Additionally I am working with a vector field and vtkImageReslice only works with scalar input.  
I think that vtkProbeFilter will work. But my main problem is that I can’t find an elegant way to obtain a regular grid as input.

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [May 22, 2019, 3:39pm UTC](https://discourse.vtk.org/t/creating-uniform-rectilinear-slice-of-3d-data/1002/4 "2019-05-22T15:39:22Z")

</div>

The vtkResampleToImage filter will take an unstructured grid as input and produce a vtkImageData as output. You can choose the dimensions and spacing of the output sample points, but not the orientation (but you could rotate the unstructured grid before passing it to vtkResampleToImage).

---

<div class="post-metadata">

### Author: ![lorensen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lorensen/32/20_2.png) [@lorensen](https://discourse.vtk.org/u/lorensen)
#### Post date: [May 22, 2019, 3:52pm UTC](https://discourse.vtk.org/t/creating-uniform-rectilinear-slice-of-3d-data/1002/5 "2019-05-22T15:52:18Z")

</div>

Probing is the most general. If your output needs to be rectilinear then your plane must be. You should be able to use vtkPlaneSource.

Bill

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/banesullivan/32/7143_2.png) [@banesullivan](https://discourse.vtk.org/u/banesullivan)
#### Post date: [June 14, 2019, 10:08pm UTC](https://discourse.vtk.org/t/creating-uniform-rectilinear-slice-of-3d-data/1002/6 "2019-06-14T22:08:37Z")

</div>

> [@philipp](#):
>
> Is there any simple way to create the input geometry from a plane. (Specifying the origin and normal of the plane?)

In [PyVista](http://docs.pyvista.org), we have a convienance method to generate a uniform, rectilinear mesh from a Plane source: [`pyvista.Plane`](https://docs.pyvista.org/tools/geometric.html#pyvista.Plane). This can be oriented at any normal and with any origin

For example:

```python
import pyvista as pv

grid = pv.Plane(center=(-1, -2, 3), direction=(1, 1, 1),
          i_resolution=10, j_resolution=10)

grid.plot(show_edges=True, color='white', show_grid=True)

```

 ![download](https://discourse.vtk.org/uploads/default/original/1X/e0a390f43f1888add95e83d9e99c9cb66d403b3e.png)

We basically implement this with the `vtkPlaneSource` algorithm and have some internal code that allows us to translate it easily using the defined normal.

Then you could probe/sample your other dataset for data values to create your “slice”:

```python
uniform_slice = grid.sample(some_dataset)
uniform_slice.plot(scalars='sample_point_scalars', show_edges=True, show_grid=True)

```
