File: schwarz.tcl

package info (click to toggle)
vtk7 7.1.1%2Bdfsg2-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 127,396 kB
  • sloc: cpp: 1,539,584; ansic: 124,382; 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: 126; objc: 83
file content (283 lines) | stat: -rw-r--r-- 7,103 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
package require vtk
package require vtkinteraction

# On older Macs, 10 is too low. Due to what looks like a driver bug
# spectral lighting behaves sort of weird and produces small differences
set threshold 30

vtkPoints points
  points InsertNextPoint 2 4 0
  points InsertNextPoint 2.6 2.6 0
  points InsertNextPoint 4 2 0
  points InsertNextPoint 1.4 4 1.4
  points InsertNextPoint 2 3 1
  points InsertNextPoint 3 2 1
  points InsertNextPoint 4 1.4 1.4
  points InsertNextPoint 0 4 2
  points InsertNextPoint 1 3 2
  points InsertNextPoint 2 2 2
  points InsertNextPoint 3 1 2
  points InsertNextPoint 4 0 2
  points InsertNextPoint 0 2.6 2.6
  points InsertNextPoint 1 2 3
  points InsertNextPoint 2 1 3
  points InsertNextPoint 2.6 0 2.6
  points InsertNextPoint 0 2 4
  points InsertNextPoint 1.4 1.4 4
  points InsertNextPoint 2 0 4

vtkCellArray faces
  faces InsertNextCell 3
  faces InsertCellPoint 0
  faces InsertCellPoint 3
  faces InsertCellPoint 4
  faces InsertNextCell 3
  faces InsertCellPoint 0
  faces InsertCellPoint 4
  faces InsertCellPoint 1
  faces InsertNextCell 3
  faces InsertCellPoint 1
  faces InsertCellPoint 4
  faces InsertCellPoint 5
  faces InsertNextCell 3
  faces InsertCellPoint 1
  faces InsertCellPoint 5
  faces InsertCellPoint 2
  faces InsertNextCell 3
  faces InsertCellPoint 2
  faces InsertCellPoint 5
  faces InsertCellPoint 6
  faces InsertNextCell 3
  faces InsertCellPoint 3
  faces InsertCellPoint 7
  faces InsertCellPoint 8
  faces InsertNextCell 3
  faces InsertCellPoint 3
  faces InsertCellPoint 8
  faces InsertCellPoint 4
  faces InsertNextCell 3
  faces InsertCellPoint 4
  faces InsertCellPoint 8
  faces InsertCellPoint 9
  faces InsertNextCell 3
  faces InsertCellPoint 4
  faces InsertCellPoint 9
  faces InsertCellPoint 5
  faces InsertNextCell 3
  faces InsertCellPoint 5
  faces InsertCellPoint 9
  faces InsertCellPoint 10
  faces InsertNextCell 3
  faces InsertCellPoint 5
  faces InsertCellPoint 10
  faces InsertCellPoint 6
  faces InsertNextCell 3
  faces InsertCellPoint 6
  faces InsertCellPoint 10
  faces InsertCellPoint 11
  faces InsertNextCell 3
  faces InsertCellPoint 7
  faces InsertCellPoint 12
  faces InsertCellPoint 8
  faces InsertNextCell 3
  faces InsertCellPoint 8
  faces InsertCellPoint 12
  faces InsertCellPoint 13
  faces InsertNextCell 3
  faces InsertCellPoint 8
  faces InsertCellPoint 13
  faces InsertCellPoint 9
  faces InsertNextCell 3
  faces InsertCellPoint 9
  faces InsertCellPoint 13
  faces InsertCellPoint 14
  faces InsertNextCell 3
  faces InsertCellPoint 9
  faces InsertCellPoint 14
  faces InsertCellPoint 10
  faces InsertNextCell 3
  faces InsertCellPoint 10
  faces InsertCellPoint 14
  faces InsertCellPoint 15
  faces InsertNextCell 3
  faces InsertCellPoint 10
  faces InsertCellPoint 15
  faces InsertCellPoint 11
  faces InsertNextCell 3
  faces InsertCellPoint 12
  faces InsertCellPoint 16
  faces InsertCellPoint 13
  faces InsertNextCell 3
  faces InsertCellPoint 13
  faces InsertCellPoint 16
  faces InsertCellPoint 17
  faces InsertNextCell 3
  faces InsertCellPoint 13
  faces InsertCellPoint 17
  faces InsertCellPoint 14
  faces InsertNextCell 3
  faces InsertCellPoint 14
  faces InsertCellPoint 17
  faces InsertCellPoint 18
  faces InsertNextCell 3
  faces InsertCellPoint 14
  faces InsertCellPoint 18
  faces InsertCellPoint 15

vtkPolyData model
  model SetPolys faces
  model SetPoints points

vtkMath rn

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

vtkTransform t0
  t0 Identity
vtkTransformPolyDataFilter tf0
  tf0 SetTransform t0
  tf0 SetInputData model

vtkTransform t1
  t1 Identity
  t1 RotateZ 90
vtkTransformPolyDataFilter tf1
  tf1 SetTransform t1
  tf1 SetInputData model

vtkTransform t2
  t2 Identity
  t2 RotateZ 180
vtkTransformPolyDataFilter tf2
  tf2 SetTransform t2
  tf2 SetInputData model

vtkTransform t3
  t3 Identity
  t3 RotateZ 270
vtkTransformPolyDataFilter tf3
  tf3 SetTransform t3
  tf3 SetInputData model

vtkAppendPolyData af
  af AddInputConnection [tf0 GetOutputPort]
  af AddInputConnection [tf1 GetOutputPort]
  af AddInputConnection [tf2 GetOutputPort]
  af AddInputConnection [tf3 GetOutputPort]

vtkTransform t4
  t4 Identity
  t4 RotateX 180
vtkTransformPolyDataFilter tf4
  tf4 SetTransform t4
  tf4 SetInputConnection [af GetOutputPort]

vtkAppendPolyData af2
  af2 AddInputConnection [af GetOutputPort]
  af2 AddInputConnection [tf4 GetOutputPort]

vtkTransform t5
  t5 Identity
  t5 Translate 0 0 -8
vtkTransformPolyDataFilter tf5
  tf5 SetTransform t5
  tf5 SetInputConnection [af2 GetOutputPort]

vtkAppendPolyData af3
  af3 AddInputConnection [af2 GetOutputPort]
  af3 AddInputConnection [tf5 GetOutputPort]

vtkTransform t6
  t6 Identity
  t6 Translate 0 -8 0
vtkTransformPolyDataFilter tf6
  tf6 SetTransform t6
  tf6 SetInputConnection [af3 GetOutputPort]

vtkAppendPolyData af4
  af4 AddInputConnection [af3 GetOutputPort]
  af4 AddInputConnection [tf6 GetOutputPort]

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

vtkCleanPolyData clean
  clean SetTolerance .001
  clean SetInputData model
  clean SetInputConnection [af2 GetOutputPort]
  clean SetInputConnection [af3 GetOutputPort]
  clean SetInputConnection [af4 GetOutputPort]

vtkButterflySubdivisionFilter subdivide
  subdivide SetInputConnection [clean GetOutputPort]
  subdivide SetNumberOfSubdivisions 3

vtkDataSetMapper mapper
   mapper SetInputConnection [subdivide GetOutputPort]

vtkActor surface
    surface SetMapper mapper

vtkFeatureEdges fe
  fe SetInputConnection [subdivide GetOutputPort]
  fe SetFeatureAngle 100

vtkStripper feStripper
  feStripper SetInputConnection [fe GetOutputPort]

vtkTubeFilter feTubes
  feTubes SetInputConnection [feStripper GetOutputPort]
  feTubes SetRadius .1

vtkPolyDataMapper feMapper
  feMapper SetInputConnection [feTubes GetOutputPort]

vtkActor edges
  edges SetMapper feMapper

# Add the actors to the renderer, set the background and size
#
ren1 AddActor surface
ren1 AddActor edges
vtkProperty backP
  backP SetDiffuseColor 1 1 .3
surface SetBackfaceProperty backP

[edges GetProperty] SetDiffuseColor .2 .2 .2
[surface GetProperty] SetDiffuseColor 1 .4 .3
[surface GetProperty] SetSpecular .4
[surface GetProperty] SetDiffuse .8
[surface GetProperty] SetSpecularPower 40

ren1 SetBackground 0.1 0.2 0.4
renWin SetSize 300 300

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

ren1 ResetCamera
set cam1 [ren1 GetActiveCamera]
$cam1 Azimuth 90
ren1 ResetCamera
$cam1 Zoom 1.5
iren Initialize

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