File: extrudeCopyCD.tcl

package info (click to toggle)
vtk7 7.1.1%2Bdfsg1-12
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 125,776 kB
  • sloc: cpp: 1,539,582; ansic: 106,521; python: 78,038; tcl: 47,013; xml: 8,142; yacc: 5,040; java: 4,439; perl: 3,132; lex: 1,926; sh: 1,500; makefile: 122; objc: 83
file content (102 lines) | stat: -rw-r--r-- 2,240 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package require vtk
package require vtkinteraction

vtkVectorText disk
  disk SetText "o"

vtkTransform t
  t Translate 1.1 0 0
vtkTransformFilter tf
  tf SetTransform t
  tf SetInputConnection [disk GetOutputPort]
vtkStripper strips
  strips SetInputConnection [tf GetOutputPort]
  strips Update

vtkAppendPolyData app
  app AddInputData [disk GetOutput]
  app AddInputData [strips GetOutput]
  app Update

set model [app GetOutput]

vtkLinearExtrusionFilter extrude
  extrude SetInputData $model

# create random cell scalars for the model before extrusion.

vtkMath rn
  rn RandomSeed 1230
vtkUnsignedCharArray cellColors
  cellColors SetNumberOfComponents 3
  cellColors SetNumberOfTuples [$model GetNumberOfCells]
for { set i 0 } { $i < [$model GetNumberOfCells] } { incr i } {
    cellColors InsertComponent $i 0 [rn Random 100 255]
    cellColors InsertComponent $i 1 [rn Random 100 255]
    cellColors InsertComponent $i 2 [rn Random 100 255]
}

[$model GetCellData] SetScalars cellColors



# Lets test the arrow source instead of creating another test.
vtkArrowSource arrow1
vtkPolyDataMapper mapper1
  mapper1 SetInputConnection [arrow1 GetOutputPort]
vtkActor actor1
  actor1 SetMapper mapper1
  actor1 SetPosition 0 -0.2 1

vtkArrowSource arrow2
  arrow2 SetShaftResolution 2
  arrow2 SetTipResolution 1
vtkPolyDataMapper mapper2
  mapper2 SetInputConnection [arrow2 GetOutputPort]
vtkActor actor2
  actor2 SetMapper mapper2
  actor2 SetPosition 1 -0.2 1





# Create the RenderWindow, Renderer and both Actors
#
vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

vtkPolyDataMapper mapper
   mapper SetInputConnection [extrude GetOutputPort]

vtkActor actor
    actor SetMapper mapper

# Add the actors to the renderer, set the background and size
#
ren1 AddActor actor
ren1 AddActor actor1
ren1 AddActor actor2

ren1 SetBackground 0.1 0.2 0.4
renWin SetSize 300 300

# render the image
#
iren AddObserver UserEvent {wm deiconify .vtkInteract}

set cam1 [ren1 GetActiveCamera]
$cam1 Azimuth 20
$cam1 Elevation 40
ren1 ResetCamera
$cam1 Zoom 1.5

iren Initialize

# prevent the tk window from showing up then start the event loop
wm withdraw .