Possible Bug When Using ProgrammableSource with vtkImageData

I’m using ParaView 5.8.0 installed though Miniconda with Python 3.7.

I have a very simple “Programmable source” to create an Image as an output:

imout = self.GetOutput()
imout.SetDimensions(10, 5, 3)
imout.SetOrigin(0,0,0)
imout.SetSpacing(2, 1, 1)

This was working perfectly fine one hour ago, showing the 3D image. I don’t know what happened, that now it doesn’t render the image anymore. I have tried to restart the computer and Paraview. Any clues?

Thanks a lot!

Rafael.

Welcome to ParaView, @rafaelmarch3!

When generating and image, you will also need to supply a script for the RequestInformation phase of the pipeline update. For this case, the following code should work:

from paraview import util
util.SetOutputWholeExtent(self, [0,9,0,4,0,2])

Note that the extent here corresponds to the image dimensions (10, 5, 3). The first two elements are the valid index values of a voxel in the x direction, the second two for y, and the last two for z.

Thanks for that Cory. It works now. In my case I had to add also the following line to set the spacing:

executive = self.GetExecutive()
outInfo = executive.GetOutputInformation(0)
outInfo.Set(executive.WHOLE_EXTENT(), 0, im.nx-1, 0, im.ny-1, 0, im.nz-1)
outInfo.Set(vtk.vtkDataObject.SPACING(), im.dx, im.dy, im.dz)

Thanks!