I'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 "edge" neighbors (neighbors that share an edge of the triangle) by using GetCellNeighbor(A, {X,Y}, <list of cell ids>), GetCellNeighbor(A, {X,Z}, <list of cell ids>), GetCellNeighbor(A, {Y,Z}, <list of cell ids>). To get the "point" neighbors it would be GetCellNeighbor(A, {X}, <list of cell ids>),GetCellNeighbor(A, {Y}, <list of cell ids>),GetCellNeighbor(A, {Z}, <list of cell ids>). <br>
<br>The GetCellNeighbor function doesn't require that the return cells don'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 <<a href="mailto:rashed.vtk@googlemail.com">rashed.vtk@googlemail.com</a>><br>
Subject: Re: [vtkusers] getcellneighbours of polydata<br>
To: <a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>
Message-ID: <<a href="mailto:28740248.post@talk.nabble.com">28740248.post@talk.nabble.com</a>><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's neighbours, surely there must be some function out<br>
there!<br>
<br>
Rashed.<br>
<br>
<br>
Andy Bauer wrote:<br>
><br>
> You may be getting confused by the fact that a cell is not considered<br>
> to be its own neighbor. The reason your code didn't work is that you<br>
> are passing in all the points of cellId to get its points. Unless you<br>
> have another cell that hsa those same exact points (and maybe others)<br>
> you won't get any cells.<br>
><br>
> As an example, if you wanted to get all cells which use pointId,<br>
> except for cellId the code would look like:<br>
> vtkSmartPointer<vtkIdList> ptIds =<br>
> vtkSmartPointer<vtkIdList>::New();<br>
> sphereSource->GetOutput()->GetCellPoints(cellId, ptIds);<br>
> vtkSmartPointer<vtkIdList> pointIds =<br>
> vtkSmartPointer<vtkIdList>::New();<br>
> pointIds->InsertNextId(ptIds->GetId(0));<br>
><br>
> sphereSource->GetOutput()->GetCellNeighbors(cellId, pointIds,<br>
> neighborCellIds);<br>
> std::cout << "There are " << neighborCellIds->GetNumberOfIds() << "<br>
> neighbors." << std::endl;<br>
><br>
> If you wanted the neighbors of cellId to share more points (e.g. edge<br>
> neighbor, face neighbor) you'd have to add in more points to pointIds.<br>
><br>
> On Fri, May 28, 2010 at 12:38 PM, rashedk <rashed.vtk at<br>
> <a href="http://googlemail.com" target="_blank">googlemail.com</a> <<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a>>> wrote:<br>
>>*<br>
> *>* Now that's interesting. It seems we are having the same problem then.<br>
> Does<br>
> *>* that mean there isn't an easy way of getting a cell's neighbours?<br>
> *>*<br>
> *>* Rashed.<br>
> *<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't understand what that means? After looking at some use cases in<br>
> VTK, I came up with this:<br>
><br>
> vtkSmartPointer<vtkIdList> ptIds =<br>
> vtkSmartPointer<vtkIdList>::New();<br>
> sphereSource->GetOutput()->GetCellPoints(cellId, ptIds);<br>
><br>
> sphereSource->GetOutput()->GetCellNeighbors(cellId, ptIds,<br>
> neighborCellIds);<br>
> std::cout << "There are " << neighborCellIds->GetNumberOfIds() << "<br>
> neighbors." << std::endl;<br>
><br>
> It doesn't segfault, but it says there are 0 neighbors, which is not<br>
> true (it's a sphere!).<br>
><br>
> Can anyone explain what is going on here?<br>
><br>
> Thanks,<br>
><br>
<br>
</blockquote><br></div><br>