[vtkusers] Deriving python classes from vtk classes?
David Gobbi
dgobbi at irus.rri.on.ca
Fri Jun 23 14:39:19 EDT 2000
On 23 Jun 2000, Alexandre Guimond wrote:
> Hi there. I just started playing with python and was hoping that I
> would be able to have python classes inherit from vtk classes. From
> what I understand, vtk classes are not "classes" in python from which
> I could derive other classes. Is there a way to simulate such a
> thing, ie deriving vtk classes in python?
The best you can do is write a python class that has the same method names
as the VTK class, and which contains a copy of the VTK class. If you
do this with e.g. a source or a filter, by simply writing python
SetInput/GetOutput methods and a few Set/Get methods you can make a
python class that is indistinguishable from a real VTK class.
You must also ensure that the pipeline behaviour is the same as for
a real VTK class, this can be difficult or impossible sometimes.
There is no way to override virtual methods from a VTK class, or
at least not unless you want to delve into some tricky c++ programming
as well as python programming.
- David
--
David Gobbi, MSc dgobbi at irus.rri.on.ca
Advanced Imaging Research Group
Robarts Research Institute, University of Western Ontario
More information about the vtkusers
mailing list