[vtkusers] Picking

Jonathan Bailleul Jonathan.Bailleul at greyc.ismra.fr
Mon Mar 31 03:36:34 EST 2003


Dear all, 


I am really pleased to see that question debated, since I was just about
to post about it. I also need to visualize interactively a vtk mesh and
to retrieve with the mouse the coordinates of a selected mesh point - I
mean the coordinates such as appearing in the vtk file.

The only question about the last message is how to insert the provided
code into a standard visualization code? I imagine that the selectpoint
method must be attached with a mouse event one, but since I'm pretty
limited with these aspects, maybe could you enlighten my doubts with
limited efforts?  :)


Here is some visualisation code that can serve as a backbone for such
modification: http://www.greyc.ismra.fr/~bailleul/These/picker.cc


Many thanks in advance!!






Denis Shamonin wrote:
> 
> ramu chandran wrote:
> 
> > Hello Users,
> >                Can somebody please tell me how to pick a point upon
> > mouse click. I get X and Y coordinate of the window upon mouseClick.
> > now how do I pick the particular point of the 3D object using these
> > two coordinates. I tried using vtkPointPicker, but its not working
> > properly. A small example code will be of great help. I am running out
> > of time. please somebody help me.
> 
> I think this can help you a little :)
> ==================================================
> 
> MyClass::MyClass()
> {
> picker = vtkCellPicker::New();
> }
> 
> void MyClass::SelectPoint(int X, int Y)
> {
>   float Point[3];
>     if(PickPoint(X,Y,Point))
>       {
>       cout<<"Point("<<Point[0]<<","<<Point[1]<<","<<Point[2]<<")\n";
>       renwin->Render();
>       }
> }
> 
> int MyClass::PickPoint(int X,int Y,float Point[3])
> {
>   float *pos;
> 
>   int result = picker->Pick((float)X,(float)Y,0.0,ren);
>   if (result)
>     {
>     pos = picker->GetPickPosition();
>     for(int i=0;i<3;i++)
>           Point[i] = pos[i];
>     return 1;
>     }
> 
>   return 0;
> }
> 
> --
> Denis Shamonin
> Address       : Section Computational Science
>                 University of Amsterdam
>                 Kruislaan 403, 1098 SJ Amsterdam
>                 the Netherlands
> 
> E-mail        : dshamoni at science.uva.nl
> URL           : http://www.science.uva.nl/~dshamoni/
> 
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers

-- 
-----------------------------------
Jonathan BAILLEUL, Doctorant
GREYC Image - Université de Caen 
http://www.greyc.ismra.fr/~bailleul



More information about the vtkusers mailing list