<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. &nbsp;I've followed the example here,&nbsp;</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&nbsp;<span class="Apple-style-span" style="font-family: monospace; white-space: pre; ">InsertNextId </span>to add a point to the list of connected points. &nbsp;I'm getting a bus error when I get to this line in the code. &nbsp;Does anyone have an idea where this might be coming from? &nbsp;I've checked that the ID I'm inserting is an int type, and the list is an empty vtkIdList. &nbsp;</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&lt;vtkPolyData&gt; mesh, <span style="color: #aa0d91">int</span> seed, vtkSmartPointer&lt;vtkIdList&gt; 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&lt;vtkIdList&gt; cellIdList = vtkSmartPointer&lt;vtkIdList&gt;::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&nbsp;</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-&gt;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 &lt;&lt; <span style="color: #c41a16">"Got "</span> &lt;&lt; cellIdList-&gt;GetNumberOfIds() &lt;&lt; <span style="color: #c41a16">" cells using point "</span> &lt;&lt; seed &lt;&lt; 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 &lt; cellIdList-&gt;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">&nbsp;&nbsp; &nbsp;<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 &lt;&lt; <span style="color: #c41a16">"Checking cell "</span> &lt;&lt; i &lt;&lt; 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-&gt;GetCell(cellIdList-&gt;GetId(i));<span class="Apple-tab-span" style="white-space:pre">                </span><span style="color: #007400">// get current cell&nbsp;</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-&gt;GetNumberOfEdges() &lt;= </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&nbsp;</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 &lt; cell-&gt;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 &lt;&lt; <span style="color: #c41a16">"Checking edge "</span> &lt;&lt; e &lt;&lt; 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-&gt;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-&gt;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-&gt;GetId(<span style="color: #1c00cf">0</span>) == seed || pointIdList-&gt;GetId(<span style="color: #1c00cf">1</span>) == seed)&nbsp;<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 &lt;&lt; </span>"Writing connected point"<span style="color: #000000"> &lt;&lt; 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-&gt;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-&gt;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 &lt;&lt; <span style="color: #c41a16">"Adding "</span> &lt;&lt; temp &lt;&lt; <span style="color: #c41a16">" to list"</span> &lt;&lt; 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-&gt;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-&gt;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 &lt;&lt; <span style="color: #c41a16">"Adding "</span> &lt;&lt; temp &lt;&lt; <span style="color: #c41a16">" to list"</span> &lt;&lt; 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-&gt;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; ">&nbsp; &nbsp; }<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>