1 |
import vtk |
2 |
from plane import Plane |
3 |
from common import Common |
4 |
|
5 |
class Carpet(Common, Plane): |
6 |
""" |
7 |
Class that represents scalar data as 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 |
""" |
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) |
25 |
# Declared because needed by the setPlane method. |
26 |
self.vtk_plane = vtk.vtkPlane() |
27 |
self.vtk_cutter = vtk.vtkCutter() |
28 |
self.transform = transform.getTransform() |
29 |
self.vtk_warp = vtk.vtkWarpScalar() |
30 |
|
31 |
Plane.setPlane(self) |
32 |
Plane.setCutter(self, data_collector.getReader().GetOutput()) |
33 |
self.warpScalar() |
34 |
|
35 |
Common.setMapperInput(self, self.vtk_warp.GetOutput(), lut) |
36 |
Common.setActorInput(self) |
37 |
Common.addActor(self) |
38 |
|
39 |
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()) |
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) |