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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1210 - (show 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 \chapter{The module \pyvisi}
2 \label{PYVISI CHAP}
3 \declaremodule{extension}{esys.pyvisi}
4 \modulesynopsis{Python Visualization Interface}
5
6 \section{Introduction}
7 \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 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 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 on-screen but with no interaction capability (on-the-fly
17 animation). All three approaches have the option to save the rendered object
18 as an image (i.e. jpg).
19
20 The following outlines the general steps to use Pyvisi:
21
22 \begin{enumerate}
23 \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 reads and loads the source data for visualization.
27 \item Create a data visualization instance (i.e. \Map, \Velocity, \Ellipsoid,
28 \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 lighting effects.
32 \item Render the object - using either the Online, Offline or Display approach.
33 \end{enumerate}
34 \begin{center}
35 \begin{math}
36 scene \rightarrow data \; input \rightarrow data \; visualization \rightarrow
37 camera \, / \, light \rightarrow render
38 \end{math}
39 \end{center}
40
41 \section{\pyvisi Classes}
42 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 \subsection{Scene Classes}
51 This subsection details the instances used to setup the viewing environment.
52
53 \subsubsection{\Scene class}
54
55 \begin{classdesc}{Scene}{renderer = Renderer.ONLINE, num_viewport = 1,
56 x_size = 1152, y_size = 864}
57 A scene is a window in which objects are to be rendered on. Only
58 one scene needs to be created. However, a scene may be divided into four
59 smaller windows called viewports (if needed). Each viewport in turn can
60 render a different object.
61 \end{classdesc}
62
63 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 \begin{methoddesc}[Scene]{render}{image_name = None}
69 Render the object using either the Online, Offline or Display mode.
70 \end{methoddesc}
71
72 \subsubsection{\Camera class}
73
74 \begin{classdesc}{Camera}{scene, viewport = Viewport.SOUTH_WEST}
75 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 \end{classdesc}
79
80 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 \begin{methoddesc}[Camera]{rightView}{}
114 Rotate the camera to view the right side of the rendered object.
115 \end{methoddesc}
116
117 \begin{methoddesc}[Camera]{isometricView}{}
118 Rotate the camera to view the isometric angle of the rendered object.
119 \end{methoddesc}
120
121 \begin{methoddesc}[Camera]{dolly}{distance}
122 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 \end{methoddesc}
125
126 \subsubsection{\Light class}
127
128 \begin{classdesc}{Light}{scene, viewport = Viewport.SOUTH_WEST}
129 A light controls the lighting effect for the rendered object and works in
130 a similar way to \Camera.
131 \end{classdesc}
132
133 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 Set the position of the light.
144 \end{methoddesc}
145
146 \begin{methoddesc}[Light]{setAngle}{elevation = 0, azimuth = 0}
147 An alternative to set the position and focal point of the light by using the
148 elevation and azimuth.
149 \end{methoddesc}
150
151
152 %##############################################################################
153
154
155 \subsection{Input Classes}
156 \label{INPUT SEC}
157 This subsection details the instances used to read and load the source data
158 for visualization.
159
160 \subsubsection{\DataCollector class}
161 \begin{classdesc}{DataCollector}{source = Source.XML}
162 A data collector is used to read data either from a XML file (using
163 \texttt{setFileName()}) or from an escript object directly (using
164 \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 \end{classdesc}
168
169 The following are some of the methods available:
170 \begin{methoddesc}[DataCollector]{setFileName}{file_name}
171 Set the XML file name to read.
172 \end{methoddesc}
173
174 \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
180 \begin{methoddesc}[DataCollector]{setActiveScalar}{scalar}
181 Specify the scalar field to load.
182 \end{methoddesc}
183
184 \begin{methoddesc}[DataCollector]{setActiveVector}{vector}
185 Specify the vector field to load.
186 \end{methoddesc}
187
188 \begin{methoddesc}[DataCollector]{setActiveTensor}{tensor}
189 Specify the tensor field to load.
190 \end{methoddesc}
191
192 \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 \end{classdesc}
197
198 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 A two-dimensional text is used to annotate the rendered object
207 (i.e. inserting titles, authors and labels).
208 \end{classdesc}
209
210 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 \label{DATAVIS SEC}
231 This subsection details the instances used to process and manipulate the source
232 data. The typical usage of some of the classes are also shown.
233
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 If a conversion is needed, the 'cell_to_point' flag (see below) must
238 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
241 \subsubsection{\Map class}
242
243 \begin{classdesc}{Map}{scene, data_collector,
244 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
245 outline = True}
246 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 \end{classdesc}
249
250 The following are some of the methods available:\\
251 Methods from \ActorThreeD and \DataSetMapper.
252
253 A typical usage of \Map is shown below.
254
255 \begin{python}
256 """
257 Author: John Ngui, john.ngui@uq.edu.au
258 """
259
260 # Import the necessary modules.
261 from esys.pyvisi import Scene, DataCollector, Map, Camera
262 from esys.pyvisi.constant import *
263 import os
264
265 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
266 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
267 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 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
283 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 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
292 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 dc2.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
298 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 # Create a Camera for the third viewport
305 c2 = Camera(scene = s, viewport = Viewport.NORTH_EAST)
306
307 # Render the object.
308 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
309 \end{python}
310
311 \subsubsection{\MapOnPlaneCut class}
312
313 \begin{classdesc}{MapOnPlaneCut}{scene, data_collector,
314 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
315 outline = True}
316 This class works in a similar way to \Map, except that it shows a scalar
317 field cut using a plane. The plane can be translated and rotated along the
318 X, Y and Z axes.
319 \end{classdesc}
320
321 The following are some of the methods available:\\
322 Methods from \ActorThreeD, \Transform and \DataSetMapper.
323
324 \subsubsection{\MapOnPlaneClip class}
325
326 \begin{classdesc}{MapOnPlaneClip}{scene, data_collector,
327 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
328 outline = True}
329 This class works in a similar way to \MapOnPlaneCut, except that it shows a
330 scalar field clipped using a plane.
331 \end{classdesc}
332
333 The following are some of the methods available:\\
334 Methods from \ActorThreeD, \Transform, \Clipper and \DataSetMapper.
335
336 \subsubsection{\MapOnScalarClip class}
337
338 \begin{classdesc}{MapOnScalarClip}{scene, data_collector,
339 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
340 outline = True}
341 This class works in a similar way to \Map, except that it shows a scalar
342 field clipped using a scalar value.
343 \end{classdesc}
344
345 The following are some of the methods available:\\
346 Methods from \ActorThreeD, \Clipper and \DataSetMapper.
347
348 \subsubsection{\Velocity class}
349
350 \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 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 \end{classdesc}
359
360 The following are some of the methods available:\\
361 Methods from \ActorThreeD, \GlyphThreeD, \MaskPoints and \DataSetMapper.
362
363 \subsubsection{\VelocityOnPlaneCut class}
364
365 \begin{classdesc}{VelocityOnPlaneCut}{scene, data_collector,
366 arrow = Arrow.TWO_D, color_mode = ColorMode.VECTOR,
367 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
368 cell_to_point = False, outline = True}
369 This class works in a similar way to \MapOnPlaneCut, except that
370 it shows a vector field using arrows cut using a plane.
371 \end{classdesc}
372
373 The following are some of the methods available:\\
374 Methods from \ActorThreeD, \GlyphThreeD, \Transform, \MaskPoints and
375 \DataSetMapper.
376
377 A typical usage of \VelocityOnPlaneCut is shown below.
378
379 \begin{python}
380 """
381 Author: John Ngui, john.ngui@uq.edu.au
382 """
383
384 # Import the necessary modules
385 from esys.pyvisi import Scene, DataCollector, VelocityOnPlaneCut, Camera
386 from esys.pyvisi.constant import *
387 import os
388
389 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
390 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
391 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 # Create a Scene.
400 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 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
406 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 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
420 c1.isometricView()
421 c1.elevation(angle = -20)
422
423 # Render the object.
424 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
425 \end{python}
426
427 \subsubsection{\VelocityOnPlaneClip class}
428
429 \begin{classdesc}{VelocityOnPlaneClip}{scene, data_collector,
430 arrow = Arrow.TWO_D, color_mode = ColorMode.VECTOR,
431 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
432 cell_to_point = False, online = True}
433 This class works in a similar way to \MapOnPlaneClip, except that it shows a
434 vector field using arrows clipped using a plane.
435 \end{classdesc}
436
437 The following are some of the methods available:\\
438 Methods from \ActorThreeD, \GlyphThreeD, \Transform, \Clipper,
439 \MaskPoints and \DataSetMapper.
440
441 \subsubsection{\Ellipsoid class}
442
443 \begin{classdesc}{Ellipsoid}{scene, data_collector,
444 viewport = Viewport = SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
445 outline = True}
446 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 \end{classdesc}
449
450 The following are some of the methods available:\\
451 Methods from \ActorThreeD, \Sphere, \TensorGlyph, \MaskPoints and
452 \DataSetMapper.
453
454 \subsubsection{\EllipsoidOnPlaneCut class}
455
456 \begin{classdesc}{EllipsoidOnPlaneCut}{scene, data_collector,
457 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
458 outline = True}
459 This class works in a similar way to \MapOnPlaneCut, except that it shows
460 a tensor field using ellipsoids cut using a plane.
461 \end{classdesc}
462
463 The following are some of the methods available:\\
464 Methods from \ActorThreeD, \Sphere, \TensorGlyph, \Transform,
465 \MaskPoints and \DataSetMapper.
466
467 \subsubsection{\EllipsoidOnPlaneClip class}
468
469 \begin{classdesc}{EllipsoidOnPlaneClip}{scene, data_collector,
470 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
471 outline = True}
472 This class works in a similar way to \MapOnPlaneClip, except that it shows a
473 tensor field using ellipsoids clipped using a plane.
474 \end{classdesc}
475
476 The following are some of the methods available:\\
477 Methods from \ActorThreeD, \Sphere, \TensorGlyph, \Transform, \Clipper,
478 \MaskPoints and \DataSetMapper.
479
480 A typical usage of \EllipsoidOnPlaneClip is shown below.
481
482 \begin{python}
483 """
484 Author: John Ngui, john.ngui@uq.edu.au
485 """
486
487 # Import the necessary modules
488 from esys.pyvisi import Scene, DataCollector, EllipsoidOnPlaneClip, Camera
489 from esys.pyvisi.constant import *
490 import os
491
492 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
493 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
494 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 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
509 dc1.setActiveTensor(tensor = TENSOR_FIELD_CELL_DATA)
510
511 # Create an EllipsoidOnPlaneClip.
512 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 # Create a Camera.
520 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
521 c1.bottomView()
522 c1.azimuth(angle = -90)
523 c1.elevation(angle = 10)
524
525 # Render the object.
526 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
527 \end{python}
528
529 \subsubsection{\Contour class}
530
531 \begin{classdesc}{Contour}{scene, data_collector,
532 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
533 outline = True}
534 Class that shows a scalar field using contour surfaces. The contour surfaces can
535 either be colored or grey-scaled, depending on the lookup table used. This
536 class can also be used to generate iso surfaces.
537 \end{classdesc}
538
539 The following are some of the methods available:\\
540 Methods from \ActorThreeD, \ContourModule and \DataSetMapper.
541
542 A typical usage of \Contour is shown below.
543
544 \begin{python}
545 """
546 Author: John Ngui, john.ngui@uq.edu.au
547 """
548
549 # Import the necessary modules
550 from esys.pyvisi import Scene, DataCollector, Contour, Camera
551 from esys.pyvisi.constant import *
552 import os
553
554 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
555 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
556 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 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
571 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 cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
580 cam1.elevation(angle = -40)
581
582 # Render the object.
583 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
584 \end{python}
585
586 \subsubsection{\ContourOnPlaneCut class}
587
588 \begin{classdesc}{ContourOnPlaneCut}{scene, data_collector,
589 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
590 outline = True}
591 This class works in a similar way to \MapOnPlaneCut, except that it shows a
592 scalar field using contour surfaces cut using a plane.
593 \end{classdesc}
594
595 The following are some of the methods available:\\
596 Methods from \ActorThreeD, \ContourModule, \Transform and \DataSetMapper.
597
598 \subsubsection{\ContourOnPlaneClip class}
599
600 \begin{classdesc}{ContourOnPlaneClip}{scene, data_collector,
601 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
602 outline = True}
603 This class works in a similar way to \MapOnPlaneClip, except that it shows a
604 scalar field using contour surfaces clipped using a plane.
605 \end{classdesc}
606
607 The following are some of the methods available:\\
608 Methods from \ActorThreeD, \ContourModule, \Transform, \Clipper and
609 \DataSetMapper.
610
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 cell_to_point = False, outline = True}
616 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 \end{classdesc}
621
622 The following are some of the methods available:\\
623 Methods from \ActorThreeD, \PointSource, \StreamLineModule, \Tube and
624 \DataSetMapper.
625
626 A typical usage of \StreamLine is shown below.
627
628 \begin{python}
629 """
630 Author: John Ngui, john.ngui@uq.edu.au
631 """
632
633 # Import the necessary modules.
634 from esys.pyvisi import Scene, DataCollector, StreamLine, Camera
635 from esys.pyvisi.constant import *
636 import os
637
638 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
639 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
640 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 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
655
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 sl1.setTubeNumberOfSides(3)
662 sl1.setTubeRadiusToVaryByVector()
663 sl1.setPointSourceRadius(0.9)
664
665 # Create a Camera.
666 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
667 c1.isometricView()
668
669 # Render the object.
670 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
671 \end{python}
672
673 \subsubsection{\Carpet class}
674
675 \begin{classdesc}{Carpet}{scene, data_collector,
676 viewport = Viewport.Viewport.SOUTH_WEST, warp_mode = WarpMode.SCALAR,
677 lut = Lut.COLOR, cell_to_point = False, outline = True}
678 This class works in a similar way to \MapOnPlaneCut, except that it shows a
679 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 Similarly, the plane can be deformated either using scalar data or vector data.
682 \end{classdesc}
683
684 The following are some of the methods available:\\
685 Methods from \ActorThreeD, \Warp, \Transform and \DataSetMapper.
686
687 A typical usage of \Carpet is shown below.
688
689 \begin{python}
690 """
691 Author: John Ngui, john.ngui@uq.edu.au
692 """
693
694 # Import the necessary modules.
695 from esys.pyvisi import Scene, DataCollector, Carpet, Camera
696 from esys.pyvisi.constant import *
697 import os
698
699 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
700 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
701 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 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
716 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 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
727 c1.isometricView()
728
729 # Render the object.
730 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
731 \end{python}
732
733 \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 \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 \subsubsection{\Image class}
754
755 \begin{classdesc}{Image}{scene, image_reader, viewport = Viewport.SOUTH_WEST}
756 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 \end{classdesc}
761
762 The following are some of the methods available:\\
763 Methods from \ActorThreeD, \PlaneSource and \Transform.
764
765 A typical usage of \Image is shown below.
766
767 \begin{python}
768 """
769 Author: John Ngui, john.ngui@uq.edu.au
770 """
771
772 # Import the necessary modules.
773 from esys.pyvisi import Scene, DataCollector, Map, ImageReader, Image, Camera
774 from esys.pyvisi import GlobalPosition
775 from esys.pyvisi.constant import *
776 import os
777
778 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
779 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
780 X_SIZE = 400
781 Y_SIZE = 400
782
783 SCALAR_FIELD_POINT_DATA = "temperature"
784 FILE_3D = "interior_3D.xml"
785 LOAD_IMAGE_NAME = "flinders.jpg"
786 SAVE_IMAGE_NAME = "image.jpg"
787 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 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
796
797 # Create a Map.
798 m1 = Map(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
799 lut = Lut.COLOR, cell_to_point = False, outline = True)
800 m1.setOpacity(0.3)
801
802 # 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
807 # 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 \end{python}
820
821 \subsubsection{\Logo class}
822
823 \begin{classdesc}{Logo}{scene, image_reader, viewport = Viewport.SOUTH_WEST}
824 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 \end{classdesc}
828
829 The following are some of the methods available:\\
830 Methods from \ImageReslice and \ActorTwoD.
831
832 \subsubsection{\Movie class}
833
834 \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 \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 Generate the movie.
851 \end{methoddesc}
852
853 A typical usage of \Movie is shown below.
854
855 \begin{python}
856 """
857 Author: John Ngui, john.ngui@uq.edu.au
858 """
859
860 # 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 #lst = []
895
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 #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 first_image = IMAGE_NAME + "000938.jpg",
909 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 \end{python}
917
918
919 %##############################################################################
920
921
922 \subsection{Coordinate Classes}
923 This subsection details the instances used to position the rendered object.
924
925 \subsubsection{\LocalPosition class}
926
927 \begin{classdesc}{LocalPosition}{x_coor, y_coor}
928 Class that defines the local positioning (X and Y) coordinate system (2D).
929 \end{classdesc}
930
931 \subsubsection{\GlobalPosition class}
932
933 \begin{classdesc}{GlobalPosition}{x_coor, y_coor, z_coor}
934 Class that defines the global positioning (X, Y and Z) coordinate system (3D).
935 \end{classdesc}
936
937
938 %##############################################################################
939
940
941 \subsection{Supporting Classes}
942 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
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 Set the scalar clip value (instead of using a plane) for the clipper.
985 \end{methoddesc}
986
987 \subsubsection{\ContourModule class}
988
989 The following are some of the methods available:
990
991 \begin{methoddesc}[ContourModule]{generateContours}{contours = None,
992 lower_range = None, upper_range = None}
993 Generate the specified number of contours within the specified range.
994 In order to generate an iso surface, the 'lower_range' and 'upper_range'
995 must be equal.
996 \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 \begin{methoddesc}[TensorGlyph]{setMaxScaleFactor}{max_scale_factor}
1023 Set the maximum allowable scale factor for the tensor glyph.
1024 \end{methoddesc}
1025
1026 \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 \begin{methoddesc}[PointSource]{setPointSourceCenter}{center}
1047 Set the center of the sphere.
1048 \end{methoddesc}
1049
1050 \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 Set the phi resolution of the sphere.
1065 \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 The following are some of the methods available:
1083
1084 \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 The following are some of the methods available:
1115
1116 \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 The following are some of the methods available:
1131
1132 \begin{methoddesc}[Warp]{setScaleFactor}{scale_factor}
1133 Set the displacement scale factor.
1134 \end{methoddesc}
1135
1136 \subsubsection{\MaskPoints class}
1137
1138 The following are some of the methods available:
1139
1140 \begin{methoddesc}[MaskPoints]{setRatio}{ratio}
1141 Mask every n'th point.
1142 \end{methoddesc}
1143
1144 \begin{methoddesc}[MaskPoints]{randomOn}{}
1145 Enables the randomization of the points selected for masking.
1146 \end{methoddesc}
1147
1148
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 \subsubsection{\ImageReslice class}
1186
1187 The following are some of the methods available:
1188
1189 \begin{methoddesc}[ImageReslice]{setSize}{size}
1190 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 \end{methoddesc}
1193
1194 \subsubsection{\DataSetMapper class}
1195
1196 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 \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 % #############################################################################
1226
1227
1228 \section{More Examples}
1229 This section shows more examples.
1230
1231 \textsf{Reading A Series of Files}
1232
1233 \begin{python}
1234 """
1235 Author: John Ngui, john.ngui@uq.edu.au
1236 """
1237
1238 # Import the necessary modules.
1239 from esys.pyvisi import Scene, DataCollector, Contour, Camera
1240 from esys.pyvisi.constant import *
1241 import os
1242
1243 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
1244 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
1245 X_SIZE = 400
1246 Y_SIZE = 300
1247
1248 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 # Create a DataCollector reading from a XML file.
1260 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 # Create a second DataCollector reading from the same XML file
1270 # but specifying a different scalar field.
1271 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 # Create a Camera.
1281 cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
1282
1283 # Read in one file one after another and render the object.
1284 for i in range(99, 104):
1285 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
1290 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
1291 IMAGE_NAME + "%04d.jpg") % i)
1292 \end{python}
1293
1294 \textsf{Manipulating A Single File with A Series of Translation}
1295
1296 \begin{python}
1297 """
1298 Author: John Ngui, john.ngui@uq.edu.au
1299 """
1300
1301 # 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 \end{python}
1341
1342 \textsf{Reading Data Directly from Escript Objects}
1343
1344 \begin{python}
1345 """
1346 Author: Lutz Gross, l.gross@uq.edu.au
1347 Author: John Ngui, john.ngui@uq.edu.au
1348 """
1349
1350 # 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 #... set some parameters ...
1364 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 # ... time, time step size and counter ...
1373 t=0
1374 h=0.1
1375 i=0
1376
1377 #... generate domain ...
1378 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 # ... set heat source: ....
1384 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 # ... start iteration:
1404 while t<0.4:
1405 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 \section{Useful Keys}
1420 This section shows some of the useful keys when interacting with the rendered
1421 object (in the Online approach).
1422
1423 \begin{table}[ht]
1424 \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 Keypress 'e' / 'q' & Exit the application if only one file is to be read, or
1442 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 Keypress 'r' & Reset the position of the rendered object to the center.
1448 \\ \hline
1449 \end{tabular}
1450 \caption{Useful keys}
1451 \end{center}
1452 \end{table}
1453
1454
1455 % ############################################################################
1456
1457
1458 \newpage
1459
1460 \section{Sample Output}
1461 This section displays some of the sample output by Pyvisi.
1462
1463 \begin{table}[ht]
1464 \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 \end{tabular}
1482 \caption{Sample output}
1483 \end{table}
1484
1485 \begin{table}[t]
1486 \begin{tabular}{c c c}
1487 \includegraphics[width=\thumbnailwidth]{figures/ContourOnPlaneClip} &
1488 \includegraphics[width=\thumbnailwidth]{figures/StreamLine} &
1489 \includegraphics[width=\thumbnailwidth]{figures/Carpet} \\
1490 ContourOnPlaneClip & StreamLine & Carpet \\
1491 \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 \end{tabular}
1499 \caption{Sample Output}
1500 \end{table}
1501
1502

  ViewVC Help
Powered by ViewVC 1.1.26