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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1963 by ksteube, Thu Sep 25 23:11:13 2008 UTC revision 1964 by caltinay, Wed Nov 5 03:21:31 2008 UTC
# Line 18  Line 18 
18  \modulesynopsis{Python Visualization Interface}  \modulesynopsis{Python Visualization Interface}
19    
20  \section{Introduction}  \section{Introduction}
21  \pyvisi is a Python module that is used to generate 2D and 3D visualization  \pyvisi is a Python module that is used to generate 2D and 3D visualizations
22  for escript and its PDE solvers: finley and bruce. This module provides  for escript and its PDE solvers finley and bruce. The module provides
23  an easy to use interface to the \VTK library (\VTKUrl). Pyvisi can be used to  an easy to use interface to the \VTK library (\VTKUrl) to render (generate)
24  render (generate) surface maps and contours for scalar fields, arrows and  surface maps and contours for scalar fields, arrows and streamlines for vector
25  streamlines for vector fields, and ellipsoids for tensor fields.    fields, and ellipsoids for tensor fields. There are three approaches for
26  There are three  rendering an object. (1) Online - object is rendered on-screen with
27  approaches for rendering an object. (1) Online - object is rendered on-screen  interaction capability (i.e. zoom and rotate), (2) Offline - object is
28  with interaction capability (i.e. zoom and rotate), (2) Offline - object is  rendered off-screen (no pop-up window) and (3) Display - object is rendered
29  rendered off-screen (no pop-up window) and (3) Display - object is rendered  on-screen but with no interaction capability (on-the-fly animation). All three
30  on-screen but with no interaction capability (on-the-fly  approaches have the option to save the rendered object as an image (e.g. jpeg)
31  animation). All three approaches have the option to save the rendered object  and subsequently converting a series of images into a movie (mpeg).
 as an image (i.e. jpg) and subsequently converting a series of images into a  
 movie (.mpg).  
32    
33  The following outlines the general steps to use Pyvisi:  The following outlines the general steps to use Pyvisi:
34    
35  \begin{enumerate}  \begin{enumerate}
36  \item Create a \Scene instance - a window in which objects are to be  \item Create a \Scene instance - a window in which objects will be rendered on.
 rendered on.  
37  \item Create a data input instance (i.e. \DataCollector or \ImageReader) -  \item Create a data input instance (i.e. \DataCollector or \ImageReader) -
38  reads and loads the source data for visualization.  reads the source data for visualization.
39  \item Create a data visualization instance (i.e. \Map, \Velocity, \Ellipsoid,  \item Create a data visualization object (i.e. \Map, \Velocity, \Ellipsoid,
40  \Contour, \Carpet, \StreamLine or \Image) -  processes and manipulates  \Contour, \Carpet, \StreamLine, etc.) - creates a visual representation of
41  the source data.  the source data.
42  \item Create a \Camera or \Light instance - controls the viewing angle and  \item Create a \Camera or \Light instance - controls the viewing angle and
43  lighting effects.  lighting effects.
44  \item Render the object - using either the Online, Offline or Display approach.  \item Render the object - using either the Online, Offline or Display approach.
45  \item Generate movie - converts a series of images into a movie.  \item Generate movie - converts a series of images into a movie. (optional)
46  \end{enumerate}  \end{enumerate}
47  \begin{center}  \begin{center}
48  \begin{math}  \begin{math}
# Line 64  full details. Line 61  full details.
61    
62    
63  \subsection{Scene Classes}  \subsection{Scene Classes}
64  This subsection details the instances used to setup the viewing environment.  This section details the instances used to setup the viewing environment.
65    
66  \subsubsection{\Scene class}  \subsubsection{\Scene class}
67    
# Line 103  Set the position of the camera. Line 100  Set the position of the camera.
100  \end{methoddesc}  \end{methoddesc}
101    
102  \begin{methoddesc}[Camera]{azimuth}{angle}  \begin{methoddesc}[Camera]{azimuth}{angle}
103  Rotate the camera to the left and right.  Rotate the camera to the left and right. The angle parameter is in degrees.
104  \end{methoddesc}  \end{methoddesc}
105    
106  \begin{methoddesc}[Camera]{elevation}{angle}  \begin{methoddesc}[Camera]{elevation}{angle}
107  Rotate the camera to the top and bottom (only between -90 and 90).  Rotate the camera up and down (angle must be between -90 and 90).
108  \end{methoddesc}  \end{methoddesc}
109    
110  \begin{methoddesc}[Camera]{backView}{}  \begin{methoddesc}[Camera]{backView}{}
# Line 131  Rotate the camera to view the right side Line 128  Rotate the camera to view the right side
128  \end{methoddesc}  \end{methoddesc}
129    
130  \begin{methoddesc}[Camera]{isometricView}{}  \begin{methoddesc}[Camera]{isometricView}{}
131  Rotate the camera to view the isometric angle of the rendered object.  Rotate the camera to view an isometric projection of the rendered object.
132  \end{methoddesc}  \end{methoddesc}
133    
134  \begin{methoddesc}[Camera]{dolly}{distance}  \begin{methoddesc}[Camera]{dolly}{distance}
135  Move the camera towards (greater than 1) the rendered object. However,  Move the camera towards (greater than 1) the rendered object. However,
136  the camera is unable to be moved away from the rendered object.  it is not possible to move the camera away from the rendered object with this
137    method.
138  \end{methoddesc}  \end{methoddesc}
139    
140  \subsubsection{\Light class}  \subsubsection{\Light class}
141    
142  \begin{classdesc}{Light}{scene, viewport = Viewport.SOUTH_WEST}  \begin{classdesc}{Light}{scene, viewport = Viewport.SOUTH_WEST}
143  A light controls the lighting effect for the rendered object and works in  A light controls the lighting effect for the rendered object and is set up in
144  a similar way to \Camera.  a similar way to \Camera.
145  \end{classdesc}  \end{classdesc}
146    
# Line 160  Set the position of the light. Line 158  Set the position of the light.
158  \end{methoddesc}  \end{methoddesc}
159    
160  \begin{methoddesc}[Light]{setAngle}{elevation = 0, azimuth = 0}  \begin{methoddesc}[Light]{setAngle}{elevation = 0, azimuth = 0}
161  An alternative to set the position and focal point of the light by using the  An alternative to set the position and focal point of the light by using
162  elevation and azimuth.  elevation and azimuth.
163  \end{methoddesc}  \end{methoddesc}
164    
# Line 175  for visualization. Line 173  for visualization.
173    
174  \subsubsection{\DataCollector class}  \subsubsection{\DataCollector class}
175  \begin{classdesc}{DataCollector}{source = Source.XML}  \begin{classdesc}{DataCollector}{source = Source.XML}
176  A data collector is used to read data either from a XML file (using  A data collector is used to read data either from an XML file (using
177  \texttt{setFileName()}) or from an escript object directly (using  \texttt{setFileName()}) or from an escript object directly (using
178  \texttt{setData()}). Writing XML files are expensive, but this approach has  \texttt{setData()}). Writing XML files is expensive but has the advantage
179  the advantage given that the results can be analyzed easily after the  that the results can be analyzed easily after the simulation has completed.  
 simulation has completed.    
180  \end{classdesc}  \end{classdesc}
181    
182  The following are some of the methods available:  The following are some of the methods available:
# Line 189  Set the XML file name to read. Line 186  Set the XML file name to read.
186    
187  \begin{methoddesc}[DataCollector]{setData}{**args}  \begin{methoddesc}[DataCollector]{setData}{**args}
188  Create data using the \textless name\textgreater=\textless data\textgreater  Create data using the \textless name\textgreater=\textless data\textgreater
189  pairing. Assumption is made that the data will be given in the  pairing. The method assumes that the data is given in the appropriate format.
 appropriate format.  
190  \end{methoddesc}  \end{methoddesc}
191    
192  \begin{methoddesc}[DataCollector]{setActiveScalar}{scalar}  \begin{methoddesc}[DataCollector]{setActiveScalar}{scalar}
# Line 211  Specify the tensor field to load. Line 207  Specify the tensor field to load.
207  An image reader is used to read data from an image in a variety of formats.  An image reader is used to read data from an image in a variety of formats.
208  \end{classdesc}  \end{classdesc}
209    
210  The following are some of the methods available:  The following is one of the methods available:
211  \begin{methoddesc}[ImageReader]{setImageName}{image_name}  \begin{methoddesc}[ImageReader]{setImageName}{image_name}
212  Set the image name to be read.  Set the filename of the image to be loaded.
213  \end{methoddesc}  \end{methoddesc}
214    
215  \subsubsection{\TextTwoD class}  \subsubsection{\TextTwoD class}
216    
217  \begin{classdesc}{Text2D}{scene, text, viewport = Viewport.SOUTH_WEST}  \begin{classdesc}{Text2D}{scene, text, viewport = Viewport.SOUTH_WEST}
218  A two-dimensional text is used to annotate the rendered object  This class is used to insert two-dimensional text for annotations
219  (i.e. inserting titles, authors and labels).  (e.g. titles, authors and labels).
220  \end{classdesc}  \end{classdesc}
221    
222  The following are some of the methods available:  The following are some of the methods available:
# Line 229  Set the 2D text size. Line 225  Set the 2D text size.
225  \end{methoddesc}  \end{methoddesc}
226    
227  \begin{methoddesc}[Text2D]{boldOn}{}  \begin{methoddesc}[Text2D]{boldOn}{}
228  Bold the 2D text.  Use bold font style for the text.
229  \end{methoddesc}  \end{methoddesc}
230    
231  \begin{methoddesc}[Text2D]{setColor}{color}  \begin{methoddesc}[Text2D]{setColor}{color}
# Line 245  Including methods from \ActorTwoD. Line 241  Including methods from \ActorTwoD.
241  \subsection{Data Visualization Classes}  \subsection{Data Visualization Classes}
242  \label{DATAVIS SEC}  \label{DATAVIS SEC}
243  This subsection details the instances used to process and manipulate the source  This subsection details the instances used to process and manipulate the source
244  data. The typical usage of some of the classes are also shown.  data. The typical usage of some of the classes is also shown. See \Sec{SAMPLEOUTPUT SEC} for sample images generated with these classes.
245    
246  One point to note is that the source can either be point or cell data. If the  One point to note is that the source can either be point or cell data. If the
247  source is cell data, a conversion to point data may or may not be  source is cell data, a conversion to point data may or may not be
248  required, in order for the object to be rendered correctly.  required, in order for the object to be rendered correctly.
249  If a conversion is needed, the 'cell_to_point' flag (see below) must  If a conversion is needed, the 'cell_to_point' flag (see below) must
250  be set to 'True', otherwise 'False' (which is the default). On occasions, an  be set to 'True', otherwise to 'False' (which is the default). On occasions, an
251  inaccurate object may be rendered from cell data even after conversion.  inaccurate object may be rendered from cell data even after conversion.
252    
253  \subsubsection{\Map class}  \subsubsection{\Map class}
# Line 329  s.render(image_name = os.path.join(PYVIS Line 325  s.render(image_name = os.path.join(PYVIS
325  \begin{classdesc}{MapOnPlaneCut}{scene, data_collector,  \begin{classdesc}{MapOnPlaneCut}{scene, data_collector,
326  viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,  viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
327  outline = True}  outline = True}
328  This class works in a similar way to \Map, except that it shows a scalar  This class works in a similar way to \Map, except that the result is a slice of
329  field cut using a plane. The plane can be translated and rotated along the  the scalar field produced by cutting the map with a plane. The plane can be
330  X, Y and Z axes.  translated and rotated to its desired position.
331  \end{classdesc}  \end{classdesc}
332    
333  The following are some of the methods available:\\  The following are some of the methods available:\\
# Line 342  Methods from \ActorThreeD, \Transform an Line 338  Methods from \ActorThreeD, \Transform an
338  \begin{classdesc}{MapOnPlaneClip}{scene, data_collector,  \begin{classdesc}{MapOnPlaneClip}{scene, data_collector,
339  viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,  viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
340  outline = True}  outline = True}
341  This class works in a similar way to \MapOnPlaneCut, except that it shows a  This class works in a similar way to \MapOnPlaneCut, except that the defined
342  scalar field clipped using a plane.  plane is used to clip the scalar field.
343  \end{classdesc}  \end{classdesc}
344    
345  The following are some of the methods available:\\  The following are some of the methods available:\\
# Line 354  Methods from \ActorThreeD, \Transform, \ Line 350  Methods from \ActorThreeD, \Transform, \
350  \begin{classdesc}{MapOnScalarClip}{scene, data_collector,  \begin{classdesc}{MapOnScalarClip}{scene, data_collector,
351  viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,  viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
352  outline = True}  outline = True}
353  This class works in a similar way to \Map, except that it shows a scalar  This class works in a similar way to \Map, except that it only shows parts of
354  field clipped using a scalar value.  the scalar field matching a scalar value.
355  \end{classdesc}  \end{classdesc}
356    
357  The following are some of the methods available:\\  The following are some of the methods available:\\
# Line 367  Methods from \ActorThreeD, \Clipper and Line 363  Methods from \ActorThreeD, \Clipper and
363  viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False}  viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False}
364  This class works in a similar way to \Map except that it  This class works in a similar way to \Map except that it
365  shows a 2D scalar field clipped using a scalar value and subsequently  shows a 2D scalar field clipped using a scalar value and subsequently
366  rotated around the z-axis to create a  3D looking effect. This class should  rotated around the z-axis to create a 3D looking effect. This class should
367  only be used with 2D data sets and NOT 3D.  only be used with 2D data sets and NOT 3D.
368  \end{classdesc}  \end{classdesc}
369    
# Line 379  Methods from \ActorThreeD, \Clipper, \Ro Line 375  Methods from \ActorThreeD, \Clipper, \Ro
375  \begin{classdesc}{Velocity}{scene, data_collector, arrow = Arrow.TWO_D,  \begin{classdesc}{Velocity}{scene, data_collector, arrow = Arrow.TWO_D,
376  color_mode = ColorMode.VECTOR, viewport = Viewport.SOUTH_WEST,    color_mode = ColorMode.VECTOR, viewport = Viewport.SOUTH_WEST,  
377  lut = Lut.COLOR, cell_to_point = False, outline = True}  lut = Lut.COLOR, cell_to_point = False, outline = True}
378  Class that shows a vector field using arrows. The arrows can either be  This class is used to display a vector field using arrows. The arrows can
379  color or gray-scale, depending on the lookup table used. If the arrows  either be color or gray-scale, depending on the lookup table used. If the
380  are colored, there are two possible coloring modes, either using vector data or  arrows are colored, there are two possible coloring modes, either using vector
381  scalar data. Similarly, there are two possible types of arrows, either  data or scalar data. Similarly, there are two possible types of arrows, either
382  using two-dimensional or three-dimensional.  two-dimensional or three-dimensional.
383  \end{classdesc}  \end{classdesc}
384    
385  The following are some of the methods available:\\  The following are some of the methods available:\\
# Line 395  Methods from \ActorThreeD, \GlyphThreeD, Line 391  Methods from \ActorThreeD, \GlyphThreeD,
391  arrow = Arrow.TWO_D, color_mode = ColorMode.VECTOR,  arrow = Arrow.TWO_D, color_mode = ColorMode.VECTOR,
392  viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,  viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
393  cell_to_point = False, outline = True}  cell_to_point = False, outline = True}
394  This class works in a similar way to \MapOnPlaneCut, except that  This class works in a similar way to \MapOnPlaneCut, except that it shows a
395  it shows a vector field using arrows cut using a plane.  vector field using arrows cut using a plane.
396  \end{classdesc}  \end{classdesc}
397    
398  The following are some of the methods available:\\  The following are some of the methods available:\\
# Line 560  s.render(image_name = os.path.join(PYVIS Line 556  s.render(image_name = os.path.join(PYVIS
556  \begin{classdesc}{Contour}{scene, data_collector,  \begin{classdesc}{Contour}{scene, data_collector,
557  viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,  viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
558  outline = True}  outline = True}
559  Class that shows a scalar field using contour surfaces. The contour surfaces can  Class that shows a scalar field using contour surfaces. The contour surfaces
560  either be color or gray-scale, depending on the lookup table used. This  can either be color or gray-scale, depending on the lookup table used. This
561  class can also be used to generate iso surfaces.  class can also be used to generate isosurfaces.
562  \end{classdesc}  \end{classdesc}
563    
564  The following are some of the methods available:\\  The following are some of the methods available:\\
# Line 599  dc1 = DataCollector(source = Source.XML) Line 595  dc1 = DataCollector(source = Source.XML)
595  dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))  dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
596  dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)  dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
597    
598  # Create a Contour.  # Create three contours.
599  ctr1 = Contour(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,  ctr1 = Contour(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
600          lut = Lut.COLOR, cell_to_point = False, outline = True)          lut = Lut.COLOR, cell_to_point = False, outline = True)
601  ctr1.generateContours(contours = 3)  ctr1.generateContours(contours = 3)
# Line 682  s = Scene(renderer = JPG_RENDERER, num_v Line 678  s = Scene(renderer = JPG_RENDERER, num_v
678  dc1 = DataCollector(source = Source.XML)  dc1 = DataCollector(source = Source.XML)
679  dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))  dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
680    
681  # Create a Streamline.  # Create streamlines.
682  sl1 = StreamLine(scene = s, data_collector = dc1,  sl1 = StreamLine(scene = s, data_collector = dc1,
683          viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.SCALAR,          viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.SCALAR,
684          lut = Lut.COLOR, cell_to_point = False, outline = True)          lut = Lut.COLOR, cell_to_point = False, outline = True)
# Line 851  s.render(image_name = os.path.join(PYVIS Line 847  s.render(image_name = os.path.join(PYVIS
847    
848  \begin{classdesc}{Logo}{scene, image_reader, viewport = Viewport.SOUTH_WEST}  \begin{classdesc}{Logo}{scene, image_reader, viewport = Viewport.SOUTH_WEST}
849  Class that displays a static image, in particular a logo  Class that displays a static image, in particular a logo
850  (i.e. company symbol) and has NO interaction capability. The position and size  (e.g. company symbol) and has NO interaction capability. The position and size
851  of the logo can be specified.  of the logo can be specified.
852  \end{classdesc}  \end{classdesc}
853    
# Line 861  Methods from \ImageReslice and \ActorTwo Line 857  Methods from \ImageReslice and \ActorTwo
857  \subsubsection{\Movie class}  \subsubsection{\Movie class}
858    
859  \begin{classdesc}{Movie}{parameter_file = "make_movie"}  \begin{classdesc}{Movie}{parameter_file = "make_movie"}
860  Class that creates a file called 'make_movie' by default (if a parameter  This class is used to create movies out of a series of images. The parameter
861  file name is not specified) which contains a list of parameters required  specifies the name of a file that will contain the required information for the
862  by the 'ppmtompeg' command to generate a movie from a series of images.  'ppmtompeg' command which is used to generate the movie.
863  \end{classdesc}  \end{classdesc}
864    
865  The following are some of the methods available:\\  The following are some of the methods available:\\
866  \begin{methoddesc}[Movie]{imageRange}{input_directory, first_image, last_image}  \begin{methoddesc}[Movie]{imageRange}{input_directory, first_image, last_image}
867  The image range from which the movie is to be generated from.  Use this method to specify that the movie is to be generated from image files
868    with filenames in a certain range (e.g. 'image000.jpg' to 'image050.jpg').
869  \end{methoddesc}  \end{methoddesc}
870    
871  \begin{methoddesc}[Movie]{imageList}{input_directory, image_list}  \begin{methoddesc}[Movie]{imageList}{input_directory, image_list}
872  The image list from which the movie is to be generated from.  Use this method to specify a list of arbitrary image filenames from which the
873    movie is to be generated.
874  \end{methoddesc}  \end{methoddesc}
875    
876  \begin{methoddesc}[Movie]{makeMovie}{movie}  \begin{methoddesc}[Movie]{makeMovie}{movie}
877  Generate the movie.  Generate the movie with the specified filename.
878  \end{methoddesc}  \end{methoddesc}
879    
880  A typical usage of \Movie is shown below.  A typical usage of \Movie is shown below.
# Line 900  Y_SIZE = 800 Line 898  Y_SIZE = 800
898  SCALAR_FIELD_POINT_DATA = "temp"  SCALAR_FIELD_POINT_DATA = "temp"
899  FILE_2D = "tempvel-"  FILE_2D = "tempvel-"
900  IMAGE_NAME = "movie"  IMAGE_NAME = "movie"
901  JPG_RENDERER = Renderer.ONLINE_JPG  JPG_RENDERER = Renderer.OFFLINE_JPG
902    
903  # Create a Scene.  # Create a Scene.
904  s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,  s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
# Line 920  cam1 = Camera(scene = s, viewport = View Line 918  cam1 = Camera(scene = s, viewport = View
918    
919  # Create a movie.  # Create a movie.
920  mov = Movie()  mov = Movie()
921  #lst = []  lst = []
922    
923  # Read in one file one after another and render the object.  # Read in one file one after another and render the object.
924  for i in range(938, 949):  for i in range(938, 949):
# Line 928  for i in range(938, 949): Line 926  for i in range(938, 949):
926              FILE_2D + "%06d.vtu") % i)              FILE_2D + "%06d.vtu") % i)
927    
928      s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \      s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
929              IMAGE_NAME + "%06d.jpg") % i)              IMAGE_NAME + "%06d.jpg" % i))
930    
931      #lst.append(IMAGE_NAME + "%06d.jpg" % i)      lst.append(IMAGE_NAME + "%06d.jpg" % i)
932    
933  # Images (first and last inclusive) from which the movie is to be generated.  # Images (first and last inclusive) from which the movie is to be generated.
934  mov.imageRange(input_directory = PYVISI_EXAMPLE_IMAGES_PATH,  mov.imageRange(input_directory = PYVISI_EXAMPLE_IMAGES_PATH,
# Line 949  mov.makeMovie(os.path.join(PYVISI_EXAMPL Line 947  mov.makeMovie(os.path.join(PYVISI_EXAMPL
947    
948    
949  \subsection{Coordinate Classes}  \subsection{Coordinate Classes}
950  This subsection details the instances used to position the rendered object.  This subsection details the instances used to position rendered objects.
951    
952  \subsubsection{\LocalPosition class}  \subsubsection{\LocalPosition class}
953    
954  \begin{classdesc}{LocalPosition}{x_coor, y_coor}  \begin{classdesc}{LocalPosition}{x_coor, y_coor}
955  Class that defines the local positioning (X and Y) coordinate system (2D).  Class that defines a position (X and Y) in the local 2D coordinate system.
956  \end{classdesc}  \end{classdesc}
957    
958  \subsubsection{\GlobalPosition class}  \subsubsection{\GlobalPosition class}
959    
960  \begin{classdesc}{GlobalPosition}{x_coor, y_coor, z_coor}  \begin{classdesc}{GlobalPosition}{x_coor, y_coor, z_coor}
961  Class that defines the global positioning (X, Y and Z) coordinate system (3D).  Class that defines a position (X, Y and Z) in the global 3D coordinate system.
962  \end{classdesc}  \end{classdesc}
963    
964    
# Line 969  Class that defines the global positionin Line 967  Class that defines the global positionin
967    
968  \subsection{Supporting Classes}  \subsection{Supporting Classes}
969  This subsection details the supporting classes and their corresponding methods  This subsection details the supporting classes and their corresponding methods
970  inherited by the input (see Section \ref{INPUT SEC}) and data  inherited by the input (see \Sec{INPUT SEC}) and data
971  visualization classes (see Section \ref{DATAVIS SEC}).  visualization classes (see \Sec{DATAVIS SEC}).
972    
973  \subsubsection{\ActorThreeD class}  \subsubsection{\ActorThreeD class}
974  Class that defines a 3D actor. \\  Class that defines a 3D actor. \\
# Line 1024  The following are some of the methods av Line 1022  The following are some of the methods av
1022  \begin{methoddesc}[ContourModule]{generateContours}{contours = None,  \begin{methoddesc}[ContourModule]{generateContours}{contours = None,
1023  lower_range = None, upper_range = None}  lower_range = None, upper_range = None}
1024  Generate the specified number of contours within the specified range.  Generate the specified number of contours within the specified range.
1025  In order to generate an iso surface, the 'lower_range' and 'upper_range'  In order to generate a single isosurface, the 'lower_range' and 'upper_range'
1026  must be equal.  must be set to the same value.
1027  \end{methoddesc}  \end{methoddesc}
1028    
1029  \subsubsection{\GlyphThreeD class}  \subsubsection{\GlyphThreeD class}
# Line 1059  Set the maximum allowable scale factor f Line 1057  Set the maximum allowable scale factor f
1057  \end{methoddesc}  \end{methoddesc}
1058    
1059  \subsubsection{\PlaneSource class}  \subsubsection{\PlaneSource class}
1060  Class that defines a plane source.  A plane source is defined by an origin  Class that defines a plane source. A plane source is defined by an origin
1061  and two other points, which form the axes (X and Y). \\  and two other points, which form the axes (X and Y). \\
1062    
1063  The following are some of the methods available:  The following are some of the methods available:
1064    
1065    \begin{methoddesc}[PlaneSource]{setOrigin}{position}
1066    Set the origin of the plane source.
1067    \end{methoddesc}
1068    
1069  \begin{methoddesc}[PlaneSource]{setPoint1}{position}  \begin{methoddesc}[PlaneSource]{setPoint1}{position}
1070  Set the first point from the origin of the plane source.  Set the first point from the origin of the plane source.
1071  \end{methoddesc}  \end{methoddesc}
# Line 1128  Translate the rendered object along the Line 1130  Translate the rendered object along the
1130  \end{methoddesc}  \end{methoddesc}
1131    
1132  \begin{methoddesc}[Transform]{rotateX}{angle}  \begin{methoddesc}[Transform]{rotateX}{angle}
1133  Rotate the plane along the x-axis.  Rotate the plane around the x-axis.
1134  \end{methoddesc}  \end{methoddesc}
1135    
1136  \begin{methoddesc}[Transform]{rotateY}{angle}  \begin{methoddesc}[Transform]{rotateY}{angle}
1137  Rotate the plane along the y-axis.  Rotate the plane around the y-axis.
1138  \end{methoddesc}  \end{methoddesc}
1139    
1140  \begin{methoddesc}[Transform]{rotateZ}{angle}  \begin{methoddesc}[Transform]{rotateZ}{angle}
1141  Rotate the plane along the z-axis.  Rotate the plane around the z-axis.
1142  \end{methoddesc}  \end{methoddesc}
1143    
1144  \begin{methoddesc}[Transform]{setPlaneToXY}{offset = 0}  \begin{methoddesc}[Transform]{setPlaneToXY}{offset = 0}
# Line 1178  Set the displacement scale factor. Line 1180  Set the displacement scale factor.
1180  \end{methoddesc}  \end{methoddesc}
1181    
1182  \subsubsection{\MaskPoints class}  \subsubsection{\MaskPoints class}
1183  Class that defines the masking of points  Class that defines masking of points. This is useful to prevent the
1184  every n'th point.  This is useful to prevent the rendered object  rendered object from being cluttered with arrows or ellipsoids. \\
 from being cluttered with arrows or ellipsoids. \\  
1185    
1186  The following are some of the methods available:  The following are some of the methods available:
1187    
# Line 1189  Mask every n'th point. Line 1190  Mask every n'th point.
1190  \end{methoddesc}  \end{methoddesc}
1191    
1192  \begin{methoddesc}[MaskPoints]{randomOn}{}  \begin{methoddesc}[MaskPoints]{randomOn}{}
1193  Enables the randomization of the points selected for masking.  Enables randomization of the points selected for masking.
1194  \end{methoddesc}  \end{methoddesc}
1195    
1196  \subsubsection{\ScalarBar class}  \subsubsection{\ScalarBar class}
# Line 1230  Set the color of the scalar bar's title. Line 1231  Set the color of the scalar bar's title.
1231  \end{methoddesc}  \end{methoddesc}
1232    
1233  \subsubsection{\ImageReslice class}  \subsubsection{\ImageReslice class}
1234  Class that defines an image reslice used to resize static  Class that defines an image reslice which is used to resize static
1235  (no interaction capability) images (i.e. logo). \\  (no interaction capability) images (i.e. logo). \\
1236    
1237  The following are some of the methods available:  The following are some of the methods available:
1238    
1239  \begin{methoddesc}[ImageReslice]{setSize}{size}  \begin{methoddesc}[ImageReslice]{setSize}{size}
1240  Set the size of the image (logo in particular), between 0 and 2. Size 1 (one)  Set the size factor of the image. The value must be between 0 and 2.
1241  displays the image in its original size (which is the default).  Size 1 (one) keeps the image in its original size (which is the default).
1242  \end{methoddesc}  \end{methoddesc}
1243    
1244  \subsubsection{\DataSetMapper class}  \subsubsection{\DataSetMapper class}
# Line 1283  The following are some of the methods av Line 1284  The following are some of the methods av
1284    
1285  \begin{methoddesc}[Rotation]{setResolution}{resolution}  \begin{methoddesc}[Rotation]{setResolution}{resolution}
1286  Set the resolution of the sweep for the rotation, which controls the  Set the resolution of the sweep for the rotation, which controls the
1287  number of intermediate points  number of intermediate points.
1288  \end{methoddesc}  \end{methoddesc}
1289    
1290  \begin{methoddesc}[Rotation]{setAngle}{angle}  \begin{methoddesc}[Rotation]{setAngle}{angle}
# Line 1295  Set the angle of rotation. Line 1296  Set the angle of rotation.
1296    
1297    
1298  \section{More Examples}  \section{More Examples}
1299  This section shows more examples.  This section provides examples for some common tasks.
1300    
1301  \textsf{Reading A Series of Files}  \subsection{Reading a Series of Files}
1302    The following script shows how to generate images from a time series using
1303    two data sources.
1304    
1305  \begin{python}  \begin{python}
1306  """  """
# Line 1325  JPG_RENDERER = Renderer.ONLINE_JPG Line 1328  JPG_RENDERER = Renderer.ONLINE_JPG
1328  s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,  s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
1329          y_size = Y_SIZE)          y_size = Y_SIZE)
1330    
1331  # Create a DataCollector reading from a XML file.  # Create a DataCollector reading from an XML file.
1332  dc1 = DataCollector(source = Source.XML)  dc1 = DataCollector(source = Source.XML)
1333  dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_1)  dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_1)
1334    
# Line 1349  mosc2.generateContours(0) Line 1352  mosc2.generateContours(0)
1352  # Create a Camera.  # Create a Camera.
1353  cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)  cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
1354    
1355  # Read in one file one after another and render the object.  # Read in one file after another and render the object.
1356  for i in range(99, 104):  for i in range(99, 104):
1357      dc1.setFileName(file_name =  os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \      dc1.setFileName(file_name =  os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
1358              FILE_2D + "%04d.vtu") % i)              FILE_2D + "%04d.vtu") % i)
# Line 1360  for i in range(99, 104): Line 1363  for i in range(99, 104):
1363              IMAGE_NAME + "%04d.jpg") % i)              IMAGE_NAME + "%04d.jpg") % i)
1364  \end{python}  \end{python}
1365    
1366  \textsf{Manipulating A Single File with A Series of Translation}  \subsection{Creating Slices of a Data Source}
1367    The following script shows how to save a series of images that slice the
1368    data at different points by gradually translating the cut plane.
1369    
1370  \begin{python}  \begin{python}
1371  """  """
# Line 1386  JPG_RENDERER = Renderer.ONLINE_JPG Line 1391  JPG_RENDERER = Renderer.ONLINE_JPG
1391  s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,  s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
1392          y_size = Y_SIZE)          y_size = Y_SIZE)
1393    
1394  # Create a DataCollector reading from a XML file.  # Create a DataCollector reading from an XML file.
1395  dc1 = DataCollector(source = Source.XML)  dc1 = DataCollector(source = Source.XML)
1396  dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))  dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
1397  dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)  dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
# Line 1401  mopc1.setPlaneToYZ(offset = 0.1) Line 1406  mopc1.setPlaneToYZ(offset = 0.1)
1406  c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)  c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
1407  c1.isometricView()  c1.isometricView()
1408    
1409  # Render the object with multiple cuts using a series of translation.  # Render the object with multiple cuts using a series of translations.
1410  for i in range(0, 5):  for i in range(0, 5):
1411      s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME +      s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME +
1412              "%02d.jpg") % i)              "%02d.jpg") % i)
1413      mopc1.translate(0.6,0,0)      mopc1.translate(0.6,0,0)
1414  \end{python}  \end{python}
1415    
1416  \textsf{Reading Data Directly from Escript Objects}  \subsection{Reading Data Directly from escript Objects}
1417    The following script shows how to combine Pyvisi code with escript code to
1418    generate visualizations on the fly.
1419    
1420  \begin{python}  \begin{python}
1421  """  """
# Line 1430  Y_SIZE = 400 Line 1437  Y_SIZE = 400
1437  JPG_RENDERER = Renderer.ONLINE_JPG  JPG_RENDERER = Renderer.ONLINE_JPG
1438    
1439  #... set some parameters ...  #... set some parameters ...
1440  xc=[0.02,0.002]  xc = [0.02,0.002]
1441  r=0.001  r = 0.001
1442  qc=50.e6  qc = 50.e6
1443  Tref=0.  Tref = 0.
1444  rhocp=2.6e6  rhocp = 2.6e6
1445  eta=75.  eta = 75.
1446  kappa=240.  kappa = 240.
1447  tend=5.  tend = 5.
1448  # ... time, time step size and counter ...  # initialize time, time step size and counter ...
1449  t=0  t=0
1450  h=0.1  h=0.1
1451  i=0  i=0
1452    
1453  #... generate domain ...  # generate domain ...
1454  mydomain = Rectangle(l0=0.05,l1=0.01,n0=250, n1=50)  mydomain = Rectangle(l0=0.05, l1=0.01, n0=250, n1=50)
1455  #... open PDE ...  # open PDE ...
1456  mypde=LinearPDE(mydomain)  mypde = LinearPDE(mydomain)
1457  mypde.setSymmetryOn()  mypde.setSymmetryOn()
1458  mypde.setValue(A=kappa*kronecker(mydomain),D=rhocp/h,d=eta,y=eta*Tref)  mypde.setValue(A=kappa*kronecker(mydomain), D=rhocp/h, d=eta, y=eta*Tref)
1459  # ... set heat source: ....  # set heat source: ...
1460  x=mydomain.getX()  x = mydomain.getX()
1461  qH=qc*whereNegative(length(x-xc)-r)  qH = qc*whereNegative(length(x-xc)-r)
1462  # ... set initial temperature ....  
1463    # set initial temperature ....
1464  T=Tref  T=Tref
1465    
1466  # Create a Scene.  # Create a Scene.
# Line 1469  m = Map(scene = s, data_collector = dc, Line 1477  m = Map(scene = s, data_collector = dc,
1477  # Create a Camera.  # Create a Camera.
1478  c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)  c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
1479    
1480  # ... start iteration:  # start iteration
1481  while t<0.4:  while t < 0.4:
1482        i+=1        i += 1
1483        t+=h        t += h
1484        mypde.setValue(Y=qH+rhocp/h*T)        mypde.setValue(Y=qH+rhocp/h*T)
1485        T=mypde.getSolution()        T = mypde.getSolution()
1486    
1487        dc.setData(temp = T)        dc.setData(temp = T)
1488                
# Line 1486  while t<0.4: Line 1494  while t<0.4:
1494  \newpage  \newpage
1495    
1496  \section{Useful Keys}  \section{Useful Keys}
1497  This section shows some of the useful keys when interacting with the rendered  This section lists keyboard shortcuts available when interacting with rendered
1498  object (in the Online approach).  objects using the Online approach.
1499    
1500  \begin{table}[ht]  \begin{table}[ht]
1501  \begin{center}  \begin{center}
# Line 1516  Keypress 'w' & Modify the representation Line 1524  Keypress 'w' & Modify the representation
1524  Keypress 'r' & Reset the position of the rendered object to the center.  Keypress 'r' & Reset the position of the rendered object to the center.
1525  \\ \hline  \\ \hline
1526  \end{tabular}  \end{tabular}
1527  \caption{Useful keys}  \caption{Useful keys in Online render mode}
1528  \end{center}  \end{center}
1529  \end{table}  \end{table}
1530    
# Line 1525  Keypress 'r' & Reset the position of the Line 1533  Keypress 'r' & Reset the position of the
1533    
1534    
1535  \newpage  \newpage
1536    \renewcommand{\textfraction}{0.06} % force first table to stay with the text
1537  \section{Sample Output}  \section{Sample Output}
1538  This section displays some of the sample output by Pyvisi.    \label{SAMPLEOUTPUT SEC}
1539    This section shows sample images produced with the various classes of Pyvisi.
1540  \begin{table}[ht]  The source code to produce these images is included in the Pyvisi distribution.
1541    %
1542    \begin{table}[hb]
1543  \begin{tabular}{c c c}  \begin{tabular}{c c c}
1544  \includegraphics[width=\thumbnailwidth]{figures/Map} &  \includegraphics[width=\thumbnailwidth]{figures/Map} &
1545  \includegraphics[width=\thumbnailwidth]{figures/MapOnPlaneCut} &  \includegraphics[width=\thumbnailwidth]{figures/MapOnPlaneCut} &
1546  \includegraphics[width=\thumbnailwidth]{figures/MapOnPlaneClip} \\  \includegraphics[width=\thumbnailwidth]{figures/MapOnPlaneClip} \\
1547  Map & MapOnPlaneCut & MapOnPlaneClip \\  Map & MapOnPlaneCut & MapOnPlaneClip \\
1548  \includegraphics[width=\thumbnailwidth]{figures/MapOnScalarClip} &  \includegraphics[width=\thumbnailwidth]{figures/MapOnScalarClip} &
1549  \includegraphics[width=\thumbnailwidth]{figures/MapOnScalarClipWithRotation} &  \includegraphics[width=\thumbnailwidth]{figures/MapOnScalarClipWithRotation} &
1550  \includegraphics[width=\thumbnailwidth]{figures/Velocity} \\  \includegraphics[width=\thumbnailwidth]{figures/StreamLine} \\
1551  MapOnScalarClip & MapOnScalarClipWithRotation & Velocity \\ \\ \\ \\  MapOnScalarClip & MapOnScalarClipWithRotation & Streamline \\ \\ \\
1552  \includegraphics[width=\thumbnailwidth]{figures/VelocityOnPlaneCut} &  \includegraphics[width=\thumbnailwidth]{figures/Velocity} &
1553  \includegraphics[width=\thumbnailwidth]{figures/VelocityOnPlaneClip} &  \includegraphics[width=\thumbnailwidth]{figures/VelocityOnPlaneCut} &
1554  \includegraphics[width=\thumbnailwidth]{figures/Ellipsoid} \\  \includegraphics[width=\thumbnailwidth]{figures/VelocityOnPlaneClip} \\
1555  VelocityOnPlaneCut & VelocityOnPlaneClip & Ellipsoid \\ \\ \\ \\  Velocity & VelocityOnPlaneCut & VelocityOnPlaneClip \\ \\ \\
1556  \includegraphics[width=\thumbnailwidth]{figures/EllipsoidOnPlaneCut} &  \includegraphics[width=\thumbnailwidth]{figures/Ellipsoid} &
1557  \includegraphics[width=\thumbnailwidth]{figures/EllipsoidOnPlaneClip} \\  \includegraphics[width=\thumbnailwidth]{figures/EllipsoidOnPlaneCut} &
1558  EllipsoidOnPlaneCut & EllipsoidOnPlaneClip \\ \\ \\ \\  \includegraphics[width=\thumbnailwidth]{figures/EllipsoidOnPlaneClip} \\
1559    Ellipsoid & EllipsoidOnPlaneCut & EllipsoidOnPlaneClip \\ \\
1560  \end{tabular}  \end{tabular}
1561  \caption{Sample output}  %\caption{Sample output}
1562  \end{table}  \end{table}
1563    %
1564    \newpage
1565    %
1566  \begin{table}[t]  \begin{table}[t]
1567  \begin{tabular}{c c c}  \begin{tabular}{c c c}
1568  \includegraphics[width=\thumbnailwidth]{figures/Contour} &  \includegraphics[width=\thumbnailwidth]{figures/Contour} &
1569  \includegraphics[width=\thumbnailwidth]{figures/ContourOnPlaneCut} &  \includegraphics[width=\thumbnailwidth]{figures/ContourOnPlaneCut} &
1570  \includegraphics[width=\thumbnailwidth]{figures/ContourOnPlaneClip} \\  \includegraphics[width=\thumbnailwidth]{figures/ContourOnPlaneClip} \\
1571  Contour & ContourOnPlaneCut & ContourOnPlaneClip\\ \\    Contour & ContourOnPlaneCut & ContourOnPlaneClip \\ \\ \\
1572  \includegraphics[width=\thumbnailwidth]{figures/StreamLine} &  \includegraphics[width=\thumbnailwidth]{figures/Carpet} &
1573  \includegraphics[width=\thumbnailwidth]{figures/Carpet} &  \includegraphics[width=\thumbnailwidth]{figures/Rectangle} &
1574  \includegraphics[width=\thumbnailwidth]{figures/Rectangle} \\  \includegraphics[width=\thumbnailwidth]{figures/Image} \\
1575  Streamline & Carpet & Rectangle \\ \\ \\  Carpet & Rectangle & Image \\ \\ \\ \\ \\
1576  \includegraphics[width=\thumbnailwidth]{figures/Text} &  \includegraphics[width=\thumbnailwidth]{figures/Text} &
1577  \includegraphics[width=\thumbnailwidth]{figures/Logo} &  \includegraphics[width=\thumbnailwidth]{figures/Logo} &
 \includegraphics[width=\thumbnailwidth]{figures/Image} \\  
 Text & Logo & Image \\ \\  
1578  \includegraphics[width=\thumbnailwidth]{figures/Legend} \\  \includegraphics[width=\thumbnailwidth]{figures/Legend} \\
1579  Legend \\ \\  Text & Logo & Legend \\ \\
1580  \end{tabular}  \end{tabular}
1581  \caption{Sample Output}  %\caption{Sample Output (continued)}
1582  \end{table}  \end{table}
1583    
1584    

Legend:
Removed from v.1963  
changed lines
  Added in v.1964

  ViewVC Help
Powered by ViewVC 1.1.26