/[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 1388 - (hide annotations)
Fri Jan 11 07:45:58 2008 UTC (13 years, 1 month ago) by trankine
File MIME type: text/x-python
File size: 2410 byte(s)
And get the *(&(*&(* name right
1 jongui 1203 """
2     Author: John Ngui, john.ngui@uq.edu.au
3     """
4    
5 jongui 1169 # Import the necessary modules.
6     from esys.pyvisi import Scene, DataCollector, MapOnPlaneCut, Camera
7     from esys.pyvisi import VelocityOnPlaneCut, StreamLine, EllipsoidOnPlaneCut
8     from esys.pyvisi import ContourOnPlaneClip, Text2D, LocalPosition
9     from esys.pyvisi.constant import *
10     import os
11    
12     PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
13     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
14     X_SIZE = 800
15     Y_SIZE = 800
16    
17     FILE_3D = "interior_3D.xml"
18     IMAGE_NAME = "all.jpg"
19     JPG_RENDERER = Renderer.ONLINE_JPG
20    
21 jongui 1210 # Create a Scene.
22 jongui 1169 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
23     y_size = Y_SIZE)
24    
25     # Create a DataCollector reading from a XML file.
26     dc1 = DataCollector(source = Source.XML)
27     dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
28    
29 jongui 1210 # Create a MapOnPlaneCut.
30 jongui 1169 mopc1 = MapOnPlaneCut(scene = s, data_collector = dc1,
31     viewport = Viewport.SOUTH_WEST)
32     mopc1.setPlaneToXY()
33    
34     # Create a VelocityOnPlaneCut.
35     vopc1 = VelocityOnPlaneCut(scene = s, data_collector = dc1,
36     arrow = Arrow.THREE_D, color_mode = ColorMode.SCALAR)
37     vopc1.setScaleFactor(scale_factor = 0.2)
38     vopc1.setPlaneToYZ(offset = 2.999)
39    
40 jongui 1210 # Create a StreamLine.
41 jongui 1169 sl1 = StreamLine(scene = s, data_collector = dc1,
42     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True,
43     color_mode = ColorMode.SCALAR)
44     sl1.setTubeRadius(radius = 0.02)
45    
46 jongui 1210 # Create an EllipsoidOnPlaneCut.
47 jongui 1169 eopc1 = EllipsoidOnPlaneCut(scene = s, data_collector = dc1,
48     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True)
49     eopc1.setScaleFactor(scale_factor = 0.1)
50     eopc1.setPlaneToXZ()
51     eopc1.rotateX(angle = -40)
52     eopc1.translate(x_offset = 0, y_offset = 0.2, z_offset = 0)
53    
54 jongui 1210 # Create a ContourOnPlaneClip.
55 jongui 1169 ctropc1 = ContourOnPlaneClip(scene = s, data_collector = dc1,
56     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True)
57     ctropc1.setPlaneToXY()
58     ctropc1.rotateY(angle = 10)
59     ctropc1.generateContours(contours = 3)
60    
61 jongui 1210 # Create a 2D text.
62 jongui 1169 t1 = Text2D(scene = s, viewport = Viewport.SOUTH_WEST, text = "Pyvisi")
63     t1.setPosition(LocalPosition(x_coor = 350, y_coor = 730))
64     t1.setColor(color = Color.BLACK)
65     t1.setFontSize(size = 30)
66     t1.boldOn()
67    
68     # Create a Camera.
69     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
70     c1.isometricView()
71    
72     # Render the object.
73     s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))

  ViewVC Help
Powered by ViewVC 1.1.26