source: development/steve/visualisation/Tutorial/Step1/Cone.tcl @ 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.4 KB
RevLine 
[2229]1#
2# This example creates a polygonal model of a cone, and then renders it to
3# the screen. It will rotate the cone 360 degrees and then exit. The basic
4# setup of source -> mapper -> actor -> renderer -> renderwindow is
5# typical of most VTK programs.
6#
7
8#
9# First we include the VTK Tcl packages which will make available
10# all of the VTK commands to Tcl.
11#
12package require vtk
13
14#
15# Next we create an instance of vtkConeSource and set some of its
16# properties. The instance of vtkConeSource "cone" is part of a visualization
17# pipeline (it is a source process object); it produces data (output type is
18# vtkPolyData) which other filters may process.
19#
20vtkConeSource cone
21cone SetHeight 3.0
22cone SetRadius 1.0
23cone SetResolution 10
24
25#
26# In this example we terminate the pipeline with a mapper process object.
27# (Intermediate filters such as vtkShrinkPolyData could be inserted in
28# between the source and the mapper.)  We create an instance of
29# vtkPolyDataMapper to map the polygonal data into graphics primitives. We
30# connect the output of the cone souece to the input of this mapper.
31#
32vtkPolyDataMapper coneMapper
33coneMapper SetInput [cone GetOutput]
34
35#
36# Create an actor to represent the cone. The actor orchestrates rendering of
37# the mapper's graphics primitives. An actor also refers to properties via a
38# vtkProperty instance, and includes an internal transformation matrix. We
39# set this actor's mapper to be coneMapper which we created above.
40#
41vtkActor coneActor
42coneActor SetMapper coneMapper
43
44#
45# Create the Renderer and assign actors to it. A renderer is like a
46# viewport. It is part or all of a window on the screen and it is responsible
47# for drawing the actors it has.  We also set the background color here.
48#
49vtkRenderer ren1
50ren1 AddActor coneActor
51ren1 SetBackground 0.1 0.2 0.4
52
53#
54# Finally we create the render window which will show up on the screen
55# We put our renderer into the render window using AddRenderer. We also
56# set the size to be 300 pixels by 300.
57#
58vtkRenderWindow renWin
59renWin AddRenderer ren1
60renWin SetSize 300 300
61
62#
63# Now we loop over 360 degreeees and render the cone each time.
64#
65for {set i 0} {$i < 360} {incr i} {
66   after 10
67   # render the image
68   renWin Render
69   # rotate the active camera by one degree
70   [ren1 GetActiveCamera] Azimuth 1
71}
72
73#
74# Free up any objects we created.
75#
76vtkCommand DeleteAllObjects
77
78#
79# Exit the application.
80#
81exit
82
83
84
Note: See TracBrowser for help on using the repository browser.