/[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 1147 - (show annotations)
Wed May 16 06:39:11 2007 UTC (12 years, 1 month ago) by ksteube
File MIME type: text/x-python
File size: 1469 byte(s)
Added back in some files that were accidentally deleted.

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
6 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/"
7 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/"
8 X_SIZE = 400
9 Y_SIZE = 400
10
11 SCALAR_FIELD_POINT_DATA = "temperature"
12 FILE_3D = "interior_3D.xml"
13 LOAD_IMAGE_NAME = "flinders.jpg"
14 SAVE_IMAGE_NAME = "image.jpg"
15 JPG_RENDERER = Renderer.ONLINE_JPG
16
17 # Create a Scene.
18 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
19 y_size = Y_SIZE)
20
21 # Create a DataCollector reading from a XML file.
22 dc1 = DataCollector(source = Source.XML)
23 dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D)
24
25 # Create a Map.
26 m1 = Map(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
27 lut = Lut.COLOR, cell_to_point = False, outline = True)
28 m1.setOpacity(0.3)
29
30 # Create an ImageReader (in place of DataCollector).
31 ir = ImageReader(ImageFormat.JPG)
32 ir.setImageName(image_name = PYVISI_EXAMPLE_MESHES_PATH + LOAD_IMAGE_NAME)
33
34 # Create an Image.
35 i = Image(scene = s, image_reader = ir, viewport = Viewport.SOUTH_WEST)
36 i.setOpacity(opacity = 0.9)
37 i.translate(0,0,-1)
38 i.setPoint1(GlobalPosition(2,0,0))
39 i.setPoint2(GlobalPosition(0,2,0))
40
41 # Create a Camera.
42 c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST)
43
44 # Render the image.
45 s.render(PYVISI_EXAMPLE_IMAGES_PATH + SAVE_IMAGE_NAME)
46

  ViewVC Help
Powered by ViewVC 1.1.26