[vtkusers] Re: point picking question
Obada Mahdi
omahdi at gmx.de
Thu Aug 31 13:56:22 EDT 2006
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
More information about the vtkusers
mailing list