--- trunk/pyvisi/py_src/carpet.py 2006/09/26 02:19:18 859 +++ trunk/pyvisi/py_src/carpet.py 2006/09/28 08:17:29 860 @@ -1,41 +1,53 @@ -""" -class that represents scalar data as plane deformated along the plane normal -and proportional to the scalar value on the plane. -""" - import vtk from plane import Plane from common import Common class Carpet(Common, Plane): """ - represents scalar data as plane deformated along the plane normal - and proportional to the scalar value on the plane. + Class that represents scalar data as plane deformated along the plane + normal and proportional to the scalar value on the plane. """ - def __init__(self, scene, data_collector, lut = None): + def __init__(self, scene, data_collector, transform, lut = None): + """ + @type scene: L{Scene } object + @param scene: Scene in which components are to be added to + @type data_collector: L{DataCollector } + object + @type transform: L{Transform } object + @param transform: Orientation of the plane + @type lut: L{BlueToRed } or + L{RedToBlue } object + @param lut: Lookup table to be used by the mapper + """ + Common.__init__(self, scene, data_collector) + # Declared because needed by the setPlane method. self.vtk_plane = vtk.vtkPlane() self.vtk_cutter = vtk.vtkCutter() - self.vtk_transform = vtk.vtkTransform() - self.vtk_transform_filter = vtk.vtkTransformPolyDataFilter() + self.transform = transform.getTransform() self.vtk_warp = vtk.vtkWarpScalar() Plane.setPlane(self) Plane.setCutter(self, data_collector.getReader().GetOutput()) self.warpScalar() - Plane.setTransformFilter(self, self.vtk_warp.GetOutput()) - Common.setMapperInput(self, self.vtk_transform_filter.GetOutput(), lut) + Common.setMapperInput(self, self.vtk_warp.GetOutput(), lut) Common.setActorInput(self) Common.addActor(self) def warpScalar(self): + """ + Set up the war scalar and deform the plane with scalar data. + """ + self.vtk_warp.SetInput(self.vtk_cutter.GetOutput()) - self.vtk_warp.SetScaleFactor(0.5) - - + def setScaleFactor(self, scale_factor): + """ + Set the displacement scale factor. + @type scale_factor: Number + @param scale_factor: Size of the displacement + """ - - + self.vtk_warp.SetScaleFactor(scale_factor)