~ubuntu-branches/ubuntu/utopic/vtk6/utopic

« back to all changes in this revision

Viewing changes to Imaging/Core/Testing/Python/TestLassoStencil.py

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2014-01-07 21:26:32 UTC
  • Revision ID: package-import@ubuntu.com-20140107212632-vzwzmu3oyc3obmsg
Tags: upstream-6.0.0
ImportĀ upstreamĀ versionĀ 6.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
import vtk
 
3
from vtk.test import Testing
 
4
from vtk.util.misc import vtkGetDataRoot
 
5
VTK_DATA_ROOT = vtkGetDataRoot()
 
6
 
 
7
# A script to test the vtkLassoStencilSource
 
8
reader = vtk.vtkPNGReader()
 
9
reader.SetDataSpacing(0.8,0.8,1.5)
 
10
reader.SetDataOrigin(0.0,0.0,0.0)
 
11
reader.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/fullhead15.png")
 
12
reader.Update()
 
13
shiftScale = vtk.vtkImageShiftScale()
 
14
shiftScale.SetInputConnection(reader.GetOutputPort())
 
15
shiftScale.SetScale(0.2)
 
16
shiftScale.Update()
 
17
points1 = vtk.vtkPoints()
 
18
points1.InsertNextPoint(80,50,0)
 
19
points1.InsertNextPoint(100,90,0)
 
20
points1.InsertNextPoint(200,50,0)
 
21
points1.InsertNextPoint(230,100,0)
 
22
points1.InsertNextPoint(150,170,0)
 
23
points1.InsertNextPoint(110,170,0)
 
24
points1.InsertNextPoint(80,50,0)
 
25
points2 = vtk.vtkPoints()
 
26
points2.InsertNextPoint(80,50,0)
 
27
points2.InsertNextPoint(100,90,0)
 
28
points2.InsertNextPoint(200,50,0)
 
29
points2.InsertNextPoint(230,100,0)
 
30
points2.InsertNextPoint(150,170,0)
 
31
points2.InsertNextPoint(110,170,0)
 
32
roiStencil1 = vtk.vtkLassoStencilSource()
 
33
roiStencil1.SetShapeToPolygon()
 
34
roiStencil1.SetSlicePoints(0,points1)
 
35
roiStencil1.SetInformationInput(reader.GetOutput())
 
36
roiStencil2 = vtk.vtkLassoStencilSource()
 
37
roiStencil2.SetShapeToPolygon()
 
38
roiStencil2.SetPoints(points2)
 
39
roiStencil2.SetInformationInput(reader.GetOutput())
 
40
roiStencil3 = vtk.vtkLassoStencilSource()
 
41
roiStencil3.SetShapeToSpline()
 
42
roiStencil3.SetPoints(points1)
 
43
roiStencil3.SetInformationInput(reader.GetOutput())
 
44
roiStencil4 = vtk.vtkLassoStencilSource()
 
45
roiStencil4.SetShapeToSpline()
 
46
roiStencil4.SetSlicePoints(0,points2)
 
47
roiStencil4.SetInformationInput(reader.GetOutput())
 
48
roiStencil4.Update()
 
49
stencil1 = vtk.vtkImageStencil()
 
50
stencil1.SetInputConnection(reader.GetOutputPort())
 
51
stencil1.SetBackgroundInputData(shiftScale.GetOutput())
 
52
stencil1.SetStencilConnection(roiStencil1.GetOutputPort())
 
53
stencil2 = vtk.vtkImageStencil()
 
54
stencil2.SetInputConnection(reader.GetOutputPort())
 
55
stencil2.SetBackgroundInputData(shiftScale.GetOutput())
 
56
stencil2.SetStencilConnection(roiStencil2.GetOutputPort())
 
57
stencil3 = vtk.vtkImageStencil()
 
58
stencil3.SetInputConnection(reader.GetOutputPort())
 
59
stencil3.SetBackgroundInputData(shiftScale.GetOutput())
 
60
stencil3.SetStencilConnection(roiStencil3.GetOutputPort())
 
61
stencil4 = vtk.vtkImageStencil()
 
62
stencil4.SetInputConnection(reader.GetOutputPort())
 
63
stencil4.SetBackgroundInputData(shiftScale.GetOutput())
 
64
stencil4.SetStencilConnection(roiStencil4.GetOutputPort())
 
65
mapper1 = vtk.vtkImageMapper()
 
66
mapper1.SetInputConnection(stencil1.GetOutputPort())
 
67
mapper1.SetColorWindow(2000)
 
68
mapper1.SetColorLevel(1000)
 
69
mapper1.SetZSlice(0)
 
70
mapper2 = vtk.vtkImageMapper()
 
71
mapper2.SetInputConnection(stencil2.GetOutputPort())
 
72
mapper2.SetColorWindow(2000)
 
73
mapper2.SetColorLevel(1000)
 
74
mapper2.SetZSlice(0)
 
75
mapper3 = vtk.vtkImageMapper()
 
76
mapper3.SetInputConnection(stencil3.GetOutputPort())
 
77
mapper3.SetColorWindow(2000)
 
78
mapper3.SetColorLevel(1000)
 
79
mapper3.SetZSlice(0)
 
80
mapper4 = vtk.vtkImageMapper()
 
81
mapper4.SetInputConnection(stencil4.GetOutputPort())
 
82
mapper4.SetColorWindow(2000)
 
83
mapper4.SetColorLevel(1000)
 
84
mapper4.SetZSlice(0)
 
85
actor1 = vtk.vtkActor2D()
 
86
actor1.SetMapper(mapper1)
 
87
actor2 = vtk.vtkActor2D()
 
88
actor2.SetMapper(mapper2)
 
89
actor3 = vtk.vtkActor2D()
 
90
actor3.SetMapper(mapper3)
 
91
actor4 = vtk.vtkActor2D()
 
92
actor4.SetMapper(mapper4)
 
93
imager1 = vtk.vtkRenderer()
 
94
imager1.AddActor2D(actor1)
 
95
imager1.SetViewport(0.5,0.0,1.0,0.5)
 
96
imager2 = vtk.vtkRenderer()
 
97
imager2.AddActor2D(actor2)
 
98
imager2.SetViewport(0.0,0.0,0.5,0.5)
 
99
imager3 = vtk.vtkRenderer()
 
100
imager3.AddActor2D(actor3)
 
101
imager3.SetViewport(0.5,0.5,1.0,1.0)
 
102
imager4 = vtk.vtkRenderer()
 
103
imager4.AddActor2D(actor4)
 
104
imager4.SetViewport(0.0,0.5,0.5,1.0)
 
105
imgWin = vtk.vtkRenderWindow()
 
106
imgWin.AddRenderer(imager1)
 
107
imgWin.AddRenderer(imager2)
 
108
imgWin.AddRenderer(imager3)
 
109
imgWin.AddRenderer(imager4)
 
110
imgWin.SetSize(512,512)
 
111
imgWin.Render()
 
112
# --- end of script --