6 |
from mapper import DataSetMapper |
from mapper import DataSetMapper |
7 |
from lookuptable import LookupTable |
from lookuptable import LookupTable |
8 |
from actor import Actor3D |
from actor import Actor3D |
9 |
from constant import Viewport, Color, Lut, VizType, ColorMode |
from constant import Viewport, Color, Lut, ColorMode |
10 |
from sphere import Sphere |
from sphere import Sphere |
11 |
from normals import Normals |
from normals import Normals |
12 |
from glyph import TensorGlyph |
from glyph import TensorGlyph |
53 |
@param outline: Places an outline around the domain surface |
@param outline: Places an outline around the domain surface |
54 |
""" |
""" |
55 |
|
|
56 |
# NOTE: Actor3D is inherited and there are two instances declared here. |
self.__scene = scene |
57 |
# As a result, when methods from Actor3D is invoked from the driver, |
self.__data_collector = data_collector |
58 |
# only the methods associated with the latest instance (which in this |
self.__viewport = viewport |
59 |
# case is the Actor3D for the Ellipsoid) can be executed. Actor3D |
self.__lut = lut |
60 |
# methods associated with Outline cannot be invoked from the driver. |
self.__cell_to_point = cell_to_point |
61 |
# They can only be called within here, which is why Outline must be |
self.__outline = outline |
62 |
# place before Ellipsoid as there is unlikely to be any changes |
|
63 |
# made to the Outline's Actor3D. |
# Keeps track whether Ellipsoid has been modified. |
64 |
|
self.__modified = True |
65 |
# ----- Outline ----- |
MaskPoints.__init__(self) |
66 |
|
Sphere.__init__(self) |
67 |
if(outline == True): |
TensorGlyph.__init__(self) |
68 |
outline = Outline(data_collector._getOutput()) |
Normals.__init__(self) |
69 |
DataSetMapper.__init__(self, outline._getOutput()) |
DataSetMapper.__init__(self) |
70 |
|
Actor3D.__init__(self) |
71 |
|
scene._addVisualizationModules(self) |
72 |
|
|
73 |
|
# ----- Outline ----- |
74 |
|
|
75 |
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
# NOTE: Changes cannot be made to the Outline's properties from the |
76 |
|
# driver. |
77 |
|
if(self.__outline == True): |
78 |
|
outline = Outline(self.__data_collector._getDataCollectorOutput()) |
79 |
|
mapper = DataSetMapper() |
80 |
|
mapper._setupDataSetMapper(outline._getOutlineOutput()) |
81 |
|
|
82 |
|
actor3D = Actor3D() |
83 |
|
actor3D._setupActor3D(mapper._getDataSetMapper()) |
84 |
# Default outline color is black. |
# Default outline color is black. |
85 |
Actor3D.setColor(self, Color.BLACK) |
actor3D.setColor(Color.BLACK) |
86 |
|
|
87 |
# Default line width is 1. |
# Default line width is 1. |
88 |
Actor3D._setLineWidth(self, 1) |
actor3D._setLineWidth(1) |
89 |
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
self.__scene._addActor3D(self.__viewport, actor3D._getActor3D()) |
90 |
|
|
91 |
# ----- Ellipsoid ----- |
# ----- Ellipsoid ----- |
92 |
|
|
93 |
# NOTE: Lookup table color mapping (color or grey scale) MUST be set |
# NOTE: Lookup table color mapping (color or grey scale) MUST be set |
94 |
# before DataSetMapper. If it is done after DataSetMapper, no effect |
# before DataSetMapper. If it is done after DataSetMapper, no effect |
95 |
# will take place. |
# will take place. |
96 |
if(lut == Lut.COLOR): # Colored lookup table. |
if(self.__lut == Lut.COLOR): # Colored lookup table. |
97 |
lookup_table = LookupTable() |
lookup_table = LookupTable() |
98 |
lookup_table._setTableValue() |
lookup_table._setTableValue() |
99 |
elif(lut == Lut.GREY_SCALE): # Grey scaled lookup table. |
elif(self.__lut == Lut.GREY_SCALE): # Grey scaled lookup table. |
100 |
lookup_table = LookupTable() |
lookup_table = LookupTable() |
101 |
lookup_table._setLookupTableToGreyScale() |
lookup_table._setLookupTableToGreyScale() |
102 |
|
|
103 |
if(cell_to_point == True): # Converts cell data to point data. |
if(self.__cell_to_point == True): # Converts cell data to point data. |
104 |
c2p = CellDataToPointData(data_collector._getOutput()) |
c2p = CellDataToPointData( |
105 |
MaskPoints.__init__(self, c2p._getOutput()) |
self.__data_collector._getDataCollectorOutput()) |
106 |
elif(cell_to_point == False): # No conversion happens. |
self._setupMaskPoints(c2p._getCellToPointOutput()) |
107 |
MaskPoints.__init__(self, data_collector._getOutput()) |
elif(self.__cell_to_point == False): # No conversion happens. |
108 |
|
self._setupMaskPoints( |
109 |
Sphere.__init__(self) |
self.__data_collector._getDataCollectorOutput()) |
110 |
TensorGlyph.__init__(self, MaskPoints._getOutput(self), |
|
111 |
Sphere._getOutput(self)) |
self._setupTensorGlyph(self._getMaskPointsOutput(), |
112 |
Normals.__init__(self, TensorGlyph._getOutput(self)) |
self._getSphereOutput()) |
113 |
|
self._setupNormals(self._getTensorGlyphOutput()) |
114 |
|
|
115 |
DataSetMapper.__init__(self, Normals._getOutput(self), |
self._setupDataSetMapper(self._getNormalsOutput(), |
116 |
lookup_table._getLookupTable()) |
lookup_table._getLookupTable()) |
|
DataSetMapper._setScalarRange(self, data_collector._getScalarRange()) |
|
117 |
|
|
118 |
data_collector._paramForUpdatingMultipleSources(VizType.ELLIPSOID, |
self._setupActor3D(self._getDataSetMapper()) |
119 |
ColorMode.SCALAR, DataSetMapper._getDataSetMapper(self)) |
self.__scene._addActor3D(self.__viewport, self._getActor3D()) |
120 |
|
|
121 |
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
def _isModified(self): |
122 |
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
""" |
123 |
|
Return whether the Ellipsoid or DataCollector has been modified. |
124 |
|
|
125 |
|
@rtype: Boolean |
126 |
|
@return: True or False |
127 |
|
""" |
128 |
|
|
129 |
|
return self.__modified or self.__data_collector._isModified() |
130 |
|
|
131 |
|
def _render(self): |
132 |
|
""" |
133 |
|
Render the ellipsoids. |
134 |
|
""" |
135 |
|
|
136 |
|
if (self._isModified() == True): |
137 |
|
if(self.__data_collector._isScalarSet() == True): |
138 |
|
self.__data_collector._setActiveScalar() |
139 |
|
if(self.__data_collector._isTensorSet() == True): |
140 |
|
self.__data_collector._setActiveTensor() |
141 |
|
|
142 |
|
self._setScalarRange(self.__data_collector._getScalarRange()) |
143 |
|
self.__modified = False |
144 |
|
|
145 |
|
|
146 |
############################################################################### |
############################################################################### |
189 |
@param outline: Places an outline around the domain surface |
@param outline: Places an outline around the domain surface |
190 |
""" |
""" |
191 |
|
|
192 |
# NOTE: Actor3D is inherited and there are two instances declared here. |
self.__scene = scene |
193 |
# As a result, when methods from Actor3D is invoked from the driver, |
self.__data_collector = data_collector |
194 |
# only the methods associated with the latest instance (which in this |
self.__viewport = viewport |
195 |
# case is the Actor3D for the Ellipsoid) can be executed. Actor3D |
self.__lut = lut |
196 |
# methods associated with Outline cannot be invoked from the driver. |
self.__cell_to_point = cell_to_point |
197 |
# They can only be called within here, which is why Outline must be |
self.__outline = outline |
198 |
# place before Ellipsoid as there is unlikely to be any changes |
|
199 |
# made to the Outline's Actor3D. |
# Keeps track whether EllipsoidOnPlaneCut has been modified. |
200 |
|
self.__modified = True |
201 |
|
Transform.__init__(self) |
202 |
|
Plane.__init__(self) |
203 |
|
Cutter.__init__(self) |
204 |
|
MaskPoints.__init__(self) |
205 |
|
Sphere.__init__(self) |
206 |
|
TensorGlyph.__init__(self) |
207 |
|
Normals.__init__(self) |
208 |
|
DataSetMapper.__init__(self) |
209 |
|
Actor3D.__init__(self) |
210 |
|
scene._addVisualizationModules(self) |
211 |
|
|
212 |
# ----- Outline ----- |
# ----- Outline ----- |
213 |
|
|
214 |
if(outline == True): |
# NOTE: Changes cannot be made to the Outline's properties from the |
215 |
outline = Outline(data_collector._getOutput()) |
# driver. |
216 |
DataSetMapper.__init__(self, outline._getOutput()) |
if(self.__outline == True): |
217 |
|
outline = Outline(self.__data_collector._getDataCollectorOutput()) |
218 |
|
mapper = DataSetMapper() |
219 |
|
mapper._setupDataSetMapper(outline._getOutlineOutput()) |
220 |
|
|
221 |
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
actor3D = Actor3D() |
222 |
|
actor3D._setupActor3D(mapper._getDataSetMapper()) |
223 |
# Default outline color is black. |
# Default outline color is black. |
224 |
Actor3D.setColor(self, Color.BLACK) |
actor3D.setColor(Color.BLACK) |
225 |
|
|
226 |
# Default line width is 1. |
# Default line width is 1. |
227 |
Actor3D._setLineWidth(self, 1) |
actor3D._setLineWidth(1) |
228 |
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
self.__scene._addActor3D(self.__viewport, actor3D._getActor3D()) |
229 |
|
|
230 |
# ----- Ellipsoid on a cut plane ----- |
# ----- Ellipsoid on a cut plane ----- |
231 |
|
|
232 |
# NOTE: Lookup table color mapping (color or grey scale) MUST be set |
# NOTE: Lookup table color mapping (color or grey scale) MUST be set |
233 |
# before DataSetMapper. If it is done after DataSetMapper, no effect |
# before DataSetMapper. If it is done after DataSetMapper, no effect |
234 |
# will take place. |
# will take place. |
235 |
if(lut == Lut.COLOR): # Colored lookup table. |
if(self.__lut == Lut.COLOR): # Colored lookup table. |
236 |
lookup_table = LookupTable() |
lookup_table = LookupTable() |
237 |
lookup_table._setTableValue() |
lookup_table._setTableValue() |
238 |
elif(lut == Lut.GREY_SCALE): # Grey scaled lookup table. |
elif(self.__lut == Lut.GREY_SCALE): # Grey scaled lookup table. |
239 |
lookup_table = LookupTable() |
lookup_table = LookupTable() |
240 |
lookup_table._setLookupTableToGreyScale() |
lookup_table._setLookupTableToGreyScale() |
241 |
|
|
242 |
Transform.__init__(self) |
self._setupPlane(self._getTransform()) |
|
Plane.__init__(self, Transform._getTransform(self)) |
|
243 |
|
|
244 |
if(cell_to_point == True): # Converts cell data to point data. |
if(self.__cell_to_point == True): # Converts cell data to point data. |
245 |
c2p = CellDataToPointData(data_collector._getOutput()) |
c2p = CellDataToPointData( |
246 |
Cutter.__init__(self, c2p._getOutput(), Plane._getPlane(self)) |
self.__data_collector._getDataCollectorOutput()) |
247 |
elif(cell_to_point == False): # No conversion happens. |
self._setupCutter(c2p._getCellToPointOutput(), self._getPlane()) |
248 |
Cutter.__init__(self, data_collector._getOutput(), |
elif(self.__cell_to_point == False): # No conversion happens. |
249 |
Plane._getPlane(self)) |
self._setupCutter(self.__data_collector._getDataCollectorOutput(), |
250 |
|
self._getPlane()) |
251 |
|
|
252 |
|
self._setupMaskPoints(self._getCutterOutput()) |
253 |
|
|
254 |
|
self._setupTensorGlyph(self._getMaskPointsOutput(), |
255 |
|
self._getSphereOutput()) |
256 |
|
self._setupNormals(self._getTensorGlyphOutput()) |
257 |
|
|
258 |
MaskPoints.__init__(self, Cutter._getOutput(self)) |
self._setupDataSetMapper(self._getNormalsOutput(), |
259 |
Sphere.__init__(self) |
lookup_table._getLookupTable()) |
260 |
|
|
261 |
TensorGlyph.__init__(self, MaskPoints._getOutput(self), |
self._setupActor3D(self._getDataSetMapper()) |
262 |
Sphere._getOutput(self)) |
self.__scene._addActor3D(self.__viewport, self._getActor3D()) |
|
Normals.__init__(self, TensorGlyph._getOutput(self)) |
|
263 |
|
|
264 |
DataSetMapper.__init__(self, Normals._getOutput(self), |
def _isModified(self): |
265 |
lookup_table._getLookupTable()) |
""" |
266 |
DataSetMapper._setScalarRange(self, data_collector._getScalarRange()) |
Return whether the EllipsoidOnPlaneCut or DataCollector has been |
267 |
|
modified. |
268 |
|
|
269 |
|
@rtype: Boolean |
270 |
|
@return: True or False |
271 |
|
""" |
272 |
|
|
273 |
data_collector._paramForUpdatingMultipleSources(VizType.ELLIPSOID, |
return self.__modified or self.__data_collector._isModified() |
274 |
ColorMode.SCALAR, DataSetMapper._getDataSetMapper(self)) |
|
275 |
|
def _render(self): |
276 |
|
""" |
277 |
|
Render the ellipsoids cut using a plane. |
278 |
|
""" |
279 |
|
|
280 |
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
if (self._isModified() == True): |
281 |
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
if(self.__data_collector._isScalarSet() == True): |
282 |
|
self.__data_collector._setActiveScalar() |
283 |
|
if(self.__data_collector._isTensorSet() == True): |
284 |
|
self.__data_collector._setActiveTensor() |
285 |
|
self._setScalarRange(self.__data_collector._getScalarRange()) |
286 |
|
self.__modified = False |
287 |
|
|
288 |
|
|
289 |
############################################################################### |
############################################################################### |
330 |
@param outline: Places an outline around the domain surface |
@param outline: Places an outline around the domain surface |
331 |
""" |
""" |
332 |
|
|
333 |
# NOTE: Actor3D is inherited and there are two instances declared here. |
self.__scene = scene |
334 |
# As a result, when methods from Actor3D is invoked from the driver, |
self.__data_collector = data_collector |
335 |
# only the methods associated with the latest instance (which in this |
self.__viewport = viewport |
336 |
# case is the Actor3D for the Ellipsoid) can be executed. Actor3D |
self.__lut = lut |
337 |
# methods associated with Outline cannot be invoked from the driver. |
self.__cell_to_point = cell_to_point |
338 |
# They can only be called within here, which is why Outline must be |
self.__outline = outline |
339 |
# place before Ellipsoid as there is unlikely to be any changes |
|
340 |
# made to the Outline's Actor3D. |
# Keeps track whether EllipsoidOnPlaneClip has been modified. |
341 |
|
self.__modified = True |
342 |
|
Transform.__init__(self) |
343 |
|
Plane.__init__(self) |
344 |
|
Clipper.__init__(self) |
345 |
|
MaskPoints.__init__(self) |
346 |
|
Sphere.__init__(self) |
347 |
|
TensorGlyph.__init__(self) |
348 |
|
Normals.__init__(self) |
349 |
|
DataSetMapper.__init__(self) |
350 |
|
Actor3D.__init__(self) |
351 |
|
scene._addVisualizationModules(self) |
352 |
|
|
353 |
# ----- Outline ----- |
# ----- Outline ----- |
354 |
|
|
355 |
if(outline == True): |
# NOTE: Changes cannot be made to the Outline's properties from the |
356 |
outline = Outline(data_collector._getOutput()) |
# driver. |
357 |
DataSetMapper.__init__(self, outline._getOutput()) |
if(self.__outline == True): |
358 |
|
outline = Outline(self.__data_collector._getDataCollectorOutput()) |
359 |
|
mapper = DataSetMapper() |
360 |
|
mapper._setupDataSetMapper(outline._getOutlineOutput()) |
361 |
|
|
362 |
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
actor3D = Actor3D() |
363 |
|
actor3D._setupActor3D(mapper._getDataSetMapper()) |
364 |
# Default outline color is black. |
# Default outline color is black. |
365 |
Actor3D.setColor(self, Color.BLACK) |
actor3D.setColor(Color.BLACK) |
366 |
|
|
367 |
# Default line width is 1. |
# Default line width is 1. |
368 |
Actor3D._setLineWidth(self, 1) |
actor3D._setLineWidth(1) |
369 |
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
self.__scene._addActor3D(self.__viewport, actor3D._getActor3D()) |
370 |
|
|
371 |
# ----- Ellipsoid on a clipped plane ----- |
# ----- Ellipsoid on a clipped plane ----- |
372 |
|
|
373 |
# NOTE: Lookup table color mapping (color or grey scale) MUST be set |
# NOTE: Lookup table color mapping (color or grey scale) MUST be set |
374 |
# before DataSetMapper. If it is done after DataSetMapper, no effect |
# before DataSetMapper. If it is done after DataSetMapper, no effect |
375 |
# will take place. |
# will take place. |
376 |
if(lut == Lut.COLOR): # Colored lookup table. |
if(self.__lut == Lut.COLOR): # Colored lookup table. |
377 |
lookup_table = LookupTable() |
lookup_table = LookupTable() |
378 |
lookup_table._setTableValue() |
lookup_table._setTableValue() |
379 |
elif(lut == Lut.GREY_SCALE): # Grey scaled lookup table. |
elif(self.__lut == Lut.GREY_SCALE): # Grey scaled lookup table. |
380 |
lookup_table = LookupTable() |
lookup_table = LookupTable() |
381 |
lookup_table._setLookupTableToGreyScale() |
lookup_table._setLookupTableToGreyScale() |
382 |
|
|
383 |
Transform.__init__(self) |
self._setupPlane(self._getTransform()) |
|
Plane.__init__(self, Transform._getTransform(self)) |
|
384 |
|
|
385 |
if(cell_to_point == True): # Converts cell data to point data. |
if(self.__cell_to_point == True): # Converts cell data to point data. |
386 |
c2p = CellDataToPointData(data_collector._getOutput()) |
c2p = CellDataToPointData( |
387 |
MaskPoints.__init__(self, c2p._getOutput()) |
self.__data_collector._getDataCollectorOutput()) |
388 |
elif(cell_to_point == False): # No conversion happens. |
self._setupMaskPoints(c2p._getCellToPointOutput()) |
389 |
MaskPoints.__init__(self, data_collector._getOutput()) |
elif(self.__cell_to_point == False): # No conversion happens. |
390 |
|
self._setupMaskPoints( |
391 |
|
self.__data_collector._getDataCollectorOutput()) |
392 |
|
|
393 |
# NOTE: TensorGlyph must come before Clipper. Otherwise clipping |
# NOTE: TensorGlyph must come before Clipper. Otherwise clipping |
394 |
# may not work correctly. |
# may not work correctly. |
395 |
Sphere.__init__(self) |
self._setupTensorGlyph(self._getMaskPointsOutput(), |
396 |
TensorGlyph.__init__(self, MaskPoints._getOutput(self), |
self._getSphereOutput()) |
397 |
Sphere._getOutput(self)) |
self._setupNormals(self._getTensorGlyphOutput()) |
|
Normals.__init__(self, TensorGlyph._getOutput(self)) |
|
398 |
|
|
399 |
# NOTE: Clipper must come after TensorGlyph. Otherwise clipping |
# NOTE: Clipper must come after TensorGlyph. Otherwise clipping |
400 |
# may not work correctly. |
# may not work correctly. |
401 |
Clipper.__init__(self, Normals._getOutput(self), |
self._setupClipper(self._getNormalsOutput(), |
402 |
Plane._getPlane(self)) |
self._getPlane()) |
403 |
Clipper._setClipFunction(self) |
self._setClipFunction() |
404 |
|
|
405 |
DataSetMapper.__init__(self, Clipper._getOutput(self), |
self._setupDataSetMapper(self._getClipperOutput(), |
406 |
lookup_table._getLookupTable()) |
lookup_table._getLookupTable()) |
407 |
DataSetMapper._setScalarRange(self, data_collector._getScalarRange()) |
|
408 |
|
self._setupActor3D(self._getDataSetMapper()) |
409 |
|
self.__scene._addActor3D(self.__viewport, self._getActor3D()) |
410 |
|
|
411 |
|
def _isModified(self): |
412 |
|
""" |
413 |
|
Return whether the EllipsoidOnPlaneClip or DataCollector has been |
414 |
|
modified. |
415 |
|
|
416 |
|
@rtype: Boolean |
417 |
|
@return: True or False |
418 |
|
""" |
419 |
|
|
420 |
|
return self.__modified or self.__data_collector._isModified() |
421 |
|
|
422 |
|
def _render(self): |
423 |
|
""" |
424 |
|
Render the ellipsoids clip using a plane. |
425 |
|
""" |
426 |
|
|
427 |
data_collector._paramForUpdatingMultipleSources(VizType.ELLIPSOID, |
if (self._isModified() == True): |
428 |
ColorMode.SCALAR, DataSetMapper._getDataSetMapper(self)) |
if(self.__data_collector._isScalarSet() == True): |
429 |
|
self.__data_collector._setActiveScalar() |
430 |
|
if(self.__data_collector._isTensorSet() == True): |
431 |
|
self.__data_collector._setActiveTensor() |
432 |
|
self._setScalarRange(self.__data_collector._getScalarRange()) |
433 |
|
self.__modified = False |
434 |
|
|
|
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
|
|
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
|
435 |
|
|