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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 820 - (show annotations)
Mon Aug 28 06:55:36 2006 UTC (14 years, 3 months ago) by gross
File MIME type: text/x-python
File size: 2995 byte(s)
make the modelframe test run
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.vtkXMLUnstructuredGridReader()
75 #_dataReader.SetFileName("Flinders_ranges.vtk")
76 _dataReader.SetFileName("/home/gross/tmp/jump_final_precon.xml")
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 _plotContour = vtk.vtkContourGrid()
84 _plotContour.SetInput(_dataReader.GetOutput())
85 # _plotContour.GenerateValues(5)
86
87
88 # set up the actor for viewing it
89 _dataActor = vtk.vtkActor()
90 _dataActor.SetMapper(_plotContour)
91 _dataActor.GetProperty().SetColor(0.2,0.2,0.2)
92 _dataActor.GetProperty().SetRepresentationToWireframe()
93
94 # add the actor to the scene
95 _renderer.AddActor(_dataActor)
96
97 # now see what was produced, with interactive playing stuff
98 _iRenderer = vtk.vtkRenderWindowInteractor()
99 _iRenderer.SetRenderWindow(_renderWindow)
100 _iRenderer.Initialize()
101 _renderWindow.Render()
102 _iRenderer.Start()
103
104 # raw_input("Press enter to continue")
105
106 # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26