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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 882 - (show annotations)
Fri Oct 27 08:15:33 2006 UTC (12 years, 7 months ago) by jongui
File MIME type: text/x-python
File size: 1871 byte(s)
Fixed some bugs in the camera module but yet to fix bugs in the plane module.

1 import vtk
2 from plane import Plane
3 from common import Common
4
5 class Carpet(Common, Plane):
6 """
7 Class that represents a scalar field as a plane deformated along the plane
8 normal and proportional to the scalar value on the plane.
9 """
10
11 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)
29 # Declared because needed by the setPlane method.
30 self.vtk_plane = vtk.vtkPlane()
31 self.vtk_cutter = vtk.vtkCutter()
32 self.transform = transform.getTransform()
33
34 if(deform == "Scalar"):
35 self.vtk_warp = vtk.vtkWarpScalar()
36 else:
37 self.vtk_warp = vtk.vtkWarpVector()
38
39
40 Plane.setPlane(self)
41 Plane.setCutter(self, data_collector.getReader().GetOutput())
42 self.warpScalar()
43
44 #Common.setMapperInput(self, self.vtk_warp.GetOutput(), lut)
45 Common.setMapperInput(self, self.vtk_cutter.GetOutput(), lut)
46 Common.setActorInput(self)
47 Common.addActor(self)
48
49 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())
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)

  ViewVC Help
Powered by ViewVC 1.1.26