Just run the following codes, you’ll get a nullptr issue. If the PointHandleRepresentation2D doesn’t have an input cursor type, which means , just comment this line code : handleRep->SetCursorShape(cursor2D->GetOutput()); ,no crash. Can VTK experts shed some lights on this? Thanks!
int main(int, char *[])
{
// Create the RenderWindow, Renderer and both Actors
//
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren1);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
vtkRegularPolygonSource *cursor2D = vtkRegularPolygonSource::New();
cursor2D->SetNumberOfSides(20);
cursor2D->GeneratePolygonOn();
cursor2D->SetRadius(23);
vtkPointHandleRepresentation2D *handleRep = vtkPointHandleRepresentation2D::New();
double *pos = new double[3]{ 80, 80, 40 };
handleRep->SetWorldPosition(pos);
handleRep->ActiveRepresentationOn();
handleRep->PickableOn();
handleRep->SetHandleSize(18);
handleRep->SetCursorShape(cursor2D->GetOutput());
vtkHandleWidget *handleWidget = vtkHandleWidget::New();
handleWidget->SetInteractor(iren);
handleWidget->SetRepresentation(handleRep);
ren1->SetBackground(0.1, 0.2, 0.4);
renWin->SetSize(300, 300);
handleWidget->ProcessEventsOn();
handleWidget->On();
iren->Initialize();
renWin->Render();
//iren->Start();
return EXIT_SUCCESS;
}