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

Contents of /trunk/pyvisi/examples/basicExample.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: 2518 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: basicExample.py,v 1.2 2005/01/11 05:43:17 paultcochrane Exp $
18
19 ## @file basicExample.py
20
21 """
22 Basic example of pyvisi usage.
23
24 Will hopefully help me write a decent interface.
25 """
26
27 # example code for how a user would write a script in pyvisi
28 from pyvisi import * # base level visualisation stuff
29 #from pyvisi.utils import * # pyvisi specific utils
30 # import the objects to render the scene using vtk
31 from pyvisi.renderers.vtk import *
32
33 # these things are just here to make data to plot, not all of which are used
34 from ESyS import *
35 import Finley
36
37 # now make some data of some kind
38 mesh = Finley.Brick(3,5,7) # a Finley mesh
39 vectorData = mesh.Nodes().getX() # get vector data from the mesh nodes
40
41 # define the scene object
42 # a Scene is a container for all of the kinds of things you want to put
43 # into your plot for instance, images, meshes, arrow/vector/quiver plots,
44 # contour plots, spheres etc.
45 scene = Scene()
46
47 # define a camera object. There will need to be one camera per scene.
48 camera = Camera()
49
50 # add the camera to the scene
51 scene.add(camera)
52
53 # create an ArrowPlot object
54 #plot = ArrowPlot()
55
56 # add the plot to the scene
57 #scene.add(plot)
58
59 # assign some data to the plot
60 #plot.setData(vectorData)
61
62 # create an Image object
63 img = Image(file="ranges.jpg",format="jpeg")
64
65 # add the image to the scene
66 scene.add(image)
67
68 # render the scene, outputing the data to a jpeg file
69 scene.render(file="example.jpg",format="jpeg")
70 # if we are just using vtk, this should head out to a file, or an opengl window
71 # if we are using mayavi with vtk, then this will be in a mayavi window
72
73 # saving a scene could also be written as (handy for PBS jobs?)
74 # could try working out the format from the filename extension
75 scene.save(file="example.jpg", format="jpeg")
76

  ViewVC Help
Powered by ViewVC 1.1.26