File: scalarColors.tcl

package info (click to toggle)
vtk6 6.3.0%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 118,880 kB
  • sloc: cpp: 1,442,792; ansic: 113,395; python: 72,383; tcl: 46,998; xml: 8,119; yacc: 4,525; java: 4,239; perl: 3,108; lex: 1,694; sh: 1,093; asm: 154; makefile: 103; objc: 17
file content (101 lines) | stat: -rw-r--r-- 2,542 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
package require vtk
package require vtkinteraction

# Color points with scalars

# get the interactor ui

vtkRenderer ren1
vtkRenderWindow renWin
  renWin AddRenderer ren1
vtkRenderWindowInteractor iren
  iren SetRenderWindow renWin

# create some points with scalars

vtkUnsignedCharArray colors
  colors SetName "Colors"
  colors SetNumberOfComponents 3
  colors SetNumberOfTuples 3
  colors InsertComponent 0 0 255
  colors InsertComponent 0 1 99
  colors InsertComponent 0 2 71

  colors InsertComponent 1 0 125
  colors InsertComponent 1 1 255
  colors InsertComponent 1 2 0

  colors InsertComponent 2 0 226
  colors InsertComponent 2 1 207
  colors InsertComponent 2 2 87

vtkUnsignedCharArray sizes
  sizes SetName "Sizes"
  sizes SetNumberOfComponents 1
  sizes SetNumberOfTuples 3
  sizes SetValue 0 1
  sizes SetValue 1 2
  sizes SetValue 2 3

vtkPoints polyVertexPoints
  polyVertexPoints SetNumberOfPoints 3
  polyVertexPoints InsertPoint 0 0.0 0.0 0.0
  polyVertexPoints InsertPoint 1 2.5 0.0 0.0
  polyVertexPoints InsertPoint 2 5.0 0.0 0.0

vtkPolyVertex aPolyVertex
  [aPolyVertex GetPointIds] SetNumberOfIds 3
  [aPolyVertex GetPointIds] SetId 0 0
  [aPolyVertex GetPointIds] SetId 1 1
  [aPolyVertex GetPointIds] SetId 2 2

vtkUnstructuredGrid aPolyVertexGrid
  aPolyVertexGrid Allocate 1 1
  aPolyVertexGrid InsertNextCell [aPolyVertex GetCellType] [aPolyVertex GetPointIds]
  aPolyVertexGrid SetPoints polyVertexPoints
  [aPolyVertexGrid GetPointData] SetScalars sizes
  [aPolyVertexGrid GetPointData] AddArray   colors

vtkSphereSource sphere
  sphere SetRadius 1.0
  sphere Update

vtkGlyph3D glyphs
  glyphs ScalingOn
  glyphs SetColorModeToColorByScalar
  glyphs SetScaleModeToScaleByScalar
  glyphs SetScaleFactor 1
  glyphs SetInputData aPolyVertexGrid
  glyphs SetSourceConnection [sphere GetOutputPort]
  glyphs SetInputArrayToProcess 0 0 0 0 "Sizes"
  glyphs SetInputArrayToProcess 3 0 0 0 "Colors"

#puts [ glyphs GetScaleModeAsString]

vtkDataSetMapper glyphsMapper
  glyphsMapper SetInputConnection [glyphs GetOutputPort]

vtkActor glyphsActor
  glyphsActor SetMapper glyphsMapper
  [glyphsActor GetProperty] BackfaceCullingOn


ren1 SetBackground .1 .2 .4

ren1 AddActor glyphsActor; [glyphsActor GetProperty] SetDiffuseColor 1 1 1

ren1 ResetCamera
[ren1 GetActiveCamera] Azimuth 30
[ren1 GetActiveCamera] Elevation 20
[ren1 GetActiveCamera] Dolly 1.25
ren1 ResetCameraClippingRange

renWin Render

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