/[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 1084 - (hide annotations)
Thu Apr 12 05:19:22 2007 UTC (13 years, 4 months ago) by jongui
File MIME type: text/x-python
File size: 1451 byte(s)
Updated the guide and fixed a minor bug with the use of the Camera.
1 jongui 1075 # Import the necessary modules.
2 jongui 1084 from esys.pyvisi import Scene, DataCollector, Map, ImageReader, Image, Camera
3 jongui 1075 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    
29 jongui 1081 # Create an ImageReader (in place of DataCollector).
30 jongui 1075 ir = ImageReader(ImageFormat.JPG)
31     ir.setImageName(image_name = PYVISI_EXAMPLE_MESHES_PATH + LOAD_IMAGE_NAME)
32    
33 jongui 1081 # Create an Image.
34 jongui 1075 i = Image(scene = s, image_reader = ir, viewport = Viewport.SOUTH_WEST)
35     i.setOpacity(opacity = 0.9)
36     i.translate(0,0,-1)
37     i.setPoint1(GlobalPosition(2,0,0))
38     i.setPoint2(GlobalPosition(0,2,0))
39    
40 jongui 1084 # Create a Camera.
41     c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST)
42    
43 jongui 1075 # Render the object.
44     s.render(PYVISI_EXAMPLE_IMAGES_PATH + SAVE_IMAGE_NAME)
45    

  ViewVC Help
Powered by ViewVC 1.1.26