TestProjectedTerrainPath.tcl 2.22 KB
Newer Older
Will Schroeder's avatar
Will Schroeder committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package require vtk
package require vtkinteraction

vtkLookupTable lut
  lut SetHueRange 0.6 0
  lut SetSaturationRange 1.0 0
  lut SetValueRange 0.5 1.0

# Read the data: a height field results
vtkDEMReader demReader
  demReader SetFileName $VTK_DATA_ROOT/Data/SainteHelens.dem
  demReader Update

set lo [lindex [[demReader GetOutput] GetScalarRange] 0]
set hi [lindex [[demReader GetOutput] GetScalarRange] 1]

Will Schroeder's avatar
Will Schroeder committed
17
vtkImageDataGeometryFilter surface
Will Schroeder's avatar
Will Schroeder committed
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
  surface SetInput [demReader GetOutput]

vtkWarpScalar warp
  warp SetInput [surface GetOutput]
  warp SetScaleFactor 1
  warp UseNormalOn
  warp SetNormal 0 0 1

vtkPolyDataNormals normals
  normals SetInput [warp GetPolyDataOutput]
  normals SetFeatureAngle 60
  normals SplittingOff

vtkPolyDataMapper demMapper
  demMapper SetInput [normals GetOutput]
  eval demMapper SetScalarRange $lo $hi
  demMapper SetLookupTable lut

vtkLODActor demActor
  demActor SetMapper demMapper
  
# Create some paths
vtkPoints pts
  pts InsertNextPoint 562669 5.1198e+006 1992.77
  pts InsertNextPoint 562801 5.11618e+006 2534.97
  pts InsertNextPoint 562913 5.11157e+006 1911.1
vtkCellArray lines
  lines InsertNextCell 3
  lines InsertCellPoint 0
  lines InsertCellPoint 1
  lines InsertCellPoint 2
vtkPolyData terrainPaths
  terrainPaths SetPoints pts
  terrainPaths SetLines lines

vtkProjectedTerrainPath projectedPaths
  projectedPaths SetInput terrainPaths
  projectedPaths SetSource [demReader GetOutput]

vtkPolyDataMapper pathMapper
  pathMapper SetInput [projectedPaths GetOutput]

vtkActor paths
  paths SetMapper pathMapper
  [paths GetProperty] SetColor 1 0 0

# 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 demActor
ren1 AddActor paths
ren1 SetBackground .1 .2 .4

iren AddObserver UserEvent {wm deiconify .vtkInteract}
iren SetDesiredUpdateRate 5

[ren1 GetActiveCamera] SetViewUp 0 0 1
[ren1 GetActiveCamera] SetPosition -99900 -21354 131801
[ren1 GetActiveCamera] SetFocalPoint 41461 41461 2815
ren1 ResetCamera
[ren1 GetActiveCamera] Dolly 1.2
ren1 ResetCameraClippingRange

renWin Render

wm withdraw .