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

Prabhu Ramachandran prabhu at aero.iitb.ac.in
Sat Feb 16 07:07:27 EST 2008


Berk Geveci wrote:
> I committed the buffer support to VTK. I also have some stuff that
> provides the python support for this but it is definitely not as
> robust as Prabhu's code in TVTK. If you don't have time in the next
> few weeks to put those in VTK, maybe I can do it using TVTK as
> baseline.

I've added this code along with tests to CVS.  The code is in 
vtk.util.numpy_support.  I am not going to add the imports to util's 
__init__ since that will add a dependency on numpy just to get anything 
in the util namespace.

This version is different from that in TVTK in that it does not do 
automatic caching of input arrays.  Therefore it will raise an error if 
you pass it a non-contiguous array.  Likewise if a user gc's the numpy 
array and uses the VTK array they will run into problems.  The array 
caching is definitely doable but adds complexity to the code.  If this 
is desired I can add it.  Do let me know.

I've added a test case for the code in 
Common/Testing/Python/TestNumpySupport.py.

cheers,
prabhu



More information about the vtk-developers mailing list