/[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 1569 - (hide annotations)
Sat May 24 04:51:38 2008 UTC (11 years, 1 month ago) by ksteube
File MIME type: text/x-python
File size: 1708 byte(s)
Config for new installation at APAC with 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 ksteube 1569 import os, sys
12 ksteube 1568
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 ksteube 1569 if not os.path.isfile("data_meshes/interior_3D.xml"):
28     print "Cannot find file data_meshes/interior_3D.xml"
29     sys.exit(1)
30    
31 ksteube 1568 # Create a DataCollector reading from a XML file.
32     dc1 = DataCollector(source = Source.XML)
33 ksteube 1569 dc1.setFileName(file_name = "data_meshes/interior_3D.xml")
34 ksteube 1568
35     # Create a Map.
36     m1 = Map(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
37     lut = Lut.COLOR, cell_to_point = False, outline = True)
38     m1.setOpacity(0.3)
39    
40     # Create an ImageReader (in place of DataCollector).
41     ir = ImageReader(ImageFormat.JPG)
42     ir.setImageName(image_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
43     LOAD_IMAGE_NAME))
44    
45     # Create an Image.
46     i = Image(scene = s, image_reader = ir, viewport = Viewport.SOUTH_WEST)
47     i.setOpacity(opacity = 0.9)
48     i.translate(0,0,-1)
49     i.setPoint1(GlobalPosition(2,0,0))
50     i.setPoint2(GlobalPosition(0,2,0))
51    
52     # Create a Camera.
53     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
54    
55     # Render the image.
56     print "Creating image file ./offscreen.jpg"
57     s.render(image_name = "offscreen.jpg")
58    

  ViewVC Help
Powered by ViewVC 1.1.26