/[escript]/trunk/doc/user/pyvisi.tex
ViewVC logotype

Annotation of /trunk/doc/user/pyvisi.tex

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1199 - (hide annotations)
Wed Jun 20 05:01:30 2007 UTC (12 years, 2 months ago) by jongui
File MIME type: application/x-tex
File size: 44756 byte(s)
- Updated the epydocs and guide.
Deleted redundant files and methods.
Tidied up the codes.
1 gross 606 \chapter{The module \pyvisi}
2 jongui 879 \label{PYVISI CHAP}
3 jongui 1002 \declaremodule{extension}{esys.pyvisi}
4     \modulesynopsis{Python Visualization Interface}
5 jongui 879
6 gross 999 \section{Introduction}
7 jongui 1002 \pyvisi is a Python module that is used to generate 2D and 3D visualization
8     for escript and its PDE solvers: finley and bruce. This module provides
9 jongui 1199 an easy to use interface to the \VTK library (\VTKUrl). Pyvisi can be used to
10     render (generate) surface maps and contours for scalar fields, arrows and
11     streamlines for vector fields, and ellipsoids for tensor fields.
12     There are three
13 jongui 1154 approaches for rendering an object. (1) Online - object is rendered on-screen
14     with interaction capability (i.e. zoom and rotate), (2) Offline - object is
15     rendered off-screen (no pop-up window) and (3) Display - object is rendered
16 jongui 1199 on-screen but with no interaction capability (on-the-fly
17 jongui 1078 animation). All three approaches have the option to save the rendered object
18 jongui 1154 as an image (i.e. jpg).
19 gross 606
20 jongui 1199 The following outlines the general steps to use Pyvisi:
21 gross 606
22 jongui 1002 \begin{enumerate}
23 jongui 1199 \item Create a \Scene instance - a window in which objects are to be
24     rendered on.
25     \item Create a data input instance (i.e. \DataCollector or \ImageReader) -
26 jongui 1076 reads and loads the source data for visualization.
27 jongui 1035 \item Create a data visualization instance (i.e. \Map, \Velocity, \Ellipsoid,
28 jongui 1199 \Contour, \Carpet, \StreamLine or \Image) - proccesses and manipulates
29     the source data.
30     \item Create a \Camera or \Light instance - controls the viewing angle and
31 jongui 1076 lighting effects.
32 jongui 1199 \item Render the object - using either the Online, Offline or Display approach.
33 jongui 1002 \end{enumerate}
34     \begin{center}
35     \begin{math}
36 jongui 1081 scene \rightarrow data \; input \rightarrow data \; visualization \rightarrow
37 jongui 1199 camera \, / \, light \rightarrow render
38 jongui 1002 \end{math}
39     \end{center}
40 gross 999
41     \section{\pyvisi Classes}
42 jongui 1035 The following subsections give a brief overview of the important classes
43     and some of their corresponding methods. Please refer to \ReferenceGuide for
44     full details.
45    
46    
47     %#############################################################################
48    
49    
50 gross 999 \subsection{Scene Classes}
51 jongui 1035 This subsection details the instances used to setup the viewing environment.
52    
53     \subsubsection{\Scene class}
54    
55 jongui 1002 \begin{classdesc}{Scene}{renderer = Renderer.ONLINE, num_viewport = 1,
56     x_size = 1152, y_size = 864}
57 jongui 1035 A scene is a window in which objects are to be rendered on. Only
58 jongui 1078 one scene needs to be created. However, a scene may be divided into four
59 jongui 1154 smaller windows called viewports (if needed). Each viewport in turn can
60 jongui 1078 render a different object.
61 gross 999 \end{classdesc}
62    
63 jongui 1035 The following are some of the methods available:
64     \begin{methoddesc}[Scene]{setBackground}{color}
65     Set the background color of the scene.
66     \end{methoddesc}
67    
68 jongui 1078 \begin{methoddesc}[Scene]{render}{image_name = None}
69     Render the object using either the Online, Offline or Display mode.
70 jongui 1035 \end{methoddesc}
71    
72     \subsubsection{\Camera class}
73    
74 jongui 1143 \begin{classdesc}{Camera}{scene, viewport = Viewport.SOUTH_WEST}
75 jongui 1035 A camera controls the display angle of the rendered object and one is
76     usually created for a \Scene. However, if a \Scene has four viewports, then a
77     separate camera may be created for each viewport.
78 gross 999 \end{classdesc}
79    
80 jongui 1035 The following are some of the methods available:
81     \begin{methoddesc}[Camera]{setFocalPoint}{position}
82     Set the focal point of the camera.
83     \end{methoddesc}
84    
85     \begin{methoddesc}[Camera]{setPosition}{position}
86     Set the position of the camera.
87     \end{methoddesc}
88    
89     \begin{methoddesc}[Camera]{azimuth}{angle}
90     Rotate the camera to the left and right.
91     \end{methoddesc}
92    
93     \begin{methoddesc}[Camera]{elevation}{angle}
94     Rotate the camera to the top and bottom (only between -90 and 90).
95     \end{methoddesc}
96    
97     \begin{methoddesc}[Camera]{backView}{}
98     Rotate the camera to view the back of the rendered object.
99     \end{methoddesc}
100    
101     \begin{methoddesc}[Camera]{topView}{}
102     Rotate the camera to view the top of the rendered object.
103     \end{methoddesc}
104    
105     \begin{methoddesc}[Camera]{bottomView}{}
106     Rotate the camera to view the bottom of the rendered object.
107     \end{methoddesc}
108    
109     \begin{methoddesc}[Camera]{leftView}{}
110     Rotate the camera to view the left side of the rendered object.
111     \end{methoddesc}
112    
113 jongui 1078 \begin{methoddesc}[Camera]{rightView}{}
114 jongui 1035 Rotate the camera to view the right side of the rendered object.
115     \end{methoddesc}
116    
117 jongui 1078 \begin{methoddesc}[Camera]{isometricView}{}
118 jongui 1035 Rotate the camera to view the isometric angle of the rendered object.
119     \end{methoddesc}
120    
121     \begin{methoddesc}[Camera]{dolly}{distance}
122 jongui 1194 Move the camera towards (greater than 1) the rendered object. However,
123     the camera is unable to be moved away from the rendered object.
124 jongui 1035 \end{methoddesc}
125    
126     \subsubsection{\Light class}
127    
128 jongui 1154 \begin{classdesc}{Light}{scene, viewport = Viewport.SOUTH_WEST}
129     A light controls the lighting effect for the rendered object and works in
130 jongui 1035 a similar way to \Camera.
131 gross 999 \end{classdesc}
132    
133 jongui 1035 The following are some of the methods available:
134     \begin{methoddesc}[Light]{setColor}{color}
135     Set the light color.
136     \end{methoddesc}
137    
138     \begin{methoddesc}[Light]{setFocalPoint}{position}
139     Set the focal point of the light.
140     \end{methoddesc}
141    
142     \begin{methoddesc}[Light]{setPosition}{position}
143 jongui 1078 Set the position of the light.
144 jongui 1035 \end{methoddesc}
145    
146     \begin{methoddesc}[Light]{setAngle}{elevation = 0, azimuth = 0}
147 jongui 1078 An alternative to set the position and focal point of the light by using the
148     elevation and azimuth.
149 jongui 1035 \end{methoddesc}
150    
151    
152     %##############################################################################
153    
154    
155 gross 999 \subsection{Input Classes}
156 jongui 1199 \label{INPUT SEC}
157 jongui 1035 This subsection details the instances used to read and load the source data
158     for visualization.
159 gross 999
160 jongui 1035 \subsubsection{\DataCollector class}
161     \begin{classdesc}{DataCollector}{source = Source.XML}
162 jongui 1154 A data collector is used to read data either from a XML file (using
163 jongui 1108 \texttt{setFileName()}) or from an escript object directly (using
164 jongui 1143 \texttt{setData()}). Writing XML files are expensive, but this approach has
165     the advantage given that the results can be analyzed easily after the
166     simulation has completed.
167 gross 999 \end{classdesc}
168    
169 jongui 1035 The following are some of the methods available:
170     \begin{methoddesc}[DataCollector]{setFileName}{file_name}
171 jongui 1078 Set the XML file name to read.
172 jongui 1035 \end{methoddesc}
173 gross 999
174 jongui 1035 \begin{methoddesc}[DataCollector]{setData}{**args}
175     Create data using the \textless name\textgreater=\textless data\textgreater
176     pairing. Assumption is made that the data will be given in the
177     appropriate format.
178     \end{methoddesc}
179 gross 999
180 jongui 1035 \begin{methoddesc}[DataCollector]{setActiveScalar}{scalar}
181     Specify the scalar field to load.
182     \end{methoddesc}
183 gross 999
184 jongui 1035 \begin{methoddesc}[DataCollector]{setActiveVector}{vector}
185     Specify the vector field to load.
186     \end{methoddesc}
187 gross 999
188 jongui 1035 \begin{methoddesc}[DataCollector]{setActiveTensor}{tensor}
189     Specify the tensor field to load.
190     \end{methoddesc}
191 gross 999
192 jongui 1035 \subsubsection{\ImageReader class}
193    
194     \begin{classdesc}{ImageReader}{format}
195     An image reader is used to read data from an image in a variety of formats.
196 gross 999 \end{classdesc}
197    
198 jongui 1035 The following are some of the methods available:
199     \begin{methoddesc}[ImageReader]{setImageName}{image_name}
200     Set the image name to be read.
201     \end{methoddesc}
202    
203     \subsubsection{\TextTwoD class}
204    
205     \begin{classdesc}{Text2D}{scene, text, viewport = Viewport.SOUTH_WEST}
206 jongui 1078 A two-dimensional text is used to annotate the rendered object
207 jongui 1154 (i.e. inserting titles, authors and labels).
208 gross 999 \end{classdesc}
209    
210 jongui 1035 The following are some of the methods available:
211     \begin{methoddesc}[Text2D]{setFontSize}{size}
212     Set the 2D text size.
213     \end{methoddesc}
214    
215     \begin{methoddesc}[Text2D]{boldOn}{}
216     Bold the 2D text.
217     \end{methoddesc}
218    
219     \begin{methoddesc}[Text2D]{setColor}{color}
220     Set the color of the 2D text.
221     \end{methoddesc}
222    
223     Including methods from \ActorTwoD.
224    
225    
226     %##############################################################################
227    
228    
229     \subsection{Data Visualization Classes}
230 jongui 1199 \label{DATAVIS SEC}
231 jongui 1035 This subsection details the instances used to process and manipulate the source
232 jongui 1154 data. The typical usage of some of the classes are also shown.
233 jongui 1078
234     One point to note is that the source can either be point or cell data. If the
235     source is cell data, a conversion to point data may or may not be
236     required, in order for the object to be rendered correctly.
237 jongui 1154 If a conversion is needed, the 'cell_to_point' flag (see below) must
238 jongui 1199 be set to 'True', otherwise 'False' (which is the default). On occasions, an
239     inaccurate object may be rendered from cell data even after conversion.
240 jongui 1078
241 jongui 1035 \subsubsection{\Map class}
242    
243     \begin{classdesc}{Map}{scene, data_collector,
244 jongui 1051 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
245     outline = True}
246 jongui 1035 Class that shows a scalar field on a domain surface. The domain surface
247     can either be colored or grey-scaled, depending on the lookup table used.
248 gross 999 \end{classdesc}
249    
250 jongui 1035 The following are some of the methods available:\\
251 jongui 1194 Methods from \ActorThreeD and \DataSetMapper.
252 jongui 1035
253 jongui 1084 A typical usage of \Map is shown below.
254 jongui 1081
255     \begin{python}
256     # Import the necessary modules.
257     from esys.pyvisi import Scene, DataCollector, Map, Camera
258     from esys.pyvisi.constant import *
259 jongui 1154 import os
260 jongui 1081
261 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
262     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
263 jongui 1081 X_SIZE = 800
264     Y_SIZE = 800
265    
266     SCALAR_FIELD_POINT_DATA = "temperature"
267     SCALAR_FIELD_CELL_DATA = "temperature_cell"
268     FILE_3D = "interior_3D.xml"
269     IMAGE_NAME = "map.jpg"
270     JPG_RENDERER = Renderer.ONLINE_JPG
271    
272     # Create a Scene with four viewports.
273     s = Scene(renderer = JPG_RENDERER, num_viewport = 4, x_size = X_SIZE,
274     y_size = Y_SIZE)
275    
276     # Create a DataCollector reading from a XML file.
277     dc1 = DataCollector(source = Source.XML)
278 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
279 jongui 1081 dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
280    
281     # Create a Map for the first viewport.
282     m1 = Map(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
283     lut = Lut.COLOR, cell_to_point = False, outline = True)
284     m1.setRepresentationToWireframe()
285    
286     # Create a Camera for the first viewport
287 jongui 1154 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
288 jongui 1081 c1.isometricView()
289    
290     # Create a second DataCollector reading from the same XML file but specifying
291     # a different scalar field.
292     dc2 = DataCollector(source = Source.XML)
293 jongui 1154 dc2.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
294 jongui 1081 dc2.setActiveScalar(scalar = SCALAR_FIELD_CELL_DATA)
295    
296     # Create a Map for the third viewport.
297     m2 = Map(scene = s, data_collector = dc2, viewport = Viewport.NORTH_EAST,
298     lut = Lut.COLOR, cell_to_point = True, outline = True)
299    
300 jongui 1154 # Create a Camera for the third viewport
301 jongui 1194 c2 = Camera(scene = s, viewport = Viewport.NORTH_EAST)
302 jongui 1154
303 jongui 1081 # Render the object.
304 jongui 1154 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
305 jongui 1081 \end{python}
306    
307 jongui 1035 \subsubsection{\MapOnPlaneCut class}
308    
309     \begin{classdesc}{MapOnPlaneCut}{scene, data_collector,
310 jongui 1051 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
311     outline = True}
312 jongui 1035 This class works in a similar way to \Map, except that it shows a scalar
313 jongui 1079 field cut using a plane. The plane can be translated and rotated along the
314     X, Y and Z axes.
315 gross 999 \end{classdesc}
316    
317 jongui 1035 The following are some of the methods available:\\
318 jongui 1194 Methods from \ActorThreeD, \Transform and \DataSetMapper.
319 jongui 1035
320     \subsubsection{\MapOnPlaneClip class}
321    
322     \begin{classdesc}{MapOnPlaneClip}{scene, data_collector,
323 jongui 1051 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
324     outline = True}
325 jongui 1035 This class works in a similar way to \MapOnPlaneCut, except that it shows a
326     scalar field clipped using a plane.
327 gross 999 \end{classdesc}
328    
329 jongui 1035 The following are some of the methods available:\\
330 jongui 1194 Methods from \ActorThreeD, \Transform, \Clipper and \DataSetMapper.
331 jongui 1035
332     \subsubsection{\MapOnScalarClip class}
333    
334     \begin{classdesc}{MapOnScalarClip}{scene, data_collector,
335 jongui 1051 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
336     outline = True}
337 jongui 1035 This class works in a similar way to \Map, except that it shows a scalar
338     field clipped using a scalar value.
339 gross 999 \end{classdesc}
340    
341 jongui 1035 The following are some of the methods available:\\
342 jongui 1194 Methods from \ActorThreeD, \Clipper and \DataSetMapper.
343 jongui 1035
344     \subsubsection{\Velocity class}
345    
346 jongui 1154 \begin{classdesc}{Velocity}{scene, data_collector, arrow = Arrow.TWO_D,
347     color_mode = ColorMode.VECTOR, viewport = Viewport.SOUTH_WEST,
348     lut = Lut.COLOR, cell_to_point = False, outline = True}
349 jongui 1035 Class that shows a vector field using arrows. The arrows can either be
350     colored or grey-scaled, depending on the lookup table used. If the arrows
351     are colored, there are two possible coloring modes, either using vector data or
352     scalar data. Similarly, there are two possible types of arrows, either
353     using two-dimensional or three-dimensional.
354 gross 999 \end{classdesc}
355    
356 jongui 1035 The following are some of the methods available:\\
357 jongui 1194 Methods from \ActorThreeD, \GlyphThreeD, \MaskPoints and \DataSetMapper.
358 jongui 1035
359     \subsubsection{\VelocityOnPlaneCut class}
360    
361 jongui 1084 \begin{classdesc}{VelocityOnPlaneCut}{scene, data_collector,
362 jongui 1035 arrow = Arrow.TWO_D, color_mode = ColorMode.VECTOR,
363 jongui 1078 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
364     cell_to_point = False, outline = True}
365 jongui 1035 This class works in a similar way to \MapOnPlaneCut, except that
366 jongui 1079 it shows a vector field using arrows cut using a plane.
367 gross 999 \end{classdesc}
368    
369 jongui 1035 The following are some of the methods available:\\
370 jongui 1194 Methods from \ActorThreeD, \GlyphThreeD, \Transform, \MaskPoints and
371     \DataSetMapper.
372 jongui 1035
373 jongui 1084 A typical usage of \VelocityOnPlaneCut is shown below.
374 jongui 1081
375     \begin{python}
376     # Import the necessary modules
377     from esys.pyvisi import Scene, DataCollector, VelocityOnPlaneCut, Camera
378     from esys.pyvisi.constant import *
379 jongui 1154 import os
380 jongui 1081
381 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
382     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
383 jongui 1081 X_SIZE = 400
384     Y_SIZE = 400
385    
386     VECTOR_FIELD_CELL_DATA = "velocity"
387     FILE_3D = "interior_3D.xml"
388     IMAGE_NAME = "velocity.jpg"
389     JPG_RENDERER = Renderer.ONLINE_JPG
390    
391     # Create a Scene with four viewports
392     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
393     y_size = Y_SIZE)
394    
395     # Create a DataCollector reading from a XML file.
396     dc1 = DataCollector(source = Source.XML)
397 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
398 jongui 1081 dc1.setActiveVector(vector = VECTOR_FIELD_CELL_DATA)
399    
400     # Create VelocityOnPlaneCut.
401     vopc1 = VelocityOnPlaneCut(scene = s, data_collector = dc1,
402     viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.VECTOR,
403     arrow = Arrow.THREE_D, lut = Lut.COLOR, cell_to_point = False,
404     outline = True)
405     vopc1.setScaleFactor(scale_factor = 0.5)
406     vopc1.setPlaneToXY(offset = 0.5)
407     vopc1.setRatio(2)
408     vopc1.randomOn()
409    
410     # Create a Camera.
411 jongui 1154 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
412 jongui 1081 c1.isometricView()
413     c1.elevation(angle = -20)
414    
415     # Render the object.
416 jongui 1154 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
417 jongui 1081 \end{python}
418    
419 jongui 1035 \subsubsection{\VelocityOnPlaneClip class}
420    
421     \begin{classdesc}{VelocityOnPlaneClip}{scene, data_collector,
422     arrow = Arrow.TWO_D, color_mode = ColorMode.VECTOR,
423 jongui 1078 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
424     cell_to_point = False, online = True}
425 jongui 1035 This class works in a similar way to \MapOnPlaneClip, except that it shows a
426     vector field using arrows clipped using a plane.
427 gross 999 \end{classdesc}
428 jongui 961
429 jongui 1035 The following are some of the methods available:\\
430 jongui 1194 Methods from \ActorThreeD, \GlyphThreeD, \Transform, \Clipper,
431     \MaskPoints and \DataSetMapper.
432 jongui 1035
433     \subsubsection{\Ellipsoid class}
434    
435     \begin{classdesc}{Ellipsoid}{scene, data_collector,
436 jongui 1079 viewport = Viewport = SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
437     outline = True}
438 jongui 1035 Class that shows a tensor field using ellipsoids. The ellipsoids can either be
439     colored or grey-scaled, depending on the lookup table used.
440 gross 999 \end{classdesc}
441    
442 jongui 1035 The following are some of the methods available:\\
443 jongui 1194 Methods from \ActorThreeD, \Sphere, \TensorGlyph, \MaskPoints and
444     \DataSetMapper.
445 jongui 1035
446     \subsubsection{\EllipsoidOnPlaneCut class}
447    
448     \begin{classdesc}{EllipsoidOnPlaneCut}{scene, data_collector,
449 jongui 1079 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
450     outline = True}
451 jongui 1035 This class works in a similar way to \MapOnPlaneCut, except that it shows
452     a tensor field using ellipsoids cut using a plane.
453 gross 999 \end{classdesc}
454    
455 jongui 1035 The following are some of the methods available:\\
456 jongui 1194 Methods from \ActorThreeD, \Sphere, \TensorGlyph, \Transform,
457     \MaskPoints and \DataSetMapper.
458 jongui 1035
459     \subsubsection{\EllipsoidOnPlaneClip class}
460    
461     \begin{classdesc}{EllipsoidOnPlaneClip}{scene, data_collector,
462 jongui 1079 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
463     outline = True}
464 jongui 1035 This class works in a similar way to \MapOnPlaneClip, except that it shows a
465     tensor field using ellipsoids clipped using a plane.
466 gross 999 \end{classdesc}
467 jongui 1035
468     The following are some of the methods available:\\
469 jongui 1194 Methods from \ActorThreeD, \Sphere, \TensorGlyph, \Transform, \Clipper,
470     \MaskPoints and \DataSetMapper.
471 gross 999
472 jongui 1084 A typical usage of \EllipsoidOnPlaneClip is shown below.
473 jongui 1081
474     \begin{python}
475     # Import the necessary modules
476     from esys.pyvisi import Scene, DataCollector, EllipsoidOnPlaneClip, Camera
477     from esys.pyvisi.constant import *
478 jongui 1154 import os
479 jongui 1081
480 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
481     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
482 jongui 1081 X_SIZE = 400
483     Y_SIZE = 400
484    
485     TENSOR_FIELD_CELL_DATA = "stress_cell"
486     FILE_3D = "interior_3D.xml"
487     IMAGE_NAME = "ellipsoid.jpg"
488     JPG_RENDERER = Renderer.ONLINE_JPG
489    
490     # Create a Scene.
491     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
492     y_size = Y_SIZE)
493    
494     # Create a DataCollector reading from a XML file.
495     dc1 = DataCollector(source = Source.XML)
496 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
497 jongui 1081 dc1.setActiveTensor(tensor = TENSOR_FIELD_CELL_DATA)
498    
499     # Create a EllipsoidOnPlaneClip.
500     eopc1 = EllipsoidOnPlaneClip(scene = s, data_collector = dc1,
501     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = True,
502     outline = True)
503     eopc1.setPlaneToXY()
504     eopc1.setScaleFactor(scale_factor = 0.2)
505     eopc1.rotateX(angle = 10)
506    
507     # Create a camera.
508 jongui 1154 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
509 jongui 1081 c1.bottomView()
510     c1.azimuth(angle = -90)
511     c1.elevation(angle = 10)
512    
513     # Render the object.
514 jongui 1154 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
515 jongui 1081 \end{python}
516    
517 jongui 1035 \subsubsection{\Contour class}
518    
519     \begin{classdesc}{Contour}{scene, data_collector,
520 jongui 1051 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
521     outline = True}
522 jongui 1079 Class that shows a scalar field using contour surfaces. The contour surfaces can
523 jongui 1035 either be colored or grey-scaled, depending on the lookup table used. This
524     class can also be used to generate iso surfaces.
525 gross 999 \end{classdesc}
526    
527 jongui 1035 The following are some of the methods available:\\
528 jongui 1194 Methods from \ActorThreeD, \ContourModule and \DataSetMapper.
529 jongui 1035
530 jongui 1084 A typical usage of \Contour is shown below.
531 jongui 1081
532     \begin{python}
533     # Import the necessary modules
534     from esys.pyvisi import Scene, DataCollector, Contour, Camera
535     from esys.pyvisi.constant import *
536 jongui 1154 import os
537 jongui 1081
538 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
539     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
540 jongui 1081 X_SIZE = 400
541     Y_SIZE = 400
542    
543     SCALAR_FIELD_POINT_DATA = "temperature"
544     FILE_3D = "interior_3D.xml"
545     IMAGE_NAME = "contour.jpg"
546     JPG_RENDERER = Renderer.ONLINE_JPG
547    
548     # Create a Scene.
549     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
550     y_size = Y_SIZE)
551    
552     # Create a DataCollector reading a XML file.
553     dc1 = DataCollector(source = Source.XML)
554 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
555 jongui 1081 dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
556    
557     # Create a Contour.
558     ctr1 = Contour(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
559     lut = Lut.COLOR, cell_to_point = False, outline = True)
560     ctr1.generateContours(contours = 3)
561    
562     # Create a Camera.
563 jongui 1154 cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
564 jongui 1081 cam1.elevation(angle = -40)
565    
566     # Render the object.
567 jongui 1154 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
568 jongui 1081 \end{python}
569    
570 jongui 1035 \subsubsection{\ContourOnPlaneCut class}
571    
572     \begin{classdesc}{ContourOnPlaneCut}{scene, data_collector,
573 jongui 1051 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
574     outline = True}
575 jongui 1035 This class works in a similar way to \MapOnPlaneCut, except that it shows a
576 jongui 1079 scalar field using contour surfaces cut using a plane.
577 gross 999 \end{classdesc}
578 gross 606
579 jongui 1035 The following are some of the methods available:\\
580 jongui 1194 Methods from \ActorThreeD, \ContourModule, \Transform and \DataSetMapper.
581 jongui 1035
582     \subsubsection{\ContourOnPlaneClip class}
583    
584     \begin{classdesc}{ContourOnPlaneClip}{scene, data_collector,
585 jongui 1051 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
586     outline = True}
587 jongui 1035 This class works in a similar way to \MapOnPlaneClip, except that it shows a
588 jongui 1079 scalar field using contour surfaces clipped using a plane.
589 gross 999 \end{classdesc}
590    
591 jongui 1035 The following are some of the methods available:\\
592 jongui 1194 Methods from \ActorThreeD, \ContourModule, \Transform, \Clipper and
593     \DataSetMapper.
594 jongui 1035
595     \subsubsection{\StreamLine class}
596    
597     \begin{classdesc}{StreamLine}{scene, data_collector,
598     viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.VECTOR, lut = Lut.COLOR,
599 jongui 1154 cell_to_point = False, outline = True}
600 jongui 1035 Class that shows the direction of particles of a vector field using streamlines.
601     The streamlines can either be colored or grey-scaled, depending on the lookup
602     table used. If the streamlines are colored, there are two possible coloring
603     modes, either using vector data or scalar data.
604 gross 999 \end{classdesc}
605    
606 jongui 1035 The following are some of the methods available:\\
607 jongui 1194 Methods from \ActorThreeD, \PointSource, \StreamLineModule, \Tube and
608     \DataSetMapper.
609 jongui 1035
610 jongui 1084 A typical usage of \StreamLine is shown below.
611 jongui 1081
612     \begin{python}
613     # Import the necessary modules.
614     from esys.pyvisi import Scene, DataCollector, StreamLine, Camera
615     from esys.pyvisi.constant import *
616 jongui 1154 import os
617 jongui 1081
618 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
619     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
620 jongui 1081 X_SIZE = 400
621     Y_SIZE = 400
622    
623     VECTOR_FIELD_CELL_DATA = "temperature"
624     FILE_3D = "interior_3D.xml"
625     IMAGE_NAME = "streamline.jpg"
626     JPG_RENDERER = Renderer.ONLINE_JPG
627    
628     # Create a Scene.
629     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
630     y_size = Y_SIZE)
631    
632     # Create a DataCollector reading from a XML file.
633     dc1 = DataCollector(source = Source.XML)
634 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
635 jongui 1081
636     # Create a Streamline.
637     sl1 = StreamLine(scene = s, data_collector = dc1,
638     viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.SCALAR,
639     lut = Lut.COLOR, cell_to_point = False, outline = True)
640     sl1.setTubeRadius(radius = 0.02)
641 jongui 1194 sl1.setTubeNumberOfSides(3)
642     sl1.setTubeRadiusToVaryByScalar()
643 jongui 1081
644     # Create a Camera.
645 jongui 1154 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
646 jongui 1081 c1.isometricView()
647    
648     # Render the object.
649 jongui 1154 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
650 jongui 1081 \end{python}
651    
652 jongui 1035 \subsubsection{\Carpet class}
653    
654     \begin{classdesc}{Carpet}{scene, data_collector,
655     viewport = Viewport.Viewport.SOUTH_WEST, warp_mode = WarpMode.SCALAR,
656 jongui 1154 lut = Lut.COLOR, cell_to_point = False, outline = True}
657 jongui 1035 This class works in a similar way to \MapOnPlaneCut, except that it shows a
658 jongui 1079 scalar field cut on a plane and deformated (warp) along the normal. The
659     plane can either be colored or grey-scaled, depending on the lookup table used.
660 jongui 1035 Similarly, the plane can be deformated either using scalar data or vector data.
661 gross 999 \end{classdesc}
662    
663 jongui 1035 The following are some of the methods available:\\
664 jongui 1194 Methods from \ActorThreeD, \Warp, \Transform and \DataSetMapper.
665 gross 999
666 jongui 1084 A typical usage of \Carpet is shown below.
667 jongui 1081
668     \begin{python}
669     # Import the necessary modules.
670     from esys.pyvisi import Scene, DataCollector, Carpet, Camera
671     from esys.pyvisi.constant import *
672 jongui 1154 import os
673 jongui 1081
674 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
675     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
676 jongui 1081 X_SIZE = 400
677     Y_SIZE = 400
678    
679     SCALAR_FIELD_CELL_DATA = "temperature_cell"
680     FILE_3D = "interior_3D.xml"
681     IMAGE_NAME = "carpet.jpg"
682     JPG_RENDERER = Renderer.ONLINE_JPG
683    
684     # Create a Scene.
685     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
686     y_size = Y_SIZE)
687    
688     # Create a DataCollector reading from a XML file.
689     dc1 = DataCollector(source = Source.XML)
690 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
691 jongui 1081 dc1.setActiveScalar(scalar = SCALAR_FIELD_CELL_DATA)
692    
693     # Create a Carpet.
694     cpt1 = Carpet(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
695     warp_mode = WarpMode.SCALAR, lut = Lut.COLOR, cell_to_point = True,
696     outline = True)
697     cpt1.setPlaneToXY(0.2)
698     cpt1.setScaleFactor(1.9)
699    
700     # Create a Camera.
701 jongui 1154 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
702 jongui 1081 c1.isometricView()
703    
704     # Render the object.
705 jongui 1154 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
706 jongui 1081 \end{python}
707    
708 jongui 1194 \subsubsection{\Legend class}
709    
710     \begin{classdesc}{Legend}{scene, data_collector,
711     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, legend = LegendType.SCALAR}
712     Class that shows a scalar field on a domain surface. The domain surface
713     can either be colored or grey-scaled, depending on the lookup table used
714     \end{classdesc}
715    
716     The following are some of the methods available:\\
717     Methods from \ActorThreeD, \ScalarBar and \DataSetMapper.
718    
719 jongui 1035 \subsubsection{\Image class}
720    
721     \begin{classdesc}{Image}{scene, image_reader, viewport = Viewport.SOUTH_WEST}
722 jongui 1112 Class that displays an image which can be scaled (upwards and downwards) and
723     has interaction capability. The image can also be translated and rotated along
724     the X, Y and Z axes. One of the most common use of this feature is pasting an
725     image on a surface map.
726 gross 999 \end{classdesc}
727    
728 jongui 1035 The following are some of the methods available:\\
729     Methods from \ActorThreeD, \PlaneSource and \Transform.
730    
731 jongui 1084 A typical usage of \Image is shown below.
732 jongui 1035
733 jongui 1081 \begin{python}
734     # Import the necessary modules.
735 jongui 1154 from esys.pyvisi import Scene, DataCollector, Map, ImageReader, Image, Camera
736     from esys.pyvisi import GlobalPosition
737 jongui 1081 from esys.pyvisi.constant import *
738 jongui 1154 import os
739 jongui 1081
740 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
741     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
742 jongui 1081 X_SIZE = 400
743     Y_SIZE = 400
744    
745 jongui 1154 SCALAR_FIELD_POINT_DATA = "temperature"
746 jongui 1081 FILE_3D = "interior_3D.xml"
747 jongui 1154 LOAD_IMAGE_NAME = "flinders.jpg"
748     SAVE_IMAGE_NAME = "image.jpg"
749 jongui 1081 JPG_RENDERER = Renderer.ONLINE_JPG
750    
751     # Create a Scene.
752     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
753     y_size = Y_SIZE)
754    
755     # Create a DataCollector reading from a XML file.
756     dc1 = DataCollector(source = Source.XML)
757 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
758 jongui 1081
759 jongui 1154 # Create a Map.
760     m1 = Map(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
761 jongui 1081 lut = Lut.COLOR, cell_to_point = False, outline = True)
762 jongui 1154 m1.setOpacity(0.3)
763 jongui 1081
764 jongui 1154 # Create an ImageReader (in place of DataCollector).
765     ir = ImageReader(ImageFormat.JPG)
766     ir.setImageName(image_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
767     LOAD_IMAGE_NAME))
768 jongui 1081
769 jongui 1154 # Create an Image.
770     i = Image(scene = s, image_reader = ir, viewport = Viewport.SOUTH_WEST)
771     i.setOpacity(opacity = 0.9)
772     i.translate(0,0,-1)
773     i.setPoint1(GlobalPosition(2,0,0))
774     i.setPoint2(GlobalPosition(0,2,0))
775    
776     # Create a Camera.
777     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
778    
779     # Render the image.
780     s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, SAVE_IMAGE_NAME))
781 jongui 1081 \end{python}
782    
783 jongui 1112 \subsubsection{\Logo class}
784 jongui 1081
785 jongui 1112 \begin{classdesc}{Logo}{scene, image_reader, viewport = Viewport.SOUTH_WEST}
786 jongui 1154 Class that displays a static image, in particular a logo
787     (i.e. company symbol) and has NO interaction capability. The position and size
788     of the logo can be specified.
789 jongui 1112 \end{classdesc}
790    
791     The following are some of the methods available:\\
792     Methods from \ImageReslice and \ActorTwoD.
793    
794 jongui 1194 \subsubsection{\Movie class}
795 jongui 1112
796 jongui 1194 \begin{classdesc}{Movie}{parameter_file = "make_movie"}
797     Class that creates a file called 'make_movie' by default (if a parameter
798     file name is not speficied) which contains a list of parameters required
799     by the 'ppmtompeg' command to generate a movie from a series of images.
800     \end{classdesc}
801    
802     The following are some of the methods available:\\
803 jongui 1199 \begin{methoddesc}[Movie]{imageRange}{input_directory, first_image, last_image}
804     The image range from which the movie is to be generated from.
805     \end{methoddesc}
806    
807     \begin{methoddesc}[Movie]{imageList}{input_directory, image_list}
808     The image list from which the movie is to be generated from.
809     \end{methoddesc}
810    
811     \begin{methoddesc}[Movie]{makeMovie}{movie}
812 jongui 1194 Generate the movie.
813     \end{methoddesc}
814    
815 jongui 1199 A typical usage of \Movie is shown below.
816 jongui 1194
817     \begin{python}
818     # Import the necessary modules.
819     from esys.pyvisi import Scene, DataCollector, Map, Camera, Velocity, Legend
820     from esys.pyvisi import Movie, LocalPosition
821     from esys.pyvisi.constant import *
822     import os
823    
824     PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
825     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
826     X_SIZE = 800
827     Y_SIZE = 800
828    
829     SCALAR_FIELD_POINT_DATA = "temp"
830     FILE_2D = "tempvel-"
831     IMAGE_NAME = "movie"
832     JPG_RENDERER = Renderer.ONLINE_JPG
833    
834     # Create a Scene.
835     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
836     y_size = Y_SIZE)
837    
838     # Create a DataCollector reading from a XML file.
839     dc1 = DataCollector(source = Source.XML)
840     dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
841    
842     # Create a Map.
843     m1 = Map(scene = s, data_collector = dc1,
844     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
845     outline = True)
846    
847     # Create a Camera.
848     cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
849    
850     # Create a movie.
851     mov = Movie()
852 jongui 1199 #lst = []
853 jongui 1194
854     # Read in one file one after another and render the object.
855     for i in range(938, 949):
856     dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
857     FILE_2D + "%06d.vtu") % i)
858    
859     s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
860     IMAGE_NAME + "%06d.jpg") % i)
861    
862 jongui 1199 #lst.append(IMAGE_NAME + "%06d.jpg" % i)
863    
864     # Images (first and last inclusive) from which the movie is to be generated.
865     mov.imageRange(input_directory = PYVISI_EXAMPLE_IMAGES_PATH,
866 jongui 1194 first_image = IMAGE_NAME + "000938.jpg",
867 jongui 1199 last_image = IMAGE_NAME + "000948.jpg")
868    
869     # Alternatively, a list of images can be specified.
870     #mov.imageList(input_directory = PYVISI_EXAMPLE_IMAGES_PATH, image_list = lst)
871    
872     # Generate the movie.
873     mov.makeMovie(os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))
874 jongui 1194 \end{python}
875    
876    
877 jongui 1035 %##############################################################################
878    
879    
880 jongui 1076 \subsection{Coordinate Classes}
881 jongui 1035 This subsection details the instances used to position the rendered object.
882    
883     \begin{classdesc}{LocalPosition}{x_coor, y_coor}
884 jongui 1199 Class that defines the local positioning (X and Y) coordinate system (2D).
885 gross 999 \end{classdesc}
886    
887 jongui 1035 \begin{classdesc}{GlobalPosition}{x_coor, y_coor, z_coor}
888 jongui 1199 Class that defines the global positioning (X, Y and Z) coordinate system (3D).
889 gross 999 \end{classdesc}
890    
891 jongui 1035
892     %##############################################################################
893    
894    
895     \subsection{Supporting Classes}
896 jongui 1199 This subsection details the supporting classes and their corresponding methods
897     inherited by the input (see Section \ref{INPUT SEC}) and data
898     visualization classes (see Section \ref{DATAVIS SEC}).
899 jongui 1035
900     \subsubsection{\ActorThreeD class}
901    
902     The following are some of the methods available:
903    
904     \begin{methoddesc}[Actor3D]{setOpacity}{opacity}
905     Set the opacity (transparency) of the 3D actor.
906     \end{methoddesc}
907    
908     \begin{methoddesc}[Actor3D]{setColor}{color}
909     Set the color of the 3D actor.
910     \end{methoddesc}
911    
912     \begin{methoddesc}[Actor3D]{setRepresentationToWireframe}{}
913     Set the representation of the 3D actor to wireframe.
914     \end{methoddesc}
915    
916     \subsubsection{\ActorTwoD class}
917    
918     The following are some of the methods available:
919    
920     \begin{methoddesc}[Actor2D]{setPosition}{position}
921     Set the position (XY) of the 2D actor. Default position is the lower left hand
922     corner of the window / viewport.
923     \end{methoddesc}
924    
925     \subsubsection{\Clipper class}
926    
927     The following are some of the methods available:
928    
929     \begin{methoddesc}[Clipper]{setInsideOutOn}{}
930     Clips one side of the rendered object.
931     \end{methoddesc}
932    
933     \begin{methoddesc}[Clipper]{setInsideOutOff}{}
934     Clips the other side of the rendered object.
935     \end{methoddesc}
936    
937     \begin{methoddesc}[Clipper]{setClipValue}{value}
938 jongui 1079 Set the scalar clip value (instead of using a plane) for the clipper.
939 jongui 1035 \end{methoddesc}
940    
941     \subsubsection{\ContourModule class}
942    
943     The following are some of the methods available:
944    
945 jongui 1143 \begin{methoddesc}[ContourModule]{generateContours}{contours = None,
946 jongui 1035 lower_range = None, upper_range = None}
947     Generate the specified number of contours within the specified range.
948 jongui 1079 In order to generate an iso surface, the 'lower_range' and 'upper_range'
949     must be equal.
950 jongui 1035 \end{methoddesc}
951    
952     \subsubsection{\GlyphThreeD class}
953    
954     The following are some of the methods available:
955    
956     \begin{methoddesc}[Glyph3D]{setScaleModeByVector}{}
957     Set the 3D glyph to scale according to the vector data.
958     \end{methoddesc}
959    
960     \begin{methoddesc}[Glyph3D]{setScaleModeByScalar}{}
961     Set the 3D glyph to scale according to the scalar data.
962     \end{methoddesc}
963    
964     \begin{methoddesc}[Glyph3D]{setScaleFactor}{scale_factor}
965     Set the 3D glyph scale factor.
966     \end{methoddesc}
967    
968     \subsubsection{\TensorGlyph class}
969    
970     The following are some of the methods available:
971    
972     \begin{methoddesc}[TensorGlyph]{setScaleFactor}{scale_factor}
973     Set the scale factor for the tensor glyph.
974     \end{methoddesc}
975    
976 jongui 1079 \begin{methoddesc}[TensorGlyph]{setMaxScaleFactor}{max_scale_factor}
977     Set the maximum allowable scale factor for the tensor glyph.
978     \end{methoddesc}
979    
980 jongui 1035 \subsubsection{\PlaneSource class}
981    
982     The following are some of the methods available:
983    
984     \begin{methoddesc}[PlaneSource]{setPoint1}{position}
985     Set the first point from the origin of the plane source.
986     \end{methoddesc}
987    
988     \begin{methoddesc}[PlaneSource]{setPoint2}{position}
989     Set the second point from the origin of the plane source.
990     \end{methoddesc}
991    
992     \subsubsection{\PointSource class}
993    
994     The following are some of the methods available:
995    
996     \begin{methoddesc}[PointSource]{setPointSourceRadius}{radius}
997     Set the radius of the sphere.
998     \end{methoddesc}
999    
1000 jongui 1143 \begin{methoddesc}[PointSource]{setPointSourceCenter}{center}
1001 jongui 1079 Set the center of the sphere.
1002     \end{methoddesc}
1003    
1004 jongui 1035 \begin{methoddesc}[PointSource]{setPointSourceNumberOfPoints}{points}
1005     Set the number of points to generate within the sphere (the larger the
1006     number of points, the more streamlines are generated).
1007     \end{methoddesc}
1008    
1009     \subsubsection{\Sphere class}
1010    
1011     The following are some of the methods available:
1012    
1013     \begin{methoddesc}[Sphere]{setThetaResolution}{resolution}
1014     Set the theta resolution of the sphere.
1015     \end{methoddesc}
1016    
1017     \begin{methoddesc}[Sphere]{setPhiResolution}{resolution}
1018 jongui 1154 Set the phi resolution of the sphere.
1019 jongui 1035 \end{methoddesc}
1020    
1021     \subsubsection{\StreamLineModule class}
1022    
1023     The following are some of the methods available:
1024    
1025     \begin{methoddesc}[StreamLineModule]{setMaximumPropagationTime}{time}
1026     Set the maximum length of the streamline expressed in elapsed time.
1027     \end{methoddesc}
1028    
1029     \begin{methoddesc}[StreamLineModule]{setIntegrationToBothDirections}{}
1030     Set the integration to occur both sides: forward (where the streamline
1031     goes) and backward (where the streamline came from).
1032     \end{methoddesc}
1033    
1034     \subsubsection{\Transform class}
1035    
1036 jongui 1112 The following are some of the methods available:
1037    
1038 jongui 1035 \begin{methoddesc}[Transform]{translate}{x_offset, y_offset, z_offset}
1039     Translate the rendered object along the x, y and z-axes.
1040     \end{methoddesc}
1041    
1042     \begin{methoddesc}[Transform]{rotateX}{angle}
1043     Rotate the plane along the x-axis.
1044     \end{methoddesc}
1045    
1046     \begin{methoddesc}[Transform]{rotateY}{angle}
1047     Rotate the plane along the y-axis.
1048     \end{methoddesc}
1049    
1050     \begin{methoddesc}[Transform]{rotateZ}{angle}
1051     Rotate the plane along the z-axis.
1052     \end{methoddesc}
1053    
1054     \begin{methoddesc}[Transform]{setPlaneToXY}{offset = 0}
1055     Set the plane orthogonal to the z-axis.
1056     \end{methoddesc}
1057    
1058     \begin{methoddesc}[Transform]{setPlaneToYZ}{offset = 0}
1059     Set the plane orthogonal to the x-axis.
1060     \end{methoddesc}
1061    
1062     \begin{methoddesc}[Transform]{setPlaneToXZ}{offset = 0}
1063     Set the plane orthogonal to the y-axis.
1064     \end{methoddesc}
1065    
1066     \subsubsection{\Tube class}
1067    
1068 jongui 1112 The following are some of the methods available:
1069    
1070 jongui 1035 \begin{methoddesc}[Tube]{setTubeRadius}{radius}
1071     Set the radius of the tube.
1072     \end{methoddesc}
1073    
1074     \begin{methoddesc}[Tube]{setTubeRadiusToVaryByVector}{}
1075     Set the radius of the tube to vary by vector data.
1076     \end{methoddesc}
1077    
1078     \begin{methoddesc}[Tube]{setTubeRadiusToVaryByScalar}{}
1079     Set the radius of the tube to vary by scalar data.
1080     \end{methoddesc}
1081    
1082     \subsubsection{\Warp class}
1083    
1084 jongui 1112 The following are some of the methods available:
1085    
1086 jongui 1035 \begin{methoddesc}[Warp]{setScaleFactor}{scale_factor}
1087     Set the displacement scale factor.
1088     \end{methoddesc}
1089    
1090 jongui 1079 \subsubsection{\MaskPoints class}
1091 jongui 1035
1092 jongui 1112 The following are some of the methods available:
1093    
1094 jongui 1079 \begin{methoddesc}[MaskPoints]{setRatio}{ratio}
1095 jongui 1199 Mask every n'th point.
1096 jongui 1079 \end{methoddesc}
1097    
1098     \begin{methoddesc}[MaskPoints]{randomOn}{}
1099     Enables the randomization of the points selected for masking.
1100     \end{methoddesc}
1101    
1102 jongui 1194
1103     \subsubsection{\ScalarBar class}
1104    
1105     The following are some of the methods available:
1106    
1107     \begin{methoddesc}[ScalarBar]{setTitle}{title}
1108     Set the title of the scalar bar.
1109     \end{methoddesc}
1110    
1111     \begin{methoddesc}[ScalarBar]{setPosition}{position}
1112     Set the local position of the scalar bar.
1113     \end{methoddesc}
1114    
1115     \begin{methoddesc}[ScalarBar]{setOrientationToHorizontal}{}
1116     Set the orientation of the scalar bar to horizontal.
1117     \end{methoddesc}
1118    
1119     \begin{methoddesc}[ScalarBar]{setOrientationToVertical}{}
1120     Set the orientation of the scalar bar to vertical.
1121     \end{methoddesc}
1122    
1123     \begin{methoddesc}[ScalarBar]{setHeight}{height}
1124     Set the height of the scalar bar.
1125     \end{methoddesc}
1126    
1127     \begin{methoddesc}[ScalarBar]{setWidth}{width}
1128     Set the width of the scalar bar.
1129     \end{methoddesc}
1130    
1131     \begin{methoddesc}[ScalarBar]{setLabelColor}{color}
1132     Set the color of the scalar bar's label.
1133     \end{methoddesc}
1134    
1135     \begin{methoddesc}[ScalarBar]{setTitleColor}{color}
1136     Set the color of the scalar bar's title.
1137     \end{methoddesc}
1138    
1139 jongui 1112 \subsubsection{\ImageReslice class}
1140 jongui 1079
1141 jongui 1112 The following are some of the methods available:
1142    
1143     \begin{methoddesc}[ImageReslice]{setSize}{size}
1144 jongui 1154 Set the size of the image (logo in particular), between 0 and 2. Size 1 (one)
1145     displays the image in its original size (which is the default).
1146 jongui 1112 \end{methoddesc}
1147    
1148 jongui 1194 \subsubsection{\DataSetMapper class}
1149 jongui 1112
1150 jongui 1194 The following are some of the methods available:
1151    
1152     \begin{methoddesc}[DataSetMapper]{setScalarRange}{lower_range, upper_range}
1153     Set the minimum and maximium scalar range for the data set mapper. This
1154     method is called when the range has been specified by the user.
1155     Therefore, the scalar range read from the source will be ignored.
1156     \end{methoddesc}
1157    
1158 jongui 1084 % #############################################################################
1159 jongui 1035
1160 jongui 1081
1161 jongui 1099 \section{More Examples}
1162     This section shows more examples.
1163 jongui 1082
1164 jongui 1084 \textsf{Reading A Series of Files}
1165 jongui 1081
1166 jongui 1084 \begin{python}
1167     # Import the necessary modules.
1168     from esys.pyvisi import Scene, DataCollector, Contour, Camera
1169     from esys.pyvisi.constant import *
1170 jongui 1154 import os
1171 jongui 1081
1172 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
1173     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
1174 jongui 1084 X_SIZE = 400
1175     Y_SIZE = 300
1176 gross 999
1177 jongui 1084 SCALAR_FIELD_POINT_DATA_1 = "lava"
1178     SCALAR_FIELD_POINT_DATA_2 = "talus"
1179     FILE_2D = "phi_talus_lava."
1180    
1181     IMAGE_NAME = "seriesofreads"
1182     JPG_RENDERER = Renderer.ONLINE_JPG
1183    
1184     # Create a Scene.
1185     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
1186     y_size = Y_SIZE)
1187    
1188 jongui 1194 # Create a DataCollector reading from a XML file.
1189 jongui 1084 dc1 = DataCollector(source = Source.XML)
1190     dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_1)
1191    
1192     # Create a Contour.
1193     mosc1 = Contour(scene = s, data_collector = dc1,
1194     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
1195     outline = True)
1196     mosc1.generateContours(0)
1197    
1198 jongui 1154 # Create a second DataCollector reading from the same XML file.
1199 jongui 1084 dc2 = DataCollector(source = Source.XML)
1200     dc2.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_2)
1201    
1202     # Create a second Contour.
1203     mosc2 = Contour(scene = s, data_collector = dc2,
1204     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
1205     outline = True)
1206     mosc2.generateContours(0)
1207    
1208 jongui 1143 # Create a Camera.
1209     cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
1210    
1211 jongui 1154 # Read in one file one after another and render the object.
1212 jongui 1084 for i in range(99, 104):
1213 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
1214     FILE_2D + "%04d.vtu") % i)
1215     dc2.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
1216     FILE_2D + "%04d.vtu") % i)
1217 jongui 1084
1218 jongui 1154 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
1219     IMAGE_NAME + "%04d.jpg") % i)
1220 jongui 1084 \end{python}
1221    
1222     \textsf{Manipulating A Single File with A Series of Translation}
1223    
1224     \begin{python}
1225    
1226     \end{python}
1227    
1228 jongui 1167 \textsf{Reading Data Directly from Escript Objects}
1229    
1230     \begin{python}
1231     # Import the necessary modules.
1232     from esys.escript import *
1233     from esys.escript.linearPDEs import LinearPDE
1234     from esys.finley import Rectangle
1235     from esys.pyvisi import Scene, DataCollector, Map, Camera
1236     from esys.pyvisi.constant import *
1237     import os
1238    
1239     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
1240     X_SIZE = 400
1241     Y_SIZE = 400
1242     JPG_RENDERER = Renderer.ONLINE_JPG
1243    
1244 jongui 1194 #... set some parameters ...
1245 jongui 1167 xc=[0.02,0.002]
1246     r=0.001
1247     qc=50.e6
1248     Tref=0.
1249     rhocp=2.6e6
1250     eta=75.
1251     kappa=240.
1252     tend=5.
1253 jongui 1194 # ... time, time step size and counter ...
1254 jongui 1167 t=0
1255     h=0.1
1256     i=0
1257    
1258 jongui 1194 #... generate domain ...
1259 jongui 1167 mydomain = Rectangle(l0=0.05,l1=0.01,n0=250, n1=50)
1260     #... open PDE ...
1261     mypde=LinearPDE(mydomain)
1262     mypde.setSymmetryOn()
1263     mypde.setValue(A=kappa*kronecker(mydomain),D=rhocp/h,d=eta,y=eta*Tref)
1264 jongui 1194 # ... set heat source: ....
1265 jongui 1167 x=mydomain.getX()
1266     qH=qc*whereNegative(length(x-xc)-r)
1267     # ... set initial temperature ....
1268     T=Tref
1269    
1270     # Create a Scene.
1271     s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
1272    
1273     # Create a DataCollector reading directly from escript objects.
1274     dc = DataCollector(source = Source.ESCRIPT)
1275    
1276     # Create a Map.
1277     m = Map(scene = s, data_collector = dc, \
1278     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, \
1279     cell_to_point = False, outline = True)
1280    
1281     # Create a Camera.
1282     c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
1283    
1284 jongui 1194 # ... start iteration:
1285     while t<0.4:
1286 jongui 1167 i+=1
1287     t+=h
1288     mypde.setValue(Y=qH+rhocp/h*T)
1289     T=mypde.getSolution()
1290    
1291     dc.setData(temp = T)
1292    
1293     # Render the object.
1294     s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
1295     "diffusion%02d.jpg") % i)
1296     \end{python}
1297    
1298     \newpage
1299    
1300 jongui 1091 \section{Useful Keys}
1301     This section shows some of the useful keys when interacting with the rendered
1302 jongui 1199 object (in the Online approach).
1303 jongui 1091
1304 jongui 1167 \begin{table}[ht]
1305 jongui 1091 \begin{center}
1306     \begin{tabular}{| c | p{13cm} |}
1307     \hline
1308     \textbf{Key} & \textbf{Description} \\ \hline
1309     Keypress 'c' / 'a' & Toggle between the camera ('c') and object ('a') mode. In
1310     camera mode, mouse events affect the camera position and focal point. In
1311     object mode, mouse events affect the rendered object's element (i.e.
1312     cut surface map, clipped velocity field, streamline, etc) that is under the
1313     mouse pointer.\\ \hline
1314     Mouse button 1 & Rotate the camera around its focal point (if in camera mode)
1315     or rotate the rendered object's element (if in object mode).\\ \hline
1316     Mourse button 2 & Pan the camera (if in camera mode) or translate the rendered
1317     object's element (if in object mode). \\ \hline
1318     Mouse button 3 & Zoom the camera (if in camera mode) or scale the rendered
1319     object's element (if in object mode). \\ \hline
1320     Keypress 3 & Toggle the render window in and out of stereo mode. By default,
1321     red-blue stereo pairs are created. \\ \hline
1322 jongui 1154 Keypress 'e' / 'q' & Exit the application if only one file is to be read, or
1323 jongui 1091 read and display the next file if multiple files are to be read. \\ \hline
1324     Keypress 's' & Modify the representation of the rendered object to surfaces.
1325     \\ \hline
1326     Keypress 'w' & Modify the representation of the rendered object to wireframe.
1327     \\ \hline
1328     \end{tabular}
1329 jongui 1167 \caption{Useful keys}
1330 jongui 1091 \end{center}
1331     \end{table}
1332    
1333    
1334     % ############################################################################
1335    
1336    
1337 jongui 1167 \newpage
1338    
1339 jongui 1091 \section{Sample Output}
1340 jongui 1199 This section displays some of the sample output.
1341 jongui 1091
1342 jongui 1167 \begin{table}[ht]
1343 jongui 1091 \begin{tabular}{c c c}
1344     \includegraphics[width=\thumbnailwidth]{figures/Map} &
1345     \includegraphics[width=\thumbnailwidth]{figures/MapOnPlaneCut} &
1346     \includegraphics[width=\thumbnailwidth]{figures/MapOnPlaneClip} \\
1347     Map & MapOnPlaneCut & MapOnPlaneClip \\
1348     \includegraphics[width=\thumbnailwidth]{figures/MapOnScalarClip} &
1349     \includegraphics[width=\thumbnailwidth]{figures/Velocity} &
1350     \includegraphics[width=\thumbnailwidth]{figures/VelocityOnPlaneCut} \\
1351     MapOnScalarClip & Velocity & VelocityOnPlaneCut \\
1352     \includegraphics[width=\thumbnailwidth]{figures/VelocityOnPlaneClip} &
1353     \includegraphics[width=\thumbnailwidth]{figures/Ellipsoid} &
1354     \includegraphics[width=\thumbnailwidth]{figures/EllipsoidOnPlaneCut} \\
1355     VelocityOnPlaneClip & Ellipsoid & EllipsoidOnPlaneCut \\
1356     \includegraphics[width=\thumbnailwidth]{figures/EllipsoidOnPlaneClip} &
1357     \includegraphics[width=\thumbnailwidth]{figures/Contour} &
1358     \includegraphics[width=\thumbnailwidth]{figures/ContourOnPlaneCut} \\
1359     EllipsoidOnPlaneClip & Contour & ContourOnPlaneCut \\
1360     \includegraphics[width=\thumbnailwidth]{figures/ContourOnPlaneClip} &
1361     \includegraphics[width=\thumbnailwidth]{figures/StreamLine} &
1362     \includegraphics[width=\thumbnailwidth]{figures/Carpet} \\
1363     ContourOnPlaneClip & StreamLine & Carpet \\
1364     \end{tabular}
1365     \caption{Sample output}
1366     \end{table}
1367    
1368    
1369    

  ViewVC Help
Powered by ViewVC 1.1.26