vtkImageMathematics as a pipeline?

I have learned that using a.SetInputConnection(b.GetOutputPort()), you establish a pipeline connection such that when you b.Update(), it will also update a.

For vtkImageMathematics, it appears there is no way to establish such a pipeline. You have to use a.SetInput1Data(b.GetOutput()), which breaks the line. How do I maintain a pipeline if my pipeline is to include some vtkImageMathematics?

vtkImageMathematics is a standard VTK filter, so you can use SetInputConnection() - it seems that you are missing the fact that the second overload lets you specify the input port, so you can say:

a.SetInputConnection(0, b.GetOutputPort())
a.SetInputConnection(1, c.GetOutputPort())

to set the two inputs.

HTH,
Aron

Hey Aron, thank you for your reply.

This is what I hoped, but I was dissuaded due to

a = vtkImageMathematics()
a.GetInputPortInformation(0) -> vtkInformation
a.GetInputPortInformation(1) -> vtkAlgorithm.cxx:878    ERR| vtkImageMathematics (000001EFEA65B210): Attempt to get information object for input port index 1 for an algorithm with 1 input ports.
a.GetNumberOfInputPorts() -> 1

but I assume I can simply ignore this and assume it works as expected.

Looking at the code, vtkImageMathematics actually uses any number of connections on the first port, so you can add or multiply several inputs. After you add two input connections, a.GetNumberOfInputConnections(0) will return 2, and I think a.GetInputPortInformation(0).GetInformationObject(i) or something similar will give you the info object for i = 0, 1, 2 ...