How to use vtkImageStack or equivalent in custom client (C++)

Hi all,

I’m working on porting an astronomy tool that used to be pure VTK to now be paraview based. In one use case, we would have multiple images of the same object (different wavelengths) and display them all simultaneously but separately using the vtkImageStack class. The user can adjust each image’s display properties (opacity, colour map, etc.) individually, and switch between which layer is being edited as well as which images are visible. The renderwindow would show the stacked images (still as a 2D image), respecting opacity and colour maps of the various layers.

How would I be able to recreate this for a paraview implementation? Will I need to create a specific plugin for it? Is there a builder or factory that already does that?

I will be very grateful for any assistance.

Hi @Pietersielie

How would I be able to recreate this for a paraview implementation?

You will need to put that logic in a dedicated representation

Will I need to create a specific plugin for it?

Yes indeed

Is there a builder or factory that already does that?

There are many representation plugin to inspire yourself from, I’d start with Examples/Plugins/Representation/ to get the hang of it and then look at the Slice representation (it is inside ParaView, not a plugin) and try to replicate it in a plugin.

Then go all the way and implement your own representation with the expected behavior.

Do not hesitate to reach out for help !


Thank you for the rapid response, I appreciate it.

Apologies if my explanation wasn’t clear. We have a custom client application, written in C++ with Qt and paraview’s VTK wrapper, that displays data as rendered by a pvserver instance. The pvserver has a custom plugin to read the FITS files (a format used in astronomy). We have already implemented a solution that can render one image, with opacity and colour map selection. This is rendered in a pqRenderView, created by the pqObjectBuilder’s createView().

This is for one image only. What we want to do, is have multiple images in the same renderwindow and switching the rendering priority around which we used to do with the vtkImageStack. And we specifically want to make sure that the data always stays on the server only, since we deal with very large images.

I have not been able to find anything that explains how this (using vtkImageStack or something with similar functionality) can be done, and the basic paraview client (with out custom reader) does not display multiple images the way we’d like to, so I cannot get inspiration from there.

Thank you for your time.

You can’t, you will have to write a custom representation/mapper for this, in a dedicated plugin.

I do not know of any such example, but it should not be that hard for a ParaView/VTK developper to implement this.


I’ve been working on understanding how to implement a representation as a plugin by following your suggestion of replicating the SliceRepresentation functionality in a plugin. I used the vtkImageSliceRepresentation in the base paraview to confirm the functionality and the StreamLinesRepresentation plugin to confirm the setup for the plugin.

The plugin loads and is selectable as a representation option in the paraview client. However, when I select it I get an error as follows:

ERROR: In vtkPVSessionCore.cxx, line 355
vtkPVSessionCore (0x55723b37dc70): Object type: vtkMySliceRepresentation, could not find requested method: "SetRepresentation"
or the method was called with incorrect arguments.

while processing
Message 0 = Invoke
  Argument 0 = vtk_object_pointer {vtkMySliceRepresentation (0x55723fa86690)}
  Argument 1 = string_value {SetRepresentation}
  Argument 2 = string_value {1}

Both vtkImageSliceRepresentation and vtkStreamLinesRepresentation inherit from vtkPVDataRepresentation (as does vtkMySliceRepresentation), and none of those classes have a SetRepresentation() method. What am I missing here?

Thank you in advance.

Hi @Pietersielie

Looks like an XML issue, but hard to say without the code.
I’d also suggest reaching out to Kitware for help: