Requesting pieces in a pipeline

I am aware of the existing vtkPieceRequestFilter, which facilitates selecting which piece to get from upstream, but if the upstream filter does not support pieces, I cannot use it.

I have made a filter, which can subdivide vtkPolyData for streaming. It works nicely, if I set the input, like

myFilter->SetInputDatat(sphereSource->GetOutput());

However, if I do

myFilter->SetInputConnection(sphereSource->GetOutputPort());

I end up getting pieces of pieces. I tried printing information during RequestInformation, RequestUpdateExtent and RequestData, but I cannot figure out how to tell if the pipeline is configure using SetInputData() or SetInputConnection. I can see the upstream filter has CAN_HANDLE_PIECE_REQUEST, but this is not suffient.

Thanks in advance
Jens

If the input was set with SetInputData(), then the upstream seen by your filter will be an instance of vtkTrivialProducer. Your filter won’t see the “true” upstream producer unless the input was set with SetInputConnection().

Thanks, this worked (of course with a bit more safeguards)

  vtkTrivialProducer* trivial =
    vtkTrivialProducer::SafeDownCast(this->GetInputConnection(0, 0)->GetProducer());

Perhaps, the vtkPieceRequestFilter could be extended to support pieces also for upstream sources not supporting pieces.