0
例如VTK上有http://www.vtk.org/Wiki/VTK/Examples/Python/Widgets/ContourWidget崩溃时开始对蟒蛇
我想没有任何变化运行的Python 3.4和7.0.0 VTK 7.1.1和这个非常例子,让蟒蛇这个官方VTK ContourWidget例子完全和默默地崩溃就行
contourWidget.Initialize(PD,1)
任何线索?
例如VTK上有http://www.vtk.org/Wiki/VTK/Examples/Python/Widgets/ContourWidget崩溃时开始对蟒蛇
我想没有任何变化运行的Python 3.4和7.0.0 VTK 7.1.1和这个非常例子,让蟒蛇这个官方VTK ContourWidget例子完全和默默地崩溃就行
contourWidget.Initialize(PD,1)
任何线索?
看来你应该在lines.InsertNextCell中使用索引对的vtkIdList。 此代码适用于我:
import vtk
import math
def mkVtkIdList(it):
vil = vtk.vtkIdList()
for i in it:
vil.InsertNextId(int(i))
return vil
if __name__ == '__main__':
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renderWindow)
renderer.SetBackground(0.1, 0.2, 0.4)
renderWindow.SetSize(600, 600)
contourRep = vtk.vtkOrientedGlyphContourRepresentation()
contourRep.GetLinesProperty().SetColor(1, 0, 0) # set color to red
contourWidget = vtk.vtkContourWidget()
contourWidget.SetInteractor(interactor)
contourWidget.SetRepresentation(contourRep)
contourWidget.On()
points = vtk.vtkPoints()
lines = vtk.vtkCellArray()
for i in range(0, 21):
angle = 2.0 * math.pi * i/20.0
points.InsertPoint(i, (0.1 * math.cos(angle), 0.1 * math.sin(angle), 0.0))
lines.InsertNextCell(mkVtkIdList([i, i+1]))
pd = vtk.vtkPolyData()
pd.SetPoints(points)
pd.SetLines(lines)
contourWidget.Initialize(pd, 1)
contourWidget.Render()
renderer.ResetCamera()
renderWindow.Render()
interactor.Initialize()
interactor.Start()
contourWidget.Off()