[vtkusers] picking woes
    Mike Dresser 
    Michael-Dresser at mail.omrf.ouhsc.edu
       
    Fri Feb 15 10:46:34 EST 2002
    
    
  
Hello all.
I'm using texture maps on plane sources to visualize 3D datasets, in
MFC/VC++6, and having a problem with picking points.  
In the vtkMFCRenderView-derived View class, I use PreTranslateMessage to
intercept messages, here WM_LBUTTONUP (before sending it on to
vtkMFCRenderView), to launch a hardware pick using the code summarized
below, essentially as suggested by Robert Mitchell in Sept 2001.  The
problem I'm having is that it works well with a relatively small dataset (40
X 41 X 20) but with a larger dataset (512 X 512 X 40) the world coordinates
returned are consistently smaller than they should be, e. g., 73,73,12 when
they should be 255,255,43.  The problem first shows up in
vtkRenderer::ViewToWorld() when the viewpoint (which seems OK) is multiplied
by the perspective transform from the camera.  I have the same problem
whether I use WinNT, with a 3dLabs Oxygen GVX210, and using VTK4 from CVS
(Sept 2001) or Win98, with an ATI Rage ... card, using VTK4 from last week.
Also, I get the same results if I use software picking via vtkPointPicker.
code excerpt
---------------------------------------------------------------------------
BOOL COMRFMAJNView::PreTranslateMessage(MSG* pMsg) 
{
  if (m_bShowVoxelInfo)  {
    if (pMsg->message == WM_LBUTTONUP)  {
      vtkAssemblyPath *path = NULL;
      vtkAbstractPropPicker *picker = NULL;
      //call InteractorStyle's picker, as if 'p' was hit
      this->Trackball->OnChar(0,0,'p',0); 
      // if one of the image planes or the extracted surface is hit
      if (
(picker=vtkAbstractPropPicker::SafeDownCast(this->Interactor->GetPicker())))
{
          path = picker->GetPath();
      }
      //if a surface/actor has been hit, get the voxel intensity that is
associated
      if ( path != NULL ) {
        vtkWorldPointPicker* pPicker = (vtkWorldPointPicker*)
this->Interactor->GetPicker();
        //.............................
        float *pos;
        pos = pPicker->GetPickPosition();
        // get values from "pos", correct for problems at edges (negative
values, 
        // values outside extents) and report them
      }
    }//end if (pMsg . . .
  }//end if (m_bShowVoxelInfo)
  return vtkMFCRenderView::PreTranslateMessage(pMsg);
}
----------------------------------------------------------------------------
----------
Any helpful suggestions will be greatly appreciated.
Mike Dresser
dresserm at omrf.ouhsc.edu
    
    
More information about the vtkusers
mailing list