本文整理汇总了Python中vtk.test.Testing.getAbsImagePath方法的典型用法代码示例。如果您正苦于以下问题:Python Testing.getAbsImagePath方法的具体用法?Python Testing.getAbsImagePath怎么用?Python Testing.getAbsImagePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtk.test.Testing
的用法示例。
在下文中一共展示了Testing.getAbsImagePath方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testThreshold
# 需要导入模块: from vtk.test import Testing [as 别名]
# 或者: from vtk.test.Testing import getAbsImagePath [as 别名]
def testThreshold(self):
global args
writefiles = "SaveData" in args
renderer = vtk.vtkRenderer()
renwin = vtk.vtkRenderWindow()
renwin.AddRenderer(renderer)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renwin)
renwin.Render()
if "GPURender" in args:
vtk.vtkPistonMapper.InitCUDAGL(renwin)
src = vtk.vtkImageMandelbrotSource()
src.SetWholeExtent(0,10,0,10,0,10)
#scale and bias until piston's threshold understands origin and spacing
src.Update()
inputdata = src.GetOutput()
if "Normalize" in args:
testdata1 = inputdata.NewInstance()
testdata1.ShallowCopy(inputdata)
testdata1.SetSpacing(1,1,1)
testdata1.SetOrigin(0,0,0)
inputdata = testdata1
d2p = vtk.vtkDataSetToPiston()
d2p.SetInputData(inputdata)
#d2p.SetInputConnection(src.GetOutputPort())
threshF = vtk.vtkPistonThreshold()
threshF.SetInputConnection(d2p.GetOutputPort())
threshF.SetMinValue(0)
threshF.SetMaxValue(80)
p2d = vtk.vtkPistonToDataSet()
p2d.SetInputConnection(threshF.GetOutputPort())
p2d.SetOutputDataSetType(vtk.VTK_POLY_DATA)
if writefiles:
writeFile(p2d, "piston_threshold.vtk")
mapper = vtk.vtkPistonMapper()
mapper.SetInputConnection(threshF.GetOutputPort())
mapper.Update()
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer.AddActor(actor)
renderer.ResetCamera()
renwin.Render()
img_file = "TestThreshold.png"
Testing.compareImage(renwin, Testing.getAbsImagePath(img_file))
if Testing.isInteractive():
iren.Start()
示例2: testvtkTkRenderWidget
# 需要导入模块: from vtk.test import Testing [as 别名]
# 或者: from vtk.test.Testing import getAbsImagePath [as 别名]
def testvtkTkRenderWidget(self):
"Test if vtkTkRenderWidget works."
self.rw.Render()
self.root.update()
img_file = "TestTkRenderWidget.png"
Testing.compareImage(self.rw, Testing.getAbsImagePath(img_file))
Testing.interact()
示例3: testImportExport
# 需要导入模块: from vtk.test import Testing [as 别名]
# 或者: from vtk.test.Testing import getAbsImagePath [as 别名]
def testImportExport(self):
"Testing if images can be imported to and from numeric arrays."
imp = vtkImageImportFromArray()
exp = vtkImageExportToArray()
idiff = vtk.vtkImageDifference()
img_dir = Testing.getAbsImagePath("")
for i in glob.glob(os.path.join(img_dir, "*.png")):
# Putting the reader outside the loop causes bad problems.
reader = vtk.vtkPNGReader()
reader.SetFileName(i)
reader.Update()
# convert the image to a Numeric Array and convert it back
# to an image data.
exp.SetInputConnection(reader.GetOutputPort())
imp.SetArray(exp.GetArray())
# ensure there is no difference between orig image and the
# one we converted and un-converted.
idiff.SetInputConnection(imp.GetOutputPort())
idiff.SetImage(reader.GetOutput())
idiff.Update()
err = idiff.GetThresholdedError()
msg = "Test failed on image %s, with threshold "\
"error: %d"%(i, err)
self.assertEqual(err, 0.0, msg)
示例4: testvtkTkRenderWindowInteractor
# 需要导入模块: from vtk.test import Testing [as 别名]
# 或者: from vtk.test.Testing import getAbsImagePath [as 别名]
def testvtkTkRenderWindowInteractor(self):
"Test if vtkTkRenderWindowInteractor works."
self.tkrw.Start()
self.tkrw.Render()
self.root.update()
img_file = "TestTkRenderWindowInteractor.png"
Testing.compareImage(self.rw, Testing.getAbsImagePath(img_file))
Testing.interact()
示例5: testGlyphs
# 需要导入模块: from vtk.test import Testing [as 别名]
# 或者: from vtk.test.Testing import getAbsImagePath [as 别名]
def testGlyphs(self):
'''Test if the glyphs are created nicely.'''
reader = vtk.vtkDataSetReader()
data_file = os.path.join(Testing.VTK_DATA_ROOT, "Data", "tensors.vtk")
reader.SetFileName(data_file)
g1 = SimpleGlyph(reader)
g1.glyph.ColorGlyphsOff()
g1.Update()
g2 = SimpleGlyph(reader)
g2.glyph.ExtractEigenvaluesOff()
g2.Update()
g2.SetPosition((2.0, 0.0, 0.0))
g3 = SimpleGlyph(reader)
g3.glyph.SetColorModeToEigenvalues()
g3.glyph.ThreeGlyphsOn()
g3.Update()
g3.SetPosition((0.0, 2.0, 0.0))
g4 = SimpleGlyph(reader)
g4.glyph.SetColorModeToEigenvalues()
g4.glyph.ThreeGlyphsOn()
g4.glyph.SymmetricOn()
g4.Update()
g4.SetPosition((2.0, 2.0, 0.0))
# 6Components symetric tensor
g5 = SimpleGlyph(reader)
g5.glyph.SetInputArrayToProcess(0, 0, 0, 0, "symTensors1")
g5.SetPosition((4.0, 2.0, 0.0))
g5.Update()
ren = vtk.vtkRenderer()
for i in (g1, g2, g3, g4, g5):
for j in i.GetActors():
ren.AddActor(j)
ren.ResetCamera();
cam = ren.GetActiveCamera()
cam.Azimuth(-20)
cam.Elevation(20)
cam.Zoom(1.1)
ren.SetBackground(0.5, 0.5, 0.5)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.Render()
img_file = "TestTensorGlyph.png"
Testing.compareImage(renWin, Testing.getAbsImagePath(img_file))
Testing.interact()
示例6: DoIt
# 需要导入模块: from vtk.test import Testing [as 别名]
# 或者: from vtk.test.Testing import getAbsImagePath [as 别名]
def DoIt(self):
self.SetUp()
self.viewer.Render()
self.tkrw.Render()
self.root.update()
# If you want to interact and use the sliders etc,
# uncomment the following line.
# self.root.mainloop()
img_file = "cursor3D.png"
Testing.compareImage(self.viewer.GetRenderWindow(), Testing.getAbsImagePath(img_file))
示例7: DoIt
# 需要导入模块: from vtk.test import Testing [as 别名]
# 或者: from vtk.test.Testing import getAbsImagePath [as 别名]
def DoIt(self):
self.SetUp()
self.renWin.Render()
self.tkrw.Render()
self.root.update()
# If you want to interact and use the sliders etc,
# uncomment the following line.
#self.root.mainloop()
img_file = "squadViewer.png"
Testing.compareImage(self.renWin, Testing.getAbsImagePath(img_file))
Testing.interact()
示例8: testRendering
# 需要导入模块: from vtk.test import Testing [as 别名]
# 或者: from vtk.test.Testing import getAbsImagePath [as 别名]
def testRendering(self):
global args
renderer = vtk.vtkRenderer()
renwin = vtk.vtkRenderWindow()
renwin.AddRenderer(renderer)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renwin)
renwin.Render()
if "GPURender" in args:
print "Testing GPU direct render path"
vtk.vtkPistonMapper.InitCUDAGL(renwin)
else:
print "Testing CPU indirect render path"
src = vtk.vtkSphereSource()
d2p = vtk.vtkDataSetToPiston()
d2p.SetInputConnection(src.GetOutputPort())
mapper = vtk.vtkPistonMapper()
mapper.SetInputConnection(d2p.GetOutputPort())
mapper.Update() #TODO: shouldn't need this
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer.AddActor(actor)
renderer.ResetCamera()
renwin.Render()
img_file = "TestRendering.png"
Testing.compareImage(renwin, Testing.getAbsImagePath(img_file))
if Testing.isInteractive():
iren.Start()
示例9: testRasterEPS
# 需要导入模块: from vtk.test import Testing [as 别名]
# 或者: from vtk.test.Testing import getAbsImagePath [as 别名]
def testRasterEPS(self):
"""Test EPS output when Write3DPropsAsRasterImage is on."""
# Get a temporary file name. Set the extension to empty since
# the exporter appends a suitable extension.
tmp_eps = tempfile.mktemp('')
# Write an EPS file.
exp = vtk.vtkGL2PSExporter()
exp.SetRenderWindow(self.renWin)
exp.SetFilePrefix(tmp_eps)
# Turn off compression so PIL can read file.
exp.CompressOff()
exp.SetSortToOff()
exp.DrawBackgroundOn()
exp.Write3DPropsAsRasterImageOn()
exp.Write()
# Now read the EPS file using PIL.
tmp_eps += '.eps'
im = Image.open(tmp_eps)
# Get a temporary name for the PNG file.
tmp_png = tempfile.mktemp('.png')
im.save(tmp_png)
# Now read the saved image and compare it for the test.
png_r = vtk.vtkPNGReader()
png_r.SetFileName(tmp_png)
png_r.Update()
img = png_r.GetOutput()
# Cleanup. Do this first because if the test fails, an
# exception is raised and the temporary files won't be
# removed.
self._cleanup([tmp_eps, tmp_png])
img_file = "TestGL2PSExporter.png"
Testing.compareImageWithSavedImage(img,
Testing.getAbsImagePath(img_file))
# Interact if necessary.
Testing.interact()
示例10: testBug
# 需要导入模块: from vtk.test import Testing [as 别名]
# 或者: from vtk.test.Testing import getAbsImagePath [as 别名]
#.........这里部分代码省略.........
# **************************************************
spacing = img_data.GetSpacing()
sx, sy, sz = spacing
origin = img_data.GetOrigin()
ox, oy, oz = origin
# An outline is shown for context.
outline = vtk.vtkOutlineFilter()
outline.SetInput(img_data)
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
# The shared picker enables us to use 3 planes at one time
# and gets the picking order right
picker = vtk.vtkCellPicker()
picker.SetTolerance(0.005)
# The 3 image plane widgets are used to probe the dataset.
planeWidgetX = vtk.vtkImagePlaneWidget()
planeWidgetX.DisplayTextOn()
planeWidgetX.SetInput(img_data)
planeWidgetX.SetPlaneOrientationToXAxes()
planeWidgetX.SetSliceIndex(32)
planeWidgetX.SetPicker(picker)
planeWidgetX.SetKeyPressActivationValue("x")
prop1 = planeWidgetX.GetPlaneProperty()
prop1.SetColor(1, 0, 0)
planeWidgetY = vtk.vtkImagePlaneWidget()
planeWidgetY.DisplayTextOn()
planeWidgetY.SetInput(img_data)
planeWidgetY.SetPlaneOrientationToYAxes()
planeWidgetY.SetSliceIndex(32)
planeWidgetY.SetPicker(picker)
planeWidgetY.SetKeyPressActivationValue("y")
prop2 = planeWidgetY.GetPlaneProperty()
prop2.SetColor(1, 1, 0)
planeWidgetY.SetLookupTable(planeWidgetX.GetLookupTable())
# for the z-slice, turn off texture interpolation:
# interpolation is now nearest neighbour, to demonstrate
# cross-hair cursor snapping to pixel centers
planeWidgetZ = vtk.vtkImagePlaneWidget()
planeWidgetZ.DisplayTextOn()
planeWidgetZ.SetInput(img_data)
planeWidgetZ.SetPlaneOrientationToZAxes()
planeWidgetZ.SetSliceIndex(46)
planeWidgetZ.SetPicker(picker)
planeWidgetZ.SetKeyPressActivationValue("z")
prop3 = planeWidgetZ.GetPlaneProperty()
prop3.SetColor(0, 0, 1)
planeWidgetZ.SetLookupTable(planeWidgetX.GetLookupTable())
# Create the RenderWindow and Renderer
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
# Add the outline actor to the renderer, set the background
# color and size
ren.AddActor(outlineActor)
renWin.SetSize(600, 600)
ren.SetBackground(0.1, 0.1, 0.2)
current_widget = planeWidgetZ
mode_widget = planeWidgetZ
# Set the interactor for the widgets
iact = vtk.vtkRenderWindowInteractor()
iact.SetRenderWindow(renWin)
planeWidgetX.SetInteractor(iact)
planeWidgetX.On()
planeWidgetY.SetInteractor(iact)
planeWidgetY.On()
planeWidgetZ.SetInteractor(iact)
planeWidgetZ.On()
# Create an initial interesting view
ren.ResetCamera();
cam1 = ren.GetActiveCamera()
cam1.Elevation(110)
cam1.SetViewUp(0, 0, -1)
cam1.Azimuth(45)
ren.ResetCameraClippingRange()
iact.Initialize()
renWin.Render()
# Compare the images and test.
img_file = "TestImagePlaneWidget.png"
Testing.compareImage(renWin, Testing.getAbsImagePath(img_file))
# Interact if necessary.
if Testing.isInteractive():
iact.Start()
示例11: testImagePlaneWidget
# 需要导入模块: from vtk.test import Testing [as 别名]
# 或者: from vtk.test.Testing import getAbsImagePath [as 别名]
#.........这里部分代码省略.........
picker.SetTolerance(0.005)
# The 3 image plane widgets are used to probe the dataset.
planeWidgetX = vtk.vtkImagePlaneWidget()
planeWidgetX.DisplayTextOn()
planeWidgetX.SetInputData(img_data)
planeWidgetX.SetPlaneOrientationToXAxes()
planeWidgetX.SetSliceIndex(32)
planeWidgetX.SetPicker(picker)
planeWidgetX.SetKeyPressActivationValue("x")
prop1 = planeWidgetX.GetPlaneProperty()
prop1.SetColor(1, 0, 0)
planeWidgetY = vtk.vtkImagePlaneWidget()
planeWidgetY.DisplayTextOn()
planeWidgetY.SetInputData(img_data)
planeWidgetY.SetPlaneOrientationToYAxes()
planeWidgetY.SetSliceIndex(32)
planeWidgetY.SetPicker(picker)
planeWidgetY.SetKeyPressActivationValue("y")
prop2 = planeWidgetY.GetPlaneProperty()
prop2.SetColor(1, 1, 0)
planeWidgetY.SetLookupTable(planeWidgetX.GetLookupTable())
# for the z-slice, turn off texture interpolation:
# interpolation is now nearest neighbour, to demonstrate
# cross-hair cursor snapping to pixel centers
planeWidgetZ = vtk.vtkImagePlaneWidget()
planeWidgetZ.DisplayTextOn()
planeWidgetZ.SetInputData(img_data)
planeWidgetZ.SetPlaneOrientationToZAxes()
planeWidgetZ.SetSliceIndex(46)
planeWidgetZ.SetPicker(picker)
planeWidgetZ.SetKeyPressActivationValue("z")
prop3 = planeWidgetZ.GetPlaneProperty()
prop3.SetColor(0, 0, 1)
planeWidgetZ.SetLookupTable(planeWidgetX.GetLookupTable())
# Now create another actor with an opacity < 1 and with some
# scalars.
p = vtk.vtkPolyData()
pts = vtk.vtkPoints()
pts.InsertNextPoint((0,0,0))
sc = vtk.vtkFloatArray()
sc.InsertNextValue(1.0)
p.SetPoints(pts)
p.GetPointData().SetScalars(sc)
m = vtk.vtkPolyDataMapper()
m.SetInputData(p)
# Share the lookup table of the widgets.
m.SetLookupTable(planeWidgetX.GetLookupTable())
m.UseLookupTableScalarRangeOn()
dummyActor = vtk.vtkActor()
dummyActor.SetMapper(m)
dummyActor.GetProperty().SetOpacity(0.0)
# Create the RenderWindow and Renderer
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.SetMultiSamples(0)
renWin.AddRenderer(ren)
# Add the dummy actor.
ren.AddActor(dummyActor)
# Add the outline actor to the renderer, set the background
# color and size
ren.AddActor(outlineActor)
renWin.SetSize(600, 600)
ren.SetBackground(0.1, 0.1, 0.2)
current_widget = planeWidgetZ
mode_widget = planeWidgetZ
# Set the interactor for the widgets
iact = vtk.vtkRenderWindowInteractor()
iact.SetRenderWindow(renWin)
planeWidgetX.SetInteractor(iact)
planeWidgetX.On()
planeWidgetY.SetInteractor(iact)
planeWidgetY.On()
planeWidgetZ.SetInteractor(iact)
planeWidgetZ.On()
# Create an initial interesting view
ren.ResetCamera();
cam1 = ren.GetActiveCamera()
cam1.Elevation(110)
cam1.SetViewUp(0, 0, -1)
cam1.Azimuth(45)
ren.ResetCameraClippingRange()
iact.Initialize()
renWin.Render()
# Compare the images and test.
img_file = "TestImagePlaneWidget.png"
Testing.compareImage(renWin, Testing.getAbsImagePath(img_file))
# Interact if necessary.
if Testing.isInteractive():
iact.Start()
示例12: parseArgs
# 需要导入模块: from vtk.test import Testing [as 别名]
# 或者: from vtk.test.Testing import getAbsImagePath [as 别名]
mapper.Update() #TODO why is this necessary
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer.AddActor(actor)
widget = vtk.vtkImplicitPlaneWidget()
widget.PlaceWidget(bounds)
widget.SetOrigin([plane.GetOrigin()[x] for x in 0,1,2])
widget.SetNormal([plane.GetNormal()[x] for x in 0,1,2])
widget.SetInteractor(iren)
widget.AddObserver("InteractionEvent", widgetCallBack)
widget.SetEnabled(1)
widget.DrawPlaneOff()
renderer.ResetCamera()
renwin.Render()
img_file = "TestSlice.png"
Testing.compareImage(renwin, Testing.getAbsImagePath(img_file))
if Testing.isInteractive():
widget.DrawPlaneOn()
iren.Start()
if __name__ == "__main__":
global args
args = parseArgs()
Testing.main([(TestSlice, 'test')])
示例13: testGlyphs
# 需要导入模块: from vtk.test import Testing [as 别名]
# 或者: from vtk.test.Testing import getAbsImagePath [as 别名]
def testGlyphs(self):
"""Test if texturing of the glyphs works correctly."""
# The Glyph
cs = vtk.vtkCubeSource()
cs.SetXLength(2.0); cs.SetYLength(1.0); cs.SetZLength(0.5)
# Create input point data.
pts = vtk.vtkPoints()
pts.InsertPoint(0, (1,1,1))
pts.InsertPoint(1, (0,0,0))
pts.InsertPoint(2, (-1,-1,-1))
polys = vtk.vtkCellArray()
polys.InsertNextCell(1)
polys.InsertCellPoint(0)
polys.InsertNextCell(1)
polys.InsertCellPoint(1)
polys.InsertNextCell(1)
polys.InsertCellPoint(2)
pd = vtk.vtkPolyData()
pd.SetPoints(pts)
pd.SetPolys(polys)
# Orient the glyphs as per vectors.
vec = vtk.vtkFloatArray()
vec.SetNumberOfComponents(3)
vec.InsertTuple3(0, 1, 0, 0)
vec.InsertTuple3(1, 0, 1, 0)
vec.InsertTuple3(2, 0, 0, 1)
pd.GetPointData().SetVectors(vec)
# The glyph filter.
g = vtk.vtkGlyph3D()
g.SetScaleModeToDataScalingOff()
g.SetVectorModeToUseVector()
g.SetInput(pd)
g.SetSource(cs.GetOutput())
m = vtk.vtkPolyDataMapper()
m.SetInputConnection(g.GetOutputPort())
a = vtk.vtkActor()
a.SetMapper(m)
# The texture.
img_file = os.path.join(Testing.VTK_DATA_ROOT, "Data",
"masonry.bmp")
img_r = vtk.vtkBMPReader()
img_r.SetFileName(img_file)
t = vtk.vtkTexture()
t.SetInputConnection(img_r.GetOutputPort())
t.InterpolateOn()
a.SetTexture(t)
# Renderer, RenderWindow etc.
ren = vtk.vtkRenderer()
ren.SetBackground(0.5, 0.5, 0.5)
ren.AddActor(a)
ren.ResetCamera();
cam = ren.GetActiveCamera()
cam.Azimuth(-90)
cam.Zoom(1.4)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
rwi = vtk.vtkRenderWindowInteractor()
rwi.SetRenderWindow(renWin)
rwi.Initialize()
rwi.Render()
# Compare the images and test.
img_file = "TestTextureGlyph.png"
Testing.compareImage(renWin, Testing.getAbsImagePath(img_file))
# Interact if necessary.
if Testing.isInteractive():
rwi.Start()