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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 786 - (show annotations)
Tue Jul 25 04:58:05 2006 UTC (13 years, 2 months ago) by gross
File MIME type: text/x-python
File size: 3661 byte(s)
switched off pyvisi
1 """
2 View the Flinders ranges, with the fault lines lying on top
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 import sys,os
25
26 vtk = True
27
28 if not vtk:
29
30 # this means that one can run the script from the examples directory
31 sys.path.append('../')
32
33 # import the python visualisation interface
34 from esys.pyvisi import *
35
36 # start a scene, using vtk as the renderer
37 scene = Scene(renderer='vtk')
38 scene.setBackgroundColor(1,1,1)
39
40 # load some vtk data
41 data = Data(scene)
42 data.load(file="Flinders_ranges.vtk")
43
44 # set up the plot
45 plot = MeshPlot(scene)
46 plot.setData(data)
47
48 # add the plot to the scene
49 scene.add(plot)
50
51 # render the scene
52 scene.render(pause=True,interactive=True)
53
54 # the interactive flag means whether or not to set up and use
55 # a window interactor object (if available)
56
57 # put an exit in here so that we don't run the vtk code
58 sys.exit()
59
60 else:
61
62 # here is the original vtk code
63
64 import vtk
65
66 # set up the renderer and render window
67 _renderer = vtk.vtkRenderer()
68 _renderWindow = vtk.vtkRenderWindow()
69 _renderWindow.AddRenderer(_renderer)
70 _renderWindow.SetSize(640,480)
71 _renderer.SetBackground(1,1,1)
72
73 # load the vtk file
74 _dataReader = vtk.vtkDataSetReader()
75 _dataReader.SetFileName("Flinders_ranges.vtk")
76
77 # load the jpeg image
78 _jpegReader = vtk.vtkJPEGReader()
79 _jpegReader.SetFileName("Flinders_eval.jpg")
80
81 # map the image onto a plane
82 _tex = vtk.vtkTexture()
83 _tex.SetInput(_jpegReader.GetOutput())
84
85 _plane = vtk.vtkPlaneSource()
86 _planeMapper = vtk.vtkPolyDataMapper()
87 _planeMapper.SetInput(_plane.GetOutput())
88 _planeActor = vtk.vtkActor()
89 _planeActor.SetMapper(_planeMapper)
90 _planeActor.SetTexture(_tex)
91
92 # alternatively, just grab the image
93 _jpgImgActor = vtk.vtkImageActor()
94 _jpgImgActor.SetInput(_jpegReader.GetOutput())
95
96 # add the actor to the scene
97 #_renderer.AddActor(_planeActor)
98 #_renderer.AddActor(_jpgImgActor)
99
100 # set up the data
101 _dataMapper = vtk.vtkDataSetMapper()
102 _dataMapper.SetInput(_dataReader.GetOutput())
103 #_dataMapper.ScalarVisibilityOff() # what exactly does this do?
104
105 # set up the actor for viewing it
106 _dataActor = vtk.vtkActor()
107 _dataActor.SetMapper(_dataMapper)
108 _dataActor.GetProperty().SetColor(0.2,0.2,0.2)
109 _dataActor.GetProperty().SetRepresentationToWireframe()
110
111 # add the actor to the scene
112 #_renderer.AddActor(_dataActor)
113
114 # try with an assembly
115 _assembly = vtk.vtkAssembly()
116 _assembly.AddPart(_planeActor)
117 _assembly.AddPart(_dataActor)
118
119 # add the assembly to the scene
120 _renderer.AddActor(_assembly)
121
122 # now see what was produced, with interactive playing stuff
123 _iRenderer = vtk.vtkRenderWindowInteractor()
124 _iRenderer.SetRenderWindow(_renderWindow)
125 _iRenderer.Initialize()
126 _renderWindow.Render()
127 _iRenderer.Start()
128
129 raw_input("Press enter to continue")
130
131 # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26