[vtkusers] c api and python and vtk - with SWIG

Mark Asbach mark.asbach at post.rwth-aachen.de
Thu Jan 29 03:34:32 EST 2004


Salut Aurélien,

> I don't think you need any cast if instead of returning a 
> vtkUnstructuredGrid * in your C++ code you return the PyObject * 
> returned by vtkPythonGetObjectFromPointer( your_vtkUnstructuredGrid * 
> ).

That's right. In fact we are doing the same thing, but you propose to 
do the cast on the C++ side which gives you cleaner code on the Python 
side but as a drawback ties your C++ code to Python.

In my project I build a C++ lib that is meant for building C++ 
programs. In addition, I offer a Python interface and I could also 
imagine offering other languages as well. That's why I'm using SWIG and 
that is also the reason why I want to keep my C++ classes fully 
independent of Python data types.

Yours, Mark





More information about the vtkusers mailing list