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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (hide annotations)
Thu Sep 25 23:11:13 2008 UTC (12 years, 5 months ago) by ksteube
File MIME type: text/x-python
File size: 2330 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 jongui 1203 """
23     Author: John Ngui, john.ngui@uq.edu.au
24     """
25    
26 ksteube 1147 # Import the necessary modules.
27     from esys.pyvisi import Scene, DataCollector, Map, ImageReader, Image, Camera
28     from esys.pyvisi import GlobalPosition
29     from esys.pyvisi.constant import *
30 jongui 1148 import os
31 ksteube 1147
32 jongui 1148 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
33     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
34 ksteube 1147 X_SIZE = 400
35     Y_SIZE = 400
36    
37     SCALAR_FIELD_POINT_DATA = "temperature"
38     FILE_3D = "interior_3D.xml"
39     LOAD_IMAGE_NAME = "flinders.jpg"
40     SAVE_IMAGE_NAME = "image.jpg"
41     JPG_RENDERER = Renderer.ONLINE_JPG
42    
43     # Create a Scene.
44     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
45     y_size = Y_SIZE)
46    
47     # Create a DataCollector reading from a XML file.
48     dc1 = DataCollector(source = Source.XML)
49 jongui 1148 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
50 ksteube 1147
51     # Create a Map.
52     m1 = Map(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
53     lut = Lut.COLOR, cell_to_point = False, outline = True)
54     m1.setOpacity(0.3)
55    
56     # Create an ImageReader (in place of DataCollector).
57     ir = ImageReader(ImageFormat.JPG)
58 jongui 1148 ir.setImageName(image_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
59     LOAD_IMAGE_NAME))
60 ksteube 1147
61     # Create an Image.
62     i = Image(scene = s, image_reader = ir, viewport = Viewport.SOUTH_WEST)
63     i.setOpacity(opacity = 0.9)
64     i.translate(0,0,-1)
65     i.setPoint1(GlobalPosition(2,0,0))
66     i.setPoint2(GlobalPosition(0,2,0))
67    
68     # Create a Camera.
69 jongui 1148 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
70 ksteube 1147
71     # Render the image.
72 jongui 1148 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, SAVE_IMAGE_NAME))
73 ksteube 1147

  ViewVC Help
Powered by ViewVC 1.1.26