/[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 852 by jongui, Wed Sep 20 03:23:16 2006 UTC revision 882 by jongui, Fri Oct 27 08:15:33 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 a scalar field as a 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            deform = None):
13            """
14            @type scene: L{Scene <scene.Scene>} object
15            @param scene: Scene in which components are to be added to
16            @type data_collector: L{DataCollector <datacollector.DataCollector>}
17                object
18            @type transform: L{Transform <geo.Transform>} object
19            @param transform: Orientation of the plane
20            @type lut: L{BlueToRed <colormap.BlueToRed>} or
21                L{RedToBlue <colormap.RedToBlue>} object
22            @param lut: Lookup table to be used by the mapper
23            @type deform: String
24            @param deform: Mode the data is deformed. Either by I{Scalar}
25                or I{Vector}
26            """
27    
28          Common.__init__(self, scene, data_collector)          Common.__init__(self, scene, data_collector)
29            # Declared because needed by the setPlane method.
30          self.vtk_plane = vtk.vtkPlane()          self.vtk_plane = vtk.vtkPlane()
31          self.vtk_cutter = vtk.vtkCutter()          self.vtk_cutter = vtk.vtkCutter()
32          self.vtk_transform = vtk.vtkTransform()          self.transform = transform.getTransform()
33          self.vtk_transform_filter = vtk.vtkTransformPolyDataFilter()          
34          self.vtk_warp = vtk.vtkWarpScalar()          if(deform == "Scalar"):
35                self.vtk_warp = vtk.vtkWarpScalar()
36            else:
37                self.vtk_warp = vtk.vtkWarpVector()
38                
39                    
40          Plane.setPlane(self)          Plane.setPlane(self)
41          Plane.setCutter(self, data_collector.getReader().GetOutput())            Plane.setCutter(self, data_collector.getReader().GetOutput())  
42          self.warpScalar()          self.warpScalar()
         Plane.setTransformFilter(self, self.vtk_warp.GetOutput())    
43                    
44          Common.setMapperInput(self, self.vtk_transform_filter.GetOutput(), lut)          #Common.setMapperInput(self, self.vtk_warp.GetOutput(), lut)
45            Common.setMapperInput(self, self.vtk_cutter.GetOutput(), lut)
46          Common.setActorInput(self)          Common.setActorInput(self)
47          Common.addActor(self)          Common.addActor(self)
48    
49      def warpScalar(self):      def warpScalar(self):
50            """
51            Set up the warp scalar and deform the plane with scalar data.
52            """
53    
54          self.vtk_warp.SetInput(self.vtk_cutter.GetOutput())          self.vtk_warp.SetInput(self.vtk_cutter.GetOutput())
         self.vtk_warp.SetScaleFactor(0.5)  
               
                               
55    
56        def setScaleFactor(self, scale_factor):
57            """
58            Set the displacement scale factor.
59            @type scale_factor: Number
60            @param scale_factor: Size of the displacement
61            """
62    
63                    self.vtk_warp.SetScaleFactor(scale_factor)
       

Legend:
Removed from v.852  
changed lines
  Added in v.882

  ViewVC Help
Powered by ViewVC 1.1.26