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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2365 - (show annotations)
Mon Apr 6 01:25:25 2009 UTC (10 years, 4 months ago) by gross
File MIME type: text/x-python
File size: 25645 byte(s)
all tests passed under scons on 4 mpi processes with  openmpi on shake34
1
2 ########################################################
3 #
4 # Copyright (c) 2003-2008 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 ########################################################
13
14 __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="https://launchpad.net/escript-finley"
21
22 """
23 @var __author__: name of author
24 @var __copyright__: copyrights
25 @var __license__: licence agreement
26 @var __url__: url entry point on documentation
27 @var __version__: version
28 @var __date__: date of the version
29 """
30
31 __author__="John Ngui, john.ngui@uq.edu.au"
32
33
34 from mapper import DataSetMapper
35 from actor import Actor3D
36 from lookuptable import LookupTable
37 from outline import Outline
38 from constant import Viewport, Color, Lut, ColorMode
39 from average import CellDataToPointData
40 from esys.escript import getMPISizeWorld
41 if getMPISizeWorld()==1: import vtk
42
43 # NOTE: DataSetMapper and Actor3D were inherited to allow access to their
44 # public methods from the driver.
45 class Map(DataSetMapper, Actor3D):
46 """
47 Class that shows a scalar field on a domain surface. The domain surface
48 can either be colored or grey-scaled, depending on the lookup table used.
49 """
50
51 # The SOUTH_WEST default viewport is used when there is only one viewport.
52 # This saves the user from specifying the viewport when there is only one.
53 # If no lut is specified, the color scheme will be used.
54 def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,
55 lut = Lut.COLOR, cell_to_point = False, outline = True):
56 """
57 Initialise the Map.
58
59 @attention: The source can either be point or cell data. If the
60 source is cell data, a conversion to point data may or may not be
61 required, in order for the object to be rendered correctly.
62 If a conversion is needed, the 'cell_to_point' flag must be set to
63 'True', otherwise 'False' (which is the default). On occasions, an
64 inaccurate object may be rendered from cell data even after conversion.
65
66 @type scene: L{Scene <scene.Scene>} object
67 @param scene: Scene in which objects are to be rendered on
68 @type data_collector: L{DataCollector <datacollector.DataCollector>}
69 object
70 @param data_collector: Deal with source of data for vizualisation
71 @type viewport: L{Viewport <constant.Viewport>} constant
72 @param viewport: Viewport in which objects are to be rendered on
73 @type lut : L{Lut <constant.Lut>} constant
74 @param lut: Lookup table color scheme
75 @type cell_to_point: Boolean
76 @param cell_to_point: Converts cell data to point data (by averaging)
77 @type outline: Boolean
78 @param outline: Places an outline around the domain surface
79 """
80
81 self.__data_collector = data_collector
82 self.__viewport = viewport
83 self.__lut = lut
84 self.__cell_to_point = cell_to_point
85 self.__outline = outline
86
87 self.__modified = True # Keeps track whether Map has been modified.
88 DataSetMapper.__init__(self)
89 Actor3D.__init__(self)
90 scene._addVisualizationModules(self)
91
92 # ----- Outline -----
93
94 # NOTE: Changes cannot be made to the Outline's properties from the
95 # driver.
96 if(self.__outline == True):
97 outline = Outline(self.__data_collector._getDataCollectorOutput())
98 mapper = DataSetMapper()
99 mapper._setupDataSetMapper(outline._getOutlineOutput())
100
101 actor3D = Actor3D()
102 actor3D._setupActor3D(mapper._getDataSetMapper())
103 # Default outline color is black.
104 actor3D.setColor(Color.BLACK)
105
106 # Default line width is 1.
107 actor3D._setLineWidth(1)
108 scene._addActor3D(self.__viewport, actor3D._getActor3D())
109
110 # ----- Map -----
111
112 # NOTE: Lookup table color mapping (color or grey scale) MUST be set
113 # before DataSetMapper. If it is done after DataSetMapper, no effect
114 # will take place.
115 if(self.__lut == Lut.COLOR): # Colored lookup table.
116 lookup_table = LookupTable()
117 lookup_table._setTableValue()
118 elif(self.__lut == Lut.GREY_SCALE): # Grey scaled lookup table.
119 lookup_table = LookupTable()
120 lookup_table._setLookupTableToGreyScale()
121
122 if(self.__cell_to_point == True): # Convert cell data to point data.
123 c2p = CellDataToPointData(
124 self.__data_collector._getDataCollectorOutput())
125 self._setupDataSetMapper(c2p._getCellToPointOutput(),
126 lookup_table._getLookupTable())
127 elif(self.__cell_to_point == False): # No conversion happens.
128 self._setupDataSetMapper(
129 self.__data_collector._getDataCollectorOutput(),
130 lookup_table._getLookupTable())
131
132 self._setupActor3D(self._getDataSetMapper())
133 scene._addActor3D(self.__viewport, self._getActor3D())
134
135 def _isModified(self):
136 """
137 Return whether the Map or DataCollector has been modified.
138
139 @rtype: Boolean
140 @return: True or False
141 """
142
143 return self.__modified or self.__data_collector._isModified()
144
145 def _render(self, scene):
146 """
147 Render the surface map.
148
149 @type scene: L{Scene <scene.Scene>} object
150 @param scene: Scene in which objects are to be rendered on
151 """
152
153 if (self._isModified() == True):
154 if(self.__data_collector._isScalarSet() == True):
155 self.__data_collector._setActiveScalar()
156
157 # self._isScalarRangeSet checks whether the scalar range has been
158 # specified by the user. If it has, then the scalar range
159 # read from the source will be ignored.
160 if(not(self._isScalarRangeSet())):
161 self._setScalarRange(self.__data_collector._getScalarRange())
162 self.__modified = False
163
164
165 ###############################################################################
166
167
168 from transform import Transform
169 from plane import Plane
170 from cutter import Cutter
171
172 # NOTE: DataSetMapper, Actor3D, Transform, Plane and Cutter were inherited
173 # to allow access to their public methods from the driver.
174 class MapOnPlaneCut(DataSetMapper, Actor3D, Transform, Plane, Cutter):
175 """
176 This class works in a similar way to L{Map <map.Map>}, except that it
177 shows a scalar field cut using a plane. The plane can be translated
178 and rotated along the X, Y and Z axes.
179 """
180
181 # The SOUTH_WEST default viewport is used when there is only one viewport.
182 # This saves the user from specifying the viewport when there is only one.
183 # If no lut is specified, the color scheme will be used.
184 def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,
185 lut = Lut.COLOR, cell_to_point = False, outline = True):
186 """
187 Initialise the MapOnPlanceCut.
188
189 @attention: The source can either be point or cell data. If the
190 source is cell data, a conversion to point data may or may not be
191 required, in order for the object to be rendered correctly.
192 If a conversion is needed, the 'cell_to_point' flag must be set to
193 'True', otherwise 'False' (which is the default). On occasions, an
194 inaccurate object may be rendered from cell data even after conversion.
195
196 @type scene: L{Scene <scene.Scene>} object
197 @param scene: Scene in which objects are to be rendered on
198 @type data_collector: L{DataCollector <datacollector.DataCollector>}
199 object
200 @param data_collector: Deal with source of data for visualisation
201 @type viewport: L{Viewport <constant.Viewport>} constant
202 @param viewport: Viewport in which objects are to be rendered on
203 @type lut : L{Lut <constant.Lut>} constant
204 @param lut: Lookup table color scheme
205 @type cell_to_point: Boolean
206 @param cell_to_point: Converts cell data to point data (by averaging)
207 @type outline: Boolean
208 @param outline: Places an outline around the domain surface
209 """
210
211 self.__data_collector = data_collector
212 self.__viewport = viewport
213 self.__lut = lut
214 self.__cell_to_point = cell_to_point
215 self.__outline = outline
216
217 # Keeps track whether MapOnPlaneCut has been modified.
218 self.__modified = True
219 Transform.__init__(self)
220 Plane.__init__(self)
221 Cutter.__init__(self)
222 DataSetMapper.__init__(self)
223 Actor3D.__init__(self)
224 scene._addVisualizationModules(self)
225
226 # ----- Outline -----
227
228 # NOTE: Changes cannot be made to the Outline's properties from the
229 # driver.
230 if(self.__outline == True):
231 outline = Outline(self.__data_collector._getDataCollectorOutput())
232 mapper = DataSetMapper()
233 mapper._setupDataSetMapper(outline._getOutlineOutput())
234
235 actor3D = Actor3D()
236 actor3D._setupActor3D(mapper._getDataSetMapper())
237 # Default outline color is black.
238 actor3D.setColor(Color.BLACK)
239
240 # Default line width is 1.
241 actor3D._setLineWidth(1)
242 scene._addActor3D(self.__viewport, actor3D._getActor3D())
243
244 # ----- Map on a plane -----
245
246 # NOTE: Lookup table color mapping (color or grey scale) MUST be set
247 # before DataSetMapper. If it is done after DataSetMapper, no effect
248 # will take place.
249 if(self.__lut == Lut.COLOR): # Colored lookup table.
250 lookup_table = LookupTable()
251 lookup_table._setTableValue()
252 elif(self.__lut == Lut.GREY_SCALE): # Grey scaled lookup table.
253 lookup_table = LookupTable()
254 lookup_table._setLookupTableToGreyScale()
255
256 self._setupPlane(self._getTransform())
257
258 if(self.__cell_to_point == True): # Converts cell data to point data.
259 c2p = CellDataToPointData(
260 self.__data_collector._getDataCollectorOutput())
261 self._setupCutter(c2p._getCellToPointOutput(), self._getPlane())
262 elif(self.__cell_to_point == False): # No conversion happens.
263 c2p = CellDataToPointData(
264 self.__data_collector._getDataCollectorOutput())
265 self._setupCutter(self.__data_collector._getDataCollectorOutput(),
266 self._getPlane())
267
268 self._setupDataSetMapper(self._getCutterOutput(),
269 lookup_table._getLookupTable())
270
271 self._setupActor3D(self._getDataSetMapper())
272 scene._addActor3D(self.__viewport, self._getActor3D())
273
274 def _isModified(self):
275 """
276 Return whether the MapOnPlaneCut or DataCollector has been modified.
277
278 @rtype: Boolean
279 @return: True or False
280 """
281
282 return self.__modified or self.__data_collector._isModified()
283
284 def _render(self, scene):
285 """
286 Render the surface map cut using a plane.
287
288 @type scene: L{Scene <scene.Scene>} object
289 @param scene: Scene in which objects are to be rendered on
290 """
291
292 if (self._isModified() == True):
293 if(self.__data_collector._isScalarSet() == True):
294 self.__data_collector._setActiveScalar()
295 # self._isScalarRangeSet checks whether the scalar range has been
296 # specified by the user. If it has, then the scalar range
297 # read from the source will be ignored.
298 if(not(self._isScalarRangeSet())):
299 self._setScalarRange(self.__data_collector._getScalarRange())
300 self.__modified = False
301
302
303 ###############################################################################
304
305
306 from clipper import Clipper
307
308 # NOTE: DataSetMapper, Actor3D, Transform, Plane and Clipper were inherited
309 # to allow access to their public methods from the driver.
310 class MapOnPlaneClip(DataSetMapper, Actor3D, Transform, Plane, Clipper):
311 """
312 This class works in a similar way to L{MapOnPlaneCut <map.MapOnPlaneCut>},
313 except that it shows a scalar field clipped using a plane.
314 """
315
316 # The SOUTH_WEST default viewport is used when there is only one viewport.
317 # This saves the user from specifying the viewport when there is only one.
318 # If no lut is specified, the color scheme will be used.
319 def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,
320 lut = Lut.COLOR, cell_to_point = False, outline = True):
321 """
322 Initialise the MapOnPlaneClip.
323
324 @attention: The source can either be point or cell data. If the
325 source is cell data, a conversion to point data may or may not be
326 required, in order for the object to be rendered correctly.
327 If a conversion is needed, the 'cell_to_point' flag must be set to
328 'True', otherwise 'False' (which is the default). On occasions, an
329 inaccurate object may be rendered from cell data even after conversion.
330
331 @type scene: L{Scene <scene.Scene>} object
332 @param scene: Scene in which objects are to be rendered on
333 @type data_collector: L{DataCollector <datacollector.DataCollector>}
334 object
335 @param data_collector: Deal with source of data for visualisation
336 @type viewport: L{Viewport <constant.Viewport>} constant
337 @param viewport: Viewport in which objects are to be rendered on
338 @type lut : L{Lut <constant.Lut>} constant
339 @param lut: Lookup table color scheme
340 @type cell_to_point: Boolean
341 @param cell_to_point: Converts cell data to point data (by averaging)
342 @type outline: Boolean
343 @param outline: Places an outline around the domain surface
344 """
345
346 self.__data_collector = data_collector
347 self.__viewport = viewport
348 self.__lut = lut
349 self.__cell_to_point = cell_to_point
350 self.__outline = outline
351
352 # Keeps track whether MapOnPlaneClip has been modified.
353 self.__modified = True
354 Transform.__init__(self)
355 Plane.__init__(self)
356 Clipper.__init__(self)
357 DataSetMapper.__init__(self)
358 Actor3D.__init__(self)
359 scene._addVisualizationModules(self)
360
361 # ----- Outline -----
362
363 # NOTE: Changes cannot be made to the Outline's properties from the
364 # driver.
365 if(self.__outline == True):
366 outline = Outline(self.__data_collector._getDataCollectorOutput())
367 mapper = DataSetMapper()
368 mapper._setupDataSetMapper(outline._getOutlineOutput())
369
370 actor3D = Actor3D()
371 actor3D._setupActor3D(mapper._getDataSetMapper())
372 # Default outline color is black.
373 actor3D.setColor(Color.BLACK)
374
375 # Default line width is 1.
376 actor3D._setLineWidth(1)
377 scene._addActor3D(self.__viewport, actor3D._getActor3D())
378
379 # ----- Map on a clipped plane -----
380
381 # NOTE: Lookup table color mapping (color or grey scale) MUST be set
382 # before DataSetMapper. If it is done after DataSetMapper, no effect
383 # will take place.
384 if(self.__lut == Lut.COLOR): # Colored lookup table.
385 lookup_table = LookupTable()
386 lookup_table._setTableValue()
387 elif(self.__lut == Lut.GREY_SCALE): # Grey scaled lookup table.
388 lookup_table = LookupTable()
389 lookup_table._setLookupTableToGreyScale()
390
391 self._setupPlane(self._getTransform())
392
393 if(self.__cell_to_point == True): # Converts cell data to point data.
394 c2p = CellDataToPointData(data_collector._getDataCollectorOutput())
395 self._setupClipper(c2p._getCellToPointOutput(), self._getPlane())
396 elif(self.__cell_to_point == False): # No conversion happens.
397 self._setupClipper(data_collector._getDataCollectorOutput(),
398 self._getPlane())
399
400 self._setClipFunction()
401 self._setupDataSetMapper(self._getClipperOutput(),
402 lookup_table._getLookupTable())
403
404 self._setupActor3D(self._getDataSetMapper())
405 scene._addActor3D(self.__viewport, self._getActor3D())
406
407 def _isModified(self):
408 """
409 Return whether the MapOnPlaneClip or DataCollector has been modified.
410
411 @rtype: Boolean
412 @return: True or False
413 """
414
415 return self.__modified or self.__data_collector._isModified()
416
417 def _render(self, scene):
418 """
419 Render the surface map clip using a plane.
420
421 @type scene: L{Scene <scene.Scene>} object
422 @param scene: Scene in which objects are to be rendered on
423 """
424
425 if (self._isModified() == True):
426 if(self.__data_collector._isScalarSet() == True):
427 self.__data_collector._setActiveScalar()
428 # self._isScalarRangeSet checks whether the scalar range has been
429 # specified by the user. If it has, then the scalar range
430 # read from the source will be ignored.
431 if(not(self._isScalarRangeSet())):
432 self._setScalarRange(self.__data_collector._getScalarRange())
433 self.__modified = False
434
435
436 #############################################################################
437
438
439 # NOTE: DataSetMapper, Actor3D and Clipper were inherited
440 # to allow access to their public methods from the driver.
441 class MapOnScalarClip(DataSetMapper, Actor3D, Clipper):
442 """
443 This class works in a similar way to L{Map <map.Map>}, except that it
444 shows a scalar field clipped using a scalar value.
445 """
446
447 # The SOUTH_WEST default viewport is used when there is only one viewport.
448 # This saves the user from specifying the viewport when there is only one.
449 # If no lut is specified, the color scheme will be used.
450 def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,
451 lut = Lut.COLOR, cell_to_point = False, outline = True):
452 """
453 Initialise the MapOnScalarClip.
454
455 @attention: The source can either be point or cell data. If the
456 source is cell data, a conversion to point data may or may not be
457 required, in order for the object to be rendered correctly.
458 If a conversion is needed, the 'cell_to_point' flag must be set to
459 'True', otherwise 'False' (which is the default). On occasions, an
460 inaccurate object may be rendered from cell data even after conversion.
461
462 @type scene: L{Scene <scene.Scene>} object
463 @param scene: Scene in which objects are to be rendered on
464 @type data_collector: L{DataCollector <datacollector.DataCollector>}
465 object
466 @param data_collector: Deal with source of data for visualisation
467 @type viewport: L{Viewport <constant.Viewport>} constant
468 @param viewport: Viewport in which objects are to be rendered on
469 @type lut : L{Lut <constant.Lut>} constant
470 @param lut: Lookup table color scheme
471 @type cell_to_point: Boolean
472 @param cell_to_point: Converts cell data to point data (by averaging)
473 @type outline: Boolean
474 @param outline: Places an outline around the domain surface
475 """
476
477 self.__data_collector = data_collector
478 self.__viewport = viewport
479 self.__lut = lut
480 self.__cell_to_point = cell_to_point
481 self.__outline = outline
482
483 # Keeps track whether MapOnScalarClip has been modified.
484 self.__modified = True
485 Clipper.__init__(self)
486 DataSetMapper.__init__(self)
487 Actor3D.__init__(self)
488 scene._addVisualizationModules(self)
489
490 # ----- Outline -----
491
492 # NOTE: Changes cannot be made to the Outline's properties from the
493 # driver.
494 if(self.__outline == True):
495 outline = Outline(self.__data_collector._getDataCollectorOutput())
496 mapper = DataSetMapper()
497 mapper._setupDataSetMapper(outline._getOutlineOutput())
498
499 actor3D = Actor3D()
500 actor3D._setupActor3D(mapper._getDataSetMapper())
501 # Default outline color is black.
502 actor3D.setColor(Color.BLACK)
503
504 # Default line width is 1.
505 actor3D._setLineWidth(1)
506 scene._addActor3D(self.__viewport, actor3D._getActor3D())
507
508 # ----- Map clipped using a scalar value -----
509
510 # NOTE: Lookup table color mapping (color or grey scale) MUST be set
511 # before DataSetMapper. If it is done after DataSetMapper, no effect
512 # will take place.
513 if(self.__lut == Lut.COLOR): # Colored lookup table.
514 lookup_table = LookupTable()
515 lookup_table._setTableValue()
516 elif(self.__lut == Lut.GREY_SCALE): # Grey scaled lookup table.
517 lookup_table = LookupTable()
518 lookup_table._setLookupTableToGreyScale()
519
520 if(self.__cell_to_point == True): # Converts cell data to point data.
521 c2p = CellDataToPointData(
522 self.__data_collector._getDataCollectorOutput())
523 # None is used because a plane is not required when a scalar
524 # value is used to perform the clipping.
525 self._setupClipper(c2p._getCellToPointOutput(), None)
526 elif(self.__cell_to_point == False): # No conversion happens.
527 self._setupClipper(
528 self.__data_collector._getDataCollectorOutput(),None)
529
530 self._setupDataSetMapper(self._getClipperOutput(),
531 lookup_table._getLookupTable())
532
533 self._setupActor3D(self._getDataSetMapper())
534 scene._addActor3D(self.__viewport, self._getActor3D())
535
536 def _isModified(self):
537 """
538 Return whether the MapOnScalarClip or DataCollector has been modified.
539
540 @rtype: Boolean
541 @return: True or False
542 """
543
544 return self.__modified or self.__data_collector._isModified()
545
546 def _render(self, scene):
547 """
548 Render the surface map clip using scalar data.
549
550 @type scene: L{Scene <scene.Scene>} object
551 @param scene: Scene in which objects are to be rendered on
552 """
553
554 if (self._isModified() == True):
555 if(self.__data_collector._isScalarSet() == True):
556 self.__data_collector._setActiveScalar()
557 # self._isScalarRangeSet checks whether the scalar range has been
558 # specified by the user. If it has, then the scalar range
559 # read from the source will be ignored.
560 if(not(self._isScalarRangeSet())):
561 self._setScalarRange(self.__data_collector._getScalarRange())
562 self.__modified = False
563
564
565 ##############################################################################
566
567
568 from rotation import Rotation
569 from geometry import Geometry
570
571 # NOTE: DataSetMapper, Actor3D, Clipper and Rotation were inherited
572 # to allow access to their public methods from the driver.
573 class MapOnScalarClipWithRotation(DataSetMapper, Actor3D, Clipper, Rotation):
574 """
575 This class works in a similar way to L{Map <map.Map>}, except that it
576 shows a 2D scalar field clipped using a scalar value and subsequently
577 rotated around the z-axis to create a 3D looking effect. This class should
578 only be used with 2D data sets and NOT 3D.
579 """
580
581 # The SOUTH_WEST default viewport is used when there is only one viewport.
582 # This saves the user from specifying the viewport when there is only one.
583 # If no lut is specified, the color scheme will be used.
584 def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,
585 lut = Lut.COLOR, cell_to_point = False):
586 """
587 Initialise the MapOnScalarClipWithRotation.
588
589 @attention: The source can either be point or cell data. If the
590 source is cell data, a conversion to point data may or may not be
591 required, in order for the object to be rendered correctly.
592 If a conversion is needed, the 'cell_to_point' flag must be set to
593 'True', otherwise 'False' (which is the default). On occasions, an
594 inaccurate object may be rendered from cell data even after conversion.
595
596 @type scene: L{Scene <scene.Scene>} object
597 @param scene: Scene in which objects are to be rendered on
598 @type data_collector: L{DataCollector <datacollector.DataCollector>}
599 object
600 @param data_collector: Deal with source of data for visualisation
601 @type viewport: L{Viewport <constant.Viewport>} constant
602 @param viewport: Viewport in which objects are to be rendered on
603 @type lut : L{Lut <constant.Lut>} constant
604 @param lut: Lookup table color scheme
605 @type cell_to_point: Boolean
606 @param cell_to_point: Converts cell data to point data (by averaging)
607 """
608
609 self.__data_collector = data_collector
610 self.__viewport = viewport
611 self.__lut = lut
612 self.__cell_to_point = cell_to_point
613
614 # Keeps track whether MapOnScalarClipWithRotation has been modified.
615 self.__modified = True
616 Clipper.__init__(self)
617 Rotation.__init__(self)
618 DataSetMapper.__init__(self)
619 Actor3D.__init__(self)
620 scene._addVisualizationModules(self)
621
622 def _isModified(self):
623 """
624 Return whether the MapOnScalarClipWithRotation or DataCollector has
625 been modified.
626
627 @rtype: Boolean
628 @return: True or False
629 """
630
631 return self.__modified or self.__data_collector._isModified()
632
633 def _render(self, scene):
634 """
635 Render the surface map clip using scalar data and subsequently rotated.
636
637 @type scene: L{Scene <scene.Scene>} object
638 @param scene: Scene in which objects are to be rendered on
639 """
640
641 # This entire 'if' section had to be moved from the __init__ method
642 # due to the use of 'GetPoints().GetNumberOfPoints()'. A source
643 # (i.e. xml file) must be
644 # supplied before 'GetPoints().GetNumberOfPoints()' is able to return
645 # the correct value
646 # when executed. This is to accommodate for lazy evaluation.
647 if (self._isModified() == True):
648
649 # Swaps the points from the y-axis to the z-axis and vice-versa.
650 # This is needed as VTK is only able to perform rotation along
651 # the z-axis.
652 output = self.__data_collector._getDataCollectorOutput()
653 num_points = output.GetPoints().GetNumberOfPoints()
654 for i in range (num_points):
655 point = output.GetPoints().GetPoint(i)
656 output.GetPoints().SetPoint(i, point[0], point[2], point[1])
657
658 # --- Map clipped using a scalar value and subsequently rotated ---
659
660 # NOTE: Lookup table color mapping (color or grey scale) MUST be set
661 # before DataSetMapper. If it is done after DataSetMapper, no effect
662 # will take place.
663 if(self.__lut == Lut.COLOR): # Colored lookup table.
664 lookup_table = LookupTable()
665 lookup_table._setTableValue()
666 elif(self.__lut == Lut.GREY_SCALE): # Grey scaled lookup table.
667 lookup_table = LookupTable()
668 lookup_table._setLookupTableToGreyScale()
669
670 if(self.__cell_to_point == True): #Converts cell data to point data.
671 c2p = CellDataToPointData(output)
672 # None is used because a plane is not required when a scalar
673 # value is used to perform the clipping.
674 self._setupClipper(c2p._getCellToPointOutput(), None)
675 elif(self.__cell_to_point == False): # No conversion happens.
676 self._setupClipper(output, None)
677
678 geometry = Geometry(self._getClipperOutput())
679
680 self._setupRotationExtrusionFilter(geometry._getGeometryOutput())
681 self._setupDataSetMapper(self._getRotationOutput(),
682 lookup_table._getLookupTable())
683
684 self._setupActor3D(self._getDataSetMapper())
685 scene._addActor3D(self.__viewport, self._getActor3D())
686
687 if(self.__data_collector._isScalarSet() == True):
688 self.__data_collector._setActiveScalar()
689 # self._isScalarRangeSet checks whether the scalar range has been
690 # specified by the user. If it has, then the scalar range
691 # read from the source will be ignored.
692 if(not(self._isScalarRangeSet())):
693 self._setScalarRange(self.__data_collector._getScalarRange())
694
695 self.__modified = False
696
697
698

  ViewVC Help
Powered by ViewVC 1.1.26