[vtk-developers] PROPOSAL: Adding buffer interface to vtkDataArray python wrappers

Berk Geveci berk.geveci at kitware.com
Tue Feb 12 16:45:33 EST 2008


Hi folks,

Currently, the only way to process VTK arrays using python modules
such as numpy (and vice versa) is to create deep copies of VTK arrays
using vtkImageExport/Import (see
VTK/Wrapping/Python/vtk/util/vtkImageExportToArray.py and
vtkImageImportFromArray.py). This is very inefficient and doubles the
memory usage. I would like to propose a change to the way VTK arrays
are wrapped to allow sharing of data between VTK arrays and python
objects using the buffer interface. The attached patch would allow us
to do things like this:

pyarray = numpy.frombuffer(vtkarray, dtype=type)

What do you think? I am pretty much a python novice so I probably
missed a better way of doing this :-)

-berk
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: arrayasbufferpatch.txt
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20080212/e4ccbd00/attachment-0001.txt>


More information about the vtk-developers mailing list