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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1148 - (show annotations)
Wed May 16 22:45:33 2007 UTC (12 years, 9 months ago) by jongui
File MIME type: text/x-python
File size: 1517 byte(s)
Added the updated files for pyvisi and removed some incorrect reference images.
1 # Import the necessary modules.
2 from esys.pyvisi import Scene, DataCollector, Map, ImageReader, Image, Camera
3 from esys.pyvisi import GlobalPosition
4 from esys.pyvisi.constant import *
5 import os
6
7 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
8 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
9 X_SIZE = 400
10 Y_SIZE = 400
11
12 SCALAR_FIELD_POINT_DATA = "temperature"
13 FILE_3D = "interior_3D.xml"
14 LOAD_IMAGE_NAME = "flinders.jpg"
15 SAVE_IMAGE_NAME = "image.jpg"
16 JPG_RENDERER = Renderer.ONLINE_JPG
17
18 # Create a Scene.
19 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
20 y_size = Y_SIZE)
21
22 # Create a DataCollector reading from a XML file.
23 dc1 = DataCollector(source = Source.XML)
24 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
25
26 # Create a Map.
27 m1 = Map(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
28 lut = Lut.COLOR, cell_to_point = False, outline = True)
29 m1.setOpacity(0.3)
30
31 # Create an ImageReader (in place of DataCollector).
32 ir = ImageReader(ImageFormat.JPG)
33 ir.setImageName(image_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
34 LOAD_IMAGE_NAME))
35
36 # Create an Image.
37 i = Image(scene = s, image_reader = ir, viewport = Viewport.SOUTH_WEST)
38 i.setOpacity(opacity = 0.9)
39 i.translate(0,0,-1)
40 i.setPoint1(GlobalPosition(2,0,0))
41 i.setPoint2(GlobalPosition(0,2,0))
42
43 # Create a Camera.
44 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
45
46 # Render the image.
47 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, SAVE_IMAGE_NAME))
48

  ViewVC Help
Powered by ViewVC 1.1.26