[vtk-developers] Wrapping vtkVariant and other special types in Python

David Gobbi david.gobbi at gmail.com
Tue May 4 14:44:23 EDT 2010


> On Mon, May 3, 2010 at 7:41 AM, Brad King <brad.king at kitware.com> wrote:
>
> It "would be nice" if python scripts could just pass
> their own values and have them automatically converted to vtkVariant
> if no other overload is a better/direct match.  I'm not sure this is
> practical, but if you have time to investigate this possibility I would
> be interested in the results.

This feature has been pushed out to my VTK on github.  With this
change, it is possible to do this:

a = vtk.vtkVariantArray()
a.InsertNextValue(1.0) # insert a float
a.InsertNextValue(1) # insert an int
a.InsertNextValue(vtk.vtkUnsignedCharArray())

The wrapper generators don't know anything about vtkVariant except
that it has the WRAP_SPECIAL property set in CMake.  This is all done
automatically based on the constructors declared in the header file.

In terms of "progress", three issues remain on my to-do list:
1) fix wrapper support for python "bool", it's pretty weak right now
2) the vtkStdString and vtkUnicodeString fixes... yikes!
3) code reorganization

  David



More information about the vtk-developers mailing list