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();

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();

        // 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.
        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

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.