vtkContourWidget: contourwidget crashes when deleting nodes of the contour
vtk crashes when deleting nodes in a vtkContourWidget. This will happen only if the last node is picked while deleting it. For example, let's say I have 3 nodes in a contour. I keep deleting the nodes with the exisiting key binding "DELETE". When I reach the last node and if that node is picked while deleting. It will cause a crash.
Sample code:
#!/usr/bin/python3
import math
import sys
# noinspection PyUnresolvedReferences
import vtkmodules.vtkInteractionStyle
# noinspection PyUnresolvedReferences
import vtkmodules.vtkRenderingOpenGL2
from vtkmodules.vtkCommonColor import vtkNamedColors
from vtkmodules.vtkCommonCore import (
vtkCommand,
vtkPoints
)
from vtkmodules.vtkCommonDataModel import (
vtkCellArray,
vtkPolyData
)
from vtkmodules.vtkInteractionWidgets import (
vtkContourWidget,
vtkOrientedGlyphContourRepresentation,
vtkWidgetEvent
)
from vtkmodules.vtkRenderingCore import (
vtkRenderWindow,
vtkRenderWindowInteractor,
vtkRenderer
)
def main():
colors = vtkNamedColors()
# colors.SetColor('bkg', [0.1, 0.2, 0.4, 1.0])
# Create the RenderWindow, Renderer and both Actors
renderer = vtkRenderer()
renderer.SetBackground(colors.GetColor3d('MidnightBlue'))
renderWindow = vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindow.SetWindowName('ContourWidget')
renderWindow.SetSize(600, 600)
interactor = vtkRenderWindowInteractor()
interactor.SetRenderWindow(renderWindow)
contourRep = vtkOrientedGlyphContourRepresentation()
contourRep.GetLinesProperty().SetColor(colors.GetColor3d('Red'))
contourWidget = vtkContourWidget()
contourWidget.SetInteractor(interactor)
contourWidget.SetRepresentation(contourRep)
contourWidget.On()
contourWidget.SetFollowCursor(1)
contourWidget.SetAllowNodePicking(1)
contourWidget.Render()
renderer.ResetCamera()
renderWindow.Render()
interactor.Initialize()
interactor.Start()
if __name__ == '__main__':
main()
Edited by Mathieu Westphal (Kitware)