File: TestBlendStencil.tcl

package info (click to toggle)
vtk 5.0.2-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 51,080 kB
  • ctags: 67,442
  • sloc: cpp: 522,627; ansic: 221,292; tcl: 43,377; python: 14,072; perl: 3,102; java: 1,436; yacc: 1,033; sh: 469; lex: 248; makefile: 181; asm: 154
file content (51 lines) | stat: -rw-r--r-- 1,115 bytes parent folder | download | duplicates (2)
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
package require vtk

# do alpha-blending of two images, but also clip with stencil

vtkBMPReader reader1
reader1 SetFileName "$VTK_DATA_ROOT/Data/masonry.bmp"

vtkPNMReader reader2
reader2 SetFileName "$VTK_DATA_ROOT/Data/B.pgm"

vtkLookupTable table
table SetTableRange 0 127 
table SetValueRange 0.0 1.0 
table SetSaturationRange 0.0 0.0 
table SetHueRange 0.0 0.0 
table SetAlphaRange 0.9 0.0 
table Build

vtkImageTranslateExtent translate
translate SetInputConnection [reader2 GetOutputPort]
translate SetTranslation 60 60 0

vtkSphere sphere
sphere SetCenter 121 131 0
sphere SetRadius 70

vtkImplicitFunctionToImageStencil functionToStencil
functionToStencil SetInput sphere
[functionToStencil GetOutput] SetUpdateExtent 0 255 0 255 0 0
[functionToStencil GetOutput] Update

vtkImageBlend blend
blend SetInput 0 [reader1 GetOutput]
blend SetInput 1 [translate GetOutput]
blend SetOpacity 1 0.8
blend SetStencil [functionToStencil GetOutput]

vtkImageViewer viewer
viewer SetInputConnection [blend GetOutputPort]
viewer SetColorWindow 255.0
viewer SetColorLevel 127.5
viewer SetZSlice 0
viewer Render