[vtkusers] Re: point picking question

Anja Ende anja.ende at googlemail.com
Fri Sep 1 05:05:38 EDT 2006


It seems that was not it! It still crashes!! The strange thing is that
calling the picker->GetMapper() also crashes. Here is the updated code!

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)
                    {
                        if (picker->GetMapper()) // Also crashes
                        {
                            double ptMapped[3];
                            double ptActual[3];

                            picker->GetSelectionPoint(ptActual);
                            picker->GetMapperPosition(ptMapped); // crashes

                            std::cout << ptActual[0] << ptActual[1] <<
std::endl;
                            std::cout << ptMapped[0] << ptMapped[1] <<
std::endl;

                            std::cout.flush();
                        }
                    }
                }


On 01/09/06, Obada Mahdi <omahdi at gmx.de> wrote:
>
> Hi Anja!
>
> On 31.08.2006, at 23:53, Anja Ende wrote:
> > Ahhhhhh...that must be it... I am so stupid! Thanks for pointing
> > that out to me! I have to wait till tomorrow to try it out...
> >
> > Wondering why
> > picker->GetSelectionPoint(ptActual);
> > worked though...must have been an accident!
>
> I would think so -- the trouble with unpredictable values is that
> they are so
> unpredictable, sometimes they even make sense.  In C/C++, undefined
> local
> variables sometimes resemble local/implicit variables or function call
> parameters and such stuff, which were used before (like in "std::cout
> << ..."
> or so).  If you happen to accidentally use such a variable, hitting a
> valid
> pointer and thus not get an immediate segfault, this can be really
> hard to
> track down, as the manifestation of the problem hardly gives you any
> hint
> about what went wrong in the first place.
>
> So, in some sense, you are lucky to have a segfault -- and it is
> nothing to be
> ashamed about, such things happen to all of us, I dare say :-)
>
> > Thanks,
> >
> > Anja
>
> You're welcome!
>
>
> Obada
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060901/5e92866d/attachment.htm>


More information about the vtkusers mailing list