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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 3 months ago) by ksteube
File MIME type: application/x-tex
File size: 51082 byte(s)
Copyright updated in all files

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

  ViewVC Help
Powered by ViewVC 1.1.26