[vtkusers] Re: point picking question
Anja Ende
anja.ende at googlemail.com
Fri Sep 1 05:39:40 EDT 2006
Ok, it seems picking does not work with 2D actors!
The casting to vtkPointPicker was the one that was wrong...
// Problem line..
vtkPointPicker *picker = (vtkPointPicker *)rwi->GetPicker();
The picker is not an instance of vtkPointPicker... I found that out when I
called it to print itself and see which member gets executed...
Anyways, if someone knows a way to do picking on 2D actors, PLEASE let me
know!
Thanks,
Anja
On 01/09/06, Anja Ende <anja.ende at googlemail.com> wrote:
>
> 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/9b0df068/attachment.htm>
More information about the vtkusers
mailing list