Get PointID with PointPicker in Polydata

Hi everybody,

I currently have some problems concerning the pointPicker in vtk. I have a dataset in polydata, which I visualize as points in a qvtk-widget as part of a qt-framework.
Here, I define:
// point Picker (picks the points behind the cursor)
vtkSmartPointer pointPicker = vtkSmartPointer::New();
pointPicker->SetTolerance(0.01);
this->qvtkWidget->GetRenderWindow()->GetInteractor()->SetPicker(pointPicker);

in the definition of the interactorstyle (in my case vtkInteractorStyleRubberBandPick) I go on with the picker implementation:

virtual void OnLeftButtonUp() override
{
  if(startpointselection == true)
  {
        // point Picker (picks the points behind the cursor)
        vtkSmartPointer<vtkPointPicker> pointPicker = vtkSmartPointer<vtkPointPicker>::New();
        pointPicker->SetTolerance(0.01);
        (this->GetInteractor())->SetPicker(pointPicker);

        // Pick a point
        pointPicker->Pick((this->GetInteractor())->GetEventPosition()[0], // x-coordinate in window coordinates
                          (this->GetInteractor())->GetEventPosition()[1], // y-coordinate in window coordinates
                          0,  // always zero.
                          (this->GetInteractor())->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
        double* worldPosition = pointPicker->GetPickPosition();
        qDebug() << "Position " << worldPosition[0] << "   " << worldPosition[1] << "   " << worldPosition[2];

        // Get point ID
        auto index = static_cast<vtkPointPicker*>(this->GetInteractor()->GetPicker())->GetPointId();
} 
// Forward events
    vtkInteractorStyleRubberBandPick::OnLeftButtonUp();

I get some values for the point picker, but I never get a pointID (only -1). Does anybody know, what might be the problem?

Have you tried to use a few magnitudes larger tolerance value?

Please use “preformatted text” option for including source code in your post. The way it is included now, the smart pointer type is not visible due to the class name is mistaken for an HTML tag.