[vtkusers] Re: point picking question

Obada Mahdi omahdi at gmx.de
Fri Sep 1 09:12:23 EDT 2006


Hi Anja!

On Sep 1, 2006, at 11:39 AM, Anja Ende wrote:
> 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!

Yikes!  I was quite confident that we'd figured it out.

> 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...

The recommended way to do this in VTK is to use the "SafeDownCast()"  
static method that is defined by each class:

| vtkPointPicker *picker = vtkPointPicker::SafeDownCast(rwi->GetPicker 
());
|
| if ( picker == NULL )
|   // didn't work, either rwi->Picker() returned `NULL', or it is  
not compatible to `vtkPointPicker'

I should have mentioned that before, but I did not think it was  
relevant.  Oh, well...

> Anyways, if someone knows a way to do picking on 2D actors, PLEASE  
> let me know!

I do not know much about that, but a quick look into the vtkPicker  
code suggests that vtkPicker and subclasses are designed for  
vtkProp3D-derived actors only.

Maybe that means vtkWorldPointPicker and by-hand computation --  
hopefully someone else on the list knows more about that.


Regards

Obada
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060901/ed5428d2/attachment.htm>


More information about the vtkusers mailing list