ParaView/Python/Programmable Filters: Difference between revisions
From KitwarePublic
< ParaView
Jump to navigationJump to search
Daviddoria (talk | contribs) No edit summary |
(added footer) |
||
Line 16: | Line 16: | ||
out.GetCellData().AddArray(newData) | out.GetCellData().AddArray(newData) | ||
</source> | </source> | ||
{{ParaView/Template/Footer}} |
Revision as of 15:14, 29 September 2009
- Convert float colors to unsigned char colors
The Transform filter converts any colors to floats, which Paraview cannot handle. To convert them back, you can use this: <source lang=text> inp = self.GetInput() out = self.GetOutput()
numCells = inp.GetNumberOfCells() data = inp.GetCellData().GetArray("Colors")
newData = vtk.vtkUnsignedCharArray() newData.SetName('Colors_converted') newData.SetNumberOfComponents(3) for i in range(0, 3*numCells):
val = int(data.GetValue(i)) newData.InsertNextValue(val)
out.GetCellData().AddArray(newData) </source>