[vtkusers] vtk, Python and SWIG - 'state of the union'

Charl P. Botha c.p.botha at ewi.tudelft.nl
Mon Oct 13 10:31:48 EDT 2003


Mark Asbach wrote:
> this topic has come up several times here, but I could find a 
> comprehensive and general solution for those who just want to integrate 
> vtk with  own python/c++ projects, especially if SWIG or Boost++/python 

What exactly are you trying to do?  Many people get tangled up in the 
different wrapping systems because they are trying to over-engineer some 
poor solution.  You don't HAVE to create a universal, earth-shattering 
scheme if that's not required, and it mostly isn't.

> I guess I found the code mentioned in the postings (SWIG pointer 
> [un]mangling) in Common/vtkPythonUtil.cxx, but doesn't seem to get 
> involved in the usual python argument parsing done by vtk. Does anybody 
> know, how to 'cast' swig pointers an vtk objects to 'native' vtk objects 
> in python? Others seem to have written their own converters from 
> vtk/python to SWIG/python:
> 
>     http://www.itk.org/pipermail/insight-users/2003-July/004388.html
> 
> The above approach seems to be available with itk only and I don't know 
> if it's general enough for non-itk projects.

The idea behind it is quite general.  You can play with it; it lives in 
InsightApplications/ConnectVTKITK.  You would be able to do something 
similar with whatever other library/code you want to inter-operate with.

Personally, if my project is mostly VTK based, I write VTK objects.  If 
it's ITK-based, I write ITK objects.  In some applications I use both, 
which is why I spent some time on playing with ITK/VTK connections in 
scripting world.  My own C++ code itself mostly conforms to either VTK 
or ITK class conventions, which makes most things (not only wrapping) 
much easier.

Regards,
Charl

-- 
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/




More information about the vtkusers mailing list