<pre>You may be getting confused by the fact that a cell is not considered to be its own neighbor.  The reason your code didn&#39;t work is that you are passing in all the points of cellId to get its points.  Unless you have another cell that hsa those same exact points (and maybe others) you won&#39;t get any cells.<br>
<br>As an example, if you wanted to get all cells which use pointId, except for cellId the code would look like:<br>  vtkSmartPointer&lt;vtkIdList&gt; ptIds =<br>    vtkSmartPointer&lt;vtkIdList&gt;::New();<br>  sphereSource-&gt;GetOutput()-&gt;GetCellPoints(cellId, ptIds);<br>
  vtkSmartPointer&lt;vtkIdList&gt; pointIds =<br>    vtkSmartPointer&lt;vtkIdList&gt;::New();<br>  pointIds-&gt;InsertNextId(ptIds-&gt;GetId(0));<br><br>  sphereSource-&gt;GetOutput()-&gt;GetCellNeighbors(cellId, pointIds, neighborCellIds);<br>
  std::cout &lt;&lt; &quot;There are &quot; &lt;&lt; neighborCellIds-&gt;GetNumberOfIds() &lt;&lt; &quot;<br>neighbors.&quot; &lt;&lt; std::endl;<br><br>If you wanted the neighbors of cellId to share more points (e.g. edge neighbor, face neighbor) you&#39;d have to add in more points to pointIds.<br>
<br>On Fri, May 28, 2010 at 12:38 PM, rashedk &lt;<a href="http://www.vtk.org/mailman/listinfo/vtkusers">rashed.vtk at googlemail.com</a>&gt; wrote:<br>&gt;<i><br></i>&gt;<i> Now that&#39;s interesting. It seems we are having the same problem then. Does<br>
</i>&gt;<i> that mean there isn&#39;t an easy way of getting a cell&#39;s neighbours?<br></i>&gt;<i><br></i>&gt;<i> Rashed.<br></i><br>The documentation of this function:<br>void vtkDataSet::GetCellNeighbors<br><br>says:<br>
Topological inquiry to get all cells using list of points exclusive of<br>cell specified (e.g., cellId). Note that the list consists of only<br>cells that use ALL the points provided.<br><br>I don&#39;t understand what that means? After looking at some use cases in<br>
VTK, I came up with this:<br><br>  vtkSmartPointer&lt;vtkIdList&gt; ptIds =<br>    vtkSmartPointer&lt;vtkIdList&gt;::New();<br>  sphereSource-&gt;GetOutput()-&gt;GetCellPoints(cellId, ptIds);<br><br>  sphereSource-&gt;GetOutput()-&gt;GetCellNeighbors(cellId, ptIds, neighborCellIds);<br>
  std::cout &lt;&lt; &quot;There are &quot; &lt;&lt; neighborCellIds-&gt;GetNumberOfIds() &lt;&lt; &quot;<br>neighbors.&quot; &lt;&lt; std::endl;<br><br>It doesn&#39;t segfault, but it says there are 0 neighbors, which is not<br>
true (it&#39;s a sphere!).<br><br>Can anyone explain what is going on here?<br><br>Thanks,<br><br><br></pre>