[vtk-developers] Python wrapper change summary

Marcus D. Hanwell marcus.hanwell at kitware.com
Fri Aug 6 15:08:35 EDT 2010


On Fri, Aug 6, 2010 at 3:01 PM, David Gobbi <david.gobbi at gmail.com> wrote:

> 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.
>

This is great news, and I am very pleased we can start using the enum
values. Can we start using the enum types in our API too, i.e. go from void
SetType(int enumValue) to void SetType(enumType enumValue)?

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

Does this mean we could deprecate some of this API, or is it still very much
required for the Tcl and Java wrappers?

>
> 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.
>

Sounds great, well worth a few of the length rebuilds required ;-) I will be
testing some of this out, and would like to start streamlining the API in
some of the classes I work on.

Thanks!

Marcus
--
Marcus D. Hanwell, Ph.D.
R&D Engineer, Kitware Inc.
(518) 881-4937
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100806/1692f544/attachment.html>


More information about the vtk-developers mailing list