File: TestPlatonicSolids.tcl

package info (click to toggle)
vtk 5.8.0-13
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 130,524 kB
  • sloc: cpp: 1,129,256; ansic: 708,203; tcl: 48,526; python: 20,875; xml: 6,779; yacc: 4,208; perl: 3,121; java: 2,788; lex: 931; sh: 660; asm: 471; makefile: 299
file content (117 lines) | stat: -rw-r--r-- 3,236 bytes parent folder | download | duplicates (8)
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
package require vtk
package require vtkinteraction
package require vtktesting

# Create five instances of vtkPlatonicSolidSource 
# corresponding to each of the five Platonic solids.
#
vtkPlatonicSolidSource tet
  tet SetSolidTypeToTetrahedron
vtkPolyDataMapper tetMapper
  tetMapper SetInputConnection [tet GetOutputPort]
vtkActor tetActor
  tetActor SetMapper tetMapper

vtkPlatonicSolidSource cube
  cube SetSolidTypeToCube
vtkPolyDataMapper cubeMapper
  cubeMapper SetInputConnection [cube GetOutputPort]
vtkActor cubeActor
  cubeActor SetMapper cubeMapper
  cubeActor AddPosition 2.0 0 0

vtkPlatonicSolidSource oct
  oct SetSolidTypeToOctahedron
vtkPolyDataMapper octMapper
  octMapper SetInputConnection [oct GetOutputPort]
vtkActor octActor
  octActor SetMapper octMapper
  octActor AddPosition 4.0 0 0

vtkPlatonicSolidSource icosa
  icosa SetSolidTypeToIcosahedron
vtkPolyDataMapper icosaMapper
  icosaMapper SetInputConnection [icosa GetOutputPort]
vtkActor icosaActor
  icosaActor SetMapper icosaMapper
  icosaActor AddPosition 6.0 0 0

vtkPlatonicSolidSource dode
  dode SetSolidTypeToDodecahedron
vtkPolyDataMapper dodeMapper
  dodeMapper SetInputConnection [dode GetOutputPort]
vtkActor dodeActor
  dodeActor SetMapper dodeMapper
  dodeActor AddPosition 8.0 0 0

# Create rendering stuff
#
vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

# Add the actors to the renderer, set the background and size
#
ren1 AddActor tetActor
ren1 AddActor cubeActor
ren1 AddActor octActor
ren1 AddActor icosaActor
ren1 AddActor dodeActor

# Create a lookup table with colors for each face
#
vtkMath math
vtkLookupTable lut
  lut SetNumberOfColors 20
  lut Build
  lut SetTableValue 0 1 0 0 1
  lut SetTableValue 1 0 1 0 1
  lut SetTableValue 2 1 1 0 1
  lut SetTableValue 3 0 0 1 1
  lut SetTableValue 4 1 0 1 1
  lut SetTableValue 5 0 1 1 1
  eval lut SetTableValue 6 $spring_green 1.0
  eval lut SetTableValue 7 $lavender 1.0
  eval lut SetTableValue 8 $mint_cream 1.0
  eval lut SetTableValue 9 $violet 1.0
  eval lut SetTableValue 10 $ivory_black 1.0
  eval lut SetTableValue 11 $coral 1.0
  eval lut SetTableValue 12 $pink 1.0
  eval lut SetTableValue 13 $salmon 1.0
  eval lut SetTableValue 14 $sepia 1.0
  eval lut SetTableValue 15 $carrot 1.0
  eval lut SetTableValue 16 $gold 1.0
  eval lut SetTableValue 17 $forest_green 1.0
  eval lut SetTableValue 18 $turquoise 1.0
  eval lut SetTableValue 19 $plum 1.0

lut SetTableRange 0 19
tetMapper SetLookupTable lut
tetMapper SetScalarRange 0 19
cubeMapper SetLookupTable lut
cubeMapper SetScalarRange 0 19
octMapper SetLookupTable lut
octMapper SetScalarRange 0 19
icosaMapper SetLookupTable lut
icosaMapper SetScalarRange 0 19
dodeMapper SetLookupTable lut
dodeMapper SetScalarRange 0 19

set cam [ren1 GetActiveCamera] 
$cam SetPosition 3.89696 7.20771 1.44123
$cam SetFocalPoint 3.96132 0 0
$cam SetViewUp -0.0079335 0.196002 -0.980571
$cam SetClippingRange 5.42814 9.78848

ren1 SetBackground 0 0 0
renWin SetSize 400 150
iren Initialize

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

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