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, ColorMode, VizType |
from constant import Viewport, Color, Lut, ColorMode |
10 |
from streamlinemodule import StreamLineModule |
from streamlinemodule import StreamLineModule |
11 |
from tube import Tube |
from tube import Tube |
12 |
from point import PointSource |
from point import PointSource |
13 |
from outline import Outline |
from outline import Outline |
14 |
from average import CellDataToPointData |
from average import CellDataToPointData |
15 |
|
from position import GlobalPosition |
16 |
|
|
17 |
# NOTE: DataSetMapper, Actor3D, PointSource, StreamLineModule and Tube were |
# NOTE: DataSetMapper, Actor3D, PointSource, StreamLineModule and Tube were |
18 |
# inherited to allow access to their public methods from the driver. |
# inherited to allow access to their public methods from the driver. |
57 |
@param outline: Places an outline around the domain surface |
@param outline: Places an outline around the domain surface |
58 |
""" |
""" |
59 |
|
|
60 |
# NOTE: Actor3D is inherited and there are two instances declared here. |
self.__scene = scene |
61 |
# As a result, when methods from Actor3D is invoked from the driver, |
self.__data_collector = data_collector |
62 |
# only the methods associated with the latest instance (which in this |
self.__viewport = viewport |
63 |
# case is the Actor3D for the Tube) can be executed. Actor3D |
self.__color_mode = color_mode |
64 |
# methods associated with Outline cannot be invoked from the driver. |
self.__lut = lut |
65 |
# They can only be called within here, which is why Outline must be |
self.__cell_to_point = cell_to_point |
66 |
# place before Tube as there is unlikely to be any changes |
self.__outline = outline |
67 |
# made to the Outline's Actor3D. |
|
68 |
|
# Keeps track whether Streamline has been modified. |
69 |
# ----- Outline ----- |
self.__modified = True |
70 |
|
PointSource.__init__(self) |
71 |
if(outline == True): |
StreamLineModule.__init__(self) |
72 |
outline = Outline(data_collector._getOutput()) |
Tube.__init__(self) |
73 |
DataSetMapper.__init__(self, outline._getOutput()) |
DataSetMapper.__init__(self) |
74 |
|
Actor3D.__init__(self) |
75 |
|
scene._addVisualizationModules(self) |
76 |
|
|
77 |
|
# ----- Outline ----- |
78 |
|
|
79 |
|
# NOTE: Changes cannot be made to the Outline's properties from the |
80 |
|
# driver. |
81 |
|
if(self.__outline == True): |
82 |
|
outline = Outline(self.__data_collector._getDataCollectorOutput()) |
83 |
|
mapper = DataSetMapper() |
84 |
|
mapper._setupDataSetMapper(outline._getOutlineOutput()) |
85 |
|
|
86 |
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
actor3D = Actor3D() |
87 |
|
actor3D._setupActor3D(mapper._getDataSetMapper()) |
88 |
# Default outline color is black. |
# Default outline color is black. |
89 |
Actor3D.setColor(self, Color.BLACK) |
actor3D.setColor(Color.BLACK) |
90 |
|
|
91 |
# Default line width is 1. |
# Default line width is 1. |
92 |
Actor3D._setLineWidth(self, 1) |
actor3D._setLineWidth(1) |
93 |
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
self.__scene._addActor3D(self.__viewport, actor3D._getActor3D()) |
94 |
|
|
95 |
# ----- Streamline ----- |
# ----- Streamline ----- |
96 |
|
|
97 |
# NOTE: Lookup table color mapping (color or grey scale) MUST be set |
# NOTE: Lookup table color mapping (color or grey scale) MUST be set |
98 |
# before DataSetMapper. If it is done after DataSetMapper, no effect |
# before DataSetMapper. If it is done after DataSetMapper, no effect |
99 |
# will take place. |
# will take place. |
100 |
if(lut == Lut.COLOR): # Colored lookup table. |
if(self.__lut == Lut.COLOR): # Colored lookup table. |
101 |
lookup_table = LookupTable() |
lookup_table = LookupTable() |
102 |
lookup_table._setTableValue() |
lookup_table._setTableValue() |
103 |
elif(lut == Lut.GREY_SCALE): # Grey scaled lookup table. |
elif(self.__lut == Lut.GREY_SCALE): # Grey scaled lookup table. |
104 |
lookup_table = LookupTable() |
lookup_table = LookupTable() |
105 |
lookup_table._setLookupTableToGreyScale() |
lookup_table._setLookupTableToGreyScale() |
106 |
|
|
107 |
if(cell_to_point == True): # Converts cell data to point data. |
if(self.__cell_to_point == True): # Converts cell data to point data. |
108 |
c2p = CellDataToPointData(data_collector._getOutput()) |
c2p = CellDataToPointData( |
109 |
PointSource.__init__(self, c2p._getOutput()) |
self.__data_collector._getDataCollectorOutput()) |
110 |
StreamLineModule.__init__(self, c2p._getOutput(), |
self._setupPointSource(c2p._getCellToPointOutput()) |
111 |
PointSource._getOutput(self)) |
self._setupStreamLineModule(c2p._getCellToPointOutput(), |
112 |
elif(cell_to_point == False): # No conversion happens. |
self._getPointSourceOutput()) |
113 |
PointSource.__init__(self, data_collector._getOutput()) |
elif(self.__cell_to_point == False): # No conversion happens. |
114 |
StreamLineModule.__init__(self, data_collector._getOutput(), |
self._setupPointSource( |
115 |
PointSource._getOutput(self)) |
self.__data_collector._getDataCollectorOutput()) |
116 |
|
self._setupStreamLineModule( |
117 |
|
self.__data_collector._getDataCollectorOutput(), |
118 |
|
self._getPointSourceOutput()) |
119 |
|
|
120 |
Tube.__init__(self, StreamLineModule._getOutput(self)) |
self._setupTube(self._getStreamLineModuleOutput()) |
121 |
DataSetMapper.__init__(self, Tube._getOutput(self), |
self._setupDataSetMapper(self._getTubeOutput(), |
122 |
lookup_table._getLookupTable()) |
lookup_table._getLookupTable()) |
123 |
|
|
124 |
if(color_mode == ColorMode.VECTOR): # Color velocity by vector. |
self._setupActor3D(self._getDataSetMapper()) |
125 |
DataSetMapper._setScalarVisibilityOn(self) |
self.__scene._addActor3D(self.__viewport, self._getActor3D()) |
126 |
StreamLineModule._setSpeedScalarsOn(self) |
|
127 |
DataSetMapper._setScalarRange(self, |
def _isModified(self): |
128 |
data_collector._getVectorRange()) |
""" |
129 |
|
Return whether the StreamLine or DataCollector has been modified. |
130 |
data_collector._paramForUpdatingMultipleSources(VizType.STREAMLINE, |
|
131 |
ColorMode.VECTOR, DataSetMapper._getDataSetMapper(self)) |
@rtype: Boolean |
132 |
|
@return: True or False |
133 |
elif(color_mode == ColorMode.SCALAR): # Color velocity by scalar. |
""" |
134 |
DataSetMapper._setScalarVisibilityOn(self) |
|
135 |
StreamLineModule._setSpeedScalarsOff(self) |
return self.__modified or self.__data_collector._isModified() |
136 |
DataSetMapper._setScalarRange(self, |
|
137 |
data_collector._getScalarRange()) |
def _render(self): |
138 |
|
""" |
139 |
data_collector._paramForUpdatingMultipleSources(VizType.STREAMLINE, |
Render the streamline. |
140 |
ColorMode.SCALAR, DataSetMapper._getDataSetMapper(self)) |
""" |
141 |
|
|
142 |
|
if (self._isModified() == True): |
143 |
|
if(self._isPointSourceCenterSet() != True): |
144 |
|
center = self.__data_collector._getCenter() |
145 |
|
center = GlobalPosition(center[0], center[1], center[2]) |
146 |
|
self.setPointSourceCenter(center) |
147 |
|
|
148 |
|
self._setPointSourceCenter() |
149 |
|
|
150 |
|
if(self.__data_collector._isScalarSet() == True): |
151 |
|
self.__data_collector._setActiveScalar() |
152 |
|
if(self.__data_collector._isVectorSet() == True): |
153 |
|
self.__data_collector._setActiveVector() |
154 |
|
|
155 |
|
# Color streamline by vector. |
156 |
|
if(self.__color_mode == ColorMode.VECTOR): |
157 |
|
self._setScalarVisibilityOn() |
158 |
|
self._setSpeedScalarsOn() |
159 |
|
self._setScalarRange(self.__data_collector._getVectorRange()) |
160 |
|
# Color streamline by scalar. |
161 |
|
elif(self.__color_mode == ColorMode.SCALAR): |
162 |
|
self._setScalarVisibilityOn() |
163 |
|
self._setSpeedScalarsOff() |
164 |
|
self._setScalarRange(self.__data_collector._getScalarRange()) |
165 |
|
|
166 |
|
self.__modified = False |
167 |
|
|
|
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
|
|
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
|
168 |
|
|