source: development/steve/visualisation/Tutorial/Step3/Cone3.py @ 2229

Last change on this file since 2229 was 2229, checked in by steve, 19 years ago

Moved directories into production and development parent directories

File size: 2.7 KB
RevLine 
[2229]1#!/usr/bin/env python
2#
3# This example demonstrates how to use multiple renderers within a
4# render window. It is a variation of the Cone.py example. Please
5# refer to that example for additional documentation.
6#
7
8import vtk
9import time
10
11#
12# Next we create an instance of vtkConeSource and set some of its
13# properties. The instance of vtkConeSource "cone" is part of a visualization
14# pipeline (it is a source process object); it produces data (output type is
15# vtkPolyData) which other filters may process.
16#
17cone = vtk.vtkConeSource()
18cone.SetHeight( 3.0 )
19cone.SetRadius( 1.0 )
20cone.SetResolution( 10 )
21
22#
23# In this example we terminate the pipeline with a mapper process object.
24# (Intermediate filters such as vtkShrinkPolyData could be inserted in
25# between the source and the mapper.)  We create an instance of
26# vtkPolyDataMapper to map the polygonal data into graphics primitives. We
27# connect the output of the cone souece to the input of this mapper.
28#
29coneMapper = vtk.vtkPolyDataMapper()
30coneMapper.SetInput(cone.GetOutput())
31
32#
33# Create an actor to represent the cone. The actor orchestrates rendering of
34# the mapper's graphics primitives. An actor also refers to properties via a
35# vtkProperty instance, and includes an internal transformation matrix. We
36# set this actor's mapper to be coneMapper which we created above.
37#
38coneActor = vtk.vtkActor()
39coneActor.SetMapper(coneMapper)
40
41#
42# Create two renderers and assign actors to them. A renderer renders into a
43# viewport within the vtkRenderWindow. It is part or all of a window on the
44# screen and it is responsible for drawing the actors it has.  We also set
45# the background color here. In this example we are adding the same actor
46# to two different renderers; it is okay to add different actors to
47# different renderers as well.
48#
49ren1 = vtk.vtkRenderer()
50ren1.AddActor(coneActor)
51ren1.SetBackground(0.1, 0.2, 0.4)
52ren1.SetViewport(0.0, 0.0, 0.5, 1.0)
53
54ren2 = vtk.vtkRenderer()
55ren2.AddActor(coneActor)
56ren2.SetBackground(0.1, 0.2, 0.4)
57ren2.SetViewport(0.5, 0.0, 1.0, 1.0)
58
59#
60# Finally we create the render window which will show up on the screen.
61# We add our two renderers into the render window using AddRenderer. We also
62# set the size to be 600 pixels by 300.
63#
64renWin = vtk.vtkRenderWindow()
65renWin.AddRenderer( ren1 )
66renWin.AddRenderer( ren2 )
67renWin.SetSize(600, 300)
68
69#
70# Make one camera view 90 degrees from other.
71#
72ren1.GetActiveCamera().Azimuth(90)
73
74#
75# Now we loop over 360 degreeees and render the cone each time.
76#
77for i in range(0,360):
78    time.sleep(0.03)
79   
80    renWin.Render()
81    ren1.GetActiveCamera().Azimuth( 1 )
82    ren2.GetActiveCamera().Azimuth( 1 )
Note: See TracBrowser for help on using the repository browser.