[vtkusers] Problem with vtkPointPicker

christine.schaller at arcor.de christine.schaller at arcor.de
Thu Nov 18 05:50:43 EST 2004


Hi all!

I've got a problem with vtkPointPicker:
On the one side of my vtkPolyData vtkPointPicker gives the correct results, but when I rotate the actor 180° and try to pick there, the vtkPicker returns points on the back of the actor!

As far as I know, the vtkPointPicker throws a line from the current cameraPosition to the picked point in actorcoordinates and returns that point, that is nearest to the cameraPosition and within a userdefined threshold. Does rotate() change the cameraPosition or does it rotate the actor? But in either case the vtkPointPicker should work correctly.

I know that there was a discussion about exactly this problem about half a year ago, but I couldn't extract enough information as to solve the problem.

Anyone out there to give a hint? I'd really appreciate any help.

Best regards
Chris
___________________________________
Here are the relevant parts of my code:

vtkCamera *cam1 = ren1->GetActiveCamera();
cam1->Zoom(1.5);
cam1->SetPosition(0.0, 0.0, -10.0);
ren1->ResetCameraClippingRange();         
ren1->ResetCamera();

the picking operation is defined in my own subclass of vtkInteractorStyle:

void InteractorStylePick::pick(int x, int y)
{
    if (CurrentRenderer==NULL || interactionProp == NULL)
    {
        return;
    }
    
picker->Pick(x, y, 0.0, this->CurrentRenderer);       
    if (picker->GetPointId() != -1)
    {
        ++currentId; //a counter of the number of picked points
        selectedPoints[picker->GetPointId()] = currentId; // the picked PointID is stored in a std::map (to avoid double selection)
        double dataPoints[3];
        picker->GetDataSet()->GetPoint(picker->GetPointId(), dataPoints);
        pts->InsertNextPoint(dataPoints);
        ca->InsertNextCell(1);
        ca->InsertCellPoint(currentId);
        pd->SetPoints(pts);
        pd->SetVerts(ca);
                
        pd->Modified();
        vtkPolyDataMapper *m = vtkPolyDataMapper::New();
        m->SetInput(pd);
        
        a->SetMapper(m);
        a->GetProperty()->SetPointSize(4);
        a->GetProperty()->SetColor(1.0, 0.0, 0.0);
        picker->GetRenderer()->AddActor(a);
        this->Interactor->Render();
        
--------------------------------------------------------------------------------------



More information about the vtkusers mailing list