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

Contents of /trunk-mpi-branch/doc/examples/pyvisi/image.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1295 - (show annotations)
Mon Sep 10 06:07:09 2007 UTC (11 years, 7 months ago) by ksteube
File MIME type: text/x-python
File size: 1565 byte(s)
Have now merged latest trunk features into MPI branch in preparation for
ending the MPI branch.
Compiles but has run time problems in bandwith reduction.

1 """
2 Author: John Ngui, john.ngui@uq.edu.au
3 """
4
5 # Import the necessary modules.
6 from esys.pyvisi import Scene, DataCollector, Map, ImageReader, Image, Camera
7 from esys.pyvisi import GlobalPosition
8 from esys.pyvisi.constant import *
9 import os
10
11 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
12 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
13 X_SIZE = 400
14 Y_SIZE = 400
15
16 SCALAR_FIELD_POINT_DATA = "temperature"
17 FILE_3D = "interior_3D.xml"
18 LOAD_IMAGE_NAME = "flinders.jpg"
19 SAVE_IMAGE_NAME = "image.jpg"
20 JPG_RENDERER = Renderer.ONLINE_JPG
21
22 # Create a Scene.
23 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
24 y_size = Y_SIZE)
25
26 # Create a DataCollector reading from a XML file.
27 dc1 = DataCollector(source = Source.XML)
28 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
29
30 # Create a Map.
31 m1 = Map(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
32 lut = Lut.COLOR, cell_to_point = False, outline = True)
33 m1.setOpacity(0.3)
34
35 # Create an ImageReader (in place of DataCollector).
36 ir = ImageReader(ImageFormat.JPG)
37 ir.setImageName(image_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
38 LOAD_IMAGE_NAME))
39
40 # Create an Image.
41 i = Image(scene = s, image_reader = ir, viewport = Viewport.SOUTH_WEST)
42 i.setOpacity(opacity = 0.9)
43 i.translate(0,0,-1)
44 i.setPoint1(GlobalPosition(2,0,0))
45 i.setPoint2(GlobalPosition(0,2,0))
46
47 # Create a Camera.
48 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
49
50 # Render the image.
51 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, SAVE_IMAGE_NAME))
52

  ViewVC Help
Powered by ViewVC 1.1.26