ImageData output with non-ImageData inputs

I would like to write a filter, that takes a vtkPointSet as input and outputs an vtkImageData, which depends on the number of points of the input (see example below).

There are two problems:

  1. In RequestInformation, I access the input data objects, because the number of points are not propagated through the pipeline. This seems to work sometimes.
    However, for example, when loading the statefile below, RequestInformation is executed without the presence of an input data object.
    Triggering a pipeline update (e.g., uncheck Generate Triangles in the Contour filter), seems to correct this issue, however the data object is that of the previous pipeline execution.
    For example, setting the Value in the Contour filter to 144 will not change the extent correctly, only a second pipeline execution will correct this.
  • What is the correct way to pass the number of points of the input in the RequestInformation stage?
  1. The UPDATE_EXTENT from the output seems to be copied upwards to the input. If further up in the pipeline, there is another ImageData (see statefile), this would cause an “The update extent specified […] is outside the whole extent.” error.
    To work around this, I remove the UPDATE_EXTENT key in RequestUpdateExtent (remove the RequestUpdateExtent code in the example below to reproduce error).
  • Is this the correct way to handle this?

Minimal Example


Programmable Filter with vtkImageData output


import vtk
out = self.GetOutput()
out.SetExtent(0, len(inputs[0].Points) - 1, 0, 1, 0, 1)
out.AllocateScalars(vtk.VTK_DOUBLE, 1)

RequestInformation Script

from paraview import util
if inputs[0].Points is None:
    print('RequestInformation: No input points')
extent = [0, len(inputs[0].Points) - 1, 0, 1, 0, 1]
util.SetOutputWholeExtent(self, extent)
print('RequestInformation: Set extent {}'.format(extent))

RequestUpdateExtent Script

import vtk

There’s simply no way to do this reliably in VTK pipelines. You cannot depend on your input to have valid data when RequestInformation pass gets executed and hence you cannot look at input dataset’s points to get the output extent.

A workaround is to produce a multiblock dataset with a single image data block. In that case, you don’ t need to do anything in RequestInformation and RequestUpdateExtent passes and hence you won’t have to rely on input dataset in these passes.