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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26