forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reconstructSurface.tcl
81 lines (67 loc) · 2.1 KB
/
reconstructSurface.tcl
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
package require vtk
package require vtkinteraction
proc readPoints {} {
global VTK_DATA_ROOT
set output [pointSource GetPolyDataOutput]
vtkPoints points
$output SetPoints points
set fp [open "$VTK_DATA_ROOT/Data/cactus.3337.pts" r]
while { [gets $fp line] != -1 } {
scan $line "%s" firstToken
if { $firstToken == "p" } {
scan $line "%s %f %f %f" firstToken x y z
points InsertNextPoint $x $y $z
}
}
points Delete; #okay, reference counting
}
# Read some points. Use a programmable filter to read them.
#
vtkProgrammableSource pointSource
pointSource SetExecuteMethod readPoints
# Construct the surface and create isosurface
#
vtkSurfaceReconstructionFilter surf
surf SetInputConnection [pointSource GetOutputPort]
vtkContourFilter cf
cf SetInputConnection [surf GetOutputPort]
cf SetValue 0 0.0
vtkReverseSense reverse
reverse SetInputConnection [cf GetOutputPort]
reverse ReverseCellsOn
reverse ReverseNormalsOn
vtkPolyDataMapper map
map SetInputConnection [reverse GetOutputPort]
map ScalarVisibilityOff
vtkActor surfaceActor
surfaceActor SetMapper map
[surfaceActor GetProperty] SetDiffuseColor 1.0000 0.3882 0.2784
[surfaceActor GetProperty] SetSpecularColor 1 1 1
[surfaceActor GetProperty] SetSpecular .4
[surfaceActor GetProperty] SetSpecularPower 50
# 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 surfaceActor
ren1 SetBackground 1 1 1
renWin SetSize 300 300
[ren1 GetActiveCamera] SetFocalPoint 0 0 0
[ren1 GetActiveCamera] SetPosition 1 0 0
[ren1 GetActiveCamera] SetViewUp 0 0 1
ren1 ResetCamera
[ren1 GetActiveCamera] Azimuth 20
[ren1 GetActiveCamera] Elevation 30
[ren1 GetActiveCamera] Dolly 1.2
ren1 ResetCameraClippingRange
# 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 .