Python Overloading Resolution issue with vtkMultiProcessController::Gather

I want to invoke the following function from python:

  int Gather(vtkDataObject* sendBuffer, std::vector<vtkSmartPointer<vtkDataObject>>& recvBuffer,
    int destProcessId)

I have the following python code

  gathered_output_surfaces = []
  controller.Gather(outputSurface, gathered_output_surfaces, 0)

outputSurface is a vtkPolyData result from vtkDataSetSurfaceFilter.

When i try to invoke gather, i get

TypeError: Gather argument 1: method requires a vtkDataArray, a vtkPolyData was provided.

Which means that it tries to call the wrong function, because of overloading resolution issues.

If i rename the function that i want to call to GatherDataObject, everything works just fine.

Do you have any suggestions @dgobbi?

cc: @ben.boeckel

What other overloads exist and what order are they declared in the class?

Note that the case of an empty [] argument, there is nothing to help with the type deduction here.

There are many Gather Overloads VTK/vtkMultiProcessController.h at master · Kitware/VTK · GitHub

Seems that overload resolution is buggy for std::vector<vtkSmartPointer<...>>, so the wrappers fall back to the vtkDataArray* overload instead. I’ll investigate.

1 Like

I’ve submitted !9434 to fix the issue.

Ben is correct that using passing [vtkPolyData()] instead of just [] provides additional type information for overload resolution. But for this particular set of overloads, just [] is sufficient. That is, the additional bit of type info isn’t needed in this particular case.