1 | # |
---|
2 | # This example demonstrates how to use multiple renderers within a |
---|
3 | # render window. It is a variation of the Cone.tcl example. Please |
---|
4 | # refer to that example for additional documentation. |
---|
5 | # |
---|
6 | |
---|
7 | # |
---|
8 | # First we include the VTK Tcl packages which will make available |
---|
9 | # all of the VTK commands to Tcl. |
---|
10 | # |
---|
11 | package require vtk |
---|
12 | |
---|
13 | # |
---|
14 | # Next we create an instance of vtkConeSource and set some of its |
---|
15 | # properties. The instance of vtkConeSource "cone" is part of a visualization |
---|
16 | # pipeline (it is a source process object); it produces data (output type is |
---|
17 | # vtkPolyData) which other filters may process. |
---|
18 | # |
---|
19 | vtkConeSource cone |
---|
20 | cone SetHeight 3.0 |
---|
21 | cone SetRadius 1.0 |
---|
22 | cone SetResolution 10 |
---|
23 | |
---|
24 | # |
---|
25 | # In this example we terminate the pipeline with a mapper process object. |
---|
26 | # (Intermediate filters such as vtkShrinkPolyData could be inserted in |
---|
27 | # between the source and the mapper.) We create an instance of |
---|
28 | # vtkPolyDataMapper to map the polygonal data into graphics primitives. We |
---|
29 | # connect the output of the cone souece to the input of this mapper. |
---|
30 | # |
---|
31 | vtkPolyDataMapper coneMapper |
---|
32 | coneMapper SetInput [cone GetOutput] |
---|
33 | |
---|
34 | # |
---|
35 | # Create an actor to represent the cone. The actor orchestrates rendering of |
---|
36 | # the mapper's graphics primitives. An actor also refers to properties via a |
---|
37 | # vtkProperty instance, and includes an internal transformation matrix. We |
---|
38 | # set this actor's mapper to be coneMapper which we created above. |
---|
39 | # |
---|
40 | vtkActor coneActor |
---|
41 | coneActor SetMapper coneMapper |
---|
42 | |
---|
43 | # |
---|
44 | # Create two renderers and assign actors to them. A renderer renders into a |
---|
45 | # viewport within the vtkRenderWindow. It is part or all of a window on the |
---|
46 | # screen and it is responsible for drawing the actors it has. We also set |
---|
47 | # the background color here. In this example we are adding the same actor |
---|
48 | # to two different renderers; it is okay to add different actors to |
---|
49 | # different renderers as well. |
---|
50 | # |
---|
51 | vtkRenderer ren1 |
---|
52 | ren1 AddActor coneActor |
---|
53 | ren1 SetBackground 0.1 0.2 0.4 |
---|
54 | ren1 SetViewport 0.0 0.0 0.5 1.0 |
---|
55 | |
---|
56 | vtkRenderer ren2 |
---|
57 | ren2 AddActor coneActor |
---|
58 | ren2 SetBackground 0.1 0.2 0.4 |
---|
59 | ren2 SetViewport 0.5 0.0 1.0 1.0 |
---|
60 | |
---|
61 | # |
---|
62 | # Finally we create the render window which will show up on the screen. |
---|
63 | # We add our two renderers into the render window using AddRenderer. We also |
---|
64 | # set the size to be 600 pixels by 300. |
---|
65 | # |
---|
66 | vtkRenderWindow renWin |
---|
67 | renWin AddRenderer ren1 |
---|
68 | renWin AddRenderer ren2 |
---|
69 | renWin SetSize 600 300 |
---|
70 | |
---|
71 | # |
---|
72 | # Make one camera view 90 degrees from other. |
---|
73 | # |
---|
74 | [ren1 GetActiveCamera] Azimuth 90 |
---|
75 | |
---|
76 | # |
---|
77 | # Now we loop over 360 degreeees and render the cone each time. |
---|
78 | # |
---|
79 | for {set i 0} {$i < 360} {incr i} { |
---|
80 | after 10 |
---|
81 | # render the image |
---|
82 | renWin Render |
---|
83 | # rotate the active camera by one degree |
---|
84 | [ren1 GetActiveCamera] Azimuth 1 |
---|
85 | [ren2 GetActiveCamera] Azimuth 1 |
---|
86 | } |
---|
87 | |
---|
88 | # |
---|
89 | # Free up any objects we created. |
---|
90 | # |
---|
91 | vtkCommand DeleteAllObjects |
---|
92 | |
---|
93 | # |
---|
94 | # Exit the application. |
---|
95 | # |
---|
96 | exit |
---|