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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1210 - (hide annotations)
Tue Jul 3 05:47:34 2007 UTC (12 years, 7 months ago) by jongui
File MIME type: application/x-tex
File size: 48036 byte(s)
Made some minor changes.
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 jongui 1210 """
257     Author: John Ngui, john.ngui@uq.edu.au
258     """
259    
260 jongui 1081 # Import the necessary modules.
261     from esys.pyvisi import Scene, DataCollector, Map, Camera
262     from esys.pyvisi.constant import *
263 jongui 1154 import os
264 jongui 1081
265 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
266     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
267 jongui 1081 X_SIZE = 800
268     Y_SIZE = 800
269    
270     SCALAR_FIELD_POINT_DATA = "temperature"
271     SCALAR_FIELD_CELL_DATA = "temperature_cell"
272     FILE_3D = "interior_3D.xml"
273     IMAGE_NAME = "map.jpg"
274     JPG_RENDERER = Renderer.ONLINE_JPG
275    
276     # Create a Scene with four viewports.
277     s = Scene(renderer = JPG_RENDERER, num_viewport = 4, x_size = X_SIZE,
278     y_size = Y_SIZE)
279    
280     # Create a DataCollector reading from a XML file.
281     dc1 = DataCollector(source = Source.XML)
282 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
283 jongui 1081 dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
284    
285     # Create a Map for the first viewport.
286     m1 = Map(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
287     lut = Lut.COLOR, cell_to_point = False, outline = True)
288     m1.setRepresentationToWireframe()
289    
290     # Create a Camera for the first viewport
291 jongui 1154 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
292 jongui 1081 c1.isometricView()
293    
294     # Create a second DataCollector reading from the same XML file but specifying
295     # a different scalar field.
296     dc2 = DataCollector(source = Source.XML)
297 jongui 1154 dc2.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
298 jongui 1081 dc2.setActiveScalar(scalar = SCALAR_FIELD_CELL_DATA)
299    
300     # Create a Map for the third viewport.
301     m2 = Map(scene = s, data_collector = dc2, viewport = Viewport.NORTH_EAST,
302     lut = Lut.COLOR, cell_to_point = True, outline = True)
303    
304 jongui 1154 # Create a Camera for the third viewport
305 jongui 1194 c2 = Camera(scene = s, viewport = Viewport.NORTH_EAST)
306 jongui 1154
307 jongui 1081 # Render the object.
308 jongui 1154 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
309 jongui 1081 \end{python}
310    
311 jongui 1035 \subsubsection{\MapOnPlaneCut class}
312    
313     \begin{classdesc}{MapOnPlaneCut}{scene, data_collector,
314 jongui 1051 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
315     outline = True}
316 jongui 1035 This class works in a similar way to \Map, except that it shows a scalar
317 jongui 1079 field cut using a plane. The plane can be translated and rotated along the
318     X, Y and Z axes.
319 gross 999 \end{classdesc}
320    
321 jongui 1035 The following are some of the methods available:\\
322 jongui 1194 Methods from \ActorThreeD, \Transform and \DataSetMapper.
323 jongui 1035
324     \subsubsection{\MapOnPlaneClip class}
325    
326     \begin{classdesc}{MapOnPlaneClip}{scene, data_collector,
327 jongui 1051 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
328     outline = True}
329 jongui 1035 This class works in a similar way to \MapOnPlaneCut, except that it shows a
330     scalar field clipped using a plane.
331 gross 999 \end{classdesc}
332    
333 jongui 1035 The following are some of the methods available:\\
334 jongui 1194 Methods from \ActorThreeD, \Transform, \Clipper and \DataSetMapper.
335 jongui 1035
336     \subsubsection{\MapOnScalarClip class}
337    
338     \begin{classdesc}{MapOnScalarClip}{scene, data_collector,
339 jongui 1051 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
340     outline = True}
341 jongui 1035 This class works in a similar way to \Map, except that it shows a scalar
342     field clipped using a scalar value.
343 gross 999 \end{classdesc}
344    
345 jongui 1035 The following are some of the methods available:\\
346 jongui 1194 Methods from \ActorThreeD, \Clipper and \DataSetMapper.
347 jongui 1035
348     \subsubsection{\Velocity class}
349    
350 jongui 1154 \begin{classdesc}{Velocity}{scene, data_collector, arrow = Arrow.TWO_D,
351     color_mode = ColorMode.VECTOR, viewport = Viewport.SOUTH_WEST,
352     lut = Lut.COLOR, cell_to_point = False, outline = True}
353 jongui 1035 Class that shows a vector field using arrows. The arrows can either be
354     colored or grey-scaled, depending on the lookup table used. If the arrows
355     are colored, there are two possible coloring modes, either using vector data or
356     scalar data. Similarly, there are two possible types of arrows, either
357     using two-dimensional or three-dimensional.
358 gross 999 \end{classdesc}
359    
360 jongui 1035 The following are some of the methods available:\\
361 jongui 1194 Methods from \ActorThreeD, \GlyphThreeD, \MaskPoints and \DataSetMapper.
362 jongui 1035
363     \subsubsection{\VelocityOnPlaneCut class}
364    
365 jongui 1084 \begin{classdesc}{VelocityOnPlaneCut}{scene, data_collector,
366 jongui 1035 arrow = Arrow.TWO_D, color_mode = ColorMode.VECTOR,
367 jongui 1078 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
368     cell_to_point = False, outline = True}
369 jongui 1035 This class works in a similar way to \MapOnPlaneCut, except that
370 jongui 1079 it shows a vector field using arrows cut using a plane.
371 gross 999 \end{classdesc}
372    
373 jongui 1035 The following are some of the methods available:\\
374 jongui 1194 Methods from \ActorThreeD, \GlyphThreeD, \Transform, \MaskPoints and
375     \DataSetMapper.
376 jongui 1035
377 jongui 1084 A typical usage of \VelocityOnPlaneCut is shown below.
378 jongui 1081
379     \begin{python}
380 jongui 1210 """
381     Author: John Ngui, john.ngui@uq.edu.au
382     """
383    
384 jongui 1081 # Import the necessary modules
385     from esys.pyvisi import Scene, DataCollector, VelocityOnPlaneCut, Camera
386     from esys.pyvisi.constant import *
387 jongui 1154 import os
388 jongui 1081
389 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
390     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
391 jongui 1081 X_SIZE = 400
392     Y_SIZE = 400
393    
394     VECTOR_FIELD_CELL_DATA = "velocity"
395     FILE_3D = "interior_3D.xml"
396     IMAGE_NAME = "velocity.jpg"
397     JPG_RENDERER = Renderer.ONLINE_JPG
398    
399 jongui 1210 # Create a Scene.
400 jongui 1081 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
401     y_size = Y_SIZE)
402    
403     # Create a DataCollector reading from a XML file.
404     dc1 = DataCollector(source = Source.XML)
405 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
406 jongui 1081 dc1.setActiveVector(vector = VECTOR_FIELD_CELL_DATA)
407    
408     # Create VelocityOnPlaneCut.
409     vopc1 = VelocityOnPlaneCut(scene = s, data_collector = dc1,
410     viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.VECTOR,
411     arrow = Arrow.THREE_D, lut = Lut.COLOR, cell_to_point = False,
412     outline = True)
413     vopc1.setScaleFactor(scale_factor = 0.5)
414     vopc1.setPlaneToXY(offset = 0.5)
415     vopc1.setRatio(2)
416     vopc1.randomOn()
417    
418     # Create a Camera.
419 jongui 1154 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
420 jongui 1081 c1.isometricView()
421     c1.elevation(angle = -20)
422    
423     # Render the object.
424 jongui 1154 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
425 jongui 1081 \end{python}
426    
427 jongui 1035 \subsubsection{\VelocityOnPlaneClip class}
428    
429     \begin{classdesc}{VelocityOnPlaneClip}{scene, data_collector,
430     arrow = Arrow.TWO_D, color_mode = ColorMode.VECTOR,
431 jongui 1078 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
432     cell_to_point = False, online = True}
433 jongui 1035 This class works in a similar way to \MapOnPlaneClip, except that it shows a
434     vector field using arrows clipped using a plane.
435 gross 999 \end{classdesc}
436 jongui 961
437 jongui 1035 The following are some of the methods available:\\
438 jongui 1194 Methods from \ActorThreeD, \GlyphThreeD, \Transform, \Clipper,
439     \MaskPoints and \DataSetMapper.
440 jongui 1035
441     \subsubsection{\Ellipsoid class}
442    
443     \begin{classdesc}{Ellipsoid}{scene, data_collector,
444 jongui 1079 viewport = Viewport = SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
445     outline = True}
446 jongui 1035 Class that shows a tensor field using ellipsoids. The ellipsoids can either be
447     colored or grey-scaled, depending on the lookup table used.
448 gross 999 \end{classdesc}
449    
450 jongui 1035 The following are some of the methods available:\\
451 jongui 1194 Methods from \ActorThreeD, \Sphere, \TensorGlyph, \MaskPoints and
452     \DataSetMapper.
453 jongui 1035
454     \subsubsection{\EllipsoidOnPlaneCut class}
455    
456     \begin{classdesc}{EllipsoidOnPlaneCut}{scene, data_collector,
457 jongui 1079 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
458     outline = True}
459 jongui 1035 This class works in a similar way to \MapOnPlaneCut, except that it shows
460     a tensor field using ellipsoids cut using a plane.
461 gross 999 \end{classdesc}
462    
463 jongui 1035 The following are some of the methods available:\\
464 jongui 1194 Methods from \ActorThreeD, \Sphere, \TensorGlyph, \Transform,
465     \MaskPoints and \DataSetMapper.
466 jongui 1035
467     \subsubsection{\EllipsoidOnPlaneClip class}
468    
469     \begin{classdesc}{EllipsoidOnPlaneClip}{scene, data_collector,
470 jongui 1079 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
471     outline = True}
472 jongui 1035 This class works in a similar way to \MapOnPlaneClip, except that it shows a
473     tensor field using ellipsoids clipped using a plane.
474 gross 999 \end{classdesc}
475 jongui 1035
476     The following are some of the methods available:\\
477 jongui 1194 Methods from \ActorThreeD, \Sphere, \TensorGlyph, \Transform, \Clipper,
478     \MaskPoints and \DataSetMapper.
479 gross 999
480 jongui 1084 A typical usage of \EllipsoidOnPlaneClip is shown below.
481 jongui 1081
482     \begin{python}
483 jongui 1210 """
484     Author: John Ngui, john.ngui@uq.edu.au
485     """
486    
487 jongui 1081 # Import the necessary modules
488     from esys.pyvisi import Scene, DataCollector, EllipsoidOnPlaneClip, Camera
489     from esys.pyvisi.constant import *
490 jongui 1154 import os
491 jongui 1081
492 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
493     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
494 jongui 1081 X_SIZE = 400
495     Y_SIZE = 400
496    
497     TENSOR_FIELD_CELL_DATA = "stress_cell"
498     FILE_3D = "interior_3D.xml"
499     IMAGE_NAME = "ellipsoid.jpg"
500     JPG_RENDERER = Renderer.ONLINE_JPG
501    
502     # Create a Scene.
503     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
504     y_size = Y_SIZE)
505    
506     # Create a DataCollector reading from a XML file.
507     dc1 = DataCollector(source = Source.XML)
508 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
509 jongui 1081 dc1.setActiveTensor(tensor = TENSOR_FIELD_CELL_DATA)
510    
511 jongui 1210 # Create an EllipsoidOnPlaneClip.
512 jongui 1081 eopc1 = EllipsoidOnPlaneClip(scene = s, data_collector = dc1,
513     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = True,
514     outline = True)
515     eopc1.setPlaneToXY()
516     eopc1.setScaleFactor(scale_factor = 0.2)
517     eopc1.rotateX(angle = 10)
518    
519 jongui 1210 # Create a Camera.
520 jongui 1154 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
521 jongui 1081 c1.bottomView()
522     c1.azimuth(angle = -90)
523     c1.elevation(angle = 10)
524    
525     # Render the object.
526 jongui 1154 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
527 jongui 1081 \end{python}
528    
529 jongui 1035 \subsubsection{\Contour class}
530    
531     \begin{classdesc}{Contour}{scene, data_collector,
532 jongui 1051 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
533     outline = True}
534 jongui 1079 Class that shows a scalar field using contour surfaces. The contour surfaces can
535 jongui 1035 either be colored or grey-scaled, depending on the lookup table used. This
536     class can also be used to generate iso surfaces.
537 gross 999 \end{classdesc}
538    
539 jongui 1035 The following are some of the methods available:\\
540 jongui 1194 Methods from \ActorThreeD, \ContourModule and \DataSetMapper.
541 jongui 1035
542 jongui 1084 A typical usage of \Contour is shown below.
543 jongui 1081
544     \begin{python}
545 jongui 1210 """
546     Author: John Ngui, john.ngui@uq.edu.au
547     """
548    
549 jongui 1081 # Import the necessary modules
550     from esys.pyvisi import Scene, DataCollector, Contour, Camera
551     from esys.pyvisi.constant import *
552 jongui 1154 import os
553 jongui 1081
554 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
555     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
556 jongui 1081 X_SIZE = 400
557     Y_SIZE = 400
558    
559     SCALAR_FIELD_POINT_DATA = "temperature"
560     FILE_3D = "interior_3D.xml"
561     IMAGE_NAME = "contour.jpg"
562     JPG_RENDERER = Renderer.ONLINE_JPG
563    
564     # Create a Scene.
565     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
566     y_size = Y_SIZE)
567    
568     # Create a DataCollector reading a XML file.
569     dc1 = DataCollector(source = Source.XML)
570 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
571 jongui 1081 dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
572    
573     # Create a Contour.
574     ctr1 = Contour(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
575     lut = Lut.COLOR, cell_to_point = False, outline = True)
576     ctr1.generateContours(contours = 3)
577    
578     # Create a Camera.
579 jongui 1154 cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
580 jongui 1081 cam1.elevation(angle = -40)
581    
582     # Render the object.
583 jongui 1154 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
584 jongui 1081 \end{python}
585    
586 jongui 1035 \subsubsection{\ContourOnPlaneCut class}
587    
588     \begin{classdesc}{ContourOnPlaneCut}{scene, data_collector,
589 jongui 1051 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
590     outline = True}
591 jongui 1035 This class works in a similar way to \MapOnPlaneCut, except that it shows a
592 jongui 1079 scalar field using contour surfaces cut using a plane.
593 gross 999 \end{classdesc}
594 gross 606
595 jongui 1035 The following are some of the methods available:\\
596 jongui 1194 Methods from \ActorThreeD, \ContourModule, \Transform and \DataSetMapper.
597 jongui 1035
598     \subsubsection{\ContourOnPlaneClip class}
599    
600     \begin{classdesc}{ContourOnPlaneClip}{scene, data_collector,
601 jongui 1051 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
602     outline = True}
603 jongui 1035 This class works in a similar way to \MapOnPlaneClip, except that it shows a
604 jongui 1079 scalar field using contour surfaces clipped using a plane.
605 gross 999 \end{classdesc}
606    
607 jongui 1035 The following are some of the methods available:\\
608 jongui 1194 Methods from \ActorThreeD, \ContourModule, \Transform, \Clipper and
609     \DataSetMapper.
610 jongui 1035
611     \subsubsection{\StreamLine class}
612    
613     \begin{classdesc}{StreamLine}{scene, data_collector,
614     viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.VECTOR, lut = Lut.COLOR,
615 jongui 1154 cell_to_point = False, outline = True}
616 jongui 1035 Class that shows the direction of particles of a vector field using streamlines.
617     The streamlines can either be colored or grey-scaled, depending on the lookup
618     table used. If the streamlines are colored, there are two possible coloring
619     modes, either using vector data or scalar data.
620 gross 999 \end{classdesc}
621    
622 jongui 1035 The following are some of the methods available:\\
623 jongui 1194 Methods from \ActorThreeD, \PointSource, \StreamLineModule, \Tube and
624     \DataSetMapper.
625 jongui 1035
626 jongui 1084 A typical usage of \StreamLine is shown below.
627 jongui 1081
628     \begin{python}
629 jongui 1210 """
630     Author: John Ngui, john.ngui@uq.edu.au
631     """
632    
633 jongui 1081 # Import the necessary modules.
634     from esys.pyvisi import Scene, DataCollector, StreamLine, Camera
635     from esys.pyvisi.constant import *
636 jongui 1154 import os
637 jongui 1081
638 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
639     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
640 jongui 1081 X_SIZE = 400
641     Y_SIZE = 400
642    
643     VECTOR_FIELD_CELL_DATA = "temperature"
644     FILE_3D = "interior_3D.xml"
645     IMAGE_NAME = "streamline.jpg"
646     JPG_RENDERER = Renderer.ONLINE_JPG
647    
648     # Create a Scene.
649     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
650     y_size = Y_SIZE)
651    
652     # Create a DataCollector reading from a XML file.
653     dc1 = DataCollector(source = Source.XML)
654 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
655 jongui 1081
656     # Create a Streamline.
657     sl1 = StreamLine(scene = s, data_collector = dc1,
658     viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.SCALAR,
659     lut = Lut.COLOR, cell_to_point = False, outline = True)
660     sl1.setTubeRadius(radius = 0.02)
661 jongui 1194 sl1.setTubeNumberOfSides(3)
662 jongui 1210 sl1.setTubeRadiusToVaryByVector()
663     sl1.setPointSourceRadius(0.9)
664 jongui 1081
665     # Create a Camera.
666 jongui 1154 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
667 jongui 1081 c1.isometricView()
668    
669     # Render the object.
670 jongui 1154 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
671 jongui 1081 \end{python}
672    
673 jongui 1035 \subsubsection{\Carpet class}
674    
675     \begin{classdesc}{Carpet}{scene, data_collector,
676     viewport = Viewport.Viewport.SOUTH_WEST, warp_mode = WarpMode.SCALAR,
677 jongui 1154 lut = Lut.COLOR, cell_to_point = False, outline = True}
678 jongui 1035 This class works in a similar way to \MapOnPlaneCut, except that it shows a
679 jongui 1079 scalar field cut on a plane and deformated (warp) along the normal. The
680     plane can either be colored or grey-scaled, depending on the lookup table used.
681 jongui 1035 Similarly, the plane can be deformated either using scalar data or vector data.
682 gross 999 \end{classdesc}
683    
684 jongui 1035 The following are some of the methods available:\\
685 jongui 1194 Methods from \ActorThreeD, \Warp, \Transform and \DataSetMapper.
686 gross 999
687 jongui 1084 A typical usage of \Carpet is shown below.
688 jongui 1081
689     \begin{python}
690 jongui 1210 """
691     Author: John Ngui, john.ngui@uq.edu.au
692     """
693    
694 jongui 1081 # Import the necessary modules.
695     from esys.pyvisi import Scene, DataCollector, Carpet, Camera
696     from esys.pyvisi.constant import *
697 jongui 1154 import os
698 jongui 1081
699 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
700     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
701 jongui 1081 X_SIZE = 400
702     Y_SIZE = 400
703    
704     SCALAR_FIELD_CELL_DATA = "temperature_cell"
705     FILE_3D = "interior_3D.xml"
706     IMAGE_NAME = "carpet.jpg"
707     JPG_RENDERER = Renderer.ONLINE_JPG
708    
709     # Create a Scene.
710     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
711     y_size = Y_SIZE)
712    
713     # Create a DataCollector reading from a XML file.
714     dc1 = DataCollector(source = Source.XML)
715 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
716 jongui 1081 dc1.setActiveScalar(scalar = SCALAR_FIELD_CELL_DATA)
717    
718     # Create a Carpet.
719     cpt1 = Carpet(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
720     warp_mode = WarpMode.SCALAR, lut = Lut.COLOR, cell_to_point = True,
721     outline = True)
722     cpt1.setPlaneToXY(0.2)
723     cpt1.setScaleFactor(1.9)
724    
725     # Create a Camera.
726 jongui 1154 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
727 jongui 1081 c1.isometricView()
728    
729     # Render the object.
730 jongui 1154 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
731 jongui 1081 \end{python}
732    
733 jongui 1194 \subsubsection{\Legend class}
734    
735     \begin{classdesc}{Legend}{scene, data_collector,
736     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, legend = LegendType.SCALAR}
737     Class that shows a scalar field on a domain surface. The domain surface
738     can either be colored or grey-scaled, depending on the lookup table used
739     \end{classdesc}
740    
741     The following are some of the methods available:\\
742     Methods from \ActorThreeD, \ScalarBar and \DataSetMapper.
743    
744 jongui 1205 \subsubsection{\Rectangle class}
745    
746     \begin{classdesc}{Rectangle}{scene, viewport = Viewport.SOUTH_WEST}
747     Class that generates a rectangle box.
748     \end{classdesc}
749    
750     The following are some of the methods available:\\
751     Methods from \ActorThreeD, \CubeSource and \DataSetMapper.
752    
753 jongui 1035 \subsubsection{\Image class}
754    
755     \begin{classdesc}{Image}{scene, image_reader, viewport = Viewport.SOUTH_WEST}
756 jongui 1112 Class that displays an image which can be scaled (upwards and downwards) and
757     has interaction capability. The image can also be translated and rotated along
758     the X, Y and Z axes. One of the most common use of this feature is pasting an
759     image on a surface map.
760 gross 999 \end{classdesc}
761    
762 jongui 1035 The following are some of the methods available:\\
763     Methods from \ActorThreeD, \PlaneSource and \Transform.
764    
765 jongui 1084 A typical usage of \Image is shown below.
766 jongui 1035
767 jongui 1081 \begin{python}
768 jongui 1210 """
769     Author: John Ngui, john.ngui@uq.edu.au
770     """
771    
772 jongui 1081 # Import the necessary modules.
773 jongui 1154 from esys.pyvisi import Scene, DataCollector, Map, ImageReader, Image, Camera
774     from esys.pyvisi import GlobalPosition
775 jongui 1081 from esys.pyvisi.constant import *
776 jongui 1154 import os
777 jongui 1081
778 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
779     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
780 jongui 1081 X_SIZE = 400
781     Y_SIZE = 400
782    
783 jongui 1154 SCALAR_FIELD_POINT_DATA = "temperature"
784 jongui 1081 FILE_3D = "interior_3D.xml"
785 jongui 1154 LOAD_IMAGE_NAME = "flinders.jpg"
786     SAVE_IMAGE_NAME = "image.jpg"
787 jongui 1081 JPG_RENDERER = Renderer.ONLINE_JPG
788    
789     # Create a Scene.
790     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
791     y_size = Y_SIZE)
792    
793     # Create a DataCollector reading from a XML file.
794     dc1 = DataCollector(source = Source.XML)
795 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
796 jongui 1081
797 jongui 1154 # Create a Map.
798     m1 = Map(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
799 jongui 1081 lut = Lut.COLOR, cell_to_point = False, outline = True)
800 jongui 1154 m1.setOpacity(0.3)
801 jongui 1081
802 jongui 1154 # Create an ImageReader (in place of DataCollector).
803     ir = ImageReader(ImageFormat.JPG)
804     ir.setImageName(image_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
805     LOAD_IMAGE_NAME))
806 jongui 1081
807 jongui 1154 # Create an Image.
808     i = Image(scene = s, image_reader = ir, viewport = Viewport.SOUTH_WEST)
809     i.setOpacity(opacity = 0.9)
810     i.translate(0,0,-1)
811     i.setPoint1(GlobalPosition(2,0,0))
812     i.setPoint2(GlobalPosition(0,2,0))
813    
814     # Create a Camera.
815     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
816    
817     # Render the image.
818     s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, SAVE_IMAGE_NAME))
819 jongui 1081 \end{python}
820    
821 jongui 1112 \subsubsection{\Logo class}
822 jongui 1081
823 jongui 1112 \begin{classdesc}{Logo}{scene, image_reader, viewport = Viewport.SOUTH_WEST}
824 jongui 1154 Class that displays a static image, in particular a logo
825     (i.e. company symbol) and has NO interaction capability. The position and size
826     of the logo can be specified.
827 jongui 1112 \end{classdesc}
828    
829     The following are some of the methods available:\\
830     Methods from \ImageReslice and \ActorTwoD.
831    
832 jongui 1194 \subsubsection{\Movie class}
833 jongui 1112
834 jongui 1194 \begin{classdesc}{Movie}{parameter_file = "make_movie"}
835     Class that creates a file called 'make_movie' by default (if a parameter
836     file name is not speficied) which contains a list of parameters required
837     by the 'ppmtompeg' command to generate a movie from a series of images.
838     \end{classdesc}
839    
840     The following are some of the methods available:\\
841 jongui 1199 \begin{methoddesc}[Movie]{imageRange}{input_directory, first_image, last_image}
842     The image range from which the movie is to be generated from.
843     \end{methoddesc}
844    
845     \begin{methoddesc}[Movie]{imageList}{input_directory, image_list}
846     The image list from which the movie is to be generated from.
847     \end{methoddesc}
848    
849     \begin{methoddesc}[Movie]{makeMovie}{movie}
850 jongui 1194 Generate the movie.
851     \end{methoddesc}
852    
853 jongui 1199 A typical usage of \Movie is shown below.
854 jongui 1194
855     \begin{python}
856 jongui 1210 """
857     Author: John Ngui, john.ngui@uq.edu.au
858     """
859    
860 jongui 1194 # Import the necessary modules.
861     from esys.pyvisi import Scene, DataCollector, Map, Camera, Velocity, Legend
862     from esys.pyvisi import Movie, LocalPosition
863     from esys.pyvisi.constant import *
864     import os
865    
866     PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
867     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
868     X_SIZE = 800
869     Y_SIZE = 800
870    
871     SCALAR_FIELD_POINT_DATA = "temp"
872     FILE_2D = "tempvel-"
873     IMAGE_NAME = "movie"
874     JPG_RENDERER = Renderer.ONLINE_JPG
875    
876     # Create a Scene.
877     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
878     y_size = Y_SIZE)
879    
880     # Create a DataCollector reading from a XML file.
881     dc1 = DataCollector(source = Source.XML)
882     dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
883    
884     # Create a Map.
885     m1 = Map(scene = s, data_collector = dc1,
886     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
887     outline = True)
888    
889     # Create a Camera.
890     cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
891    
892     # Create a movie.
893     mov = Movie()
894 jongui 1199 #lst = []
895 jongui 1194
896     # Read in one file one after another and render the object.
897     for i in range(938, 949):
898     dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
899     FILE_2D + "%06d.vtu") % i)
900    
901     s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
902     IMAGE_NAME + "%06d.jpg") % i)
903    
904 jongui 1199 #lst.append(IMAGE_NAME + "%06d.jpg" % i)
905    
906     # Images (first and last inclusive) from which the movie is to be generated.
907     mov.imageRange(input_directory = PYVISI_EXAMPLE_IMAGES_PATH,
908 jongui 1194 first_image = IMAGE_NAME + "000938.jpg",
909 jongui 1199 last_image = IMAGE_NAME + "000948.jpg")
910    
911     # Alternatively, a list of images can be specified.
912     #mov.imageList(input_directory = PYVISI_EXAMPLE_IMAGES_PATH, image_list = lst)
913    
914     # Generate the movie.
915     mov.makeMovie(os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))
916 jongui 1194 \end{python}
917    
918    
919 jongui 1035 %##############################################################################
920    
921    
922 jongui 1076 \subsection{Coordinate Classes}
923 jongui 1035 This subsection details the instances used to position the rendered object.
924    
925 jongui 1205 \subsubsection{\LocalPosition class}
926    
927 jongui 1035 \begin{classdesc}{LocalPosition}{x_coor, y_coor}
928 jongui 1199 Class that defines the local positioning (X and Y) coordinate system (2D).
929 gross 999 \end{classdesc}
930    
931 jongui 1205 \subsubsection{\GlobalPosition class}
932    
933 jongui 1035 \begin{classdesc}{GlobalPosition}{x_coor, y_coor, z_coor}
934 jongui 1199 Class that defines the global positioning (X, Y and Z) coordinate system (3D).
935 gross 999 \end{classdesc}
936    
937 jongui 1035
938     %##############################################################################
939    
940    
941     \subsection{Supporting Classes}
942 jongui 1199 This subsection details the supporting classes and their corresponding methods
943     inherited by the input (see Section \ref{INPUT SEC}) and data
944     visualization classes (see Section \ref{DATAVIS SEC}).
945 jongui 1035
946     \subsubsection{\ActorThreeD class}
947    
948     The following are some of the methods available:
949    
950     \begin{methoddesc}[Actor3D]{setOpacity}{opacity}
951     Set the opacity (transparency) of the 3D actor.
952     \end{methoddesc}
953    
954     \begin{methoddesc}[Actor3D]{setColor}{color}
955     Set the color of the 3D actor.
956     \end{methoddesc}
957    
958     \begin{methoddesc}[Actor3D]{setRepresentationToWireframe}{}
959     Set the representation of the 3D actor to wireframe.
960     \end{methoddesc}
961    
962     \subsubsection{\ActorTwoD class}
963    
964     The following are some of the methods available:
965    
966     \begin{methoddesc}[Actor2D]{setPosition}{position}
967     Set the position (XY) of the 2D actor. Default position is the lower left hand
968     corner of the window / viewport.
969     \end{methoddesc}
970    
971     \subsubsection{\Clipper class}
972    
973     The following are some of the methods available:
974    
975     \begin{methoddesc}[Clipper]{setInsideOutOn}{}
976     Clips one side of the rendered object.
977     \end{methoddesc}
978    
979     \begin{methoddesc}[Clipper]{setInsideOutOff}{}
980     Clips the other side of the rendered object.
981     \end{methoddesc}
982    
983     \begin{methoddesc}[Clipper]{setClipValue}{value}
984 jongui 1079 Set the scalar clip value (instead of using a plane) for the clipper.
985 jongui 1035 \end{methoddesc}
986    
987     \subsubsection{\ContourModule class}
988    
989     The following are some of the methods available:
990    
991 jongui 1143 \begin{methoddesc}[ContourModule]{generateContours}{contours = None,
992 jongui 1035 lower_range = None, upper_range = None}
993     Generate the specified number of contours within the specified range.
994 jongui 1079 In order to generate an iso surface, the 'lower_range' and 'upper_range'
995     must be equal.
996 jongui 1035 \end{methoddesc}
997    
998     \subsubsection{\GlyphThreeD class}
999    
1000     The following are some of the methods available:
1001    
1002     \begin{methoddesc}[Glyph3D]{setScaleModeByVector}{}
1003     Set the 3D glyph to scale according to the vector data.
1004     \end{methoddesc}
1005    
1006     \begin{methoddesc}[Glyph3D]{setScaleModeByScalar}{}
1007     Set the 3D glyph to scale according to the scalar data.
1008     \end{methoddesc}
1009    
1010     \begin{methoddesc}[Glyph3D]{setScaleFactor}{scale_factor}
1011     Set the 3D glyph scale factor.
1012     \end{methoddesc}
1013    
1014     \subsubsection{\TensorGlyph class}
1015    
1016     The following are some of the methods available:
1017    
1018     \begin{methoddesc}[TensorGlyph]{setScaleFactor}{scale_factor}
1019     Set the scale factor for the tensor glyph.
1020     \end{methoddesc}
1021    
1022 jongui 1079 \begin{methoddesc}[TensorGlyph]{setMaxScaleFactor}{max_scale_factor}
1023     Set the maximum allowable scale factor for the tensor glyph.
1024     \end{methoddesc}
1025    
1026 jongui 1035 \subsubsection{\PlaneSource class}
1027    
1028     The following are some of the methods available:
1029    
1030     \begin{methoddesc}[PlaneSource]{setPoint1}{position}
1031     Set the first point from the origin of the plane source.
1032     \end{methoddesc}
1033    
1034     \begin{methoddesc}[PlaneSource]{setPoint2}{position}
1035     Set the second point from the origin of the plane source.
1036     \end{methoddesc}
1037    
1038     \subsubsection{\PointSource class}
1039    
1040     The following are some of the methods available:
1041    
1042     \begin{methoddesc}[PointSource]{setPointSourceRadius}{radius}
1043     Set the radius of the sphere.
1044     \end{methoddesc}
1045    
1046 jongui 1143 \begin{methoddesc}[PointSource]{setPointSourceCenter}{center}
1047 jongui 1079 Set the center of the sphere.
1048     \end{methoddesc}
1049    
1050 jongui 1035 \begin{methoddesc}[PointSource]{setPointSourceNumberOfPoints}{points}
1051     Set the number of points to generate within the sphere (the larger the
1052     number of points, the more streamlines are generated).
1053     \end{methoddesc}
1054    
1055     \subsubsection{\Sphere class}
1056    
1057     The following are some of the methods available:
1058    
1059     \begin{methoddesc}[Sphere]{setThetaResolution}{resolution}
1060     Set the theta resolution of the sphere.
1061     \end{methoddesc}
1062    
1063     \begin{methoddesc}[Sphere]{setPhiResolution}{resolution}
1064 jongui 1154 Set the phi resolution of the sphere.
1065 jongui 1035 \end{methoddesc}
1066    
1067     \subsubsection{\StreamLineModule class}
1068    
1069     The following are some of the methods available:
1070    
1071     \begin{methoddesc}[StreamLineModule]{setMaximumPropagationTime}{time}
1072     Set the maximum length of the streamline expressed in elapsed time.
1073     \end{methoddesc}
1074    
1075     \begin{methoddesc}[StreamLineModule]{setIntegrationToBothDirections}{}
1076     Set the integration to occur both sides: forward (where the streamline
1077     goes) and backward (where the streamline came from).
1078     \end{methoddesc}
1079    
1080     \subsubsection{\Transform class}
1081    
1082 jongui 1112 The following are some of the methods available:
1083    
1084 jongui 1035 \begin{methoddesc}[Transform]{translate}{x_offset, y_offset, z_offset}
1085     Translate the rendered object along the x, y and z-axes.
1086     \end{methoddesc}
1087    
1088     \begin{methoddesc}[Transform]{rotateX}{angle}
1089     Rotate the plane along the x-axis.
1090     \end{methoddesc}
1091    
1092     \begin{methoddesc}[Transform]{rotateY}{angle}
1093     Rotate the plane along the y-axis.
1094     \end{methoddesc}
1095    
1096     \begin{methoddesc}[Transform]{rotateZ}{angle}
1097     Rotate the plane along the z-axis.
1098     \end{methoddesc}
1099    
1100     \begin{methoddesc}[Transform]{setPlaneToXY}{offset = 0}
1101     Set the plane orthogonal to the z-axis.
1102     \end{methoddesc}
1103    
1104     \begin{methoddesc}[Transform]{setPlaneToYZ}{offset = 0}
1105     Set the plane orthogonal to the x-axis.
1106     \end{methoddesc}
1107    
1108     \begin{methoddesc}[Transform]{setPlaneToXZ}{offset = 0}
1109     Set the plane orthogonal to the y-axis.
1110     \end{methoddesc}
1111    
1112     \subsubsection{\Tube class}
1113    
1114 jongui 1112 The following are some of the methods available:
1115    
1116 jongui 1035 \begin{methoddesc}[Tube]{setTubeRadius}{radius}
1117     Set the radius of the tube.
1118     \end{methoddesc}
1119    
1120     \begin{methoddesc}[Tube]{setTubeRadiusToVaryByVector}{}
1121     Set the radius of the tube to vary by vector data.
1122     \end{methoddesc}
1123    
1124     \begin{methoddesc}[Tube]{setTubeRadiusToVaryByScalar}{}
1125     Set the radius of the tube to vary by scalar data.
1126     \end{methoddesc}
1127    
1128     \subsubsection{\Warp class}
1129    
1130 jongui 1112 The following are some of the methods available:
1131    
1132 jongui 1035 \begin{methoddesc}[Warp]{setScaleFactor}{scale_factor}
1133     Set the displacement scale factor.
1134     \end{methoddesc}
1135    
1136 jongui 1079 \subsubsection{\MaskPoints class}
1137 jongui 1035
1138 jongui 1112 The following are some of the methods available:
1139    
1140 jongui 1079 \begin{methoddesc}[MaskPoints]{setRatio}{ratio}
1141 jongui 1199 Mask every n'th point.
1142 jongui 1079 \end{methoddesc}
1143    
1144     \begin{methoddesc}[MaskPoints]{randomOn}{}
1145     Enables the randomization of the points selected for masking.
1146     \end{methoddesc}
1147    
1148 jongui 1194
1149     \subsubsection{\ScalarBar class}
1150    
1151     The following are some of the methods available:
1152    
1153     \begin{methoddesc}[ScalarBar]{setTitle}{title}
1154     Set the title of the scalar bar.
1155     \end{methoddesc}
1156    
1157     \begin{methoddesc}[ScalarBar]{setPosition}{position}
1158     Set the local position of the scalar bar.
1159     \end{methoddesc}
1160    
1161     \begin{methoddesc}[ScalarBar]{setOrientationToHorizontal}{}
1162     Set the orientation of the scalar bar to horizontal.
1163     \end{methoddesc}
1164    
1165     \begin{methoddesc}[ScalarBar]{setOrientationToVertical}{}
1166     Set the orientation of the scalar bar to vertical.
1167     \end{methoddesc}
1168    
1169     \begin{methoddesc}[ScalarBar]{setHeight}{height}
1170     Set the height of the scalar bar.
1171     \end{methoddesc}
1172    
1173     \begin{methoddesc}[ScalarBar]{setWidth}{width}
1174     Set the width of the scalar bar.
1175     \end{methoddesc}
1176    
1177     \begin{methoddesc}[ScalarBar]{setLabelColor}{color}
1178     Set the color of the scalar bar's label.
1179     \end{methoddesc}
1180    
1181     \begin{methoddesc}[ScalarBar]{setTitleColor}{color}
1182     Set the color of the scalar bar's title.
1183     \end{methoddesc}
1184    
1185 jongui 1112 \subsubsection{\ImageReslice class}
1186 jongui 1079
1187 jongui 1112 The following are some of the methods available:
1188    
1189     \begin{methoddesc}[ImageReslice]{setSize}{size}
1190 jongui 1154 Set the size of the image (logo in particular), between 0 and 2. Size 1 (one)
1191     displays the image in its original size (which is the default).
1192 jongui 1112 \end{methoddesc}
1193    
1194 jongui 1194 \subsubsection{\DataSetMapper class}
1195 jongui 1112
1196 jongui 1194 The following are some of the methods available:
1197    
1198     \begin{methoddesc}[DataSetMapper]{setScalarRange}{lower_range, upper_range}
1199     Set the minimum and maximium scalar range for the data set mapper. This
1200     method is called when the range has been specified by the user.
1201     Therefore, the scalar range read from the source will be ignored.
1202     \end{methoddesc}
1203    
1204 jongui 1205 \subsubsection{\CubeSource class}
1205    
1206     The following are some of the methods available:
1207    
1208     \begin{methoddesc}[CubeSource]{setCenter}{center}
1209     Set the cube source center.
1210     \end{methoddesc}
1211    
1212     \begin{methoddesc}[CubeSource]{setXLength}{length}
1213     Set the cube source length along the x-axis.
1214     \end{methoddesc}
1215    
1216     \begin{methoddesc}[CubeSource]{setYLength}{length}
1217     Set the cube source length along the y-axis.
1218     \end{methoddesc}
1219    
1220     \begin{methoddesc}[CubeSource]{setZLength}{length}
1221     Set the cube source length along the z-axis.
1222     \end{methoddesc}
1223    
1224    
1225 jongui 1084 % #############################################################################
1226 jongui 1035
1227 jongui 1081
1228 jongui 1099 \section{More Examples}
1229     This section shows more examples.
1230 jongui 1082
1231 jongui 1084 \textsf{Reading A Series of Files}
1232 jongui 1081
1233 jongui 1084 \begin{python}
1234 jongui 1210 """
1235     Author: John Ngui, john.ngui@uq.edu.au
1236     """
1237    
1238 jongui 1084 # Import the necessary modules.
1239     from esys.pyvisi import Scene, DataCollector, Contour, Camera
1240     from esys.pyvisi.constant import *
1241 jongui 1154 import os
1242 jongui 1081
1243 jongui 1154 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
1244     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
1245 jongui 1084 X_SIZE = 400
1246     Y_SIZE = 300
1247 gross 999
1248 jongui 1084 SCALAR_FIELD_POINT_DATA_1 = "lava"
1249     SCALAR_FIELD_POINT_DATA_2 = "talus"
1250     FILE_2D = "phi_talus_lava."
1251    
1252     IMAGE_NAME = "seriesofreads"
1253     JPG_RENDERER = Renderer.ONLINE_JPG
1254    
1255     # Create a Scene.
1256     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
1257     y_size = Y_SIZE)
1258    
1259 jongui 1194 # Create a DataCollector reading from a XML file.
1260 jongui 1084 dc1 = DataCollector(source = Source.XML)
1261     dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_1)
1262    
1263     # Create a Contour.
1264     mosc1 = Contour(scene = s, data_collector = dc1,
1265     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
1266     outline = True)
1267     mosc1.generateContours(0)
1268    
1269 jongui 1210 # Create a second DataCollector reading from the same XML file
1270     # but specifying a different scalar field.
1271 jongui 1084 dc2 = DataCollector(source = Source.XML)
1272     dc2.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_2)
1273    
1274     # Create a second Contour.
1275     mosc2 = Contour(scene = s, data_collector = dc2,
1276     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
1277     outline = True)
1278     mosc2.generateContours(0)
1279    
1280 jongui 1143 # Create a Camera.
1281     cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
1282    
1283 jongui 1154 # Read in one file one after another and render the object.
1284 jongui 1084 for i in range(99, 104):
1285 jongui 1154 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
1286     FILE_2D + "%04d.vtu") % i)
1287     dc2.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
1288     FILE_2D + "%04d.vtu") % i)
1289 jongui 1084
1290 jongui 1154 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
1291     IMAGE_NAME + "%04d.jpg") % i)
1292 jongui 1084 \end{python}
1293    
1294     \textsf{Manipulating A Single File with A Series of Translation}
1295    
1296     \begin{python}
1297 jongui 1210 """
1298     Author: John Ngui, john.ngui@uq.edu.au
1299     """
1300 jongui 1084
1301 jongui 1210 # Import the necessary modules.
1302     from esys.pyvisi import Scene, DataCollector, MapOnPlaneCut, Camera
1303     from esys.pyvisi.constant import *
1304     import os
1305    
1306     PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
1307     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
1308     X_SIZE = 400
1309     Y_SIZE = 400
1310    
1311     SCALAR_FIELD_POINT_DATA = "temperature"
1312     FILE_3D = "interior_3D.xml"
1313     IMAGE_NAME = "seriesofcuts"
1314     JPG_RENDERER = Renderer.ONLINE_JPG
1315    
1316     # Create a Scene.
1317     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
1318     y_size = Y_SIZE)
1319    
1320     # Create a DataCollector reading from a XML file.
1321     dc1 = DataCollector(source = Source.XML)
1322     dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
1323     dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
1324    
1325     # Create a MapOnPlaneCut.
1326     mopc1 = MapOnPlaneCut(scene = s, data_collector = dc1,
1327     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
1328     outline = True)
1329     mopc1.setPlaneToYZ(offset = 0.1)
1330    
1331     # Create a Camera.
1332     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
1333     c1.isometricView()
1334    
1335     # Render the object with multiple cuts using a series of translation.
1336     for i in range(0, 5):
1337     s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME +
1338     "%02d.jpg") % i)
1339     mopc1.translate(0.6,0,0)
1340 jongui 1084 \end{python}
1341    
1342 jongui 1167 \textsf{Reading Data Directly from Escript Objects}
1343    
1344     \begin{python}
1345 jongui 1210 """
1346     Author: Lutz Gross, l.gross@uq.edu.au
1347     Author: John Ngui, john.ngui@uq.edu.au
1348     """
1349    
1350 jongui 1167 # Import the necessary modules.
1351     from esys.escript import *
1352     from esys.escript.linearPDEs import LinearPDE
1353     from esys.finley import Rectangle
1354     from esys.pyvisi import Scene, DataCollector, Map, Camera
1355     from esys.pyvisi.constant import *
1356     import os
1357    
1358     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
1359     X_SIZE = 400
1360     Y_SIZE = 400
1361     JPG_RENDERER = Renderer.ONLINE_JPG
1362    
1363 jongui 1194 #... set some parameters ...
1364 jongui 1167 xc=[0.02,0.002]
1365     r=0.001
1366     qc=50.e6
1367     Tref=0.
1368     rhocp=2.6e6
1369     eta=75.
1370     kappa=240.
1371     tend=5.
1372 jongui 1194 # ... time, time step size and counter ...
1373 jongui 1167 t=0
1374     h=0.1
1375     i=0
1376    
1377 jongui 1194 #... generate domain ...
1378 jongui 1167 mydomain = Rectangle(l0=0.05,l1=0.01,n0=250, n1=50)
1379     #... open PDE ...
1380     mypde=LinearPDE(mydomain)
1381     mypde.setSymmetryOn()
1382     mypde.setValue(A=kappa*kronecker(mydomain),D=rhocp/h,d=eta,y=eta*Tref)
1383 jongui 1194 # ... set heat source: ....
1384 jongui 1167 x=mydomain.getX()
1385     qH=qc*whereNegative(length(x-xc)-r)
1386     # ... set initial temperature ....
1387     T=Tref
1388    
1389     # Create a Scene.
1390     s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
1391    
1392     # Create a DataCollector reading directly from escript objects.
1393     dc = DataCollector(source = Source.ESCRIPT)
1394    
1395     # Create a Map.
1396     m = Map(scene = s, data_collector = dc, \
1397     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, \
1398     cell_to_point = False, outline = True)
1399    
1400     # Create a Camera.
1401     c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
1402    
1403 jongui 1194 # ... start iteration:
1404     while t<0.4:
1405 jongui 1167 i+=1
1406     t+=h
1407     mypde.setValue(Y=qH+rhocp/h*T)
1408     T=mypde.getSolution()
1409    
1410     dc.setData(temp = T)
1411    
1412     # Render the object.
1413     s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
1414     "diffusion%02d.jpg") % i)
1415     \end{python}
1416    
1417     \newpage
1418    
1419 jongui 1091 \section{Useful Keys}
1420     This section shows some of the useful keys when interacting with the rendered
1421 jongui 1199 object (in the Online approach).
1422 jongui 1091
1423 jongui 1167 \begin{table}[ht]
1424 jongui 1091 \begin{center}
1425     \begin{tabular}{| c | p{13cm} |}
1426     \hline
1427     \textbf{Key} & \textbf{Description} \\ \hline
1428     Keypress 'c' / 'a' & Toggle between the camera ('c') and object ('a') mode. In
1429     camera mode, mouse events affect the camera position and focal point. In
1430     object mode, mouse events affect the rendered object's element (i.e.
1431     cut surface map, clipped velocity field, streamline, etc) that is under the
1432     mouse pointer.\\ \hline
1433     Mouse button 1 & Rotate the camera around its focal point (if in camera mode)
1434     or rotate the rendered object's element (if in object mode).\\ \hline
1435     Mourse button 2 & Pan the camera (if in camera mode) or translate the rendered
1436     object's element (if in object mode). \\ \hline
1437     Mouse button 3 & Zoom the camera (if in camera mode) or scale the rendered
1438     object's element (if in object mode). \\ \hline
1439     Keypress 3 & Toggle the render window in and out of stereo mode. By default,
1440     red-blue stereo pairs are created. \\ \hline
1441 jongui 1154 Keypress 'e' / 'q' & Exit the application if only one file is to be read, or
1442 jongui 1091 read and display the next file if multiple files are to be read. \\ \hline
1443     Keypress 's' & Modify the representation of the rendered object to surfaces.
1444     \\ \hline
1445     Keypress 'w' & Modify the representation of the rendered object to wireframe.
1446     \\ \hline
1447 jongui 1205 Keypress 'r' & Reset the position of the rendered object to the center.
1448     \\ \hline
1449 jongui 1091 \end{tabular}
1450 jongui 1167 \caption{Useful keys}
1451 jongui 1091 \end{center}
1452     \end{table}
1453    
1454    
1455     % ############################################################################
1456    
1457    
1458 jongui 1167 \newpage
1459    
1460 jongui 1091 \section{Sample Output}
1461 jongui 1206 This section displays some of the sample output by Pyvisi.
1462 jongui 1091
1463 jongui 1167 \begin{table}[ht]
1464 jongui 1091 \begin{tabular}{c c c}
1465     \includegraphics[width=\thumbnailwidth]{figures/Map} &
1466     \includegraphics[width=\thumbnailwidth]{figures/MapOnPlaneCut} &
1467     \includegraphics[width=\thumbnailwidth]{figures/MapOnPlaneClip} \\
1468     Map & MapOnPlaneCut & MapOnPlaneClip \\
1469     \includegraphics[width=\thumbnailwidth]{figures/MapOnScalarClip} &
1470     \includegraphics[width=\thumbnailwidth]{figures/Velocity} &
1471     \includegraphics[width=\thumbnailwidth]{figures/VelocityOnPlaneCut} \\
1472     MapOnScalarClip & Velocity & VelocityOnPlaneCut \\
1473     \includegraphics[width=\thumbnailwidth]{figures/VelocityOnPlaneClip} &
1474     \includegraphics[width=\thumbnailwidth]{figures/Ellipsoid} &
1475     \includegraphics[width=\thumbnailwidth]{figures/EllipsoidOnPlaneCut} \\
1476     VelocityOnPlaneClip & Ellipsoid & EllipsoidOnPlaneCut \\
1477     \includegraphics[width=\thumbnailwidth]{figures/EllipsoidOnPlaneClip} &
1478     \includegraphics[width=\thumbnailwidth]{figures/Contour} &
1479     \includegraphics[width=\thumbnailwidth]{figures/ContourOnPlaneCut} \\
1480     EllipsoidOnPlaneClip & Contour & ContourOnPlaneCut \\
1481 jongui 1206 \end{tabular}
1482     \caption{Sample output}
1483     \end{table}
1484    
1485     \begin{table}[t]
1486     \begin{tabular}{c c c}
1487 jongui 1091 \includegraphics[width=\thumbnailwidth]{figures/ContourOnPlaneClip} &
1488     \includegraphics[width=\thumbnailwidth]{figures/StreamLine} &
1489     \includegraphics[width=\thumbnailwidth]{figures/Carpet} \\
1490     ContourOnPlaneClip & StreamLine & Carpet \\
1491 jongui 1206 \includegraphics[width=\thumbnailwidth]{figures/Rectangle} &
1492     \includegraphics[width=\thumbnailwidth]{figures/Text} &
1493     \includegraphics[width=\thumbnailwidth]{figures/Logo} \\
1494     Rectangle & Text & Logo \\
1495     \includegraphics[width=\thumbnailwidth]{figures/Image} &
1496     \includegraphics[width=\thumbnailwidth]{figures/Legend} \\
1497     Image & Legend \\
1498 jongui 1091 \end{tabular}
1499 jongui 1206 \caption{Sample Output}
1500 jongui 1091 \end{table}
1501    
1502    

  ViewVC Help
Powered by ViewVC 1.1.26