I&#39;m pretty sure that GetCellNeighbors is the function that you want.  The confusion probably stems from the fact that people may define a neighbor of a cell differently.  By specifying what points are shared between the cells, this clears up that confusion.  As an example, if you have triangle cell A with point X, Y, and Z, you could find the &quot;edge&quot; neighbors (neighbors that share an edge of the triangle) by using GetCellNeighbor(A, {X,Y}, &lt;list of cell ids&gt;), GetCellNeighbor(A, {X,Z}, &lt;list of cell ids&gt;), GetCellNeighbor(A, {Y,Z}, &lt;list of cell ids&gt;).  To get the &quot;point&quot; neighbors it would be GetCellNeighbor(A, {X}, &lt;list of cell ids&gt;),GetCellNeighbor(A, {Y}, &lt;list of cell ids&gt;),GetCellNeighbor(A, {Z}, &lt;list of cell ids&gt;).  <br>
<br>The GetCellNeighbor function doesn&#39;t require that the return cells don&#39;t use other points, just that the returned cells must use the list points in the input.<br><br>Andy<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Date: Tue, 1 Jun 2010 03:56:18 -0700 (PDT)<br>
From: rashedk &lt;<a href="mailto:rashed.vtk@googlemail.com">rashed.vtk@googlemail.com</a>&gt;<br>
Subject: Re: [vtkusers] getcellneighbours of polydata<br>
To: <a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>
Message-ID: &lt;<a href="mailto:28740248.post@talk.nabble.com">28740248.post@talk.nabble.com</a>&gt;<br>
Content-Type: text/plain; charset=us-ascii<br>
<br>
<br>
It is strange why this function is called getcellneighbours, if you what you<br>
mentioned is correct. It is then really returning cells which use (ALL) the<br>
points specified. I am still looking for a function that would return<br>
cellIds of a cell&#39;s neighbours, surely there must be some function out<br>
there!<br>
<br>
Rashed.<br>
<br>
<br>
Andy Bauer wrote:<br>
&gt;<br>
&gt; You may be getting confused by the fact that a cell is not considered<br>
&gt; to be its own neighbor.  The reason your code didn&#39;t work is that you<br>
&gt; are passing in all the points of cellId to get its points.  Unless you<br>
&gt; have another cell that hsa those same exact points (and maybe others)<br>
&gt; you won&#39;t get any cells.<br>
&gt;<br>
&gt; As an example, if you wanted to get all cells which use pointId,<br>
&gt; except for cellId the code would look like:<br>
&gt;   vtkSmartPointer&lt;vtkIdList&gt; ptIds =<br>
&gt;     vtkSmartPointer&lt;vtkIdList&gt;::New();<br>
&gt;   sphereSource-&gt;GetOutput()-&gt;GetCellPoints(cellId, ptIds);<br>
&gt;   vtkSmartPointer&lt;vtkIdList&gt; pointIds =<br>
&gt;     vtkSmartPointer&lt;vtkIdList&gt;::New();<br>
&gt;   pointIds-&gt;InsertNextId(ptIds-&gt;GetId(0));<br>
&gt;<br>
&gt;   sphereSource-&gt;GetOutput()-&gt;GetCellNeighbors(cellId, pointIds,<br>
&gt; neighborCellIds);<br>
&gt;   std::cout &lt;&lt; &quot;There are &quot; &lt;&lt; neighborCellIds-&gt;GetNumberOfIds() &lt;&lt; &quot;<br>
&gt; neighbors.&quot; &lt;&lt; std::endl;<br>
&gt;<br>
&gt; If you wanted the neighbors of cellId to share more points (e.g. edge<br>
&gt; neighbor, face neighbor) you&#39;d have to add in more points to pointIds.<br>
&gt;<br>
&gt; On Fri, May 28, 2010 at 12:38 PM, rashedk &lt;rashed.vtk at<br>
&gt; <a href="http://googlemail.com" target="_blank">googlemail.com</a> &lt;<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a>&gt;&gt; wrote:<br>
&gt;&gt;*<br>
&gt; *&gt;* Now that&#39;s interesting. It seems we are having the same problem then.<br>
&gt; Does<br>
&gt; *&gt;* that mean there isn&#39;t an easy way of getting a cell&#39;s neighbours?<br>
&gt; *&gt;*<br>
&gt; *&gt;* Rashed.<br>
&gt; *<br>
&gt; The documentation of this function:<br>
&gt; void vtkDataSet::GetCellNeighbors<br>
&gt;<br>
&gt; says:<br>
&gt; Topological inquiry to get all cells using list of points exclusive of<br>
&gt; cell specified (e.g., cellId). Note that the list consists of only<br>
&gt; cells that use ALL the points provided.<br>
&gt;<br>
&gt; I don&#39;t understand what that means? After looking at some use cases in<br>
&gt; VTK, I came up with this:<br>
&gt;<br>
&gt;   vtkSmartPointer&lt;vtkIdList&gt; ptIds =<br>
&gt;     vtkSmartPointer&lt;vtkIdList&gt;::New();<br>
&gt;   sphereSource-&gt;GetOutput()-&gt;GetCellPoints(cellId, ptIds);<br>
&gt;<br>
&gt;   sphereSource-&gt;GetOutput()-&gt;GetCellNeighbors(cellId, ptIds,<br>
&gt; neighborCellIds);<br>
&gt;   std::cout &lt;&lt; &quot;There are &quot; &lt;&lt; neighborCellIds-&gt;GetNumberOfIds() &lt;&lt; &quot;<br>
&gt; neighbors.&quot; &lt;&lt; std::endl;<br>
&gt;<br>
&gt; It doesn&#39;t segfault, but it says there are 0 neighbors, which is not<br>
&gt; true (it&#39;s a sphere!).<br>
&gt;<br>
&gt; Can anyone explain what is going on here?<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
<br>
</blockquote><br></div><br>