<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Dear VTK Users,<br>
    I write you because I have troubles managing vtkAreaPicker and
    vtkRenderedAreaPicker to pick vtkOpenGLActor objects containing
    thousands vertices.<br>
    <br>
    => I am currently writing an application based on VTK 7.1 ( <a
      class="moz-txt-link-freetext"
      href="https://github.com/morphomuseum/ISE-MeshTools">https://github.com/morphomuseum/ISE-MeshTools</a>
    )<br>
    <br>
    If only one vtkOpenGLActor is rendered, I have no problem to pick
    it, no matter how "large" it is in terms of number of vertices, and
    no matter how complex it is in terms of morphology.<br>
    <br>
     But as soon as I have several vtkOpenGLActor objects rendered at
    the same time, vtkAreaPicker does not behave as I would have
    expected.<br>
    <br>
     <br>
    The expected behaviour would be as follows : <br>
    - one can open several surfaces (meshes) which are opened as
    vtkPolyData objects, which in turns are rendered as vtkOpenGLActor
    objects<br>
    - these objects can be "selected"/"unselected" using the an
    interactor style such as vtkInteractorStyleRubberBandPick.  The idea
    is that one will interact in a second step with all the "selected"
    objects (= with more than one single object at once).<br>
    <br>
    I have set up my interactor style following the example :<br>
    <a class="moz-txt-link-freetext"
      href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Picking/AreaPicking">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Picking/AreaPicking</a><br>
    <br>
    The pick callback function is as follows :<br>
    <pre class="de1"><span class="kw4">void</span> PickCallbackFunction<span class="br0">(</span>vtkObject<span class="sy2">*</span> caller,
                          <span class="kw4">long</span> <span class="kw4">unsigned</span> <span class="kw4">int</span> vtkNotUsed<span class="br0">(</span>eventId<span class="br0">)</span>,
                          <span class="kw4">void</span><span class="sy2">*</span> vtkNotUsed<span class="br0">(</span>clientData<span class="br0">)</span>,
                          <span class="kw4">void</span><span class="sy2">*</span> vtkNotUsed<span class="br0">(</span>callData<span class="br0">)</span><span class="br0">)</span>
<span class="br0">{</span>
  std<span class="sy4">::</span><span class="kw3">cout</span> <span class="sy1"><<</span> <span class="st0">"Pick."</span> <span class="sy1"><<</span> std<span class="sy4">::</span><span class="me2">endl</span><span class="sy4">;</span>
  vtkAreaPicker<span class="sy2">*</span> areaPicker <span class="sy1">=</span> <span class="kw2">static_cast</span><span class="sy1"><</span>vtkAreaPicker<span class="sy2">*</span><span class="sy1">></span><span class="br0">(</span>caller<span class="br0">)</span><span class="sy4">;</span>
  vtkProp3DCollection<span class="sy2">*</span> props <span class="sy1">=</span> areaPicker<span class="sy2">-</span><span class="sy1">></span>GetProp3Ds<span class="br0">(</span><span class="br0">)</span><span class="sy4">;</span>
 
  <span class="kw1">for</span><span class="br0">(</span>vtkIdType i <span class="sy1">=</span> <span class="nu0">0</span><span class="sy4">;</span> i <span class="sy1"><</span> props<span class="sy2">-</span><span class="sy1">></span>GetNumberOfItems<span class="br0">(</span><span class="br0">)</span><span class="sy4">;</span> i<span class="sy2">++</span><span class="br0">)</span>
    <span class="br0">{</span>
    vtkProp3D<span class="sy2">*</span> prop <span class="sy1">=</span> props<span class="sy2">-</span><span class="sy1">></span>GetNextProp3D<span class="br0">(</span><span class="br0">)</span><span class="sy4">;</span>
    std<span class="sy4">::</span><span class="kw3">cout</span> <span class="sy1"><<</span> <span class="st0">"Picked prop: "</span> <span class="sy1"><<</span> prop <span class="sy1"><<</span> std<span class="sy4">::</span><span class="me2">endl</span><span class="sy4">;</span>
    <span class="br0">}</span>
<span class="br0">}

</span></pre>
    As soon as I have added to the rendered several other vtkOpenGLActor
    objects containing thousands of vertices, I can not get the correct
    picked vtkPropr3D objects.<br>
    <br>
    The same thing arises if I use a vtkRenderedAreaPicker instead.<br>
    <br>
    <br>
    Here is an illustration of my issue : <a
      class="moz-txt-link-freetext"
      href="http://morphomuseum.com/img/vtkareapicker.jpg">http://morphomuseum.com/img/vtkareapicker.jpg</a><br>
    <br>
    Top : I have opened 5 different surface objects (mandible, maxillar,
    premaxillar, upper teeth and lower teeth)<br>
    Top left : I try to select the mandible (blue rectangle)<br>
    Top right : the pickCallBack function retrieves the wrong surface
    object (the maxillar => in the software I write, "selected"
    actors are drawn grey) <br>
    <br>
    Bottom : I have opened 1 mesh containing thousands of vertices
    (lower teeth) and I have set up 16 landmarks (green and orange
    spheres)<br>
    Bottom left : I try to pick the teeth mesh (blue rectangle).<br>
    Bottom right : nothing was selected (
    props->GetNumberOfItems()==0)<br>
    <br>
    <br>
    Many thanks in advance if you can help,<br>
    Best wishes,<br>
    Renaud<br>
    <div class="moz-signature">---------------------------------------------------------<br>
      <b>Dr. Renaud Lebrun</b><br>
      <p style="color:red">Institut des Sciences de l'Evolution</p>
      Université de Montpellier<br>
      Campus Triolet, bât. 22<br>
      Place Eugène Bataillon<br>
      34095 Montpellier cedex 5, FRANCE<br>
      Tél : +33 (0)4 67 14 32 60 <br>
      <a
href="mailto:renaud.lebrun@umontpellier.fr?Subject=X-Ray+%C2%B5CT+access"
        target="_top">renaud.Lebrun@umontpellier.fr</a><br>
      <a href="http://morphomuseum.com">MORPHOMUSEUM</a> </div>
  </body>
</html>