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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 337 - (show annotations)
Mon Dec 12 01:57:07 2005 UTC (14 years, 5 months ago) by cochrane
File MIME type: text/x-python
File size: 3912 byte(s)
Initial merge of pyvisi into esys repository.
1 # Copyright (C) 2004 Paul Cochrane
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # $Id: FlindersFaultLinesExample.py,v 1.1 2004/11/23 12:35:40 paultcochrane Exp $
18
19 ## @file FlindersFaultLinesExample.py
20
21 """
22 View the Flinders ranges, with the fault lines lying on top
23
24 Will hopefully help me write a decent interface.
25 """
26
27 import sys,os
28
29 vtk = True
30
31 if not vtk:
32
33 # this means that one can run the script from the examples directory
34 sys.path.append('../')
35
36 # import the python visualisation interface
37 from pyvisi import *
38
39 # start a scene, using vtk as the renderer
40 scene = Scene(renderer='vtk')
41 scene.setBackgroundColor(1,1,1)
42
43 # load some vtk data
44 data = Data(scene)
45 data.load(file="Flinders_ranges.vtk")
46
47 # set up the plot
48 plot = MeshPlot(scene)
49 plot.setData(data)
50
51 # add the plot to the scene
52 scene.add(plot)
53
54 # render the scene
55 scene.render(pause=True,interactive=True)
56
57 # the interactive flag means whether or not to set up and use
58 # a window interactor object (if available)
59
60 # put an exit in here so that we don't run the vtk code
61 sys.exit()
62
63 else:
64
65 # here is the original vtk code
66
67 import vtk
68
69 # set up the renderer and render window
70 _renderer = vtk.vtkRenderer()
71 _renderWindow = vtk.vtkRenderWindow()
72 _renderWindow.AddRenderer(_renderer)
73 _renderWindow.SetSize(640,480)
74 _renderer.SetBackground(1,1,1)
75
76 # load the vtk file
77 _dataReader = vtk.vtkDataSetReader()
78 _dataReader.SetFileName("Flinders_ranges.vtk")
79
80 # load the jpeg image
81 _jpegReader = vtk.vtkJPEGReader()
82 _jpegReader.SetFileName("Flinders_eval.jpg")
83
84 # map the image onto a plane
85 _tex = vtk.vtkTexture()
86 _tex.SetInput(_jpegReader.GetOutput())
87
88 _plane = vtk.vtkPlaneSource()
89 _planeMapper = vtk.vtkPolyDataMapper()
90 _planeMapper.SetInput(_plane.GetOutput())
91 _planeActor = vtk.vtkActor()
92 _planeActor.SetMapper(_planeMapper)
93 _planeActor.SetTexture(_tex)
94
95 # alternatively, just grab the image
96 _jpgImgActor = vtk.vtkImageActor()
97 _jpgImgActor.SetInput(_jpegReader.GetOutput())
98
99 # add the actor to the scene
100 #_renderer.AddActor(_planeActor)
101 #_renderer.AddActor(_jpgImgActor)
102
103 # set up the data
104 _dataMapper = vtk.vtkDataSetMapper()
105 _dataMapper.SetInput(_dataReader.GetOutput())
106 #_dataMapper.ScalarVisibilityOff() # what exactly does this do?
107
108 # set up the actor for viewing it
109 _dataActor = vtk.vtkActor()
110 _dataActor.SetMapper(_dataMapper)
111 _dataActor.GetProperty().SetColor(0.2,0.2,0.2)
112 _dataActor.GetProperty().SetRepresentationToWireframe()
113
114 # add the actor to the scene
115 #_renderer.AddActor(_dataActor)
116
117 # try with an assembly
118 _assembly = vtk.vtkAssembly()
119 _assembly.AddPart(_planeActor)
120 _assembly.AddPart(_dataActor)
121
122 # add the assembly to the scene
123 _renderer.AddActor(_assembly)
124
125 # now see what was produced, with interactive playing stuff
126 _iRenderer = vtk.vtkRenderWindowInteractor()
127 _iRenderer.SetRenderWindow(_renderWindow)
128 _iRenderer.Initialize()
129 _renderWindow.Render()
130 _iRenderer.Start()
131
132 raw_input("Press enter to continue")
133
134 # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26