File: Delaunay2DTransform.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 (80 lines) | stat: -rw-r--r-- 1,905 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
package require vtk
package require vtkinteraction

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

# create some points on a sphere such that the data is not in the form
# of z = f(x,y)
#

vtkMath math1
vtkPoints points
vtkFloatArray vectors
vectors SetNumberOfComponents 3
for {set i 0} {$i<100} {incr i 1} {
    set theta [math1 Random 0.31415 2.8]
    set phi [math1 Random 0.31415 2.8]
    eval points InsertPoint $i [expr cos($theta)*sin($phi)] [expr sin($theta)*sin($phi)] [expr cos($phi)]
    eval vectors InsertTuple3 $i [expr cos($theta)*sin($phi)] [expr sin($theta)*sin($phi)] [expr cos($phi)]
}

vtkPolyData profile
    profile SetPoints points
    [profile GetPointData] SetVectors vectors

# build a transform that rotates this data into z = f(x,y)
#
vtkTransform transform
transform RotateX 90


# triangulate the data using the specified transform
#
vtkDelaunay2D del1
    del1 SetInput profile
    del1 SetTransform transform
    del1 BoundingTriangulationOff
    del1 SetTolerance 0.001
    del1 SetAlpha 0.0

    
vtkShrinkPolyData shrink
    shrink SetInputConnection [del1 GetOutputPort]

vtkPolyDataMapper map
    map SetInputConnection [shrink GetOutputPort]

vtkActor triangulation
    triangulation SetMapper map
    [triangulation GetProperty] SetColor 1 0 0
    [triangulation GetProperty] BackfaceCullingOn

# Add the actors to the renderer, set the background and size
#
ren1 AddActor triangulation
ren1 SetBackground 1 1 1
renWin SetSize 300 300
renWin Render

set cam1 [ren1 GetActiveCamera]
$cam1 Zoom 1.5
$cam1 Azimuth 90
$cam1 Elevation 30
$cam1 Azimuth -60

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

renWin Render

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