lundi 19 octobre 2009

swig bindings of VTK : a call to arms

I don't know how common our situation is... We use VTK through it's Python interface but we also need to develop some algorithms in C++ and make them accessible to the Python runtime. The problem is that, as far as I know, the VTK bindings are not inter-operable with swig. The result is that we can allocate VTK data structures from Python but we can't give them to our C++ algorithm.

There are multiple solutions to this problem. The one we chose is to use swig to wrap our algorithm *and* VTK, in two different but inter-operable modules.

We will start by wrapping and testing the parts of VTK that we need right now, but if other people out there have a similar need perhaps we could collaborate and come up with better bindings.

So... is there anyone interested in participating in this not-yet-born open source project?

2 commentaires:

Anonyme a dit...

Boost.Python ?

pj

MAD a dit...

Right, using boost::python::object I could access from C++ the Python interface to the VTK objects ; but there are problems doing it this way.

Take the vtkImageData class for example. All the member functions that return pointers to the actual data (in C++) are 'translated' to Python by returning a string that can be parsed to extract the value and type of the pointer. That would be a huge hack, of course. Using the Python interface the programmer is expected to call the virtual functions to set/get any data element - in our situation the performance cost is not acceptable.

I guess I could also use Boost.Python to wrap both VTK and my dll giving my dll direct access to the VTK objects ... but that would represent pretty much the same amount of work as doing it with swig.