1 |
""" |
2 |
@author: John Ngui |
3 |
@author: Lutz Gross |
4 |
""" |
5 |
|
6 |
import vtk |
7 |
from common import * |
8 |
|
9 |
class Contour(Common): |
10 |
""" |
11 |
Class that shows a scalar field by contour surfaces. |
12 |
""" |
13 |
|
14 |
def __init__(self, scene, data_collector, lut = None): |
15 |
""" |
16 |
@type scene: L{Scene <scene.Scene>} object |
17 |
@param scene: Scene in which components are to be added to |
18 |
@type data_collector: L{DataCollector <datacollector.DataCollector>} |
19 |
object |
20 |
@param data_collector: Source of data for visualization |
21 |
@type lut: L{BlueToRed <colormap.BlueToRed>} or |
22 |
L{RedToBLue <colormap.RedToBlue>} object |
23 |
@param lut: Lookup table to be used by the mapper |
24 |
""" |
25 |
|
26 |
Common.__init__(self, scene, data_collector) |
27 |
self.vtk_contour = vtk.vtkContourFilter() |
28 |
self.setContour() |
29 |
|
30 |
Common.setMapperInput(self, self.vtk_contour.GetOutput(), lut) |
31 |
Common.setActorInput(self) |
32 |
Common.addActor(self) |
33 |
|
34 |
def setContour(self): |
35 |
""" |
36 |
Set up the contour. |
37 |
""" |
38 |
|
39 |
self.vtk_contour.SetInput(self.data_collector.getReader().GetOutput()) |
40 |
|
41 |
def generateValues(self, number_contours, min_range, max_range): |
42 |
""" |
43 |
Generate the specified number of contours within the specified range. |
44 |
|
45 |
@type number_contours: Number |
46 |
@param number_contours: Number of contours to generate |
47 |
@type min_range: Number |
48 |
@param min_range: Minimum contour range |
49 |
@type max_range: Number |
50 |
@param max_range: Maximum contour range |
51 |
""" |
52 |
|
53 |
self.vtk_contour.GenerateValues(number_contours, min_range, max_range) |
54 |
|
55 |
from contour import Contour |
56 |
from plane import Plane |
57 |
|
58 |
class ContourOnPlane(Contour, Plane): |
59 |
""" |
60 |
Class that shows a scalar field by contour surfaces on a given plane. |
61 |
""" |
62 |
|
63 |
def __init__(self, scene, data_collector, transform, lut = None): |
64 |
""" |
65 |
@type scene: L{Scene <scene.Scene>} object |
66 |
@param scene: Scene in which components rae to be added to |
67 |
@type data_collector: L{DataCollector <datacollector.DataCollector>} |
68 |
object |
69 |
@param data_collector: Source of data for visualization |
70 |
@param transform: L{Transform <geo.Transform>} object |
71 |
@type transform: Orientation of the plane |
72 |
@type lut: L{BlueToRed <colormap.BlueToRed>} or |
73 |
L{RedToBLue <colormap.RedToBlue>} object |
74 |
@param lut: Lookup table to be used by the mapper |
75 |
""" |
76 |
|
77 |
# Declared because they are needed by the setContour method. |
78 |
self.data_collector = data_collector |
79 |
self.vtk_contour = vtk.vtkContourFilter() |
80 |
|
81 |
Contour.setContour(self) |
82 |
# "Cut" is used to distinguish cutting from clipping. |
83 |
Plane.__init__(self, scene, data_collector, |
84 |
self.vtk_contour.GetOutput(), transform, lut, "Cut") |
85 |
|
86 |
|
87 |
from contour import Contour |
88 |
from plane import Plane |
89 |
|
90 |
class ContourOnClip(Contour, Plane): |
91 |
""" |
92 |
Class that shows a scalar field by contour surfaces on a given clip. |
93 |
""" |
94 |
|
95 |
def __init__(self, scene, data_collector, transform, lut = None): |
96 |
""" |
97 |
@type scene: L{Scene <scene.Scene>} object |
98 |
@param scene: Scene in which components rae to be added to |
99 |
@type data_collector: L{DataCollector <datacollector.DataCollector>} |
100 |
object |
101 |
@param data_collector: Source of data for visualization |
102 |
@param transform: L{Transform <geo.Transform>} object |
103 |
@type transform: Orientation of the plane |
104 |
@type lut: L{BlueToRed <colormap.BlueToRed>} or |
105 |
L{RedToBLue <colormap.RedToBlue>} object |
106 |
@param lut: Lookup table to be used by the mapper |
107 |
""" |
108 |
|
109 |
# Declared because they are needed by the setContour method. |
110 |
self.data_collector = data_collector |
111 |
self.vtk_contour = vtk.vtkContourFilter() |
112 |
|
113 |
|
114 |
Contour.setContour(self) |
115 |
# "Clip" is used to distinguish clipping from cutting. |
116 |
Plane.__init__(self, scene, data_collector, |
117 |
self.vtk_contour.GetOutput(), transform, lut, "Clip") |