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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 605 - (show annotations)
Mon Mar 20 07:16:27 2006 UTC (13 years, 7 months ago) by gross
File MIME type: text/x-python
File size: 3052 byte(s)
pyvisi with vtk runs noe on the altix
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: vtkDataLoadExample.py,v 1.3 2005/11/08 05:13:04 paultcochrane Exp $
18
19 ## @file view2DMeshExample.py
20
21 """
22 Example of loading a two-dimensional mesh into pyvisi and viewing it
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 esys.pyvisi import *
38 # import vtk stuff
39 from esys.pyvisi.renderers.vtk import *
40
41 # start a scene, using vtk as the renderer
42 scene = Scene()
43 scene.setBackgroundColor(1,1,1)
44
45 # load some vtk data
46 data = Data(scene)
47 data.load(file="Flinders_ranges.vtk")
48
49 # set up the plot
50 plot = MeshPlot(scene)
51 plot.setData(data)
52
53 # render the scene
54 scene.render(pause=True,interactive=True)
55
56 # the interactive flag means whether or not to set up and use
57 # a window interactor object (if available)
58
59 # put an exit in here so that we don't run the vtk code
60 sys.exit()
61
62 else:
63
64 # here is the original vtk code
65
66 import vtk
67
68 # set up the renderer and render window
69 _renderer = vtk.vtkRenderer()
70 _renderWindow = vtk.vtkRenderWindow()
71 _renderWindow.AddRenderer(_renderer)
72 _renderWindow.SetSize(640,480)
73 _renderer.SetBackground(1,1,1)
74
75 # load the vtk file
76 _dataReader = vtk.vtkDataSetReader()
77 #_dataReader.SetFileName("Flinders_ranges.vtk")
78 _dataReader.SetFileName("t.vtk")
79
80 # set up the data
81 _dataMapper = vtk.vtkDataSetMapper()
82 _dataMapper.SetInput(_dataReader.GetOutput())
83 _dataMapper.ScalarVisibilityOff() # what exactly does this do?
84
85 # set up the actor for viewing it
86 _dataActor = vtk.vtkActor()
87 _dataActor.SetMapper(_dataMapper)
88 _dataActor.GetProperty().SetColor(0.2,0.2,0.2)
89 _dataActor.GetProperty().SetRepresentationToWireframe()
90
91 # add the actor to the scene
92 _renderer.AddActor(_dataActor)
93
94 # now see what was produced, with interactive playing stuff
95 _iRenderer = vtk.vtkRenderWindowInteractor()
96 _iRenderer.SetRenderWindow(_renderWindow)
97 _iRenderer.Initialize()
98 _renderWindow.Render()
99 _iRenderer.Start()
100
101 raw_input("Press enter to continue")
102
103 # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26