[vtkusers] Can I mix Boost.Python and VTK Python wrapper?
David Gobbi
david.gobbi at gmail.com
Wed Feb 23 09:00:11 EST 2011
Hi Andrew,
It is possible to generate VTK/Python objects from the memory address
of the C++ VTK objects. In the python wrappers, you can get the memory
address of a VTK object like this:
o = vtk.vtkObject()
address = o.__this__
and to create a python-wrapped object from a memory address, do this:
o = vtk.vtkObject(address)
Also, if you want an object to "look" like a VTK/Python object even if
it isn't, you can add a __vtk__() method which will be called when a
conversion to a VTK/Python object is required by the wrappers.
If you are successful using this to mix Boost.Python and VTK/Python,
please report back to the list because there are probably other people
who are interested in doing the same. More information about the
wrappers is provided here:
http://vtk.org/gitweb?p=VTK.git;a=blob;f=Wrapping/Python/README_WRAP.txt
Cheers,
- David
2011/2/23 Андрей Траченко <goodrone at gmail.com>:
> I have an application in C++, which uses VTK. Now I'm exposing C++
> classes to Python using Boost.Python library and using my C++ classes
> within Python scripts.
>
> Now I want to pass VTK objects between C++ and Python code. Is there
> any correct way to do it? As far as I understand, vtkSmartPointer is
> used as a "smart pointer" in terms of Boost.Python to wrap VTK C++
> classes.
>
> Currently I'm swapping vtkUnstructuredGrid and other stuff using
> temporary files, and it's way too slow on large datasets, so I hope I
> could build a "bridge" between C++ and Python for VTK.
>
> Thanks!
> Andrew
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list