[vtkusers] Python 2.2 Core

Brad Howes bradhowes at mac.com
Sun Mar 17 13:48:10 EST 2002


I've just begun working with VTK and its Python interfaces. I got everything
to compile on my RedHat 7.2 Intel box without problems. I can run all of the
examples (though the Tcl/Tk ones report a Segmentation Fault upon exiting).
I had no problem converting hello.tcl into a hello.py script, and it too
runs. However, when I try to do the same for xyPlot.tcl, I run into a
problem with the following snippet:

  from vtkpython import *
  a = vtkTransform()
  b = vtkTransformPolyDataFilter()
  b.SetTransform( a )

Python burps saying that `a' is not a VTK object. The routine that says this
is vtkPythonoGetPointerFromObject in Common/vtkPythonUtil.cxx. I'm still
trying to grok the VTK/Python interfacing and object mapping, but I think
there's a bug here. The conditional on line 1343

  if ( obj->ob_type != &PyVTKObjectType )

returns true for the vtkTransform objects. I see in GDB that obj->ob_type
indeed has a different value. I believe this is because
vtkTransformPython.cxx has a custom `new' method which installs a different
class structure than PyVTKObjectType.

On a whim, I forced the conditional to always give false, and I changed the
code that looked for and executed a '__vtk__' function into one that
demangled '__this__'. This got rid of the error message, but I introduced a
segmentation fault. This appears to be caused by the code that searches for
a class object in the internal class dictionary. The search returns a NULL
pointer, which is not checked for, and soon after a Py_INCREF is attempted
on the NULL, causing the seg fault.

Has anyone got any hints on where to go from here? I've tried this on both
the VTK-4 release as well as a nightly build tarball pulled last week.

Thanks,

Brad

PS: just got to say that this is one incredible package! My book order is in
the works. Just hope I can get this problem solved so I can show my boss a
cool demo.




More information about the vtkusers mailing list