/[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 996 - (show annotations)
Mon Feb 26 03:43:13 2007 UTC (13 years, 9 months ago) by jongui
File MIME type: text/x-python
File size: 11033 byte(s)
Updated the drivers. Setting the active scalar/vector/tensor is now done in the DataCollector. i.e. 
dc = DataCollector(...)
dc.setFileName(...)
dc.setActiveScalar(...)

The use of setActiveScalar / setActiveVector / setActiveTensor have to be done after the setFileName.
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
10 from sphere import Sphere
11 from normals import Normals
12 from glyph import TensorGlyph
13 from outline import Outline
14 from point import StructuredPoints
15 from probe import Probe
16
17 # 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 """
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 # 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 """
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 @param viewport: Viewport in which objects are to be rendered on
39 @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
64 # 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 StructuredPoints.__init__(self, data_collector._getOutput())
81 Probe.__init__(self, data_collector._getOutput(),
82 StructuredPoints._getStructuredPoints(self))
83
84 Sphere.__init__(self)
85 TensorGlyph.__init__(self, Probe._getOutput(self),
86 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 ###############################################################################
98
99
100 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 # Cutter, StructuredPoints and Probe were inherited to allow access to
106 # their public methods from the driver.
107 class EllipsoidOnPlaneCut(DataSetMapper, Actor3D, Sphere, Normals,
108 TensorGlyph, Transform, Plane, Cutter, StructuredPoints, Probe):
109 """
110 Class that show a tensor field using ellipsoids on a cut plane.
111 """
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 # 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 """
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 @param viewport: Viewport in which objects are to be rendered on
126 @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 DataSetMapper.__init__(self, outline._getOutput())
146
147 Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
148 # Default outline color is black.
149 Actor3D.setColor(self, Color.BLACK)
150
151 # Default line width is 1.
152 Actor3D._setLineWidth(self, 1)
153 scene._addActor3D(viewport, Actor3D._getActor3D(self))
154
155 # ----- Ellipsoid on a cut plane -----
156
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 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 Plane._getPlane(self))
176 Sphere.__init__(self)
177
178 TensorGlyph.__init__(self, Cutter._getOutput(self),
179 Sphere._getOutput(self))
180 Normals.__init__(self, TensorGlyph._getOutput(self))
181
182 DataSetMapper.__init__(self, Normals._getOutput(self),
183 lookup_table._getLookupTable())
184 DataSetMapper._setScalarRange(self, data_collector._getScalarRange())
185
186 Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
187 scene._addActor3D(viewport, Actor3D._getActor3D(self))
188
189
190 ###############################################################################
191
192
193 from clipper import Clipper
194
195 # NOTE: DataSetMapper, Actor3D, Sphere, Normals, TensorGlyph, Transform, Plane,
196 # Clipper, StructuredPoints and Probe were inherited to allow access to
197 # their public methods from the driver.
198 class EllipsoidOnPlaneClip(DataSetMapper, Actor3D, Sphere, Normals,
199 TensorGlyph, Transform, Plane, Clipper, StructuredPoints, Probe):
200 """
201 Class that show a tensor field using ellipsoids on a clipped plane.
202 """
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 # 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 """
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 @param viewport: Viewport in which object are to be rendered on
217 @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 DataSetMapper.__init__(self, outline._getOutput())
237
238 Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
239 # Default outline color is black.
240 Actor3D.setColor(self, Color.BLACK)
241
242 # Default line width is 1.
243 Actor3D._setLineWidth(self, 1)
244 scene._addActor3D(viewport, Actor3D._getActor3D(self))
245
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 StructuredPoints.__init__(self, data_collector._getOutput())
262 Probe.__init__(self, data_collector._getOutput(),
263 StructuredPoints._getStructuredPoints(self))
264
265 # NOTE: TensorGlyph must come before Clipper. Otherwise the output
266 # will be incorrect.
267 Sphere.__init__(self)
268 TensorGlyph.__init__(self, Probe._getOutput(self),
269 Sphere._getOutput(self))
270
271 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 DataSetMapper._setScalarRange(self, data_collector._getScalarRange())
281
282 Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
283 scene._addActor3D(viewport, Actor3D._getActor3D(self))
284

  ViewVC Help
Powered by ViewVC 1.1.26