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

Contents of /trunk-mpi-branch/doc/examples/pyvisi/all.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1295 - (show annotations)
Mon Sep 10 06:07:09 2007 UTC (11 years, 7 months ago) by ksteube
File MIME type: text/x-python
File size: 2410 byte(s)
Have now merged latest trunk features into MPI branch in preparation for
ending the MPI branch.
Compiles but has run time problems in bandwith reduction.

1 """
2 Author: John Ngui, john.ngui@uq.edu.au
3 """
4
5 # 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 # Create a Scene.
22 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 # Create a MapOnPlaneCut.
30 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 # Create a StreamLine.
41 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 # Create an EllipsoidOnPlaneCut.
47 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 # Create a ContourOnPlaneClip.
55 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 # Create a 2D text.
62 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