我有一个简单的VTK Python代码,它绘制了一个四面体:
# plot a tetrahedron
import numpy
import vtk
node_coords = numpy.array(
[
[1.0, 0.0, -1.0 / numpy.sqrt(8)],
[-0.5, +numpy.sqrt(3.0) / 2.0, -1.0 / numpy.sqrt(8)],
[-0.5, -numpy.sqrt(3.0) / 2.0, -1.0 / numpy.sqrt(8)],
[0.0, 0.0, numpy.sqrt(2.0) - 1.0 / numpy.sqrt(8)],
]
) / numpy.sqrt(3.0)
cells = numpy.array([[0, 1, 2, 3]])
cell_id = 0
line_width = 3.0
def get_line_actor(x0, x1, line_width=1.0):
source = vtk.vtkLineSource()
source.SetPoint1(x0)
source.SetPoint2(x1)
# mapper
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
# actor
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# color actor
actor.GetProperty().SetColor(0, 0, 0)
actor.GetProperty().SetLineWidth(line_width)
return actor
# Visualize
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
for ij in [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]]:
x0, x1 = node_coords[cells[cell_id][ij]]
renderer.AddActor(get_line_actor(x0, x1, line_width))
renderer.SetBackground(1.0, 1.0, 1.0)
renderWindow.Render()
renderWindowInteractor.Start()
我现在想为这段代码添加持续集成测试(它在无头环境中运行),但我得到的只是
Received 'aborted' signal
添加关闭窗口的代码
# renderWindowInteractor.Start()
render_window.Finalize()
del render_window, render_window_interactor
没有帮助。你知道吗
如何在无头环境中使用VTK?你知道吗
原来是
Render
调用使VTK抛出。对于单元测试,我可以注释掉那些行即使在无头环境中,代码的其余部分也将正确执行。你知道吗
相关问题 更多 >
编程相关推荐