[PySide] Binding C++/VTK code using Shiboken
Matthew Woehlke
matthew.woehlke at kitware.com
Thu Dec 12 18:07:47 CET 2013
On 2013-12-12 11:09, Nicolas SAUBAT wrote:
> I'm trying to bind to Python a C++ framework, called CamiTK
> (http://camitk.imag.fr) which is based on Qt and VTK (http://www.vtk.org/).
> For binding Qt C++ classes, no problem, we can tell Shiboken how to use
> Qt in Python, thanks to the provided typesystem.xml files.
> But I was wondering, how we can do the same stuff using VTK ?
Well. That's a good question.
If you just want to generate bindings for VTK-based objects, VTK has its
own wrapping system that will allow you to do that. (IME it's rather
limited compared to Shiboken; no support for enums, STL containers,
etc.) However, getting the two to talk to each other is likely to be an
issue.
What you would ultimately need to do, I think, is to be able to teach
Shiboken how to get a vtkObject* from a PyObject. As far as the Shiboken
architecture, I think you should be able to write custom converters for
this.
The problem comes with how VTK implements its conversions, which depends
on having a pointer to the call arguments, which is not available in
Shiboken. As such, I'm not sure that (at the C++ level) it is possible
to get the vtkObject* from *just* a PyObject.
TBH, I have the same problem and haven't solved it, except that I
decided the best thing to do would be to rewrite VTK's wrapping to just
use Shiboken and be done with it ;-). If you find a solution, please let
me know. (If you can throw $$ at making VTK use Shiboken, please also
let me know ;-).)
Note that it's probably impossible to wrap a VTK-derived object with
Shiboken in any useful way.
--
Matthew
More information about the PySide
mailing list