/[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 1811 - (hide annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 10 months ago) by ksteube
File MIME type: text/x-python
File size: 2473 byte(s)
Copyright updated in all files

1 ksteube 1811
2     ########################################################
3     #
4     # Copyright (c) 2003-2008 by University of Queensland
5     # Earth Systems Science Computational Center (ESSCC)
6     # http://www.uq.edu.au/esscc
7     #
8     # Primary Business: Queensland, Australia
9     # Licensed under the Open Software License version 3.0
10     # http://www.opensource.org/licenses/osl-3.0.php
11     #
12     ########################################################
13    
14     __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15     Earth Systems Science Computational Center (ESSCC)
16     http://www.uq.edu.au/esscc
17     Primary Business: Queensland, Australia"""
18     __license__="""Licensed under the Open Software License version 3.0
19     http://www.opensource.org/licenses/osl-3.0.php"""
20     __url__="http://www.uq.edu.au/esscc/escript-finley"
21    
22 ksteube 1568 """
23     Author: Ken Steube
24     """
25    
26     # Example of creating an image in a file (without the need for an X connection)
27    
28     # Import the necessary modules.
29     from esys.pyvisi import Scene, DataCollector, Map, ImageReader, Image, Camera
30     from esys.pyvisi import GlobalPosition
31     from esys.pyvisi.constant import *
32 ksteube 1569 import os, sys
33 ksteube 1568
34     PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
35     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
36     X_SIZE = 400
37     Y_SIZE = 400
38    
39     SCALAR_FIELD_POINT_DATA = "temperature"
40     FILE_3D = "interior_3D.xml"
41     LOAD_IMAGE_NAME = "flinders.jpg"
42     JPG_RENDERER = Renderer.OFFLINE_JPG
43    
44     # Create a Scene.
45     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
46     y_size = Y_SIZE)
47    
48 ksteube 1569 if not os.path.isfile("data_meshes/interior_3D.xml"):
49     print "Cannot find file data_meshes/interior_3D.xml"
50     sys.exit(1)
51    
52 ksteube 1568 # Create a DataCollector reading from a XML file.
53     dc1 = DataCollector(source = Source.XML)
54 ksteube 1569 dc1.setFileName(file_name = "data_meshes/interior_3D.xml")
55 ksteube 1568
56     # Create a Map.
57     m1 = Map(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
58     lut = Lut.COLOR, cell_to_point = False, outline = True)
59     m1.setOpacity(0.3)
60    
61     # Create an ImageReader (in place of DataCollector).
62     ir = ImageReader(ImageFormat.JPG)
63     ir.setImageName(image_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
64     LOAD_IMAGE_NAME))
65    
66     # Create an Image.
67     i = Image(scene = s, image_reader = ir, viewport = Viewport.SOUTH_WEST)
68     i.setOpacity(opacity = 0.9)
69     i.translate(0,0,-1)
70     i.setPoint1(GlobalPosition(2,0,0))
71     i.setPoint2(GlobalPosition(0,2,0))
72    
73     # Create a Camera.
74     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
75    
76     # Render the image.
77     print "Creating image file ./offscreen.jpg"
78     s.render(image_name = "offscreen.jpg")
79    

  ViewVC Help
Powered by ViewVC 1.1.26