[vtkusers] vtk and python - some questions.

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Wed Oct 25 02:14:27 EDT 2000


>>>>> "Chris" == Chris Myers <myers at tc.cornell.edu> writes:

    Chris> This is somewhat tangential to the main thread regarding
    Chris> VTK, Python and SWIG, but it is related.


    Chris> Has anybody thought about such things, or how they might be
    Chris> made to work?

        Well, if the python wrappers were perfect, this would never be
a problem. :) I think using py_cpp is a step towards the goals you are
seeking.  this is because, if all of VTK were wrapped with py_cpp then
vtkUnstructured grid would be a proper python object and not only
could you pass it along to any function that requires a
vtkUnstructuredGrid you could also derive a sub class and pass an
instance of the subclass!!  Imagine the number of cool things you
could do.

        OTOH if you had a contributed c++ class that you want to use
from python you could still wrap it using py_cpp and then expose just
that class and use it with the rest of the python classes.

        Hopefully, it should not be too hard to use py_cpp.  It
certainly looks interesting and is well worth the effort.  Let me see
if I can find some time soon. :)

    Chris> P.S.  Having looked at the VTK introspection code that
    Chris> Prabhu wrote to implement his VTK-CFD, I can understand his
    Chris> frustration with the lack of certain features in the
    Chris> Python/VTK interface.  SWIG-wrapped objects can be
    Chris> examined, for example, through the __class__ and __bases__
    Chris> attributes, to reconstruct available methods for those
    Chris> objects.  I dug around in the Python/C API a bit trying to

        There are positive things to what I had to do.  I learnt
regexp's while building vtkPipeline.py. ;) Besides the current
wrappings do allow one to do quite a bit (with a little imagination).
The only thing is that vtk objects behave strangely at times.  Most of
the functions work, except for wierd Segfaults which I have to trap
with dirty hacks.

    Chris> understand this better when Prabhu was asking a few months
    Chris> ago about introspection-related matters, but I don't recall
    Chris> reaching any real conclusions.  Are there attributes of
    Chris> python objects that could be incorporated into the existing
    Chris> VTK/Python wrappers without introducing too much extra
    Chris> code?

        Well, IMHO, the pipeline browser for python works well.  So I
really cannot blame the python wrappers.  But there is scope for some
fantastic improvements with the wrappers.  I sincerely hope I can be
part of those improvements. :)

        Actually, if we do improve the python wrappers, the pipeline
browser would really suffer and I'd have to rewrite the parser engine.
But that shouldnt be too hard.


More information about the vtkusers mailing list