# Requesting pieces in a pipeline

**URL:** https://discourse.vtk.org/t/requesting-pieces-in-a-pipeline/14662
**Category:** Support
**Created:** [October 4, 2024, 10:00pm UTC](https://discourse.vtk.org/t/requesting-pieces-in-a-pipeline/14662 "2024-10-04T22:00:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)
#### Post date: [October 4, 2024, 10:00pm UTC](https://discourse.vtk.org/t/requesting-pieces-in-a-pipeline/14662/1 "2024-10-04T22:00:37Z")

</div>

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

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

```

However, if I do

```auto
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

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 4, 2024, 10:36pm UTC](https://discourse.vtk.org/t/requesting-pieces-in-a-pipeline/14662/2 "2024-10-04T22:36:28Z")

</div>

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()`.

---

<div class="post-metadata">

### Author: ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)
#### Post date: [October 5, 2024, 5:33am UTC](https://discourse.vtk.org/t/requesting-pieces-in-a-pipeline/14662/3 "2024-10-05T05:33:39Z")

</div>

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

```auto
  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.
