[vtkusers] Re: point picking question

Anja Ende anja.ende at googlemail.com
Thu Aug 31 13:08:40 EDT 2006


Ok, I figured out that the GetMapperPosition() was the answer to my
question. However, I have another problem now...

I included the following code in my left mouse button handler and it causes
a segmentation fault!!!

vtkRenderWindowInteractor *rwi = this->Interactor;
 if (rwi)
 {
           vtkPointPicker *picker = (vtkPointPicker *)rwi->GetPicker();
            picker->Pick(x, y, m_viewer->GetCurrentSlice(),
this->CurrentRenderer);

            std::cout << "PointId: " << picker->GetPointId() << "\n";
            std::cout.flush();
             if (picker->GetPointId() != -1)
             {
                        double * ptActual, *ptMapped;
                        picker->GetSelectionPoint(ptActual); // OK
                        picker->GetMapperPosition(ptMapped); // CRASHES!!!!!
                        std::cout.flush();
             }
 }

This is a bit crazy... I guess the mapper is not set. So, I thought I would
explicitly add a picker in my vtkImageViewer type class and I have the
following code where I set my interactor...

// rwi is the render window interactor

if (!this->m_interactor)
 {
      this->m_interactor = rwi;
      rwi->Register(this);
 }

vtkPointPicker * picker = vtkPointPicker::New();
picker->SetTolerance(0.005);
picker->AddPickList(m_actor2D);
picker->PickFromListOn();
rwi->SetPicker(picker);
picker->Delete();

However, now it picks nothing. The PointID is always -1. Please if someone
can help me solve this problem, I would be really grateful!

Thanks,
Anja

On 31/08/06, Anja Ende <anja.ende at googlemail.com> wrote:
>
> Hi everyone,
>
> I have a reslicer interface where I click on a 2D image and it reslices
> the volume at that point and returns me the slice.
>
> Now, I could have the image zoomed and I want to pick the point in the
> original image regardless of the zoom factor. Of course, I can probably do
> that by taking the current zoom factor into account but there might be round
> off errors, so I was wondering if there is a better way.
>
> I can get the points bu using vtkPointPicker class and that seems to work.
> However, I do not know what to do with those values as the reslicer will not
> accept those values.
>
> So, I was wondering if there was a way to pick points on the rendered 2D
> image (regardless of its zoom factor) that actually refers to the points in
> the original image size.
>
> Cheers and thanks,
>
> Anja
>
> Shamesless plug:
> ----------------------
> I actually have another open question. I still have not figured out the
> correct strategy for setting the output setting. So, if someone would be
> kind enough to help me with that
>
> http://public.kitware.com/pipermail/vtkusers/2006-August/086765.html
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060831/090c9da1/attachment.htm>


More information about the vtkusers mailing list