[vtkusers] To access scalar value using vtkPointpicker

Hamp Donald hampdonald at yahoo.com
Tue Jun 8 11:06:42 EDT 2004


Hi
    Please find below the code for vtkPointPicker. It
is working nicely in my PC. Can anyone suggest me how
to display the scalar values associated with points. 

Respond Please. 

Best Regards
Subhas 

// Define picking method
                                                      
                                                    
static void pickControl(void *arg)
{
float *selPt;
float *pickpos;
                                                      
                                                    
vtkRenderWindowInteractor *iren =
(vtkRenderWindowInteractor *)arg;
  vtkPointPicker *pointpicker = (vtkPointPicker
*)iren->GetPicker();
                                                      
                                                    
                                                      
                                                    
                                                      
                                                    
  selPt = pointpicker->GetSelectionPoint();
                                                      
                                                    
    cout<<"Screen location:"<<selPt[0]<<"
"<<selPt[1]<<"\n";
                                                      
                                                    
 if ( pointpicker->GetPointId() >= 0 )
    {
    pickpos = pointpicker->GetPickPosition();
                                                      
                                                    
    cout << "Point Id:" << pointpicker->GetPointId()
<< endl;
    cout<<"Point location:"<<pickpos[0]<<"
"<<pickpos[1]<<" "<<pickpos[2]<<"\n";

}

main()
 {

vtkPolyDataReader* face = vtkPolyDataReader::New();
//face->SetFileName("vrml.vtk");
face->SetFileName("general.vtk");
//face->SetFileName("decFace.vtk");
                                                      
                                                    
vtkPolyDataMapper* faceMapper  =
vtkPolyDataMapper::New();
faceMapper->SetInput(face->GetOutput());
faceMapper->SetScalarRange(0,0.2);
                                                      
                                                    
                                                      
                                                    
                                                      
                                                    
vtkActor* faceActor = vtkActor::New();
faceActor->SetMapper(faceMapper);
//faceActor->GetProperty()->SetColor(1.0, 0.49, 0.25);
// faceActor->GetProperty()->SetColor(0.5, 0.5, 1);
// faceActor->GetProperty()->SetOpacity(0.5);
                                                      
                                                    
vtkPointPicker *pointpicker = vtkPointPicker::New();  
                                                      
                                                  
                                                      
                                                    
                                                      
                                                    
                                                      
                                                    
vtkRenderer* ren1 = vtkRenderer::New();
vtkRenderWindow* renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren1);
vtkRenderWindowInteractor* iren =
vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
iren->SetPicker(pointpicker);
iren->SetEndPickMethod(pickControl, (void *)iren);
                                                      
                                                    
                                                      
                                                    
                                                      
                                                    
 vtkInteractorStyleTrackballCamera *style =
    vtkInteractorStyleTrackballCamera::New();
  iren->SetInteractorStyle(style);
                                                      
                                                    
ren1->AddActor(faceActor);
ren1->SetBackground(1, 1, 1);
renWin->SetSize(250, 250);
#define compile
vtkCamera* cam1 = vtkCamera::New();
#ifdef compile
cam1->SetClippingRange(0.0475572, 2.37786);
cam1->SetFocalPoint(0.052665, -0.129454, -0.0573973);
cam1->SetPosition(0.327637, -0.116299, -0.256418);
cam1->SetViewUp(-0.0225386, 0.999137, 0.034901);
#endif
ren1->SetActiveCamera(cam1);
                                                      
                                                    
                                                      
                                                    
iren->Initialize();
//renWin->Render();
iren->Start();
                                                      
                                                    
                                                      
                                                    
//clean up
face->Delete();
faceMapper->Delete();
faceActor->Delete();
ren1->Delete();
renWin->Delete();
iren->Delete();
cam1->Delete();
                                                      
                                                    
                                                      
                                                    
                                                      
                                                    
                                                      
                                                    
}
                                                      
                                                    



	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 



More information about the vtkusers mailing list