# Multiple output types

**URL:** <https://discourse.vtk.org/t/multiple-output-types/11518>\
**Category:** Development\
**Created:** [May 22, 2023, 9:22pm UTC](https://discourse.vtk.org/t/multiple-output-types/11518 "2023-05-22T21:22:58Z")\
**Posts on this page:** 4\
**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:** [May 22, 2023, 9:22pm UTC](https://discourse.vtk.org/t/multiple-output-types/11518/1 "2023-05-22T21:22:58Z")

</div>

I am developing a filter which I would like to output whatever the downstream filter can take as input.

When calling `RequestDataObject`, I can set the output type to something based on the upstream filter, but the downstream filter (say a mapper) does not have anything in its inputVector that I can use.

When calling `RequestInformation`, I tried getting the output and calling Delete() on it and inserted a new vtkDataSet object (different type). This crashes the pipeline. Is there any workaround for doing this.

Alternatively, is it possible during the `RequestData` to verify if an output port is connected and then at least avoid producing all outputs?

Thanks in advance

---

<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:** [May 22, 2023, 9:57pm UTC](https://discourse.vtk.org/t/multiple-output-types/11518/2 "2023-05-22T21:57:19Z")

</div>

I found a solution - if a better option exists please advice.

Unfortunately, I could not use `UpdateExtent` and ended up with 2 output ports and a pair of booleans for enabling each of the two outputs. Not so elegant

---

<div class="post-metadata">

**Author:** ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)\
**Post date:** [May 23, 2023, 10:24pm UTC](https://discourse.vtk.org/t/multiple-output-types/11518/3 "2023-05-23T22:24:15Z")

</div>

Hello,

> [@Jens\_Munk\_Hansen](#):
>
> I tried getting the output and calling Delete() on it and inserted a new vtkDataSet object (different type). This crashes the pipeline. Is there any workaround for doing this.

None that I’m aware of. Those objects are internal ones managed by VTK. Replacing them certainly spells disaster.

If I underestood it right, that kind of functionality would be much easier with a language that supports reflection (e.g. programmatically asking an object which methods it has and which types are returned by them.). C++ doesn’t have such feature, so it is up to the API to implement it or something like it. A number of VTK classes have some limited metadata API, which is not exactly full-fledged reflection.

Anyway, it would be good if you shared some of the code.

best,

PC

---

<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:** [May 23, 2023, 10:41pm UTC](https://discourse.vtk.org/t/multiple-output-types/11518/4 "2023-05-23T22:41:46Z")

</div>

I will share a snippet of code Thursday. My solution now is to add a port for each data type and add some properties where I can switch on/off the different outputs. Thanks for reaching out and confirm that you also are unware of such a possibility.
