Creating uniform rectilinear slice of 3D data

#1

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

(Andras Lasso) #2

Probably vtkImageReslice is the most suitable filter for this. You can set the plane orientation and position using SetResliceAxes method.

#3

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.

(David Gobbi) #4

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).

(Bill Lorensen) #5

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

(Bane Sullivan) #6

In PyVista, we have a convienance method to generate a uniform, rectilinear mesh from a Plane source: pyvista.Plane. This can be oriented at any normal and with any origin

For example:

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)

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”:

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