[vtkusers] SWIG'ed module and python-vtk

Bram Stolk bram at sara.nl
Wed Jul 26 10:36:10 EDT 2006

Hi there,

If I swig a API with references to vtk classes, I get a class
in type names when interfacing with python vtk.

When presented with a 'vtkObject*', SWIG will be expecting objects
with the named type '_p_vtkObject'

I tried to accomodate this by removing the '_p_' prefix from
the type name, but even then there is no match:

TypeError: argument number 1: a 'vtkObject' is expected, 
'vtkobject(vtkOpenGLActor (0x825b6f0)
)' is received.

When looking at the vtk4.4 sources, however, I see some traces
for SWIG accomodations.

e.g. In file Common/vtkPythonUtil.cxx I find:

// mangle a void pointer into a SWIG-style string
char *vtkPythonManglePointer(void *ptr, const char *type)
  static char ptrText[128];
  sprintf(ptrText,"_%*.*lx_%s",2*(int)sizeof(void *),2*(int)sizeof(void *),
  return ptrText;

So... has anyone figured out to use the vtk python module with
a 'roll-your-own' swigged module that uses vtk objects?



Bram Stolk, VR Engineer SARA, Amsterdam.   tel +31 20 592 3000

"Windows is a 32-bit extension to a 16-bit graphical shell for an 8-bit 
 operating system originally coded for a 4-bit microprocessor by a 2-bit 
 company that can't stand 1 bit of competition."

More information about the vtkusers mailing list