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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26