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:
- 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?
- 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
Script
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')
return
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
self.GetExecutive().GetInputInformation(0).GetInformationObject(0).Remove(vtk.vtkStreamingDemandDrivenPipeline.UPDATE_EXTENT())