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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1568 - (hide annotations)
Sat May 24 03:15:08 2008 UTC (12 years, 5 months ago) by ksteube
File MIME type: text/x-python
File size: 1599 byte(s)
Some testing on ac.apac.edu.au, more work needed
New pyvisi example offscreen.py for offscreen rendering

1 ksteube 1568 """
2     Author: Ken Steube
3     """
4    
5     # Example of creating an image in a file (without the need for an X connection)
6    
7     # Import the necessary modules.
8     from esys.pyvisi import Scene, DataCollector, Map, ImageReader, Image, Camera
9     from esys.pyvisi import GlobalPosition
10     from esys.pyvisi.constant import *
11     import os
12    
13     PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
14     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
15     X_SIZE = 400
16     Y_SIZE = 400
17    
18     SCALAR_FIELD_POINT_DATA = "temperature"
19     FILE_3D = "interior_3D.xml"
20     LOAD_IMAGE_NAME = "flinders.jpg"
21     JPG_RENDERER = Renderer.OFFLINE_JPG
22    
23     # Create a Scene.
24     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
25     y_size = Y_SIZE)
26    
27     # Create a DataCollector reading from a XML file.
28     dc1 = DataCollector(source = Source.XML)
29     dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
30    
31     # Create a Map.
32     m1 = Map(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
33     lut = Lut.COLOR, cell_to_point = False, outline = True)
34     m1.setOpacity(0.3)
35    
36     # Create an ImageReader (in place of DataCollector).
37     ir = ImageReader(ImageFormat.JPG)
38     ir.setImageName(image_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
39     LOAD_IMAGE_NAME))
40    
41     # Create an Image.
42     i = Image(scene = s, image_reader = ir, viewport = Viewport.SOUTH_WEST)
43     i.setOpacity(opacity = 0.9)
44     i.translate(0,0,-1)
45     i.setPoint1(GlobalPosition(2,0,0))
46     i.setPoint2(GlobalPosition(0,2,0))
47    
48     # Create a Camera.
49     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
50    
51     # Render the image.
52     print "Creating image file ./offscreen.jpg"
53     s.render(image_name = "offscreen.jpg")
54    

  ViewVC Help
Powered by ViewVC 1.1.26