/[escript]/trunk/doc/examples/pyvisi/movie.py
ViewVC logotype

Annotation of /trunk/doc/examples/pyvisi/movie.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1203 - (hide annotations)
Thu Jun 21 23:17:16 2007 UTC (13 years, 8 months ago) by jongui
File MIME type: text/x-python
File size: 1845 byte(s)
Made some minor changes to the exampels.
1 jongui 1203 """
2     Author: John Ngui, john.ngui@uq.edu.au
3     """
4    
5 jongui 1191 # Import the necessary modules.
6     from esys.pyvisi import Scene, DataCollector, Map, Camera, Velocity, Legend
7     from esys.pyvisi import Movie, LocalPosition
8     from esys.pyvisi.constant import *
9     import os
10    
11     PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
12     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
13     X_SIZE = 800
14     Y_SIZE = 800
15    
16     SCALAR_FIELD_POINT_DATA = "temp"
17     FILE_2D = "tempvel-"
18     IMAGE_NAME = "movie"
19     JPG_RENDERER = Renderer.ONLINE_JPG
20    
21     # Create a Scene.
22     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
23     y_size = Y_SIZE)
24    
25     # Create a DataCollector reading from a XML file.
26     dc1 = DataCollector(source = Source.XML)
27     dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
28    
29     # Create a Map.
30     m1 = Map(scene = s, data_collector = dc1,
31     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
32     outline = True)
33    
34     # Create a Camera.
35     cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
36    
37     # Create a movie.
38 jongui 1202 mov = Movie()
39 jongui 1197 #lst = []
40 jongui 1191
41     # Read in one file one after another and render the object.
42     for i in range(938, 949):
43     dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
44     FILE_2D + "%06d.vtu") % i)
45    
46     s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
47     IMAGE_NAME + "%06d.jpg") % i)
48    
49 jongui 1197 #lst.append(IMAGE_NAME + "%06d.jpg" % i)
50    
51     # Images (first and last inclusive) from which the movie is to be generated.
52     mov.imageRange(input_directory = PYVISI_EXAMPLE_IMAGES_PATH,
53 jongui 1191 first_image = IMAGE_NAME + "000938.jpg",
54 jongui 1197 last_image = IMAGE_NAME + "000948.jpg")
55 jongui 1191
56 jongui 1197 # Alternatively, a list of images can be specified.
57     #mov.imageList(input_directory = PYVISI_EXAMPLE_IMAGES_PATH, image_list = lst)
58    
59     # Generate the movie.
60     mov.makeMovie(os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))
61    

  ViewVC Help
Powered by ViewVC 1.1.26