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

Annotation of /trunk/doc/examples/pyvisi/all.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1169 - (hide annotations)
Fri May 25 03:44:14 2007 UTC (13 years, 9 months ago) by jongui
File MIME type: text/x-python
File size: 2387 byte(s)
Added another example that shows the use of multiple modules in a script together.
1 jongui 1169 # Import the necessary modules.
2     from esys.pyvisi import Scene, DataCollector, MapOnPlaneCut, Camera
3     from esys.pyvisi import VelocityOnPlaneCut, StreamLine, EllipsoidOnPlaneCut
4     from esys.pyvisi import ContourOnPlaneClip, Text2D, LocalPosition
5     from esys.pyvisi.constant import *
6     import os
7    
8     PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
9     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
10     X_SIZE = 800
11     Y_SIZE = 800
12    
13     FILE_3D = "interior_3D.xml"
14     IMAGE_NAME = "all.jpg"
15     JPG_RENDERER = Renderer.ONLINE_JPG
16    
17     # Create a Scene with four viewports.
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 = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
24    
25     # Create a MapOnPlaneCut.
26     mopc1 = MapOnPlaneCut(scene = s, data_collector = dc1,
27     viewport = Viewport.SOUTH_WEST)
28     mopc1.setPlaneToXY()
29    
30     # Create a VelocityOnPlaneCut.
31     vopc1 = VelocityOnPlaneCut(scene = s, data_collector = dc1,
32     arrow = Arrow.THREE_D, color_mode = ColorMode.SCALAR)
33     vopc1.setScaleFactor(scale_factor = 0.2)
34     vopc1.setPlaneToYZ(offset = 2.999)
35    
36     # Create a SstreamLine.
37     sl1 = StreamLine(scene = s, data_collector = dc1,
38     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True,
39     color_mode = ColorMode.SCALAR)
40     sl1.setTubeRadius(radius = 0.02)
41    
42     # Create a EllipsoidOnPlaneCut.
43     eopc1 = EllipsoidOnPlaneCut(scene = s, data_collector = dc1,
44     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True)
45     eopc1.setScaleFactor(scale_factor = 0.1)
46     eopc1.setPlaneToXZ()
47     eopc1.rotateX(angle = -40)
48     eopc1.translate(x_offset = 0, y_offset = 0.2, z_offset = 0)
49    
50     # Create a ContourOnPlaneClip.
51     ctropc1 = ContourOnPlaneClip(scene = s, data_collector = dc1,
52     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True)
53     ctropc1.setPlaneToXY()
54     ctropc1.rotateY(angle = 10)
55     ctropc1.generateContours(contours = 3)
56    
57     # Create a 2D text.
58     t1 = Text2D(scene = s, viewport = Viewport.SOUTH_WEST, text = "Pyvisi")
59     t1.setPosition(LocalPosition(x_coor = 350, y_coor = 730))
60     t1.setColor(color = Color.BLACK)
61     t1.setFontSize(size = 30)
62     t1.boldOn()
63    
64     # Create a Camera.
65     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
66     c1.isometricView()
67    
68     # Render the object.
69     s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))

  ViewVC Help
Powered by ViewVC 1.1.26