[vtk-developers] python wrappers & external types

David Gobbi david.gobbi at gmail.com
Thu Jul 1 18:45:46 EDT 2010


I've written a few demos and one large application with VTK/Python and
PyQt, so items like this are definitely on my mind as I'm working on
the VTK wrappers.

What I'm thinking of doing, now that the wrappers can deal with
"non-vtkObject" objects, is to eventually treat all externals as
opaque types.  So let me know if the following would work for you.

Tomorrow I'm adding my vtkWrapHierarchy support to VTK, which allows
the VTK wrappers to do the following:
1) find out if any type they encounter is external to the kit
2) find the base class of any type in the kit
3) find the header file for any class in the kit (i.e. for helper classes)

For my first commit, this information will only be used in a very
crude manner, i.e. to make sure the wrappers don't wrap methods with a
"vtkSomething *" parameter unless "vtkSomething" is derived from
vtkObjectBase.  This will allow the VTK BTX/ETX markers to be
eliminated for such methods.

In the future, though, external objects could be detected and wrapped
as opaque objects.  They would dealt with using reference semantics
(rather than value semantics) but I don't think that will be a
problem.  As far as the wrappers are concerned, there will just be a
pointer to some unknown object being passed back and forth.  The only
thing that we have to worry about is getting a reference to a
temporary that disappears before the reference does, so it might be
necessary to do some fancy stuff with python weakrefs.  I haven't
thought that far ahead, though.

If I ever get around to doing it myself, it would be a while before I
could start on it.  But if you are inclined, I can point you to the
interesting places in the code.

  David


On Thu, Jul 1, 2010 at 3:33 PM, Clinton Stimpson <clinton at elemtech.com> wrote:
> Hi,
>
> I'm working on making VTK Python work with Python wrappers generated with SIP
> (PyQt's wrapper generator).
>
> Is there is a way to hook into VTK's python wrapping generator to deal with
> external types implemented in other libraries?  Or what would it take to make
> that work?
>
> For example, I'm able to teach SIP to deal with external types, such as VTK
> classes.  Only a PyObject -> vtkObject and vtkObject -> PyObject methods are
> implemented for each VTK class (using vtkPythonUtil).
> So, it works if a VTK class is passed through a method of a SIP wrapped class.
>
> I'm interested in making it work the other way too.
> I just tried to wrap a class and a method of interest got ignored and skipped
> over.
>
> Thanks,
> Clint
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>



More information about the vtk-developers mailing list