ParaView/Python/Programmable Filters

From KitwarePublic
< ParaView
Revision as of 20:20, 14 September 2009 by Daviddoria (talk | contribs) (New page: * 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: <sourc lang=text> i...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
  • 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: <sourc 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>