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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26