Commit 74d7e025 authored by David Gobbi's avatar David Gobbi Committed by David Partyka
Browse files

Fix mistakes in previous commit.

parent 8235ecfc
......@@ -54,8 +54,21 @@ class vtkImageImportFromArray:
'L':VTK_UNSIGNED_LONG, # uint64
'f':VTK_FLOAT, # float32
'd':VTK_DOUBLE, # float64
'F':VTK_FLOAT, # float32
'D':VTK_DOUBLE, # float64
}
__sizeDict = { VTK_SIGNED_CHAR:1,
VTK_UNSIGNED_CHAR:1,
VTK_SHORT:2,
VTK_UNSIGNED_SHORT:2,
VTK_INT:4,
VTK_UNSIGNED_INT:4,
VTK_LONG:4,
VTK_UNSIGNED_LONG:4,
VTK_FLOAT:4,
VTK_DOUBLE:8 }
# convert 'Int32' to 'unsigned short'
def SetConvertIntToUnsignedShort(self,yesno):
self.__ConvertIntToUnsignedShort = yesno
......@@ -100,8 +113,10 @@ class vtkImageImportFromArray:
ar_type = self.__typeDict[typecode]
complexComponents = 1
if (typecode == 'F' or typecode == 'D'):
numComponents = numComponents * 2
complexComponents = 2
if (self.__ConvertIntToUnsignedShort and typecode == 'i'):
imTmpArr = imArray.astype('h').flat
......@@ -109,7 +124,7 @@ class vtkImageImportFromArray:
else:
imTmpArr = imArray.flat
size = len(imTmpArr)*self.__sizeDict[type]*numComponents
size = len(imTmpArr)*self.__sizeDict[ar_type]*complexComponents
self.__import.CopyImportVoidPointer(imTmpArr,size)
self.__import.SetDataScalarType(ar_type)
self.__import.SetNumberOfScalarComponents(numComponents)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment