File: spikeF.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 (94 lines) | stat: -rw-r--r-- 3,121 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
# This example demonstrates the use of glyphing. We also use a mask filter
# to select a subset of points to glyph.

#
# First we include the VTK Tcl packages which will make available
# all of the vtk commands from Tcl. The vtkinteraction package defines
# a simple Tcl/Tk interactor widget.
#
package require vtk
package require vtkinteraction
package require vtktesting

# Read a data file. This originally was a Cyberware laser digitizer scan
# of Fran J.'s face. Surface normals are generated based on local geometry
# (i.e., the polygon normals surrounding eash point are averaged). We flip
# the normals because we want them to point out from Fran's face.
#
vtkPolyDataReader fran
    fran SetFileName "$VTK_DATA_ROOT/Data/fran_cut.vtk"
vtkPolyDataNormals normals
    normals SetInputConnection [fran GetOutputPort]
    normals FlipNormalsOn
vtkPolyDataMapper franMapper
    franMapper SetInputConnection [normals GetOutputPort]
vtkActor franActor
    franActor SetMapper franMapper
   eval [franActor GetProperty] SetColor 1.0 0.49 0.25

# We subsample the dataset because we want to glyph just a subset of
# the points. Otherwise the display is cluttered and cannot be easily
# read. The RandonModeOn and SetOnRatio combine to random select one out
# of every 10 points in the dataset.
#
vtkMaskPoints ptMask
    ptMask SetInputConnection [normals GetOutputPort]
    ptMask SetOnRatio 10
    ptMask RandomModeOn

# In this case we are using a cone as a glyph. We transform the cone so
# its base is at 0,0,0. This is the point where glyph rotation occurs.
vtkConeSource cone
    cone SetResolution 6
vtkTransform transform
    transform Translate 0.5 0.0 0.0
vtkTransformPolyDataFilter transformF
    transformF SetInputConnection [cone GetOutputPort]
    transformF SetTransform transform

# vtkGlyph3D takes two inputs: the input point set (SetInputConnection)
# which can be any vtkDataSet; and the glyph (SetSourceConnection) which
# must be a vtkPolyData.  We are interested in orienting the glyphs by the
# surface normals that we previosuly generated.
vtkGlyph3D glyph
    glyph SetInputConnection  [ptMask GetOutputPort]
    glyph SetSourceConnection [transformF GetOutputPort]
    glyph SetVectorModeToUseNormal
    glyph SetScaleModeToScaleByVector
    glyph SetScaleFactor 0.004
vtkPolyDataMapper spikeMapper
    spikeMapper SetInputConnection [glyph GetOutputPort]
vtkActor spikeActor
    spikeActor SetMapper spikeMapper
    eval [spikeActor GetProperty] SetColor 0.0 0.79 0.34

# Create the RenderWindow, Renderer and both Actors
#
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 franActor
ren1 AddActor spikeActor

renWin SetSize 500 500
ren1 SetBackground 0.1 0.2 0.4

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

set cam1 [ren1 GetActiveCamera]
$cam1 Zoom 1.4
$cam1 Azimuth 110
iren Initialize

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

iren Start