<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello there!<div class=""><br class=""></div><div class="">I use VTK 6.3 in a project for my thesis in an Qt desktop application.</div><div class=""><br class=""></div><div class="">I am storing Pointclouds and do some manipulation, calculating hulls, etc.</div><div class="">For the hulls I display some vtkLines in an extra vtkActor and wanted to create a possiblity to modify the polygon.</div><div class=""><br class=""></div><div class="">Therfore i want to be able to move points AND want to pick lines and create a new Point on the line to be able to move that one to.</div><div class=""><br class=""></div><div class="">So I wanted to use the <font face="Courier New" class="">vtkCellPicker</font> to pick the lines (which works quite well so far …).</div><div class=""><br class=""></div><div class="">Since I needed a ContextMenu in Qt I manipulated the MouseEvents and use them allready in the Qt MainWindow. Like this: <a href="https://www.vtk.org/Wiki/VTK/Examples/Cxx/Qt/EventQtSlotConnect" class="">https://www.vtk.org/Wiki/VTK/Examples/Cxx/Qt/EventQtSlotConnect</a></div><div class=""><br class=""></div><div class="">In my Code I want to detect a <font face="Courier New" class="">vtkLine</font> with this <font face="Courier New" class="">vtkCellPicker</font>, like this:</div><div class=""><br class=""></div><div class=""><div class=""><font face="PT Mono" class="">m_picker->Pick(x, y, 0, m_mainStyle->GetDefaultRenderer());</font></div><div class=""><font face="PT Mono" class="">long l = m_cicker->GetCellId();</font></div><div class=""><font face="PT Mono" class="">if(l > 0)</font></div><div class=""><font face="PT Mono" class="">{</font></div><div class=""><font face="PT Mono" class="">  vtkSmartPointer<vtkActor> actor = m_picker->GetActor();</font></div><div class=""><font face="PT Mono" class="">  long O = actor->GetMapper()->GetInput()->GetCellType(l);</font></div><div class=""><font face="PT Mono" class=""><br class=""></font></div><div class=""><font face="PT Mono" class="">  if(O == 3)</font></div><div class=""><font face="PT Mono" class="">  {</font></div><div class=""><font face="PT Mono" class="">    vtkSmartPointer<vtkLine> line = vtkLine::SafeDownCast(actor->GetMapper()->GetInput()->GetCell(l));</font></div><div class=""><font face="PT Mono" class="">    vtkSmartPointer<vtkPoints> points = line->GetPoints();</font></div><div class=""><font face="PT Mono" class="">    double p[3];</font></div><div class=""><font face="PT Mono" class="">    if(points->GetNumberOfPoints() > 0)</font></div><div class=""><font face="PT Mono" class="">    {</font></div><div class=""><font face="PT Mono" class="">      for(int i = 0; i < points->GetNumberOfPoints(); i++)</font></div><div class=""><font face="PT Mono" class="">      {</font></div><div class=""><font face="PT Mono" class="">        points->GetPoint(i, p);</font></div><div class=""><font face="PT Mono" class="">        std::cout << "(" << p[0] << ", " << p[1] << ", " << p[2] << ")" << std::endl;</font></div><div class=""><font face="PT Mono" class="">      }</font></div><div class=""><font face="PT Mono" class="">    }</font></div><div class=""><font face="PT Mono" class="">  }</font></div><div class=""><font face="PT Mono" class="">}</font></div></div><div class=""><br class=""></div><div class="">As I said … this works pretty well, except for any random points, the CellPicker also picks vertices from the Pointcloud (<font face="PT Mono" class="">CellType == 1</font>) and on random points my program crashes, because of an assertion fail …</div><div class=""><br class=""></div><div class="">I found out that the call to <font face="PT Mono" class="">vtkCellPicker::Pick() </font>calls superclass <font face="PT Mono" class="">vtkPicker::Pick() </font>and there is a call to <span style="white-space: pre; background-color: rgb(255, 255, 255);" class=""><font face="PT Mono" class="">IntersectWithLine()</font></span> from the CellPicker, in this function the call to <span style="white-space: pre; background-color: rgb(255, 255, 255);" class=""><font face="PT Mono" class="">IntersectActorWithLine()</font></span> calls in line 414 this one <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73); font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;">int</span><span style="color: rgb(36, 41, 46); font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre; background-color: rgb(255, 255, 255);" class=""> cellType = data-></span><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197); font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;">GetCellType</span><span style="color: rgb(36, 41, 46); font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre; background-color: rgb(255, 255, 255);" class="">(cellId); </span>… and here I get the assertion fail:</div><div class=""><br class=""></div><div class=""><span style="font-variant-ligatures: normal; orphans: 2; white-space: pre-wrap; widows: 2; background-color: rgb(255, 255, 255);" class=""><font face="PT Mono" class="">viewer: /build/vtk6-YpT4yb/vtk6-6.2.0+dfsg1/Common/Core/vtkDataArrayTemplate.h:191: T vtkDataArrayTemplate<T>::GetValue(vtkIdType) [with T = unsigned char; vtkIdType = long long int]: Assertion `id >= 0 && id < this->Size' failed.</font></span></div><div class=""><br class=""></div><div class="">Refered to <a href="https://github.com/Kitware/VTK/blob/release-6.3/Rendering/Core/vtkCellPicker.cxx#L414" class="">https://github.com/Kitware/VTK/blob/release-6.3/Rendering/Core/vtkCellPicker.cxx#L414</a></div><div class=""><br class=""></div><div class="">I really don’t know how to debug this, and why this happens.</div><div class=""><br class=""></div><div class="">Any Ideas for me?</div><div class=""><br class=""></div><div class="">If there is anything not clear - ask me, I can try to go more into detail, give more Code, or something like that.</div><div class=""><br class=""></div><div class="">Thank you!</div><div class=""><br class=""></div><div class="">Jaspar</div></body></html>