/[escript]/trunk/pyvisi/py_src/carpet.py
ViewVC logotype

Diff of /trunk/pyvisi/py_src/carpet.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 859 by jongui, Wed Sep 20 03:23:16 2006 UTC revision 860 by jongui, Thu Sep 28 08:17:29 2006 UTC
# Line 1  Line 1 
 """  
 class that represents scalar data as plane deformated along the plane normal  
 and proportional to the scalar value on the plane.  
 """  
   
1  import vtk  import vtk
2  from plane import Plane  from plane import Plane
3  from common import Common  from common import Common
4    
5  class Carpet(Common, Plane):  class Carpet(Common, Plane):
6      """      """
7      represents scalar data as plane deformated along the plane normal      Class that represents scalar data as plane deformated along the plane
8      and proportional to the scalar value on the plane.      normal and proportional to the scalar value on the plane.
9      """      """
10    
11      def __init__(self, scene, data_collector, lut = None):      def __init__(self, scene, data_collector, transform, lut = None):
12            """
13            @type scene: L{Scene <scene.Scene>} object
14            @param scene: Scene in which components are to be added to
15            @type data_collector: L{DataCollector <datacollector.DataCollector>}
16                object
17            @type transform: L{Transform <geo.Transform>} object
18            @param transform: Orientation of the plane
19            @type lut: L{BlueToRed <colormap.BlueToRed>} or
20                L{RedToBlue <colormap.RedToBlue>} object
21            @param lut: Lookup table to be used by the mapper
22            """
23    
24          Common.__init__(self, scene, data_collector)          Common.__init__(self, scene, data_collector)
25            # Declared because needed by the setPlane method.
26          self.vtk_plane = vtk.vtkPlane()          self.vtk_plane = vtk.vtkPlane()
27          self.vtk_cutter = vtk.vtkCutter()          self.vtk_cutter = vtk.vtkCutter()
28          self.vtk_transform = vtk.vtkTransform()          self.transform = transform.getTransform()
         self.vtk_transform_filter = vtk.vtkTransformPolyDataFilter()  
29          self.vtk_warp = vtk.vtkWarpScalar()          self.vtk_warp = vtk.vtkWarpScalar()
30                    
31          Plane.setPlane(self)          Plane.setPlane(self)
32          Plane.setCutter(self, data_collector.getReader().GetOutput())            Plane.setCutter(self, data_collector.getReader().GetOutput())  
33          self.warpScalar()          self.warpScalar()
         Plane.setTransformFilter(self, self.vtk_warp.GetOutput())    
34                    
35          Common.setMapperInput(self, self.vtk_transform_filter.GetOutput(), lut)          Common.setMapperInput(self, self.vtk_warp.GetOutput(), lut)
36          Common.setActorInput(self)          Common.setActorInput(self)
37          Common.addActor(self)          Common.addActor(self)
38    
39      def warpScalar(self):      def warpScalar(self):
40            """
41            Set up the war scalar and deform the plane with scalar data.
42            """
43    
44          self.vtk_warp.SetInput(self.vtk_cutter.GetOutput())          self.vtk_warp.SetInput(self.vtk_cutter.GetOutput())
         self.vtk_warp.SetScaleFactor(0.5)  
               
                               
45    
46        def setScaleFactor(self, scale_factor):
47            """
48            Set the displacement scale factor.
49            @type scale_factor: Number
50            @param scale_factor: Size of the displacement
51            """
52    
53                    self.vtk_warp.SetScaleFactor(scale_factor)
       

Legend:
Removed from v.859  
changed lines
  Added in v.860

  ViewVC Help
Powered by ViewVC 1.1.26