Is it possible to set Reader/Filter output port data TYPE dynamically?

Hi guys,
I am writing a Reader for a specific file type.
The content of a file may be a vtkPolyData, vtkUnstructuredGrid or list of thiese two types.
So can I set output port data type at run time based on file content ?

====================================
following is some code I have tried:
1.
I have tried to set OutputPortInformation by
info->Set(vtkDataObject::DATA_TYPE_NAME(), “vtkDataObject”);
in member function FillOutputPortInformation()
The result is I got a nullptr when request vtkInformation in member function RequestData
2.
I have also tried to set the pointer to vtkPolyData::New()
but filter output nothing.

You have to implement RequestDataObject.

See vtkDataObjectTreeToPointSetFilter for en example.

Thank you Mathieu, I will test it follow your guide!

1 Like