<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hello,</div><div><br></div><div>I'm trying to find all the points connected to a vertex point in a polydata mesh. I've followed the example here, </div><div><br></div><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/CellPointNeighbors">http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/CellPointNeighbors</a><div><br></div><div>And the email thread below, which both seem like what I want to do.</div><div>http://vtk.1045678.n5.nabble.com/Neighbours-of-a-point-in-a-mesh-td1236245.html<br><div><br></div><div>However, I'm having a problem when I try to use <span class="Apple-style-span" style="font-family: monospace; white-space: pre; ">InsertNextId </span>to add a point to the list of connected points. I'm getting a bus error when I get to this line in the code. Does anyone have an idea where this might be coming from? I've checked that the ID I'm inserting is an int type, and the list is an empty vtkIdList. </div><div><br></div><div>Thanks,</div><div>Sara</div><div><br></div><div>my subroutine to find connected neighbors is below.</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: #aa0d91">void</span> GetConnectedVertices(vtkSmartPointer<vtkPolyData> mesh, <span style="color: #aa0d91">int</span> seed, vtkSmartPointer<vtkIdList> connectedVertices)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>vtkSmartPointer<vtkIdList> cellIdList = vtkSmartPointer<vtkIdList>::New();<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-style-span" style="color: rgb(0, 116, 0); ">//get all connected cells </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>mesh->GetPointCells(seed, cellIdList);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>cout << <span style="color: #c41a16">"Got "</span> << cellIdList->GetNumberOfIds() << <span style="color: #c41a16">" cells using point "</span> << seed << endl;</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span><br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #aa0d91">for</span>(vtkIdType i = <span style="color: #1c00cf">0</span>; i < cellIdList->GetNumberOfIds(); i++){<span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #007400">// loop through each cell using the seed point</span></div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"> <br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>cout << <span style="color: #c41a16">"Checking cell "</span> << i << endl;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>vtkCell* cell = mesh->GetCell(cellIdList->GetId(i));<span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #007400">// get current cell </span></div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span><br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span></span><span style="color: #aa0d91">if</span><span style="color: #000000">(cell->GetNumberOfEdges() <= </span><span style="color: #1c00cf">0</span><span style="color: #000000">){<span class="Apple-tab-span" style="white-space:pre"> </span></span>//if the cell doesn't have any edges, it is a line, so skip </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(170, 13, 145); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span></span>continue<span style="color: #000000">;</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span><br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #aa0d91">for</span>(vtkIdType e = <span style="color: #1c00cf">0</span>; e < cell->GetNumberOfEdges(); e++)<span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #007400">// loop through each edge of the cell</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>cout << <span style="color: #c41a16">"Checking edge "</span> << e << endl;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>vtkCell* edge = cell->GetEdge(e);<span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #007400">// get current edge</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>vtkIdList* pointIdList = edge->GetPointIds();<span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #007400">// get list of points on edge</span></div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span><br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #aa0d91">if</span>(pointIdList->GetId(<span style="color: #1c00cf">0</span>) == seed || pointIdList->GetId(<span style="color: #1c00cf">1</span>) == seed) <span style="color: #007400">// if one of the points on the edge are the vertex point</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(196, 26, 22); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span>cout << </span>"Writing connected point"<span style="color: #000000"> << endl;</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #aa0d91">if</span>(pointIdList->GetId(<span style="color: #1c00cf">0</span>) == seed)<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-style-span" style="color: rgb(0, 116, 0); ">// if first point on edge is vertex</span><span class="Apple-tab-span" style="white-space:pre"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #aa0d91">int</span> temp = pointIdList->GetId(<span style="color: #1c00cf">1</span>);<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-style-span" style="color: rgb(0, 116, 0); ">// get second point from list</span><span class="Apple-tab-span" style="white-space:pre"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>cout << <span style="color: #c41a16">"Adding "</span> << temp << <span style="color: #c41a16">" to list"</span> << endl;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span></span><font class="Apple-style-span" color="#000000">connectedVertices->InsertNextId(temp);</font><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000"> </font></span>// and insert it into connected point list<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><span class="Apple-tab-span" style="white-space:pre"> </span></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #aa0d91">else</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #aa0d91">int</span> temp = pointIdList->GetId(<span style="color: #1c00cf">0</span>);<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-style-span" style="color: rgb(0, 116, 0); ">// get second point from list</span><span class="Apple-tab-span" style="white-space:pre"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>cout << <span style="color: #c41a16">"Adding "</span> << temp << <span style="color: #c41a16">" to list"</span> << endl;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span>connectedVertices->InsertNextId(temp);<span class="Apple-tab-span" style="white-space:pre"> </span></span>// else insert first point into connected point list</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> }<span class="Apple-tab-span" style="white-space:pre"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">}</div></div><div><br></div><pre class="de1"><span class="sy1"></span><span class="br0"></span></pre></div></body></html>