I’m working on vtkPartitionedDataSetCollections in Python and I’m trying to use the vtkDataAssemblyVisitor to traverse the associated assembly.
However, when I try to create my specialized Python class (shown below) derived from vtkDataAssemblyVisitor I get a “TypeError: this is an abstract class and cannot be instantiated” error…
Is there any way I can use this Visitor pattern from Python?
Any guidance will be gratefully received…
class VTKDatasetToApexMesh(vtkDataAssemblyVisitor):
def __init__(self):
self.target=None
def Visit(self, node):
print('Visiting {}'.format(node))
There’s nothing in VTK’s wrapping that makes inheriting from a C++ class callable from C++ automatically. It would need something like vtkPythonAlgorithm that looks at the “self” object and calls Python methods in the C++ implementation to work properly.
The VTK python wrappers don’t implement a virtual method hook that would allow this to work. By “hook”, I mean wrapper code that would call the Python subclass method (e.g. “Visit”) when the corresponding C++ virtual method is called. I know that this description makes it sound like a trivial thing, but implementing it is definitely non-trivial.
I’ve though about implementing this many times, but have never gotten around to actually doing it.