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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1148 - (hide annotations)
Wed May 16 22:45:33 2007 UTC (13 years, 2 months ago) by jongui
File MIME type: text/x-python
File size: 2276 byte(s)
Added the updated files for pyvisi and removed some incorrect reference images.
1 ksteube 1147 # Import the necessary modules.
2     from esys.pyvisi import Scene, DataCollector, Contour, Camera
3     from esys.pyvisi.constant import *
4 jongui 1148 import os
5 ksteube 1147
6 jongui 1148 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
7     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
8 ksteube 1147 X_SIZE = 400
9     Y_SIZE = 300
10    
11     SCALAR_FIELD_POINT_DATA_1 = "lava"
12     SCALAR_FIELD_POINT_DATA_2 = "talus"
13     FILE_2D = "phi_talus_lava."
14     FIRST_FILE_NAME = "phi_talus_lava.0099.vtu"
15    
16     IMAGE_NAME = "seriesofreads"
17     JPG_RENDERER = Renderer.ONLINE_JPG
18    
19    
20     # Create a Scene.
21     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
22     y_size = Y_SIZE)
23    
24     # Create a DataCollector reading from a XML file. An initial file must always
25     # be assigned when the DataCollector is created, although the same file is
26     # read again in the for-loop.
27     dc1 = DataCollector(source = Source.XML)
28 jongui 1148 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
29     FIRST_FILE_NAME))
30 ksteube 1147 dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_1)
31    
32     # Create a Contour.
33     mosc1 = Contour(scene = s, data_collector = dc1,
34     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
35     outline = True)
36     mosc1.generateContours(0)
37    
38     # Create a second DataCollector reading from the same XML file. An initial
39     # file must always be assigned when the DataCollector is created,
40     # although the same file is read again in the for-loop.
41     dc2 = DataCollector(source = Source.XML)
42 jongui 1148 dc2.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
43     FIRST_FILE_NAME))
44 ksteube 1147 dc2.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_2)
45    
46     # Create a second Contour.
47     mosc2 = Contour(scene = s, data_collector = dc2,
48     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
49     outline = True)
50     mosc2.generateContours(0)
51    
52     # Create a Camera.
53 jongui 1148 cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
54 ksteube 1147
55     # Read in one file one after another and render the object.
56     for i in range(99, 104):
57 jongui 1148 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
58     FILE_2D + "%04d.vtu") % i)
59     dc2.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
60     FILE_2D + "%04d.vtu") % i)
61 ksteube 1147
62 jongui 1148 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
63     IMAGE_NAME + "%04d.jpg") % i)

  ViewVC Help
Powered by ViewVC 1.1.26