/[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 1094 - (hide annotations)
Mon Apr 16 06:04:25 2007 UTC (15 years, 11 months ago) by jongui
File MIME type: text/x-python
File size: 1470 byte(s)
Fixed the bug related to the use of the 'setData' method in the DataCollector. Reading directly from escript objects should now work.
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 jongui 1094 m1.setOpacity(0.3)
29 jongui 1075
30 jongui 1081 # Create an ImageReader (in place of DataCollector).
31 jongui 1075 ir = ImageReader(ImageFormat.JPG)
32     ir.setImageName(image_name = PYVISI_EXAMPLE_MESHES_PATH + LOAD_IMAGE_NAME)
33    
34 jongui 1081 # Create an Image.
35 jongui 1075 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 jongui 1084 # Create a Camera.
42     c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST)
43    
44 jongui 1075 # Render the object.
45     s.render(PYVISI_EXAMPLE_IMAGES_PATH + SAVE_IMAGE_NAME)
46    

  ViewVC Help
Powered by ViewVC 1.1.26