File: volRCClipPlanes.tcl

package info (click to toggle)
vtk6 6.3.0%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 118,880 kB
  • sloc: cpp: 1,442,792; ansic: 113,395; python: 72,383; tcl: 46,998; xml: 8,119; yacc: 4,525; java: 4,239; perl: 3,108; lex: 1,694; sh: 1,093; asm: 154; makefile: 103; objc: 17
file content (123 lines) | stat: -rw-r--r-- 3,636 bytes parent folder | download | duplicates (12)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package require vtk

# Simple volume rendering example.
vtkSLCReader reader
    reader SetFileName "$VTK_DATA_ROOT/Data/sphere.slc"

reader Update

# Create transfer functions for opacity and color
vtkPiecewiseFunction opacityTransferFunction
    opacityTransferFunction AddPoint  20   0.0
    opacityTransferFunction AddPoint  255  1.0

vtkColorTransferFunction colorTransferFunction

# Improve coverage
    colorTransferFunction SetColorSpaceToRGB
    colorTransferFunction AddRGBPoint 100 1 1 1
    colorTransferFunction AddRGBPoint   0 0 0 0
    colorTransferFunction AddRGBPoint 200 1 0 1
    colorTransferFunction AddRGBPoint 100 0 0 0
    colorTransferFunction RemovePoint 100
    colorTransferFunction RemovePoint   0
    colorTransferFunction RemovePoint 200
    colorTransferFunction AddHSVPoint 100 1 1 1
    colorTransferFunction AddHSVPoint   0 0 0 0
    colorTransferFunction AddHSVPoint 200 1 0 1
    colorTransferFunction AddHSVPoint 100 0 0 0
    colorTransferFunction RemovePoint   0
    colorTransferFunction RemovePoint 200
    colorTransferFunction RemovePoint 100
    colorTransferFunction AddRGBSegment   0 1 1 1 100 0 0 0
    colorTransferFunction AddRGBSegment  50 1 1 1 150 0 0 0
    colorTransferFunction AddRGBSegment  60 1 1 1  90 0 0 0
    colorTransferFunction AddHSVSegment  90 1 1 1 105 0 0 0
    colorTransferFunction AddHSVSegment  40 1 1 1 155 0 0 0
    colorTransferFunction AddHSVSegment  30 1 1 1  95 0 0 0


    colorTransferFunction RemoveAllPoints
    colorTransferFunction AddHSVPoint      0.0 0.01 1.0 1.0
    colorTransferFunction AddHSVPoint    127.5 0.50 1.0 1.0
    colorTransferFunction AddHSVPoint    255.0 0.99 1.0 1.0
    colorTransferFunction SetColorSpaceToHSV

# Create properties, mappers, volume actors, and ray cast function
vtkVolumeProperty volumeProperty
    volumeProperty SetColor colorTransferFunction
    volumeProperty SetScalarOpacity opacityTransferFunction
    volumeProperty SetInterpolationTypeToLinear

vtkVolumeRayCastCompositeFunction  compositeFunction

vtkVolumeRayCastMapper volumeMapper
    volumeMapper SetInputConnection [reader GetOutputPort]
    volumeMapper SetVolumeRayCastFunction compositeFunction

vtkVolume volume
    volume SetMapper volumeMapper
    volume SetProperty volumeProperty

# Create geometric sphere
vtkSphereSource sphereSource
    sphereSource SetCenter  25 25 25
    sphereSource SetRadius  30
    sphereSource SetThetaResolution 15
    sphereSource SetPhiResolution 15

vtkPolyDataMapper sphereMapper
    sphereMapper SetInputConnection [sphereSource GetOutputPort]

vtkActor sphereActor
    sphereActor SetMapper sphereMapper

# Set up the planes
vtkPlane plane1
plane1 SetOrigin 25 25 20
plane1 SetNormal 0 0 1

vtkPlane plane2
plane2 SetOrigin 25 25 30
plane2 SetNormal 0 0 -1

vtkPlane plane3
plane3 SetOrigin 20 25 25
plane3 SetNormal 1 0 0

vtkPlane plane4
plane4 SetOrigin 30 25 25
plane4 SetNormal -1 0 0

sphereMapper AddClippingPlane plane1
sphereMapper AddClippingPlane plane2

volumeMapper AddClippingPlane plane3
volumeMapper AddClippingPlane plane4


# Okay now the graphics stuff
vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
    renWin SetSize 256 256
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

[ren1 GetCullers] InitTraversal
set culler [[ren1 GetCullers] GetNextItem]
$culler SetSortingStyleToBackToFront

ren1 AddViewProp sphereActor
ren1 AddViewProp volume
ren1 SetBackground 0.1 0.2 0.4
renWin Render

[ren1 GetActiveCamera] Azimuth 45
[ren1 GetActiveCamera] Elevation 15
[ren1 GetActiveCamera] Roll 45
[ren1 GetActiveCamera] Zoom 2.0

wm withdraw .

iren Initialize