'NewDataObject' cannot create 'vtkPointSet' with `VTKPythonAlgorithmBase`
vtkPointSet
is no longer abstract, yet VTKPythonAlgorithmBase
still cannot instantiate that type.
If I try to use VTKPythonAlgorithmBase
in a way that should preserve the input data type, it fails to instantiate vtkPointSet
:
import vtk
from vtkmodules.util.vtkAlgorithm import VTKPythonAlgorithmBase
class PreserveTypeAlgorithm(VTKPythonAlgorithmBase):
def __init__(self, nInputPorts=1, nOutputPorts=1):
VTKPythonAlgorithmBase.__init__(
self,
nInputPorts=nInputPorts,
nOutputPorts=nOutputPorts,
)
# THIS IS CRUCIAL to preserve data type through filter
def RequestDataObject(self, request, inInfo, outInfo):
"""Preserve data type."""
self.OutputType = self.GetInputData(inInfo, 0, 0).GetClassName()
self.FillOutputPortInformation(0, outInfo.GetInformationObject(0))
return 1
def RequestData(self, request, inInfo, outInfo):
"""Perform algorithm execution."""
inp = self.GetInputData(inInfo, 0, 0)
out = self.GetOutputData(outInfo, 0)
out.DeepCopy(inp) # TODO: do stuff
return 1
pointset = vtk.vtkPointSet()
alg = PreserveTypeAlgorithm()
alg.SetInputDataObject(pointset)
alg.Update()
Resulting in:
2023-01-05 17:52:50.255 ( 0.224s) [ 1619D77A] vtkDataObjectTypes.cxx:280 WARN| 'NewDataObject' cannot create 'vtkPointSet'.
2023-01-05 17:52:50.255 ( 0.224s) [ 1619D77A]vtkDemandDrivenPipeline:610 ERR| vtkCompositeDataPipeline (0x600003650700): Algorithm vtkPythonAlgorithm (0x600003d50370) did not create output for port 0 when asked by REQUEST_DATA_OBJECT and does not specify a concrete DATA_TYPE_NAME.