[vtkusers] SetArray() method with python?

Richard A Rowe rar109 at york.ac.uk
Tue May 8 11:03:42 EDT 2007


Dear All,

Is it possible to use the SetArray() method using python?
I have a 3D array in python called colourMap[ ][ ][ ]. I'd like to use the information within this array to selectively change the colour of a vtk mesh. To change the colour I know to use:

polyData.GetPointData().SetScalars(scalars)

where polyData is a vtkPolyData() and scalars is a vtkDataArray()

Currently I am using a for loop:

scalars = vtk.vtkIntArray()

for x in range(NumberOfPoints):
    scalars.InsertNextValue(colourMap[0][0][x])


Would it be faster to refer to the colourMap data using:

scalars.SetArray(colourMap[0][0])?

than inserting each value one by one?

Is it possible to use scalars.SetArray(colourMap[0][0]) in a python vtk setup?

So far I've had no joy. Please let me know if I've missed something or if anyone has any suggestions.

Kind Regards,

Richard. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070508/adb49746/attachment.htm>


More information about the vtkusers mailing list