[vtkusers] Re: point picking question

Anja Ende anja.ende at googlemail.com
Thu Aug 31 17:53:53 EDT 2006


Hi!

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!

Thanks,

Anja



On 31/08/06, Obada Mahdi <omahdi at gmx.de> wrote:
>
> Hi Anja!
>
> On Aug 31, 2006, at 7:08 PM, Anja Ende wrote:
> > 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!!!!!
> [...]
>
> In case this is not pseudo-code with the "double *ptActual,
> *ptMapped;" added for clarification:
>
> It seems that you mixed up the semantics of those "Get...(double*)"
> calls a bit -- you can either do
>
> | double *ptActual, *ptMapped;
> |
> | ptActual = picker->GetSelectionPoint();
> | std::cout << ptActual[0] ...
>
> accessing some internal storage of the picker, or have it copy the
> return value to the location you specify as parameter, like
>
> | double ptActual[3], ptMapped[3];
> |
> | picker->GetSelectionPoint(ptActual);
> | std::cout << ptActual[0] ...
>
> In the code above, results are written to the address pointed to by
> `ptActual' and `ptMapped', which are undefined and might hold about
> any value at run time.
>
>
> HTH,
>
> Obada
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060831/a486a5d5/attachment.htm>


More information about the vtkusers mailing list