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

David Gobbi david.gobbi at gmail.com
Tue Feb 12 17:45:19 EST 2008


Hi Berk,

As far as I can see, you chose the right way to move forward.
It has been possible for years to convert a numpy array to
VTK without duplication, but never before has it been possible
to do the reverse.

Even though I wrote the vtkImageImport/Export, I have hardly
ever used them because of the memory waste.

A nice addition to this would be a "vtk.util.fromvtk()" function
that will automatically check the data type and the number
of scalar components.

   David



2008/2/12 Berk Geveci <berk.geveci at kitware.com>:
> 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
>
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>



More information about the vtk-developers mailing list