Python classes derived from VTKPythonAlgorithmBase
have the usual SetInputArrayToProcess
method but no GetInputArrayToProcess
. However, GetInputArrayInformation
does exist and works just like in C++.
Ist this done on purpose? Is there a canonical way to handle input arrays in python algorithms?
I’m currently working around this by defining my own (limited version of) GetInputArrayToProcess
:
class MyFilter(VTKPythonAlgorithmBase):
def GetInputArrayToProcess(self, id, data_object):
""" emulates the missing vtkAlgorithm::GetInputArrayToProcess method """
info = self.GetInputArrayInformation(id)
field = info.Get(vtkDataObject.FIELD_ASSOCIATION())
name = info.Get(vtkDataObject.FIELD_NAME())
if field == vtkDataObject.FIELD_ASSOCIATION_POINTS:
return data_object.PointData[name]
elif field == vtkDataObject.FIELD_ASSOCIATION_CELLS:
return data_object.CellData[name]
elif field == vtkDataObject.FIELD_ASSOCIATION_NONE:
return data_object.FieldData[name]
else: # not implemented
return None
def RequestData(self, request, inInfo, outInfo):
input_data = dsa.WrapDataObject(vtkDataObject.GetData(inInfo[0], 0))
input_array = self.GetInputArrayToProcess(0, input_data)