


import vtk
#import cassandra

class DataSetTransformer:
     def __init__(self):

         print "Transform DataSet"
         self.dsIn = None

     def SetDataSetIn(self, dataSetIn):
         self.dsIn = dataSetIn

     def ReadFromFile(self, FileNameIn):
         reader = vtk.vtkSetReader()
         reader.SetFileName(FileNameIn)
         self.dsIn = reader.GetOutput()

     def Run(self):   
         range = self.dsIn.GetScalarRange()
         print min, max

         mapper = vtk.vtkDataSetMapper()
         mapper.SetInput(self.dsIn)
         mapper.SetScalarRange(range)

         mapper.Update()
         actor = vtk.vtkActor()
         actor.SetMapper(mapper)

         #adding of a scalar bar
         lTable = vtk.vtkLookupTable()
         lTable.SetRange(range)
         lTable.Build();
         #lTable.SetScaleToLog10();

         nbPt = self.dsIn.GetNumberOfPoints()
         print nbPt
         for indexPt in range(10):
             value = self.dsIn.GetPointData().GetScalars().GetTuple1(indexPt)
             selfIn.dsIn.GetPointData().GetScalars().SetTuple1(index, (-1*value))

         #dsOut = thresh.GetOutput()

         mapper.SetInput(selfIn.dsIn)  #   thresh.GetOutput())

         cassandra.getPipeLineManager().addDataSet(selfIn.dsIn, "Inverted")
         cassandra.getPipeLineManager().addMapper(mapper, "Inverted Mapper")
         cassandra.getPipeLineManager().addActor(actor, "Inverted")
