File: VolumeOutlineSourceClipped.tcl

package info (click to toggle)
vtk7 7.1.1%2Bdfsg2-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 127,396 kB
  • sloc: cpp: 1,539,584; ansic: 124,382; python: 78,038; tcl: 47,013; xml: 8,142; yacc: 5,040; java: 4,439; perl: 3,132; lex: 1,926; sh: 1,500; makefile: 126; objc: 83
file content (139 lines) | stat: -rw-r--r-- 3,883 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package require vtk
package require vtkinteraction

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

# Create transfer functions for opacity and color
vtkPiecewiseFunction opacityTransferFunction
    opacityTransferFunction AddPoint    0  0.0
    opacityTransferFunction AddPoint   30  0.0
    opacityTransferFunction AddPoint   80  0.5
    opacityTransferFunction AddPoint  255  0.5

vtkColorTransferFunction colorTransferFunction
    colorTransferFunction AddRGBPoint      0.0 0.0 0.0 0.0
    colorTransferFunction AddRGBPoint     64.0 1.0 0.0 0.0
    colorTransferFunction AddRGBPoint    128.0 0.0 0.0 1.0
    colorTransferFunction AddRGBPoint    192.0 0.0 1.0 0.0
    colorTransferFunction AddRGBPoint    255.0 0.0 0.2 0.0

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

vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
    renWin SetSize 300 300
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

renWin SetMultiSamples 0

ren1 SetBackground 0.1 0.2 0.4

# Translate the volume to center it at (0,0,0)
vtkTransform userTrans
    userTrans PostMultiply
    userTrans Identity
    userTrans Translate -24.5 -24.5 -24.5

# Clipping planes are in world coords
vtkPlane plane1
    plane1 SetOrigin -24 0 0
    plane1 SetNormal 1 0 0

vtkPlane plane2
    plane2 SetOrigin 24 0 0
    plane2 SetNormal -1 0 0

vtkPlane plane3
    plane3 SetOrigin 0 -15 0
    plane3 SetNormal 0.163176 0.925417 -0.342020

vtkPlane plane4
    plane4 SetOrigin 0 24 0
    plane4 SetNormal 0 -1 0

vtkPlane plane5
    plane5 SetOrigin 0 0 -24
    plane5 SetNormal 0 0 1

vtkPlane plane6
    plane6 SetOrigin 0 0 24
    plane6 SetNormal 0 0 -1

vtkPlaneCollection clippingPlanes
    clippingPlanes AddItem plane1
    clippingPlanes AddItem plane2
    clippingPlanes AddItem plane3
    clippingPlanes AddItem plane4
    clippingPlanes AddItem plane5
    clippingPlanes AddItem plane6

# Cropping planes are in data coords
vtkVolumeTextureMapper2D volumeMapper1
    volumeMapper1 SetInputConnection [reader GetOutputPort]
    volumeMapper1 CroppingOn
    volumeMapper1 SetCroppingRegionPlanes 16 33 16 33 16 33
    volumeMapper1 SetClippingPlanes clippingPlanes

vtkVolume volume1
    volume1 SetMapper volumeMapper1
    volume1 SetProperty volumeProperty

vtkVolumeOutlineSource outline1
    outline1 SetVolumeMapper volumeMapper1
    outline1 GenerateFacesOn
    outline1 GenerateScalarsOn

vtkTransformPolyDataFilter preTrans1
    preTrans1 SetInputConnection [outline1 GetOutputPort]
    preTrans1 SetTransform userTrans

vtkClipClosedSurface outlineClip1
    outlineClip1 SetInputConnection [preTrans1 GetOutputPort]
    outlineClip1 SetClippingPlanes clippingPlanes
    outlineClip1 GenerateFacesOff
    outlineClip1 GenerateOutlineOn
    outlineClip1 SetScalarModeToColors
    outlineClip1 SetClipColor 1 1 0
    outlineClip1 SetActivePlaneId 2
    outlineClip1 SetActivePlaneColor 0 1 0

vtkTransformPolyDataFilter postTrans1
    postTrans1 SetInputConnection [outlineClip1 GetOutputPort]
    postTrans1 SetTransform [userTrans GetInverse]

vtkDataSetMapper outlineMapper1
    outlineMapper1 SetInputConnection [postTrans1 GetOutputPort]

vtkActor outlineActor1
    outlineActor1 SetMapper outlineMapper1

volume1 SetUserTransform userTrans
outlineActor1 SetUserTransform userTrans

ren1 AddViewProp outlineActor1
ren1 AddViewProp volume1

volumeMapper1 SetCroppingRegionFlagsToFence

outline1 GenerateScalarsOn

ren1 ResetCamera
[ren1 GetActiveCamera] Zoom 1.35
renWin Render

iren AddObserver UserEvent {wm deiconify .vtkInteract}
iren Initialize

wm withdraw .