Ok, it seems picking does not work with 2D actors!<br><br>The casting to vtkPointPicker was the one that was wrong...<br><br>// Problem line..<br><span class="q">vtkPointPicker *picker = (vtkPointPicker *)rwi->GetPicker();
<br><br>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...<br><br>Anyways, if someone knows a way to do picking on 2D actors, PLEASE let me know!
<br><br>Thanks,<br><br>Anja<br></span><br><div><span class="gmail_quote">On 01/09/06, <b class="gmail_sendername">Anja Ende</b> <<a href="mailto:anja.ende@googlemail.com">anja.ende@googlemail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>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!</div><div><span class="q"><br><br>vtkRenderWindowInteractor *rwi = this->Interactor;
<br> if (rwi)<br>
{<br> vtkPointPicker *picker = (vtkPointPicker *)rwi->GetPicker();<br> picker->Pick(x, y, m_viewer->GetCurrentSlice(), this->CurrentRenderer);<br>
<br> std::cout << "PointId: " << picker->GetPointId() << "\n";<br> std::cout.flush();<br> if (picker->GetPointId() != -1)
<br> {<br></span></div><div> if (picker->GetMapper()) // Also crashes<br> {<br> double ptMapped[3];<br> double ptActual[3];
<br> <br> picker->GetSelectionPoint(ptActual);<br> picker->GetMapperPosition(ptMapped); // crashes<br> <br> std::cout << ptActual[0] << ptActual[1] << std::endl;
<br> std::cout << ptMapped[0] << ptMapped[1] << std::endl;<br> <br> std::cout.flush();</div><div><span class="e" id="q_10d68a04d12bc0e0_3">
<br> }<br> }
<br> }<br><br><br><div><span class="gmail_quote">On 01/09/06, <b class="gmail_sendername">Obada Mahdi</b> <<a href="mailto:omahdi@gmx.de" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
omahdi@gmx.de</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Anja!<br><br>On 31.08.2006, at 23:53, Anja Ende wrote:<br>> Ahhhhhh...that must be it... I am so stupid! Thanks for pointing<br>> that out to me! I have to wait till tomorrow to try it out...<br>><br>> Wondering why
<br>> picker->GetSelectionPoint(ptActual);<br>> worked though...must have been an accident!<br><br>I would think so -- the trouble with unpredictable values is that<br>they are so<br>unpredictable, sometimes they even make sense. In C/C++, undefined
<br>local<br>variables sometimes resemble local/implicit variables or function call<br>parameters and such stuff, which were used before (like in "std::cout<br><< ..."<br>or so). If you happen to accidentally use such a variable, hitting a
<br>valid<br>pointer and thus not get an immediate segfault, this can be really<br>hard to<br>track down, as the manifestation of the problem hardly gives you any<br>hint<br>about what went wrong in the first place.<br><br>
So, in some sense, you are lucky to have a segfault -- and it is<br>nothing to be<br>ashamed about, such things happen to all of us, I dare say :-)<br><br>> Thanks,<br>><br>> Anja<br><br>You're welcome!<br><br><br>
Obada<br></blockquote></div><br>
</span></div></blockquote></div><br>