1 |
jongui |
943 |
""" |
2 |
|
|
@author: John NGUI |
3 |
|
|
""" |
4 |
|
|
|
5 |
|
|
import vtk |
6 |
|
|
from mapper import DataSetMapper |
7 |
|
|
from lookuptable import LookupTable |
8 |
|
|
from actor import Actor3D |
9 |
|
|
from constant import Viewport, Color, Lut |
10 |
|
|
from sphere import Sphere |
11 |
|
|
from normals import Normals |
12 |
|
|
from glyph import TensorGlyph |
13 |
|
|
from outline import Outline |
14 |
jongui |
945 |
from point import StructuredPoints |
15 |
|
|
from probe import Probe |
16 |
jongui |
943 |
|
17 |
jongui |
947 |
# NOTE: DataSetMapper, Actor3D, Sphere, Normals, TensorGlyph, |
18 |
|
|
# StructuredPoints and Probe were inherited to allow access to their |
19 |
|
|
# public methods from the driver. |
20 |
|
|
class Ellipsoid(DataSetMapper, Actor3D, Sphere, Normals, TensorGlyph, |
21 |
|
|
StructuredPoints, Probe): |
22 |
jongui |
943 |
""" |
23 |
|
|
Class that show a tensor field using ellipsoid. |
24 |
|
|
""" |
25 |
|
|
|
26 |
|
|
# The SOUTH_WEST default viewport is used when there is only one viewport. |
27 |
|
|
# This saves the user from specifying the viewport when there is only one. |
28 |
jongui |
996 |
# If no lut is specified, the color scheme will be used. |
29 |
|
|
def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST, |
30 |
|
|
lut = Lut.COLOR, outline = True): |
31 |
jongui |
943 |
""" |
32 |
|
|
@type scene: L{Scene <scene.Scene>} object |
33 |
|
|
@param scene: Scene in which objects are to be rendered on |
34 |
|
|
@type data_collector: L{DataCollector <datacollector.DataCollector>} |
35 |
|
|
object |
36 |
|
|
@param data_collector: Deal with source of data for visualisation |
37 |
|
|
@type viewport: L{Viewport <constant.Viewport>} constant |
38 |
jongui |
947 |
@param viewport: Viewport in which objects are to be rendered on |
39 |
jongui |
943 |
@type lut : L{Lut <constant.Lut>} constant |
40 |
|
|
@param lut: Lookup table color scheme |
41 |
|
|
@type outline: Boolean |
42 |
|
|
@param outline: Places an outline around the domain surface |
43 |
|
|
""" |
44 |
|
|
|
45 |
|
|
# NOTE: Actor3D is inherited and there are two instances declared here. |
46 |
|
|
# As a result, when methods from Actor3D is invoked from the driver, |
47 |
|
|
# only the methods associated with the latest instance (which in this |
48 |
|
|
# case is the Actor3D for the Ellipsoid) can be executed. Actor3D |
49 |
|
|
# methods associated with Outline cannot be invoked from the driver. |
50 |
|
|
# They can only be called within here, which is why Outline must be |
51 |
|
|
# place before Ellipsoid as there is unlikely to be any changes |
52 |
|
|
# made to the Outline's Actor3D. |
53 |
|
|
|
54 |
|
|
# ----- Outline ----- |
55 |
|
|
|
56 |
|
|
if(outline == True): |
57 |
|
|
outline = Outline(data_collector._getOutput()) |
58 |
|
|
DataSetMapper.__init__(self, outline._getOutput()) |
59 |
|
|
|
60 |
|
|
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
61 |
|
|
# Default outline color is black. |
62 |
|
|
Actor3D.setColor(self, Color.BLACK) |
63 |
jongui |
947 |
|
64 |
jongui |
943 |
# Default line width is 1. |
65 |
|
|
Actor3D._setLineWidth(self, 1) |
66 |
|
|
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
67 |
|
|
|
68 |
|
|
# ----- Ellipsoid ----- |
69 |
|
|
|
70 |
|
|
# NOTE: Lookup table color mapping (color or grey scale) MUST be set |
71 |
|
|
# before DataSetMapper. If it is done after DataSetMapper, no effect |
72 |
|
|
# will take place. |
73 |
|
|
if(lut == Lut.COLOR): # Colored lookup table. |
74 |
|
|
lookup_table = LookupTable() |
75 |
|
|
lookup_table._setTableValue() |
76 |
|
|
elif(lut == Lut.GREY_SCALE): # Grey scaled lookup table. |
77 |
|
|
lookup_table = LookupTable() |
78 |
|
|
lookup_table._setLookupTableToGreyScale() |
79 |
|
|
|
80 |
jongui |
945 |
StructuredPoints.__init__(self, data_collector._getOutput()) |
81 |
|
|
Probe.__init__(self, data_collector._getOutput(), |
82 |
|
|
StructuredPoints._getStructuredPoints(self)) |
83 |
|
|
|
84 |
jongui |
943 |
Sphere.__init__(self) |
85 |
jongui |
945 |
TensorGlyph.__init__(self, Probe._getOutput(self), |
86 |
jongui |
943 |
Sphere._getOutput(self)) |
87 |
|
|
Normals.__init__(self, TensorGlyph._getOutput(self)) |
88 |
|
|
|
89 |
|
|
DataSetMapper.__init__(self, Normals._getOutput(self), |
90 |
|
|
lookup_table._getLookupTable()) |
91 |
|
|
DataSetMapper._setScalarRange(self, data_collector._getScalarRange()) |
92 |
|
|
|
93 |
|
|
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
94 |
|
|
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
95 |
|
|
|
96 |
|
|
|
97 |
jongui |
947 |
############################################################################### |
98 |
|
|
|
99 |
|
|
|
100 |
jongui |
943 |
from transform import Transform |
101 |
|
|
from plane import Plane |
102 |
|
|
from cutter import Cutter |
103 |
|
|
|
104 |
|
|
# NOTE: DataSetMapper, Actor3D, Sphere, Normals, TensorGlyph, Transform, Plane, |
105 |
jongui |
947 |
# Cutter, StructuredPoints and Probe were inherited to allow access to |
106 |
|
|
# their public methods from the driver. |
107 |
jongui |
943 |
class EllipsoidOnPlaneCut(DataSetMapper, Actor3D, Sphere, Normals, |
108 |
jongui |
945 |
TensorGlyph, Transform, Plane, Cutter, StructuredPoints, Probe): |
109 |
jongui |
943 |
""" |
110 |
jongui |
947 |
Class that show a tensor field using ellipsoids on a cut plane. |
111 |
jongui |
943 |
""" |
112 |
|
|
|
113 |
|
|
# The SOUTH_WEST default viewport is used when there is only one viewport. |
114 |
|
|
# This saves the user from specifying the viewport when there is only one. |
115 |
jongui |
996 |
# If no lut is specified, the color scheme will be used. |
116 |
|
|
def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST, |
117 |
|
|
lut = Lut.COLOR, outline = True): |
118 |
jongui |
943 |
""" |
119 |
|
|
@type scene: L{Scene <scene.Scene>} object |
120 |
|
|
@param scene: Scene in which objects are to be rendered on |
121 |
|
|
@type data_collector: L{DataCollector <datacollector.DataCollector>} |
122 |
|
|
object |
123 |
|
|
@param data_collector: Deal with source of data for visualisation |
124 |
|
|
@type viewport: L{Viewport <constant.Viewport>} constant |
125 |
jongui |
947 |
@param viewport: Viewport in which objects are to be rendered on |
126 |
jongui |
943 |
@type lut : L{Lut <constant.Lut>} constant |
127 |
|
|
@param lut: Lookup table color scheme |
128 |
|
|
@type outline: Boolean |
129 |
|
|
@param outline: Places an outline around the domain surface |
130 |
|
|
""" |
131 |
|
|
|
132 |
|
|
# NOTE: Actor3D is inherited and there are two instances declared here. |
133 |
|
|
# As a result, when methods from Actor3D is invoked from the driver, |
134 |
|
|
# only the methods associated with the latest instance (which in this |
135 |
|
|
# case is the Actor3D for the Ellipsoid) can be executed. Actor3D |
136 |
|
|
# methods associated with Outline cannot be invoked from the driver. |
137 |
|
|
# They can only be called within here, which is why Outline must be |
138 |
|
|
# place before Ellipsoid as there is unlikely to be any changes |
139 |
|
|
# made to the Outline's Actor3D. |
140 |
|
|
|
141 |
|
|
# ----- Outline ----- |
142 |
|
|
|
143 |
|
|
if(outline == True): |
144 |
|
|
outline = Outline(data_collector._getOutput()) |
145 |
jongui |
947 |
DataSetMapper.__init__(self, outline._getOutput()) |
146 |
jongui |
943 |
|
147 |
jongui |
947 |
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
148 |
|
|
# Default outline color is black. |
149 |
|
|
Actor3D.setColor(self, Color.BLACK) |
150 |
jongui |
943 |
|
151 |
jongui |
947 |
# Default line width is 1. |
152 |
|
|
Actor3D._setLineWidth(self, 1) |
153 |
|
|
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
154 |
jongui |
943 |
|
155 |
jongui |
947 |
# ----- Ellipsoid on a cut plane ----- |
156 |
jongui |
943 |
|
157 |
|
|
# NOTE: Lookup table color mapping (color or grey scale) MUST be set |
158 |
|
|
# before DataSetMapper. If it is done after DataSetMapper, no effect |
159 |
|
|
# will take place. |
160 |
|
|
if(lut == Lut.COLOR): # Colored lookup table. |
161 |
|
|
lookup_table = LookupTable() |
162 |
|
|
lookup_table._setTableValue() |
163 |
|
|
elif(lut == Lut.GREY_SCALE): # Grey scaled lookup table. |
164 |
|
|
lookup_table = LookupTable() |
165 |
|
|
lookup_table._setLookupTableToGreyScale() |
166 |
|
|
|
167 |
|
|
Transform.__init__(self) |
168 |
|
|
Plane.__init__(self, Transform._getTransform(self)) |
169 |
|
|
|
170 |
jongui |
945 |
StructuredPoints.__init__(self, data_collector._getOutput()) |
171 |
|
|
Probe.__init__(self, data_collector._getOutput(), |
172 |
|
|
StructuredPoints._getStructuredPoints(self)) |
173 |
|
|
|
174 |
|
|
Cutter.__init__(self, Probe._getOutput(self), |
175 |
jongui |
943 |
Plane._getPlane(self)) |
176 |
jongui |
947 |
Sphere.__init__(self) |
177 |
jongui |
943 |
|
178 |
|
|
TensorGlyph.__init__(self, Cutter._getOutput(self), |
179 |
|
|
Sphere._getOutput(self)) |
180 |
jongui |
947 |
Normals.__init__(self, TensorGlyph._getOutput(self)) |
181 |
jongui |
943 |
|
182 |
|
|
DataSetMapper.__init__(self, Normals._getOutput(self), |
183 |
|
|
lookup_table._getLookupTable()) |
184 |
jongui |
947 |
DataSetMapper._setScalarRange(self, data_collector._getScalarRange()) |
185 |
jongui |
943 |
|
186 |
|
|
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
187 |
|
|
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
188 |
|
|
|
189 |
|
|
|
190 |
jongui |
947 |
############################################################################### |
191 |
|
|
|
192 |
|
|
|
193 |
jongui |
943 |
from clipper import Clipper |
194 |
|
|
|
195 |
|
|
# NOTE: DataSetMapper, Actor3D, Sphere, Normals, TensorGlyph, Transform, Plane, |
196 |
jongui |
947 |
# Clipper, StructuredPoints and Probe were inherited to allow access to |
197 |
|
|
# their public methods from the driver. |
198 |
jongui |
943 |
class EllipsoidOnPlaneClip(DataSetMapper, Actor3D, Sphere, Normals, |
199 |
jongui |
945 |
TensorGlyph, Transform, Plane, Clipper, StructuredPoints, Probe): |
200 |
jongui |
943 |
""" |
201 |
jongui |
947 |
Class that show a tensor field using ellipsoids on a clipped plane. |
202 |
jongui |
943 |
""" |
203 |
|
|
|
204 |
|
|
# The SOUTH_WEST default viewport is used when there is only one viewport. |
205 |
|
|
# This saves the user from specifying the viewport when there is only one. |
206 |
jongui |
996 |
# If no lut is specified, the color scheme will be used. |
207 |
|
|
def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST, |
208 |
|
|
lut = Lut.COLOR, outline = True): |
209 |
jongui |
943 |
""" |
210 |
|
|
@type scene: L{Scene <scene.Scene>} object |
211 |
|
|
@param scene: Scene in which objects are to be rendered on |
212 |
|
|
@type data_collector: L{DataCollector <datacollector.DataCollector>} |
213 |
|
|
object |
214 |
|
|
@param data_collector: Deal with source of data for visualisation |
215 |
|
|
@type viewport: L{Viewport <constant.Viewport>} constant |
216 |
jongui |
947 |
@param viewport: Viewport in which object are to be rendered on |
217 |
jongui |
943 |
@type lut : L{Lut <constant.Lut>} constant |
218 |
|
|
@param lut: Lookup table color scheme |
219 |
|
|
@type outline: Boolean |
220 |
|
|
@param outline: Places an outline around the domain surface |
221 |
|
|
""" |
222 |
|
|
|
223 |
|
|
# NOTE: Actor3D is inherited and there are two instances declared here. |
224 |
|
|
# As a result, when methods from Actor3D is invoked from the driver, |
225 |
|
|
# only the methods associated with the latest instance (which in this |
226 |
|
|
# case is the Actor3D for the Ellipsoid) can be executed. Actor3D |
227 |
|
|
# methods associated with Outline cannot be invoked from the driver. |
228 |
|
|
# They can only be called within here, which is why Outline must be |
229 |
|
|
# place before Ellipsoid as there is unlikely to be any changes |
230 |
|
|
# made to the Outline's Actor3D. |
231 |
|
|
|
232 |
|
|
# ----- Outline ----- |
233 |
|
|
|
234 |
|
|
if(outline == True): |
235 |
|
|
outline = Outline(data_collector._getOutput()) |
236 |
jongui |
947 |
DataSetMapper.__init__(self, outline._getOutput()) |
237 |
jongui |
943 |
|
238 |
jongui |
947 |
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
239 |
|
|
# Default outline color is black. |
240 |
|
|
Actor3D.setColor(self, Color.BLACK) |
241 |
jongui |
943 |
|
242 |
jongui |
947 |
# Default line width is 1. |
243 |
|
|
Actor3D._setLineWidth(self, 1) |
244 |
|
|
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
245 |
jongui |
943 |
|
246 |
|
|
# ----- Ellipsoid on a clipped plane ----- |
247 |
|
|
|
248 |
|
|
# NOTE: Lookup table color mapping (color or grey scale) MUST be set |
249 |
|
|
# before DataSetMapper. If it is done after DataSetMapper, no effect |
250 |
|
|
# will take place. |
251 |
|
|
if(lut == Lut.COLOR): # Colored lookup table. |
252 |
|
|
lookup_table = LookupTable() |
253 |
|
|
lookup_table._setTableValue() |
254 |
|
|
elif(lut == Lut.GREY_SCALE): # Grey scaled lookup table. |
255 |
|
|
lookup_table = LookupTable() |
256 |
|
|
lookup_table._setLookupTableToGreyScale() |
257 |
|
|
|
258 |
|
|
Transform.__init__(self) |
259 |
|
|
Plane.__init__(self, Transform._getTransform(self)) |
260 |
|
|
|
261 |
jongui |
945 |
StructuredPoints.__init__(self, data_collector._getOutput()) |
262 |
|
|
Probe.__init__(self, data_collector._getOutput(), |
263 |
|
|
StructuredPoints._getStructuredPoints(self)) |
264 |
|
|
|
265 |
jongui |
943 |
# NOTE: TensorGlyph must come before Clipper. Otherwise the output |
266 |
|
|
# will be incorrect. |
267 |
|
|
Sphere.__init__(self) |
268 |
jongui |
945 |
TensorGlyph.__init__(self, Probe._getOutput(self), |
269 |
jongui |
943 |
Sphere._getOutput(self)) |
270 |
jongui |
947 |
|
271 |
jongui |
943 |
Normals.__init__(self, TensorGlyph._getOutput(self)) |
272 |
|
|
# NOTE: Clipper must come after TensorGlyph. Otherwise the output |
273 |
|
|
# will be incorrect. |
274 |
|
|
Clipper.__init__(self, Normals._getOutput(self), |
275 |
|
|
Plane._getPlane(self)) |
276 |
|
|
Clipper._setClipFunction(self) |
277 |
|
|
|
278 |
|
|
DataSetMapper.__init__(self, Clipper._getOutput(self), |
279 |
|
|
lookup_table._getLookupTable()) |
280 |
jongui |
947 |
DataSetMapper._setScalarRange(self, data_collector._getScalarRange()) |
281 |
jongui |
943 |
|
282 |
|
|
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
283 |
|
|
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
284 |
|
|
|