[vtk-developers] vtkArray and Python
David Gobbi
david.gobbi at gmail.com
Mon Apr 18 18:02:44 EDT 2011
Hi Timothy,
With the new python wrappers in VTK 5.8, all VTK constants
are wrapped automatically, so you can to do this:
from vtk import *
array = vtkArray.CreateArray(vtkArray.SPARSE, VTK_DOUBLE)
All #define'd constants in VTK are found in the "vtk" module. The
names are always identical to the C++ names.
For older versions of VTK, "from vtk.util.vtkConstants import *" will
import VTK_DOUBLE and all the other constants.
- David
On Mon, Apr 18, 2011 at 3:17 PM, Timothy Shead <tshead at sandia.gov> wrote:
> Gang:
>
> If I wanted to create a sparse array of doubles in Python, it would look
> like the following:
>
> array = vtkArray.CreateArray(vtkArray.SPARSE, 11)
>
> where "11" is the value for VTK_DOUBLE, which I knew to look-up in
> vtkType.h. I'm wondering whether there's an enumeration of VTK types
> anywhere that's Python-accessible. Otherwise, I'd be inclined to put such
> an enumeration in vtkArray, so I could write
>
> array = vtkArray.CreateArray(vtkArray.SPARSE, vtkArray.DOUBLE)
>
> ... any thoughts? Objections? It would be duplicating the enumeration in
> vtkType.h, but it seems to be justifiable for purposes of discoverability
> ...
>
> Cheers,
> Tim
>
> --
> Timothy M. Shead
> Sandia National Laboratories
> 1461, Scalable Analysis and Visualization
More information about the vtk-developers
mailing list