File: Plot3DVectors.tcl

package info (click to toggle)
vtk 5.0.4-1.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 51,084 kB
  • ctags: 70,426
  • sloc: cpp: 524,166; ansic: 220,276; tcl: 43,377; python: 14,037; perl: 3,102; java: 1,436; yacc: 1,033; sh: 339; lex: 248; makefile: 197; asm: 154
file content (105 lines) | stat: -rw-r--r-- 3,205 bytes parent folder | download | duplicates (3)
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
package require vtk
package require vtkinteraction

#
# All Plot3D vector functions
#

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

set vectorLabels  "Velocity Vorticity Momentum Pressure_Gradient"
set vectorFunctions  "200 201 202 210"
vtkCamera camera
vtkLight light

# All text actors will share the same text prop

vtkTextProperty textProp
  textProp SetFontSize 10
  textProp SetFontFamilyToArial
  textProp SetColor .3 1 1

set i 0
foreach vectorFunction $vectorFunctions {
  vtkPLOT3DReader pl3d$vectorFunction
    pl3d$vectorFunction SetXYZFileName "$VTK_DATA_ROOT/Data/bluntfinxyz.bin"
    pl3d$vectorFunction SetQFileName "$VTK_DATA_ROOT/Data/bluntfinq.bin"
    pl3d$vectorFunction SetVectorFunctionNumber [expr int($vectorFunction)]
    pl3d$vectorFunction Update
vtkStructuredGridGeometryFilter plane$vectorFunction
    plane$vectorFunction SetInputConnection [pl3d$vectorFunction GetOutputPort]
    plane$vectorFunction SetExtent 25 25 0 100 0 100
vtkHedgeHog hog$vectorFunction
  hog$vectorFunction SetInputConnection [plane$vectorFunction GetOutputPort]
  set maxnorm [[[[pl3d$vectorFunction GetOutput] GetPointData] GetVectors] GetMaxNorm]
  hog$vectorFunction SetScaleFactor [expr 1.0 / $maxnorm]
vtkPolyDataMapper mapper$vectorFunction
    mapper$vectorFunction SetInputConnection [hog$vectorFunction GetOutputPort]
vtkActor actor$vectorFunction
    actor$vectorFunction SetMapper mapper$vectorFunction

vtkRenderer ren$vectorFunction
  ren$vectorFunction SetBackground 0.5 .5 .5
  ren$vectorFunction SetActiveCamera camera
  ren$vectorFunction AddLight light
  renWin AddRenderer ren$vectorFunction

ren$vectorFunction AddActor actor$vectorFunction

vtkTextMapper textMapper$vectorFunction
  textMapper$vectorFunction SetInput [lindex $vectorLabels $i]
  textMapper$vectorFunction SetTextProperty textProp
vtkActor2D text$vectorFunction
  text$vectorFunction SetMapper textMapper$vectorFunction
  text$vectorFunction SetPosition 2 5

  if { [info command "rtExMath"] == ""} {
    ren$vectorFunction AddActor2D text$vectorFunction
  }
incr i
}
#
# now layout renderers
set column 1
set row 1
set deltaX [expr 1.0/2.0]
set deltaY [expr 1.0/2.0]

foreach vectorFunction $vectorFunctions {
    ren${vectorFunction} SetViewport [expr ($column - 1) * $deltaX + ($deltaX * .05)] [expr ($row - 1) * $deltaY + ($deltaY*.05)] [expr $column * $deltaX - ($deltaX * .05)] [expr $row * $deltaY - ($deltaY * .05)]
    incr column
    if { $column > 2 } {set column 1; incr row}
}


camera SetViewUp 1 0 0
camera SetFocalPoint 0 0 0
camera SetPosition .4 -.5 -.75
ren200 ResetCamera
camera Dolly 1.25
ren200 ResetCameraClippingRange
ren201 ResetCameraClippingRange
ren202 ResetCameraClippingRange
ren210 ResetCameraClippingRange

eval light SetPosition [camera GetPosition]
eval light SetFocalPoint [camera GetFocalPoint]

renWin SetSize 350 350
renWin Render

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 .