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

  ViewVC Help
Powered by ViewVC 1.1.26