[vtk-developers] Python wrapper change summary

David Gobbi david.gobbi at gmail.com
Fri Aug 6 15:01:15 EDT 2010


Hi All,

This is a brief summary of new vtk/python features for people to try:

1) The wrapping of vtkVariant, vtkArrayRange, vtkArrayCoordinates etc.
has changed.  Each of these types now has its own "type object" which
doubles as the object constructor.  This means that if you do
"help(vtkVariant)" in python, all the methods will be listed.  In the
future, this also means that I will be able to wrap more operator
methods.  For people who want to try out vtkVariant, there is an
example here: http://www.vtk.org/Wiki/VTK/Examples/Python/Variant

2) Constants are automatically wrapped, as long as they are defined in
one of the following ways in the headers:

#define VTK_CELL_SIZE 512
const int VTK_CELL_SIZE = 512;
enum { VTK_CELL_SIZE = 512, ... };

Some important header files aren't wrapped yet, such as vtkCellType.h,
but they will be soon.  Enums and constant variables that are class
members are also wrapped, so vtkDataObject.POINT_DATA_FIELD can be
used.  Note that the vast majority of these enums have BTX/ETX around
them and are only wrapped because in the git head I am forcing the
wrappers to ignore BTX/ETX in the main "kit" directories.  So the
wrapping of these enums will only become permanent when the BTX/ETX
markers are removed.

3) The vtkDataArray GetTuple() and SetTuple() methods are wrapped.  So
python users don't have to use the SetTuple2(), GetTuple3() methods
anymore.

v = vtkIntArray()
v.SetNumberOfComponents(3)
v.InsertNextTuple((1, 2, 3))
or to insert without intermediate conversion to "double":
v.InsertNextTupleValue((1,2,3))
(x,y,z) = v.GetTuple(0)
or use RHS get method:
rval  = [0,0,0]
v.GetTupleValue(1, rval)

4) Clinton has added a two-way VTK/Python/SIP bridge and has wrapped
the GUISupport/Qt directory.  I've compiled this but haven't tried it
yet.  A couple tests/examples would be nice (hint hint).

So, that's it for now.  Enjoy.

   David



More information about the vtk-developers mailing list