[vtkusers] c api and python and vtk

REGAT-BARREL Aurélien arbvtk at yahoo.fr
Wed Jan 28 13:47:11 EST 2004


Hello,
if you simply want to convert VTK objects instances drom C++ to Python or from Python to C++, have a look at these functions defined in vtkPythonUtil.h :
vtkPythonGetObjectFromPointer // C++ -> Python
vtkPythonGetPointerFromObject // Python -> C++
 
I have written a small example here :
http://coding.bug.free.fr/lib/vtk/vtkpythoncpp.htm
It is in french but you should understand.
 
Creating a VTK object and filling it from C++ is much faster that creating it from Python and filling it from python with values returned by C++ since you will do a lots of InsertNextValue from Python and it is very slow due to wrapping. Thats the reason why I had to deal with vtkPythonGetObjectFromPointer .
Good luck.
 
Aurélien

rharder at uiuc.edu wrote:
Hi,
I have a problem. It's probably easy, but the available
documentation is not making it obvious.

I have a set of C codes that manipulate a data structure, one
component of which is an array of doubles. I've managed to
wrap the C codes with SWIG so I have access to the structure
with the typical SWIG accessor functions, i.e. Sp4Array_data_get()
What do I have to do to get this data array into vtk?
data is declared within the structure as double* data.

I would like to avoid using Numarray or Numeric, I think I 
should write a short C++ function to move the data to a
vtk datatype and the pass it back to python to impliment the
visualization. How do I do that, assuming that is what's needed?
I don't get how my C++ instantiation of a vtk datatype is 
passed back to a python instantiation of the same type.

I may not be able to see the forest for the trees, this is my
first forray into python and vtk. Thanks in advance for any
help you can offer.

Ross

_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: 
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers


---------------------------------
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Testez le nouveau Yahoo! Mail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040128/3d9fd343/attachment.htm>


More information about the vtkusers mailing list