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

  ViewVC Help
Powered by ViewVC 1.1.26