/[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 1811 - (hide annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 6 months ago) by ksteube
File MIME type: text/x-python
File size: 3175 byte(s)
Copyright updated in all files

1 ksteube 1811
2     ########################################################
3     #
4     # Copyright (c) 2003-2008 by University of Queensland
5     # Earth Systems Science Computational Center (ESSCC)
6     # http://www.uq.edu.au/esscc
7     #
8     # Primary Business: Queensland, Australia
9     # Licensed under the Open Software License version 3.0
10     # http://www.opensource.org/licenses/osl-3.0.php
11     #
12     ########################################################
13    
14     __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15     Earth Systems Science Computational Center (ESSCC)
16     http://www.uq.edu.au/esscc
17     Primary Business: Queensland, Australia"""
18     __license__="""Licensed under the Open Software License version 3.0
19     http://www.opensource.org/licenses/osl-3.0.php"""
20     __url__="http://www.uq.edu.au/esscc/escript-finley"
21    
22 jongui 1203 """
23     Author: John Ngui, john.ngui@uq.edu.au
24     """
25    
26 jongui 1169 # Import the necessary modules.
27     from esys.pyvisi import Scene, DataCollector, MapOnPlaneCut, Camera
28     from esys.pyvisi import VelocityOnPlaneCut, StreamLine, EllipsoidOnPlaneCut
29     from esys.pyvisi import ContourOnPlaneClip, Text2D, LocalPosition
30     from esys.pyvisi.constant import *
31     import os
32    
33     PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
34     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
35     X_SIZE = 800
36     Y_SIZE = 800
37    
38     FILE_3D = "interior_3D.xml"
39     IMAGE_NAME = "all.jpg"
40     JPG_RENDERER = Renderer.ONLINE_JPG
41    
42 jongui 1210 # Create a Scene.
43 jongui 1169 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
44     y_size = Y_SIZE)
45    
46     # Create a DataCollector reading from a XML file.
47     dc1 = DataCollector(source = Source.XML)
48     dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))
49    
50 jongui 1210 # Create a MapOnPlaneCut.
51 jongui 1169 mopc1 = MapOnPlaneCut(scene = s, data_collector = dc1,
52     viewport = Viewport.SOUTH_WEST)
53     mopc1.setPlaneToXY()
54    
55     # Create a VelocityOnPlaneCut.
56     vopc1 = VelocityOnPlaneCut(scene = s, data_collector = dc1,
57     arrow = Arrow.THREE_D, color_mode = ColorMode.SCALAR)
58     vopc1.setScaleFactor(scale_factor = 0.2)
59     vopc1.setPlaneToYZ(offset = 2.999)
60    
61 jongui 1210 # Create a StreamLine.
62 jongui 1169 sl1 = StreamLine(scene = s, data_collector = dc1,
63     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True,
64     color_mode = ColorMode.SCALAR)
65     sl1.setTubeRadius(radius = 0.02)
66    
67 jongui 1210 # Create an EllipsoidOnPlaneCut.
68 jongui 1169 eopc1 = EllipsoidOnPlaneCut(scene = s, data_collector = dc1,
69     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True)
70     eopc1.setScaleFactor(scale_factor = 0.1)
71     eopc1.setPlaneToXZ()
72     eopc1.rotateX(angle = -40)
73     eopc1.translate(x_offset = 0, y_offset = 0.2, z_offset = 0)
74    
75 jongui 1210 # Create a ContourOnPlaneClip.
76 jongui 1169 ctropc1 = ContourOnPlaneClip(scene = s, data_collector = dc1,
77     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True)
78     ctropc1.setPlaneToXY()
79     ctropc1.rotateY(angle = 10)
80     ctropc1.generateContours(contours = 3)
81    
82 jongui 1210 # Create a 2D text.
83 jongui 1169 t1 = Text2D(scene = s, viewport = Viewport.SOUTH_WEST, text = "Pyvisi")
84     t1.setPosition(LocalPosition(x_coor = 350, y_coor = 730))
85     t1.setColor(color = Color.BLACK)
86     t1.setFontSize(size = 30)
87     t1.boldOn()
88    
89     # Create a Camera.
90     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
91     c1.isometricView()
92    
93     # Render the object.
94     s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))

  ViewVC Help
Powered by ViewVC 1.1.26