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

  ViewVC Help
Powered by ViewVC 1.1.26