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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
|
package require vtk
package require vtkinteraction
# Create the RenderWindow, Renderer and both Actors
#
vtkRenderer ren1
vtkRenderWindow renWin
renWin AddRenderer ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
# create a soccer ball
#
vtkPoints points
# first point repeated because polygons were 1-offset
points InsertNextPoint 0.348012 0 0.93749
points InsertNextPoint 0.348012 0 0.93749
points InsertNextPoint 0.107542 0.330979 0.93749
points InsertNextPoint -0.281548 0.204556 0.93749
points InsertNextPoint -0.281548 -0.204556 0.93749
points InsertNextPoint 0.107542 -0.330979 0.93749
points InsertNextPoint 0.694318 0 0.719669
points InsertNextPoint 0.799191 -0.327801 0.502204
points InsertNextPoint 0.965027 -0.20654 0.154057
points InsertNextPoint 0.965027 0.20654 0.154057
points InsertNextPoint 0.799191 0.327801 0.502204
points InsertNextPoint 0.214556 0.660335 0.719669
points InsertNextPoint 0.558721 0.65878 0.502204
points InsertNextPoint 0.494641 0.853971 0.154057
points InsertNextPoint 0.101778 0.981619 0.154057
points InsertNextPoint -0.0647933 0.861372 0.502204
points InsertNextPoint -0.561715 0.40811 0.719669
points InsertNextPoint -0.453883 0.734949 0.502204
points InsertNextPoint -0.659322 0.734323 0.154057
points InsertNextPoint -0.902124 0.400134 0.154057
points InsertNextPoint -0.839236 0.204556 0.502204
points InsertNextPoint -0.561715 -0.40811 0.719669
points InsertNextPoint -0.839236 -0.204556 0.502204
points InsertNextPoint -0.902124 -0.400134 0.154057
points InsertNextPoint -0.659322 -0.734323 0.154057
points InsertNextPoint -0.453883 -0.734949 0.502204
points InsertNextPoint 0.214556 -0.660335 0.719669
points InsertNextPoint -0.0647933 -0.861372 0.502204
points InsertNextPoint 0.101778 -0.981619 0.154057
points InsertNextPoint 0.494641 -0.853971 0.154057
points InsertNextPoint 0.558721 -0.65878 0.502204
points InsertNextPoint 0.902124 0.400134 -0.154057
points InsertNextPoint 0.839236 0.204556 -0.502204
points InsertNextPoint 0.561715 0.40811 -0.719669
points InsertNextPoint 0.453883 0.734949 -0.502204
points InsertNextPoint 0.659322 0.734323 -0.154057
points InsertNextPoint -0.101778 0.981619 -0.154057
points InsertNextPoint 0.0647933 0.861372 -0.502204
points InsertNextPoint -0.214556 0.660335 -0.719669
points InsertNextPoint -0.558721 0.65878 -0.502204
points InsertNextPoint -0.494641 0.853971 -0.154057
points InsertNextPoint -0.965027 0.20654 -0.154057
points InsertNextPoint -0.799191 0.327801 -0.502204
points InsertNextPoint -0.694318 0 -0.719669
points InsertNextPoint -0.799191 -0.327801 -0.502204
points InsertNextPoint -0.965027 -0.20654 -0.154057
points InsertNextPoint -0.494641 -0.853971 -0.154057
points InsertNextPoint -0.558721 -0.65878 -0.502204
points InsertNextPoint -0.214556 -0.660335 -0.719669
points InsertNextPoint 0.0647933 -0.861372 -0.502204
points InsertNextPoint -0.101778 -0.981619 -0.154057
points InsertNextPoint 0.659322 -0.734323 -0.154057
points InsertNextPoint 0.453883 -0.734949 -0.502204
points InsertNextPoint 0.561715 -0.40811 -0.719669
points InsertNextPoint 0.839236 -0.204556 -0.502204
points InsertNextPoint 0.902124 -0.400134 -0.154057
points InsertNextPoint 0.281548 -0.204556 -0.93749
points InsertNextPoint -0.107542 -0.330979 -0.93749
points InsertNextPoint -0.348012 0 -0.93749
points InsertNextPoint -0.107542 0.330979 -0.93749
points InsertNextPoint 0.281548 0.204556 -0.93749
vtkCellArray faces
faces InsertNextCell 5
faces InsertCellPoint 5
faces InsertCellPoint 4
faces InsertCellPoint 3
faces InsertCellPoint 2
faces InsertCellPoint 1
faces InsertNextCell 5
faces InsertCellPoint 10
faces InsertCellPoint 9
faces InsertCellPoint 8
faces InsertCellPoint 7
faces InsertCellPoint 6
faces InsertNextCell 5
faces InsertCellPoint 15
faces InsertCellPoint 14
faces InsertCellPoint 13
faces InsertCellPoint 12
faces InsertCellPoint 11
faces InsertNextCell 5
faces InsertCellPoint 20
faces InsertCellPoint 19
faces InsertCellPoint 18
faces InsertCellPoint 17
faces InsertCellPoint 16
faces InsertNextCell 5
faces InsertCellPoint 25
faces InsertCellPoint 24
faces InsertCellPoint 23
faces InsertCellPoint 22
faces InsertCellPoint 21
faces InsertNextCell 5
faces InsertCellPoint 30
faces InsertCellPoint 29
faces InsertCellPoint 28
faces InsertCellPoint 27
faces InsertCellPoint 26
faces InsertNextCell 5
faces InsertCellPoint 35
faces InsertCellPoint 34
faces InsertCellPoint 33
faces InsertCellPoint 32
faces InsertCellPoint 31
faces InsertNextCell 5
faces InsertCellPoint 40
faces InsertCellPoint 39
faces InsertCellPoint 38
faces InsertCellPoint 37
faces InsertCellPoint 36
faces InsertNextCell 5
faces InsertCellPoint 45
faces InsertCellPoint 44
faces InsertCellPoint 43
faces InsertCellPoint 42
faces InsertCellPoint 41
faces InsertNextCell 5
faces InsertCellPoint 50
faces InsertCellPoint 49
faces InsertCellPoint 48
faces InsertCellPoint 47
faces InsertCellPoint 46
faces InsertNextCell 5
faces InsertCellPoint 55
faces InsertCellPoint 54
faces InsertCellPoint 53
faces InsertCellPoint 52
faces InsertCellPoint 51
faces InsertNextCell 5
faces InsertCellPoint 60
faces InsertCellPoint 59
faces InsertCellPoint 58
faces InsertCellPoint 57
faces InsertCellPoint 56
faces InsertNextCell 6
faces InsertCellPoint 2
faces InsertCellPoint 11
faces InsertCellPoint 12
faces InsertCellPoint 10
faces InsertCellPoint 6
faces InsertCellPoint 1
faces InsertNextCell 6
faces InsertCellPoint 3
faces InsertCellPoint 16
faces InsertCellPoint 17
faces InsertCellPoint 15
faces InsertCellPoint 11
faces InsertCellPoint 2
faces InsertNextCell 6
faces InsertCellPoint 4
faces InsertCellPoint 21
faces InsertCellPoint 22
faces InsertCellPoint 20
faces InsertCellPoint 16
faces InsertCellPoint 3
faces InsertNextCell 6
faces InsertCellPoint 5
faces InsertCellPoint 26
faces InsertCellPoint 27
faces InsertCellPoint 25
faces InsertCellPoint 21
faces InsertCellPoint 4
faces InsertNextCell 6
faces InsertCellPoint 1
faces InsertCellPoint 6
faces InsertCellPoint 7
faces InsertCellPoint 30
faces InsertCellPoint 26
faces InsertCellPoint 5
faces InsertNextCell 6
faces InsertCellPoint 12
faces InsertCellPoint 13
faces InsertCellPoint 35
faces InsertCellPoint 31
faces InsertCellPoint 9
faces InsertCellPoint 10
faces InsertNextCell 6
faces InsertCellPoint 17
faces InsertCellPoint 18
faces InsertCellPoint 40
faces InsertCellPoint 36
faces InsertCellPoint 14
faces InsertCellPoint 15
faces InsertNextCell 6
faces InsertCellPoint 22
faces InsertCellPoint 23
faces InsertCellPoint 45
faces InsertCellPoint 41
faces InsertCellPoint 19
faces InsertCellPoint 20
faces InsertNextCell 6
faces InsertCellPoint 27
faces InsertCellPoint 28
faces InsertCellPoint 50
faces InsertCellPoint 46
faces InsertCellPoint 24
faces InsertCellPoint 25
faces InsertNextCell 6
faces InsertCellPoint 7
faces InsertCellPoint 8
faces InsertCellPoint 55
faces InsertCellPoint 51
faces InsertCellPoint 29
faces InsertCellPoint 30
faces InsertNextCell 6
faces InsertCellPoint 9
faces InsertCellPoint 31
faces InsertCellPoint 32
faces InsertCellPoint 54
faces InsertCellPoint 55
faces InsertCellPoint 8
faces InsertNextCell 6
faces InsertCellPoint 14
faces InsertCellPoint 36
faces InsertCellPoint 37
faces InsertCellPoint 34
faces InsertCellPoint 35
faces InsertCellPoint 13
faces InsertNextCell 6
faces InsertCellPoint 19
faces InsertCellPoint 41
faces InsertCellPoint 42
faces InsertCellPoint 39
faces InsertCellPoint 40
faces InsertCellPoint 18
faces InsertNextCell 6
faces InsertCellPoint 24
faces InsertCellPoint 46
faces InsertCellPoint 47
faces InsertCellPoint 44
faces InsertCellPoint 45
faces InsertCellPoint 23
faces InsertNextCell 6
faces InsertCellPoint 29
faces InsertCellPoint 51
faces InsertCellPoint 52
faces InsertCellPoint 49
faces InsertCellPoint 50
faces InsertCellPoint 28
faces InsertNextCell 6
faces InsertCellPoint 32
faces InsertCellPoint 33
faces InsertCellPoint 60
faces InsertCellPoint 56
faces InsertCellPoint 53
faces InsertCellPoint 54
faces InsertNextCell 6
faces InsertCellPoint 37
faces InsertCellPoint 38
faces InsertCellPoint 59
faces InsertCellPoint 60
faces InsertCellPoint 33
faces InsertCellPoint 34
faces InsertNextCell 6
faces InsertCellPoint 42
faces InsertCellPoint 43
faces InsertCellPoint 58
faces InsertCellPoint 59
faces InsertCellPoint 38
faces InsertCellPoint 39
faces InsertNextCell 6
faces InsertCellPoint 47
faces InsertCellPoint 48
faces InsertCellPoint 57
faces InsertCellPoint 58
faces InsertCellPoint 43
faces InsertCellPoint 44
faces InsertNextCell 6
faces InsertCellPoint 52
faces InsertCellPoint 53
faces InsertCellPoint 56
faces InsertCellPoint 57
faces InsertCellPoint 48
faces InsertCellPoint 49
vtkFloatArray faceColors
faceColors InsertNextValue 1
faceColors InsertNextValue 1
faceColors InsertNextValue 1
faceColors InsertNextValue 1
faceColors InsertNextValue 1
faceColors InsertNextValue 1
faceColors InsertNextValue 1
faceColors InsertNextValue 1
faceColors InsertNextValue 1
faceColors InsertNextValue 1
faceColors InsertNextValue 1
faceColors InsertNextValue 1
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
faceColors InsertNextValue 2
vtkFloatArray vertexColors
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vertexColors InsertNextValue 2
vtkPolyData model
model SetPolys faces
model SetPoints points
[model GetCellData] SetScalars faceColors
[model GetPointData] SetScalars vertexColors
vtkTextureMapToSphere ballTC
ballTC SetInputData model
vtkLookupTable lut
lut SetNumberOfColors 3
lut Build
lut SetTableValue 0 0 0 0 1
lut SetTableValue 1 1 .3 .3 1
lut SetTableValue 2 .8 .8 .9 1
vtkDataSetMapper mapper
mapper SetInputConnection [ballTC GetOutputPort]
mapper SetScalarModeToUseCellData
mapper SetLookupTable lut
mapper SetScalarRange 0 2
vtkPNMReader earth
earth SetFileName "$VTK_DATA_ROOT/Data/earth.ppm"
vtkTexture texture
texture SetInputConnection [earth GetOutputPort]
vtkActor soccerBall
soccerBall SetMapper mapper
soccerBall SetTexture texture
# Add the actors to the renderer, set the background and size
#
ren1 AddActor soccerBall
ren1 SetBackground 0.1 0.2 0.4
renWin SetSize 300 300
[ren1 GetActiveCamera] SetPosition 4.19682 4.65178 6.23545
[ren1 GetActiveCamera] SetFocalPoint 0 0 0
[ren1 GetActiveCamera] SetViewAngle 21.4286
[ren1 GetActiveCamera] SetViewUp 0.451577 -0.833646 0.317981
# render the image
#
iren AddObserver UserEvent {wm deiconify .vtkInteract}
set cam1 [ren1 GetActiveCamera]
$cam1 Zoom 1.4
ren1 ResetCameraClippingRange
iren Initialize
# prevent the tk window from showing up then start the event loop
wm withdraw .
|