Commit fae72d5e authored by Nikhil Shetty's avatar Nikhil Shetty

Adding auto-converted python tests.

Note: these tests were not a part of pre-modular-vtk and have been especially
converted for vtk-modular in order to have the complete set of python tests for
each tcl test. The likelyhood of them failing is high and more work may be
needed to get them to work.

Change-Id: Iac82a32eddc1da9042450ced177258a364e5b07b
parent 03f912b8
......@@ -9,3 +9,5 @@ add_test_python(TestTemplates.py)
add_test_python(headBone.py Graphics)
add_test_python(scalarColors.py Graphics)
add_test_python(scalarConn.py Graphics)
add_test_python(TestConvexPointSet.py Graphics)
add_test_python(otherDataSetAttributes.py Filters)
#!/usr/bin/env python
# create points in the configuration of an octant with one 2:1 face
#
points = vtk.vtkPoints()
aConvex = vtk.vtkConvexPointSet()
points.InsertPoint(0,0,0,0)
points.InsertPoint(1,1,0,0)
points.InsertPoint(2,1,1,0)
points.InsertPoint(3,0,1,0)
points.InsertPoint(4,0,0,1)
points.InsertPoint(5,1,0,1)
points.InsertPoint(6,1,1,1)
points.InsertPoint(7,0,1,1)
points.InsertPoint(8,0.5,0,0)
points.InsertPoint(9,1,0.5,0)
points.InsertPoint(10,0.5,1,0)
points.InsertPoint(11,0,0.5,0)
points.InsertPoint(12,0.5,0.5,0)
i = 0
while i < 13:
aConvex.GetPointIds().InsertId(i,i)
i = i + 1
aConvexGrid = vtk.vtkUnstructuredGrid()
aConvexGrid.Allocate(1,1)
aConvexGrid.InsertNextCell(aConvex.GetCellType(),aConvex.GetPointIds())
aConvexGrid.SetPoints(points)
# Display the cell
dsm = vtk.vtkDataSetMapper()
dsm.SetInput(aConvexGrid)
a = vtk.vtkActor()
a.SetMapper(dsm)
a.GetProperty().SetColor(0,1,0)
# Contour and clip the cell with elevation scalars
ele = vtk.vtkElevationFilter()
ele.SetInput(aConvexGrid)
ele.SetLowPoint(-1,-1,-1)
ele.SetHighPoint(1,1,1)
ele.SetScalarRange(-1,1)
# Clip
#
clip = vtk.vtkClipDataSet()
clip.SetInputConnection(ele.GetOutputPort())
clip.SetValue(0.5)
g = vtk.vtkDataSetSurfaceFilter()
g.SetInputConnection(clip.GetOutputPort())
map = vtk.vtkPolyDataMapper()
map.SetInputConnection(g.GetOutputPort())
map.ScalarVisibilityOff()
clipActor = vtk.vtkActor()
clipActor.SetMapper(map)
clipActor.GetProperty().SetColor(1,0,0)
clipActor.AddPosition(2,0,0)
# Contour
#
contour = vtk.vtkContourFilter()
contour.SetInputConnection(ele.GetOutputPort())
contour.SetValue(0,0.5)
g2 = vtk.vtkDataSetSurfaceFilter()
g2.SetInputConnection(contour.GetOutputPort())
map2 = vtk.vtkPolyDataMapper()
map2.SetInputConnection(g2.GetOutputPort())
map2.ScalarVisibilityOff()
contourActor = vtk.vtkActor()
contourActor.SetMapper(map2)
contourActor.GetProperty().SetColor(1,0,0)
contourActor.AddPosition(1,2,0)
# Create graphics stuff
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and size
#
ren1.AddActor(a)
ren1.AddActor(clipActor)
ren1.AddActor(contourActor)
ren1.SetBackground(1,1,1)
renWin.SetSize(250,150)
aCam = vtk.vtkCamera()
aCam.SetFocalPoint(1.38705,1.37031,0.639901)
aCam.SetPosition(1.89458,-5.07106,-4.17439)
aCam.SetViewUp(0.00355726,0.598843,-0.800858)
aCam.SetClippingRange(4.82121,12.1805)
ren1.SetActiveCamera(aCam)
renWin.Render()
cam1 = ren1.GetActiveCamera()
cam1.Zoom(1.5)
# render the image
#
renWin.Render()
# prevent the tk window from showing up then start the event loop
# --- end of script --
#!/usr/bin/env python
i = 0
while i < expr.expr(globals(), locals(),["argc","-","1"]):
if (lindex(argv,i) == "-A"):
auto_path = "" + str(auto_path) + " " + str(lindex(argv,expr.expr(globals(), locals(),["i","+1"]))) + ""
pass
i = i + 1
dsa = vtk.vtkDataSetAttributes()
for array in "Bit Char Double Float Int Long Short UnsignedChar UnsignedInt UnsignedLong UnsignedShort".split():
locals()[get_variable_name("vtk", array, "Array")].locals()[get_variable_name("a", array, "Array")]()
locals()[get_variable_name("a", array, "Array")].Allocate(1,1)
locals()[get_variable_name("a", array, "Array")].SetNumberOfComponents(3)
locals()[get_variable_name("a", array, "Array")].SetNumberOfTuples(4)
locals()[get_variable_name("a", array, "Array")].SetName(locals()[get_variable_name("a", array, "Array")])
# SetComponent
k = 0
i = 0
while i < locals()[get_variable_name("a", array, "Array")].GetNumberOfTuples():
j = 0
while j < locals()[get_variable_name("a", array, "Array")].GetNumberOfComponents():
locals()[get_variable_name("a", array, "Array")].SetComponent(i,j,1)
k = k + 1
j = j + 1
i = i + 1
dsa.AddArray(locals()[get_variable_name("a", array, "Array")])
del locals()[get_variable_name("a", array, "Array")]
pass
for attribute in "Scalars Vectors Normals TCoords".split():
dsa.locals()[get_variable_name("SetActive", attribute, "")](aFloatArray)
dsa.locals()[get_variable_name("Get", attribute, "")](aFloatArray)
dsa.locals()[get_variable_name("Get", attribute, "")](foo)
pass
aFloatTensors = vtk.vtkFloatArray()
aFloatTensors.Allocate(1,1)
aFloatTensors.SetNumberOfComponents(9)
aFloatTensors.SetNumberOfTuples(4)
aFloatTensors.SetName(aFloatTensors)
i = 0
while i < aFloatTensors.GetNumberOfTuples():
j = 0
while j < aFloatTensors.GetNumberOfComponents():
aFloatTensors.SetComponent(i,j,1)
k = k + 1
j = j + 1
i = i + 1
dsa.AddArray(aFloatTensors)
del aFloatTensors
dsa.SetActiveTensors(aFloatTensors)
dsa.GetTensors(aFloatTensors)
dsa.GetTensors(foo)
dsa.RemoveArray(aFloatArray)
dsa2 = vtk.vtkDataSetAttributes()
dsa2.CopyAllocate(dsa,4,4)
dsa2.CopyData(dsa,0,0)
del dsa2
dsa3 = vtk.vtkDataSetAttributes()
dsa3.InterpolateAllocate(dsa,4,4)
dsa3.InterpolateEdge(dsa,0,0,1,0.5)
dsa4 = vtk.vtkDataSetAttributes()
dsa4.InterpolateAllocate(dsa,4,4)
dsa4.InterpolateTime(dsa,dsa3,0,0.5)
del dsa4
del dsa3
del dsa
exit
# --- end of script --
......@@ -3,3 +3,4 @@ add_test_python(TestThinPlateWarp.py Hybrid)
add_test_python(TestThinPlateWarp3D.py Hybrid)
add_test_python(cylindrical.py Graphics)
add_test_python(spherical.py Graphics)
add_test_python(SliceOrder.py Graphics)
#!/usr/bin/env python
#
# these transformations permute medical image data to maintain proper orientation
# regardless of the acqusition order. After applying these transforms with
# vtkTransformFilter, a view up of 0,-1,0 will result in the body part
# facing the viewer.
# NOTE: some transformations have a -1 scale factor for one of the components.
# To ensure proper polygon orientation and normal direction, you must
# apply the vtkPolyDataNormals filter.
#
# Naming:
# si - superior to inferior (top to bottom)
# is - inferior to superior (bottom to top)
# ap - anterior to posterior (front to back)
# pa - posterior to anterior (back to front)
# lr - left to right
# rl - right to left
#
si = vtk.vtkTransform()
si.SetMatrix([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1])
is = vtk.vtkTransform()
is.SetMatrix([1,0,0,0,0,0,-1,0,0,-1,0,0,0,0,0,1])
ap = vtk.vtkTransform()
ap.Scale(1,-1,1)
pa = vtk.vtkTransform()
pa.Scale(1,-1,-1)
lr = vtk.vtkTransform()
lr.SetMatrix([0,0,-1,0,0,-1,0,0,1,0,0,0,0,0,0,1])
rl = vtk.vtkTransform()
rl.SetMatrix([0,0,1,0,0,-1,0,0,1,0,0,0,0,0,0,1])
#
# the previous transforms assume radiological views of the slices (viewed from the feet). other
# modalities such as physical sectioning may view from the head. these transforms modify the original
# with a 180 rotation about y
#
hf = vtk.vtkTransform()
hf.SetMatrix([-1,0,0,0,0,1,0,0,0,0,-1,0,0,0,0,1])
hfsi = vtk.vtkTransform()
hfsi.Concatenate(hf.GetMatrix())
hfsi.Concatenate(si.GetMatrix())
hfis = vtk.vtkTransform()
hfis.Concatenate(hf.GetMatrix())
hfis.Concatenate(is.GetMatrix())
hfap = vtk.vtkTransform()
hfap.Concatenate(hf.GetMatrix())
hfap.Concatenate(ap.GetMatrix())
hfpa = vtk.vtkTransform()
hfpa.Concatenate(hf.GetMatrix())
hfpa.Concatenate(pa.GetMatrix())
hflr = vtk.vtkTransform()
hflr.Concatenate(hf.GetMatrix())
hflr.Concatenate(lr.GetMatrix())
hfrl = vtk.vtkTransform()
hfrl.Concatenate(hf.GetMatrix())
hfrl.Concatenate(rl.GetMatrix())
# --- end of script --
......@@ -45,3 +45,5 @@ add_test_python(streamSurface2.py Graphics)
add_test_python(stripF.py Graphics)
add_test_python(teapotHulls.py Graphics)
add_test_python(tubeComb.py Graphics)
add_test_python(SliceOrder.py Graphics)
add_test_python(deciFranFace.py Graphics)
#!/usr/bin/env python
#
# these transformations permute medical image data to maintain proper orientation
# regardless of the acqusition order. After applying these transforms with
# vtkTransformFilter, a view up of 0,-1,0 will result in the body part
# facing the viewer.
# NOTE: some transformations have a -1 scale factor for one of the components.
# To ensure proper polygon orientation and normal direction, you must
# apply the vtkPolyDataNormals filter.
#
# Naming:
# si - superior to inferior (top to bottom)
# is - inferior to superior (bottom to top)
# ap - anterior to posterior (front to back)
# pa - posterior to anterior (back to front)
# lr - left to right
# rl - right to left
#
si = vtk.vtkTransform()
si.SetMatrix([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1])
is = vtk.vtkTransform()
is.SetMatrix([1,0,0,0,0,0,-1,0,0,-1,0,0,0,0,0,1])
ap = vtk.vtkTransform()
ap.Scale(1,-1,1)
pa = vtk.vtkTransform()
pa.Scale(1,-1,-1)
lr = vtk.vtkTransform()
lr.SetMatrix([0,0,-1,0,0,-1,0,0,1,0,0,0,0,0,0,1])
rl = vtk.vtkTransform()
rl.SetMatrix([0,0,1,0,0,-1,0,0,1,0,0,0,0,0,0,1])
#
# the previous transforms assume radiological views of the slices (viewed from the feet). other
# modalities such as physical sectioning may view from the head. these transforms modify the original
# with a 180 rotation about y
#
hf = vtk.vtkTransform()
hf.SetMatrix([-1,0,0,0,0,1,0,0,0,0,-1,0,0,0,0,1])
hfsi = vtk.vtkTransform()
hfsi.Concatenate(hf.GetMatrix())
hfsi.Concatenate(si.GetMatrix())
hfis = vtk.vtkTransform()
hfis.Concatenate(hf.GetMatrix())
hfis.Concatenate(is.GetMatrix())
hfap = vtk.vtkTransform()
hfap.Concatenate(hf.GetMatrix())
hfap.Concatenate(ap.GetMatrix())
hfpa = vtk.vtkTransform()
hfpa.Concatenate(hf.GetMatrix())
hfpa.Concatenate(pa.GetMatrix())
hflr = vtk.vtkTransform()
hflr.Concatenate(hf.GetMatrix())
hflr.Concatenate(lr.GetMatrix())
hfrl = vtk.vtkTransform()
hfrl.Concatenate(hf.GetMatrix())
hfrl.Concatenate(rl.GetMatrix())
# --- end of script --
#!/usr/bin/env python
# Create the RenderWindow, Renderer and both Actors
#
ren1 = vtk.vtkRenderer()
ren2 = vtk.vtkRenderer()
ren3 = vtk.vtkRenderer()
ren4 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
renWin.AddRenderer(ren2)
renWin.AddRenderer(ren3)
renWin.AddRenderer(ren4)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
pnm1 = vtk.vtkPNGReader()
pnm1.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/fran_cut.png")
atext = vtk.vtkTexture()
atext.SetInputConnection(pnm1.GetOutputPort())
atext.InterpolateOn()
# create a cyberware source
#
fran = vtk.vtkPolyDataReader()
fran.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/fran_cut.vtk")
topologies = "On Off"
accumulates = "On Off"
for topology in topologies.split():
for accumulate in accumulates.split():
locals()[get_variable_name("deci", topology, "", accumulate, "")] = vtk.vtkDecimatePro()
locals()[get_variable_name("deci", topology, "", accumulate, "")].SetInputConnection(fran.GetOutputPort())
locals()[get_variable_name("deci", topology, "", accumulate, "")].SetTargetReduction(.95)
locals()[get_variable_name("deci", topology, "", accumulate, "")].locals()[get_variable_name("PreserveTopology", topology, "")]()
locals()[get_variable_name("deci", topology, "", accumulate, "")].locals()[get_variable_name("AccumulateError", accumulate, "")]()
locals()[get_variable_name("mapper", topology, "", accumulate, "")] = vtk.vtkPolyDataMapper()
locals()[get_variable_name("mapper", topology, "", accumulate, "")].SetInputConnection(locals()[get_variable_name("deci", topology, "", accumulate, "")].GetOutputPort())
locals()[get_variable_name("fran", topology, "", accumulate, "")] = vtk.vtkActor()
locals()[get_variable_name("fran", topology, "", accumulate, "")].SetMapper(locals()[get_variable_name("mapper", topology, "", accumulate, "")])
locals()[get_variable_name("fran", topology, "", accumulate, "")].SetTexture(atext)
pass
pass
# Add the actors to the renderer, set the background and size
#
ren1.SetViewport(0,.5,.5,1)
ren2.SetViewport(.5,.5,1,1)
ren3.SetViewport(0,0,.5,.5)
ren4.SetViewport(.5,0,1,.5)
ren1.AddActor(franOnOn)
ren2.AddActor(franOnOff)
ren3.AddActor(franOffOn)
ren4.AddActor(franOffOff)
camera = vtk.vtkCamera()
ren1.SetActiveCamera(camera)
ren2.SetActiveCamera(camera)
ren3.SetActiveCamera(camera)
ren4.SetActiveCamera(camera)
ren1.GetActiveCamera().SetPosition(0.314753,-0.0699988,-0.264225)
ren1.GetActiveCamera().SetFocalPoint(0.00188636,-0.136847,-5.84226e-09)
ren1.GetActiveCamera().SetViewAngle(30)
ren1.GetActiveCamera().SetViewUp(0,1,0)
ren1.ResetCameraClippingRange()
ren2.ResetCameraClippingRange()
ren3.ResetCameraClippingRange()
ren4.ResetCameraClippingRange()
ren1.SetBackground(1,1,1)
ren2.SetBackground(1,1,1)
ren3.SetBackground(1,1,1)
ren4.SetBackground(1,1,1)
renWin.SetSize(500,500)
# render the image
#
iren.Initialize()
# prevent the tk window from showing up then start the event loop
# --- end of script --
......@@ -34,3 +34,7 @@ add_test_python(testDataSetTriangleFilter.py Graphics)
add_test_python(testDataSetTriangleFilter2.py Graphics)
add_test_python(testReflect.py Graphics)
add_test_python(warplens.py Graphics)
add_test_python(TestRandomAttributeGenerator.py Graphics)
add_test_python(WarpScalarImage.py Graphics)
add_test_python(WarpVectorImage.py Graphics)
add_test_python(cursor2D.py Graphics)
#!/usr/bin/env python
# Create the RenderWindow, Renderer and interactive renderer
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
# make sure to have the same regression image on all platforms.
renWin.SetMultiSamples(0)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Force a starting random value
raMath = vtk.vtkMath()
raMath.RandomSeed(6)
# Generate random attributes on a plane
#
ps = vtk.vtkPlaneSource()
ps.SetXResolution(10)
ps.SetYResolution(10)
ag = vtk.vtkRandomAttributeGenerator()
ag.SetInputConnection(ps.GetOutputPort())
ag.GenerateAllDataOn()
ss = vtk.vtkSphereSource()
ss.SetPhiResolution(16)
ss.SetThetaResolution(32)
tg = vtk.vtkTensorGlyph()
tg.SetInputConnection(ag.GetOutputPort())
tg.SetSourceConnection(ss.GetOutputPort())
tg.SetScaleFactor(0.1)
tg.SetMaxScaleFactor(10)
tg.ClampScalingOn()
n = vtk.vtkPolyDataNormals()
n.SetInputConnection(tg.GetOutputPort())
cs = vtk.vtkConeSource()
cs.SetResolution(6)
glyph = vtk.vtkGlyph3D()
glyph.SetInputConnection(ag.GetOutputPort())
glyph.SetSourceConnection(cs.GetOutputPort())
glyph.SetScaleModeToDataScalingOff()
glyph.SetScaleFactor(0.05)
pdm = vtk.vtkPolyDataMapper()
pdm.SetInputConnection(n.GetOutputPort())
#pdm SetInputConnection [glyph GetOutputPort]
a = vtk.vtkActor()
a.SetMapper(pdm)
pm = vtk.vtkPolyDataMapper()
pm.SetInputConnection(ps.GetOutputPort())
pa = vtk.vtkActor()
pa.SetMapper(pm)
ren1.AddActor(a)
ren1.AddActor(pa)
ren1.SetBackground(0,0,0)
renWin.SetSize(300,300)
renWin.Render()
# prevent the tk window from showing up then start the event loop
# --- end of script --
#!/usr/bin/env python
# create a rendering window
renWin = vtk.vtkRenderWindow()
renWin.SetMultiSamples(0)
renWin.SetSize(200,200)
wavelet = vtk.vtkRTAnalyticSource()
wavelet.SetWholeExtent(-100,100,-100,100,0,0)
wavelet.SetCenter(0,0,0)
wavelet.SetMaximum(255)
wavelet.SetStandardDeviation(.5)
wavelet.SetXFreq(60)
wavelet.SetYFreq(30)
wavelet.SetZFreq(40)
wavelet.SetXMag(10)
wavelet.SetYMag(18)
wavelet.SetZMag(5)
wavelet.SetSubsampleRate(1)
warp = vtk.vtkWarpScalar()
warp.SetInputConnection(wavelet.GetOutputPort())
mapper = vtk.vtkDataSetMapper()
mapper.SetInputConnection(warp.GetOutputPort())
mapper.SetScalarRange(75,290)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renderer.ResetCamera()
renderer.GetActiveCamera().Elevation(-10)
renWin.AddRenderer(renderer)
# --- end of script --
#!/usr/bin/env python
# create pipeline
#
reader = vtk.vtkDataSetReader()
reader.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/RectGrid2.vtk")
reader.Update()
warper = vtk.vtkWarpVector()
warper.SetInputConnection(reader.GetOutputPort())
warper.SetScaleFactor(0.2)
extract = vtk.vtkExtractGrid()
extract.SetInputConnection(warper.GetOutputPort())
extract.SetVOI(0,100,0,100,7,15)
mapper = vtk.vtkDataSetMapper()
mapper.SetInputConnection(extract.GetOutputPort())
mapper.SetScalarRange(0.197813,0.710419)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# Graphics stuff
# Create the RenderWindow, Renderer and both Actors
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.SetMultiSamples(0)
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and size
#
ren1.AddActor(actor)
ren1.SetBackground(1,1,1)
renWin.SetSize(400,400)
cam1 = ren1.GetActiveCamera()
cam1.SetClippingRange(3.76213,10.712)
cam1.SetFocalPoint(-0.0842503,-0.136905,0.610234)
cam1.SetPosition(2.53813,2.2678,-5.22172)
cam1.SetViewUp(-0.241047,0.930635,0.275343)
iren.Initialize()
# render the image
#
# prevent the tk window from showing up then start the event loop
# --- end of script --
#!/usr/bin/env python
# create four cursors configured differently
cursor = vtk.vtkCursor2D()
cursor.SetModelBounds(15,45,15,45,0,0)
cursor.SetFocalPoint(30,30,0)
cursor.AllOff()
cursor.AxesOn()
cursor.OutlineOn()
cursorMapper = vtk.vtkPolyDataMapper2D()
cursorMapper.SetInputConnection(cursor.GetOutputPort())
cursorActor = vtk.vtkActor2D()
cursorActor.SetMapper(cursorMapper)
cursorActor.GetProperty().SetColor(1,0,0)
cursor2 = vtk.vtkCursor2D()
cursor2.SetModelBounds(75,105,15,45,0,0)
cursor2.SetFocalPoint(90,30,0)
cursor2.AllOff()
cursor2.AxesOn()
cursor2.OutlineOn()
cursor2.PointOn()
cursor2Mapper = vtk.vtkPolyDataMapper2D()
cursor2Mapper.SetInputConnection(cursor2.GetOutputPort())
cursor2Actor = vtk.vtkActor2D()
cursor2Actor.SetMapper(cursor2Mapper)
cursor2Actor.GetProperty().SetColor(0,1,0)
cursor3 = vtk.vtkCursor2D()
cursor3.SetModelBounds(15,45,75,105,0,0)
cursor3.SetFocalPoint(30,90,0)
cursor3.AllOff()
cursor3.AxesOn()
cursor3.OutlineOff()
cursor3.PointOn()
cursor3.SetRadius(3)
cursor3Mapper = vtk.vtkPolyDataMapper2D()
cursor3Mapper.SetInputConnection(cursor3.GetOutputPort())
cursor3Actor = vtk.vtkActor2D()
cursor3Actor.SetMapper(cursor3Mapper)
cursor3Actor.GetProperty().SetColor(0,1,0)
cursor4 = vtk.vtkCursor2D()
cursor4.SetModelBounds(75,105,75,105,0,0)
cursor4.SetFocalPoint(90,90,0)
cursor4.AllOff()
cursor4.AxesOn()
cursor4.SetRadius(0.0)
cursor4Mapper = vtk.vtkPolyDataMapper2D()
cursor4Mapper.SetInputConnection(cursor4.GetOutputPort())
cursor4Actor = vtk.vtkActor2D()
cursor4Actor.SetMapper(cursor4Mapper)
cursor4Actor.GetProperty().SetColor(1,0,0)
# rendering support
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# read data
ren1.AddActor(cursorActor)
ren1.AddActor(cursor2Actor)
ren1.AddActor(cursor3Actor)
ren1.AddActor(cursor4Actor)
ren1.SetBackground(0,0,0)
renWin.SetSize(120,120)
renWin.Render()
iren.Initialize()
# prevent the tk window from showing up then start the event loop
# --- end of script --
......@@ -19,3 +19,4 @@ add_test_python(earth.py Hybrid)
add_test_python(imageToPolyData.py Hybrid)
add_test_python(largeImageOffset.py Hybrid)
add_test_python(largeImageParallel.py Hybrid)
add_test_python(TestProcrustesRigidCentroid.py Hybrid)
#!/usr/bin/env python
sphere = vtk.vtkSphereSource()
# make two copies of the shape and distort them a little
transform1 = vtk.vtkTransform()
transform1.Translate(0.2,0.1,0.3)
transform1.Scale(1.3,1.1,0.8)
transform2 = vtk.vtkTransform()
transform2.Translate(0.3,0.7,0.1)
transform2.Scale(1.0,0.1,1.8)
transformer1 = vtk.vtkTransformPolyDataFilter()
transformer1.SetInputConnection(sphere.GetOutputPort())
transformer1.SetTransform(transform1)
transformer2 = vtk.vtkTransformPolyDataFilter()
transformer2.SetInputConnection(sphere.GetOutputPort())
transformer2.SetTransform(transform2)
# map these three shapes into the first renderer
map1a = vtk.vtkPolyDataMapper()
map1a.SetInputConnection(sphere.GetOutputPort())
Actor1a = vtk.vtkActor()
Actor1a.SetMapper(map1a)
Actor1a.GetProperty().SetDiffuseColor(1.0000,0.3882,0.2784)
map1b = vtk.vtkPolyDataMapper()
map1b.SetInputConnection(transformer1.GetOutputPort())
Actor1b = vtk.vtkActor()
Actor1b.SetMapper(map1b)
Actor1b.GetProperty().SetDiffuseColor(0.3882,1.0000,0.2784)
map1c = vtk.vtkPolyDataMapper()
map1c.SetInputConnection(transformer2.GetOutputPort())
Actor1c = vtk.vtkActor()
Actor1c.SetMapper(map1c)
Actor1c.GetProperty().SetDiffuseColor(0.3882,0.2784,1.0000)
group = vtk.vtkMultiBlockDataGroupFilter()
group.AddInputConnection(sphere.GetOutputPort())
group.AddInputConnection(transformer1.GetOutputPort())
group.AddInputConnection(transformer2.GetOutputPort())
# -- align the shapes using Procrustes (using SetModeToRigidBody) --
procrustes1 = vtk.vtkProcrustesAlignmentFilter()
procrustes1.SetInputConnection(group.GetOutputPort())
procrustes1.GetLandmarkTransform().SetModeToRigidBody()
procrustes1.StartFromCentroidOn()
procrustes1.Update()
# map the aligned shapes into the second renderer
map2a = vtk.vtkPolyDataMapper()
map2a.SetInputData