/[escript]/trunk/pyvisi_old/examples/view2DMeshExample.py
ViewVC logotype

Contents of /trunk/pyvisi_old/examples/view2DMeshExample.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 786 - (show annotations)
Tue Jul 25 04:58:05 2006 UTC (13 years, 1 month ago) by gross
File MIME type: text/x-python
File size: 2270 byte(s)
switched off pyvisi
1 """
2 Example of loading a two-dimensional mesh into pyvisi and viewing it
3
4 Will hopefully help me write a decent interface.
5
6 @var __author__: name of author
7 @var __license__: licence agreement
8 @var __copyright__: copyrights
9 @var __url__: url entry point on documentation
10 @var __version__: version
11 @var __date__: date of the version
12 """
13
14 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
15 http://www.access.edu.au
16 Primary Business: Queensland, Australia"""
17 __license__="""Licensed under the Open Software License version 3.0
18 http://www.opensource.org/licenses/osl-3.0.php"""
19 __author__="Paul Cochrane"
20 __url__="http://www.iservo.edu.au/esys"
21 __version__="$Revision$"
22 __date__="$Date$"
23
24
25 import sys,os
26
27 # this means that one can run the script from the examples directory
28 sys.path.append('../')
29
30 # import the python visualisation interface
31 from esys.pyvisi import *
32 # import vtk stuff
33 from esys.pyvisi.renderers.vtk import *
34
35 # start a scene, using vtk as the renderer
36 scene = Scene()
37 scene.setSize()
38 scene.setBackgroundColor(0,0,0)
39
40 # render the scene
41 scene.render(pause=True)
42
43 # put an exit in here so that we don't run the vtk code
44 sys.exit()
45
46 # here is the original vtk code
47
48 import vtk
49
50 # set up the renderer and render window
51 _renderer = vtk.vtkRenderer()
52 _renderWindow = vtk.vtkRenderWindow()
53 _renderWindow.AddRenderer(_renderer)
54 _renderWindow.SetSize(1024,768)
55 _renderer.SetBackground(0,0,0)
56
57 # load the jpeg file
58 _jpegReader = vtk.vtkJPEGReader()
59 _jpegReader.SetFileName("Flinders_eval.jpg")
60
61 # set the jpeg file to the texture
62 _tex = vtk.vtkTexture()
63 _tex.SetInput(_jpegReader.GetOutput())
64
65 # get the plane and add it to the "scene"
66 _plane = vtk.vtkPlaneSource()
67 _planeMapper = vtk.vtkPolyDataMapper()
68 _planeMapper.SetInput(_plane.GetOutput())
69 _planeActor = vtk.vtkActor()
70 _planeActor.SetMapper(_planeMapper)
71 _planeActor.SetTexture(_tex)
72 _renderer.AddActor(_planeActor)
73
74 # set up a camera
75 _camera = vtk.vtkCamera()
76 _camera.SetFocalPoint(0,0,0)
77 _camera.SetPosition(1,1,1)
78 _camera.ComputeViewPlaneNormal()
79 _camera.SetViewUp(1,0,0)
80 _camera.OrthogonalizeViewUp()
81
82 _renderer.SetActiveCamera(_camera)
83 _renderer.ResetCamera()
84
85 # now see what was produced
86 _renderWindow.Render()
87
88 raw_input("Press enter to continue")
89
90

  ViewVC Help
Powered by ViewVC 1.1.26