Hi!<div><br></div><div>I&#39;m trying to build the 1-ring neighborhood of each point on a mesh by using a modified version of the VertexConnectivity example <a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/VertexConnectivity">http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/VertexConnectivity</a>), actually is the same version, the only thing I&#39;ve changed is the source (instead of a &quot;SphereSource&quot; I&#39;m using a vtkXMLPolyDataReader). See the my code below...</div>
<div><br></div><div>My mesh has 40938 points, and the code behaves well until it arrives to the point 38454. At this point I always get a run-time error &quot;Segmentation fault&quot;. I&#39;ve managed to isolate the problem and I&#39;m pretty sure it happens when calling the function:</div>
<div><br></div><div>mesh-&gt;GetPointCells(id, cellIdList), </div><div><br></div><div>where &quot;id&quot; is, in my case, 38454...  </div><div><br></div><div>I&#39;ve also tried with other meshes (with different number of points) and I ALWAYS get the same &quot;Segmentation Fault&quot; error... The strangest thing is that when implementing the original example (using the sphere) I do not get any errors at all!</div>
<div><br></div><div>Am I doing something wrong? There might be a problem with my meshes? It might be a bug in vtkPolyData::GetPointCells()???</div><div><br></div><div>Heres the code:</div><div><br></div><div><div>vtkSmartPointer&lt;vtkIdList&gt; GetConnectedVertices(vtkSmartPointer&lt;vtkPolyData&gt; mesh, int id);</div>
<div> </div><div>int main(int, char* argv[])</div><div>{</div><div>  // vtkSmartPointer&lt;vtkSphereSource&gt; sphereSource =</div><div>  //       vtkSmartPointer&lt;vtkSphereSource&gt;::New();</div><div>  //   sphereSource-&gt;Update();</div>
<div> vtkSmartPointer&lt;vtkXMLPolyDataReader&gt; sphereSource = <span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkXMLPolyDataReader&gt;::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>sphereSource-&gt;SetFileName(argv[1]);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>sphereSource-&gt;Update();</div><div> </div><div>
  vtkSmartPointer&lt;vtkTriangleFilter&gt; triangleFilter =</div><div>      vtkSmartPointer&lt;vtkTriangleFilter&gt;::New();</div><div>  triangleFilter-&gt;SetInputConnection(sphereSource-&gt;GetOutputPort());</div><div>  triangleFilter-&gt;Update();</div>
<div> </div><div>  vtkSmartPointer&lt;vtkExtractEdges&gt; extractEdges =</div><div>    vtkSmartPointer&lt;vtkExtractEdges&gt;::New();</div><div>  extractEdges-&gt;SetInputConnection(triangleFilter-&gt;GetOutputPort());</div>
<div>  extractEdges-&gt;Update();</div><div> </div><div>  vtkSmartPointer&lt;vtkPolyData&gt; mesh = extractEdges-&gt;GetOutput();</div><div><br></div><div>  vtkSmartPointer&lt;vtkIdList&gt; connectedVertices = GetConnectedVertices(mesh, 38455);</div>
<div> </div><div>  vtkSmartPointer&lt;vtkIdTypeArray&gt; ids =</div><div>    vtkSmartPointer&lt;vtkIdTypeArray&gt;::New();</div><div>  ids-&gt;SetNumberOfComponents(1);</div><div> </div><div>  std::cout &lt;&lt; &quot;Connected vertices: &quot;;</div>
<div>  for(vtkIdType i = 0; i &lt; connectedVertices-&gt;GetNumberOfIds(); i++)</div><div>    {</div><div>    std::cout &lt;&lt; connectedVertices-&gt;GetId(i) &lt;&lt; &quot; &quot;;</div><div>    ids-&gt;InsertNextValue(connectedVertices-&gt;GetId(i));</div>
<div>    }</div><div>  std::cout &lt;&lt; std::endl;</div><div> </div><div>  vtkSmartPointer&lt;vtkDataSetMapper&gt; connectedVertexMapper =</div><div>    vtkSmartPointer&lt;vtkDataSetMapper&gt;::New();</div><div> </div><div>
  {</div><div>    vtkSmartPointer&lt;vtkSelectionNode&gt; selectionNode =</div><div>      vtkSmartPointer&lt;vtkSelectionNode&gt;::New();</div><div>    selectionNode-&gt;SetFieldType(vtkSelectionNode::POINT);</div><div>    selectionNode-&gt;SetContentType(vtkSelectionNode::INDICES);</div>
<div>    selectionNode-&gt;SetSelectionList(ids);</div><div> </div><div>    vtkSmartPointer&lt;vtkSelection&gt; selection =</div><div>        vtkSmartPointer&lt;vtkSelection&gt;::New();</div><div>    selection-&gt;AddNode(selectionNode);</div>
<div> </div><div>    vtkSmartPointer&lt;vtkExtractSelection&gt; extractSelection =</div><div>        vtkSmartPointer&lt;vtkExtractSelection&gt;::New();</div><div> </div><div>    extractSelection-&gt;SetInput(0, extractEdges-&gt;GetOutput());</div>
<div>    extractSelection-&gt;SetInput(1, selection);</div><div>    extractSelection-&gt;Update();</div><div> </div><div>    vtkSmartPointer&lt;vtkVertexGlyphFilter&gt; glyphFilter =</div><div>      vtkSmartPointer&lt;vtkVertexGlyphFilter&gt;::New();</div>
<div>    glyphFilter-&gt;SetInputConnection(extractSelection-&gt;GetOutputPort());</div><div>    glyphFilter-&gt;Update();</div><div> </div><div>    connectedVertexMapper-&gt;SetInputConnection(glyphFilter-&gt;GetOutputPort());</div>
<div>  }</div><div> </div><div>  vtkSmartPointer&lt;vtkActor&gt; connectedVertexActor =</div><div>    vtkSmartPointer&lt;vtkActor&gt;::New();</div><div>  connectedVertexActor-&gt;SetMapper(connectedVertexMapper);</div><div>
  connectedVertexActor-&gt;GetProperty()-&gt;SetColor(1,0,0);</div><div>  connectedVertexActor-&gt;GetProperty()-&gt;SetPointSize(5);</div><div> </div><div>  vtkSmartPointer&lt;vtkDataSetMapper&gt; queryVertexMapper =</div>
<div>    vtkSmartPointer&lt;vtkDataSetMapper&gt;::New();</div><div> </div><div>  {</div><div>    vtkSmartPointer&lt;vtkIdTypeArray&gt; ids =</div><div>      vtkSmartPointer&lt;vtkIdTypeArray&gt;::New();</div><div>    ids-&gt;SetNumberOfComponents(1);</div>
<div>    ids-&gt;InsertNextValue(0);</div><div> </div><div>    vtkSmartPointer&lt;vtkSelectionNode&gt; selectionNode =</div><div>      vtkSmartPointer&lt;vtkSelectionNode&gt;::New();</div><div>    selectionNode-&gt;SetFieldType(vtkSelectionNode::POINT);</div>
<div>    selectionNode-&gt;SetContentType(vtkSelectionNode::INDICES);</div><div>    selectionNode-&gt;SetSelectionList(ids);</div><div> </div><div>    vtkSmartPointer&lt;vtkSelection&gt; selection =</div><div>        vtkSmartPointer&lt;vtkSelection&gt;::New();</div>
<div>    selection-&gt;AddNode(selectionNode);</div><div> </div><div>    vtkSmartPointer&lt;vtkExtractSelection&gt; extractSelection =</div><div>        vtkSmartPointer&lt;vtkExtractSelection&gt;::New();</div><div> </div>
<div>    extractSelection-&gt;SetInput(0, extractEdges-&gt;GetOutput());</div><div>    extractSelection-&gt;SetInput(1, selection);</div><div>    extractSelection-&gt;Update();</div><div> </div><div>    vtkSmartPointer&lt;vtkVertexGlyphFilter&gt; glyphFilter =</div>
<div>      vtkSmartPointer&lt;vtkVertexGlyphFilter&gt;::New();</div><div>    glyphFilter-&gt;SetInputConnection(extractSelection-&gt;GetOutputPort());</div><div>    glyphFilter-&gt;Update();</div><div> </div><div>    queryVertexMapper-&gt;SetInputConnection(glyphFilter-&gt;GetOutputPort());</div>
<div>  }</div><div> </div><div>  vtkSmartPointer&lt;vtkActor&gt; queryVertexActor =</div><div>    vtkSmartPointer&lt;vtkActor&gt;::New();</div><div>  queryVertexActor-&gt;SetMapper(queryVertexMapper);</div><div>  queryVertexActor-&gt;GetProperty()-&gt;SetColor(0,1,0);</div>
<div>  queryVertexActor-&gt;GetProperty()-&gt;SetPointSize(5);</div><div> </div><div>  vtkSmartPointer&lt;vtkDataSetMapper&gt; sphereMapper =</div><div>    vtkSmartPointer&lt;vtkDataSetMapper&gt;::New();</div><div>  sphereMapper-&gt;SetInputConnection(extractEdges-&gt;GetOutputPort());</div>
<div>  vtkSmartPointer&lt;vtkActor&gt; sphereActor =</div><div>    vtkSmartPointer&lt;vtkActor&gt;::New();</div><div>  sphereActor-&gt;SetMapper(sphereMapper);</div><div> </div><div>    //Create a renderer, render window, and interactor</div>
<div>  vtkSmartPointer&lt;vtkRenderer&gt; renderer =</div><div>    vtkSmartPointer&lt;vtkRenderer&gt;::New();</div><div>  vtkSmartPointer&lt;vtkRenderWindow&gt; renderWindow =</div><div>    vtkSmartPointer&lt;vtkRenderWindow&gt;::New();</div>
<div>  renderWindow-&gt;AddRenderer(renderer);</div><div>  vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; renderWindowInteractor =</div><div>    vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();</div><div>  renderWindowInteractor-&gt;SetRenderWindow(renderWindow);</div>
<div> </div><div>  //Add the actors to the scene</div><div>  renderer-&gt;AddActor(sphereActor);</div><div>  renderer-&gt;AddActor(queryVertexActor);</div><div>  renderer-&gt;AddActor(connectedVertexActor);</div><div>  renderer-&gt;SetBackground(.3, .2, .1); // Background color dark red</div>
<div> </div><div>  //Render and interact</div><div>  renderWindow-&gt;Render();</div><div>  renderWindowInteractor-&gt;Start();</div><div> </div><div>  return EXIT_SUCCESS;</div><div>}</div><div> </div><div>vtkSmartPointer&lt;vtkIdList&gt; GetConnectedVertices(vtkSmartPointer&lt;vtkPolyData&gt; mesh, int id)</div>
<div>{</div><div>  vtkSmartPointer&lt;vtkIdList&gt; connectedVertices =</div><div>      vtkSmartPointer&lt;vtkIdList&gt;::New();</div><div> </div><div>  //get all cells that vertex &#39;id&#39; is a part of</div><div>  vtkSmartPointer&lt;vtkIdList&gt; cellIdList =</div>
<div>      vtkSmartPointer&lt;vtkIdList&gt;::New();</div><div>  mesh-&gt;GetPointCells(id, cellIdList);</div><div> </div><div>  /*</div><div>  cout &lt;&lt; &quot;Vertex 0 is used in cells &quot;;</div><div>  for(vtkIdType i = 0; i &lt; cellIdList-&gt;GetNumberOfIds(); i++)</div>
<div>    {</div><div>    cout &lt;&lt; cellIdList-&gt;GetId(i) &lt;&lt; &quot;, &quot;;</div><div>    }</div><div>  cout &lt;&lt; endl;</div><div>  */</div><div> </div><div>  for(vtkIdType i = 0; i &lt; cellIdList-&gt;GetNumberOfIds(); i++)</div>
<div>    {</div><div>    //cout &lt;&lt; &quot;id &quot; &lt;&lt; i &lt;&lt; &quot; : &quot; &lt;&lt; cellIdList-&gt;GetId(i) &lt;&lt; endl;</div><div> </div><div>    vtkSmartPointer&lt;vtkIdList&gt; pointIdList =</div><div>
      vtkSmartPointer&lt;vtkIdList&gt;::New();</div><div>    mesh-&gt;GetCellPoints(cellIdList-&gt;GetId(i), pointIdList);</div><div> </div><div>    //cout &lt;&lt; &quot;End points are &quot; &lt;&lt; pointIdList-&gt;GetId(0) &lt;&lt; &quot; and &quot; &lt;&lt; pointIdList-&gt;GetId(1) &lt;&lt; endl;</div>
<div> </div><div>    if(pointIdList-&gt;GetId(0) != id)</div><div>      {</div><div>      //cout &lt;&lt; &quot;Connected to &quot; &lt;&lt; pointIdList-&gt;GetId(0) &lt;&lt; endl;</div><div>      connectedVertices-&gt;InsertNextId(pointIdList-&gt;GetId(0));</div>
<div>      }</div><div>    else</div><div>      {</div><div>      //cout &lt;&lt; &quot;Connected to &quot; &lt;&lt; pointIdList-&gt;GetId(1) &lt;&lt; endl;</div><div>      connectedVertices-&gt;InsertNextId(pointIdList-&gt;GetId(1));</div>
<div>      }</div><div>    }</div><div> </div><div>  return connectedVertices;</div><div>}</div></div><div><br></div><div>Thanks!</div><div><br></div><div>Miguel</div><div><br></div><div><br></div>