[vtkusers] Cell Picking in Java

Antoine Boivin a.boivin at m2m-ndt.com
Tue May 24 11:00:36 EDT 2005


You can use this :

public void mouseClicked(MouseEvent e){
    vtkPropPicker pickActor = new vtkPropPicker();

    pickActor.PickProp(

        e.getX(),

        renWin.GetRenderWindow().GetSize()[1] - e.getY,

        renWin.GetRenderer());

    vtkActor actorPicked = pickActor.GetActor();

    if (actorPicked == yourActor) {

        vtkCellPicker pickCell = new vtkCellPicker();

        pickCell.Pick(

            e.getX(),

            renWin.GetRenderWindow().GetSize()[1] - e.getY(),

            0,

            renWin.GetRenderer());

        System.out.println(pickCell.GetCellId());

    }

}



renWin is your vtkPanel

yourActor is the actor you want to pick



You don't need to use a vtkRenderWindowInteractor 

the vtkPanel make the same thing.



  ----- Original Message ----- 
  From: alban desbos 
  To: vtkusers at vtk.org 
  Sent: Tuesday, May 24, 2005 2:23 PM
  Subject: [vtkusers] Cell Picking in Java


  Hi,



  I have a problem with the cell picking in Java.

  When I click with the mouse, I want to know the cell Id, but I often get a wrong result.

  I tried with different tolerance values but it's still the same thing.

  If someone know how to use vtkPicker with Java. Thank you in advance.

  Alban



  //renWin is a vtkPanel

  iren = new vtkRenderWindowInteractor();
  iren.SetRenderWindow(renWin.GetRenderWindow());

  ...

  public void mouseClicked(MouseEvent e) {

     picker = new vtkCellPicker();
     iren.SetPicker(picker); //iren
     picker.SetTolerance(0.01);
     picker.Pick(e.getX(), e.getY(), 0, renWin.GetRenderer());
     System.out.println(picker.GetCellId());
   }



  La puissance n’est pas innée : elle se construit. Cliquez ici pour découvrir Nike Free !






------------------------------------------------------------------------------


  _______________________________________________
  This is the private VTK discussion list. 
  Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
  Follow this link to subscribe/unsubscribe:
  http://www.vtk.org/mailman/listinfo/vtkusers


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050524/3ef72b71/attachment.htm>


More information about the vtkusers mailing list