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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 637 - (show annotations)
Thu Mar 23 10:55:31 2006 UTC (14 years, 2 months ago) by gross
File MIME type: text/x-python
File size: 2812 byte(s)
more copyright statements added
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 vtk = True
28
29 if not vtk:
30
31 # this means that one can run the script from the examples directory
32 sys.path.append('../')
33
34 # import the python visualisation interface
35 from esys.pyvisi import *
36 # import vtk stuff
37 from esys.pyvisi.renderers.vtk import *
38
39 # start a scene, using vtk as the renderer
40 scene = Scene()
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 # 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 _dataReader.SetFileName("t.vtk")
77
78 # set up the data
79 _dataMapper = vtk.vtkDataSetMapper()
80 _dataMapper.SetInput(_dataReader.GetOutput())
81 _dataMapper.ScalarVisibilityOff() # what exactly does this do?
82
83 # set up the actor for viewing it
84 _dataActor = vtk.vtkActor()
85 _dataActor.SetMapper(_dataMapper)
86 _dataActor.GetProperty().SetColor(0.2,0.2,0.2)
87 _dataActor.GetProperty().SetRepresentationToWireframe()
88
89 # add the actor to the scene
90 _renderer.AddActor(_dataActor)
91
92 # now see what was produced, with interactive playing stuff
93 _iRenderer = vtk.vtkRenderWindowInteractor()
94 _iRenderer.SetRenderWindow(_renderWindow)
95 _iRenderer.Initialize()
96 _renderWindow.Render()
97 _iRenderer.Start()
98
99 raw_input("Press enter to continue")
100
101 # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26