I'm creating a 3D tracing application to get polygonal models from 3D
Dicom images. I'm able to click points and create contour lines between
those points. I'm now trying to connect points between the contour
lines to create a 3D mesh. I have a single vtkPolyData object that
contains all the points/cells/lines. My problem is that the pick event
returns a cell id of 0 most of the time, and always crashes eventually
when doing the Pick().<br>
<br>Here is the code from the picker (I created it as an observer on a vtkImagePlaneWidget):<br><br> vtkRenderer *m_ren1,<br>wxVTKRenderWindowInteractor *m_vtkWindow,<br><br>void ObserverMousePicker::Execute(<div id=":1nw" class="ii gt">
vtkObject *caller, unsigned long event, void*) <br>
{<br> double *p;<br> vtkIdType pid;<br> frame->cellPicker->Pick(m_vtkWindow->GetEventPosition()[0], m_vtkWindow->GetEventPosition()[1], 0.0, m_ren1);<br> vtkIdType cid = frame->cellPicker->GetCellId();<br>
<br> /* get the current cursor position and create a new point */<br> p = m_planeWidgetZ->GetCurrentCursorPosition();<br> pid = m_points->InsertNextPoint(p);<br> <br> /* check if were creating a new contour */<br>
if (frame->newContour) {<br> log->WriteLog("This should be a new contour");<br> frame->newContour = false;<br> }<br> else { /* otherwise connect the current and previous points */<br>
if (m_points->GetNumberOfPoints() > 1) {<br> frame->lines->InsertNextCell(2);<br> frame->lines->InsertCellPoint(pid-1);<br> log->WriteLog(wxString::Format("Inserted cell %d",pid-1));<br>
frame->lines->InsertCellPoint(pid);<br> log->WriteLog(wxString::Format("Inserted cell %d",pid));<br> }<br> }<br><br> /* insert the next cell in the poly and draw it */<br>
m_conn->InsertNextCell(1, &pid);<br> m_poly->Modified();<br> m_vtkWindow->Render();<br><br> log->WriteLog(wxString::Format("%f\t%f\t%f", p[0], p[1], p[2]));<br>}<br><br>Again,
it almost always picks a cell ID of zero, even when I click in the same
general spot repeatedly (maybe a tolerance thing?). More problematic is
that it always crashes at the Pick() function if I click enough times.</div>