[vtkusers] Creating a very large VTK array from a numpy array

Jim Geach jimgeach at physics.mcgill.ca
Mon Sep 26 10:25:00 EDT 2011


Hi List, 

I'm rendering very large grids that require use of VTK's USE_64BIT_IDS. Following a previous post where I was having trouble with this, I upgraded to version 5.8 which fixed a bug that was not allowing ImageData to use the 64bit indexing (and this flag was set to "ON" in the CMake, and the machine is more than capable).

Now I've got a new problem: I'm working from Python, and creating VTK arrays from numpy arrays, but I still run into problems when the number of elements gets too large. As an example of what I'm talking about:

from numpy import zeros
import vtk

a = zeros(2**32 - 1).astype(uint8) 		#to create a massive array
im = vtk.vtkImageImport() 			#believe this is the standard method to convert to vtk
im.CopyImportVoidPointer(a.tostring(),a.size)	#do conversion

throws the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: error return without exception set

I'm guessing the type of the second argument of CopyImportVoidPointer is the key here, but trying a few different castings I can't get it to work.

So, I guess my question boils down to: how do I convert extremely large numpy arrays into vtk arrays using the standard methods? (Note that in practice, my numpy arrays will consist of unsigned chars for volume rendering).

Thanks, Jim 




More information about the vtkusers mailing list