<div dir="ltr">Yes this is a great start. Since I am on a performance kick, I would probably use (under the hood) vtkStaticCellLocator which builds the links between points and cells much faster (threaded using vtkSMPTools and a parallel sort). The actual "counting" of the neighbors could then be sped up using vtkSMPTools as well. It's probably overkill, but I'd like VTK to knock off the socks of anyone using it, and also to support our HPC friends who have this humbling habit of dumping really big data on top of VTK :-)<div><br></div><div>Best,<br>W</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 22, 2016 at 8:25 AM, Lodron, Gerald <span dir="ltr"><<a href="mailto:Gerald.Lodron@joanneum.at" target="_blank">Gerald.Lodron@joanneum.at</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In my case the definition would be an edge, but yes it would be useful to define that as parameter….<br>
<br>
I already found a maybe not beautiful algorithm for vertices, not edges, may you want to reuse it as initial code:<br>
<br>
vtkSmartPointer<vtkUnsignedIntArray> neighbours = vtkSmartPointer<vtkUnsignedIntArray>::New();<br>
neighbours ->SetName("NumberOfNeighbours");<br>
neighbours ->SetNumberOfValues(numberOfCells);<br>
<br>
vtkSmartPointer<vtkIdList> cellPointIds = vtkSmartPointer<vtkIdList>::New();<br>
<br>
vtkSmartPointer<vtkIdList> ptids = vtkSmartPointer<vtkIdList>::New();<br>
vtkSmartPointer<vtkIdList> cellids = vtkSmartPointer<vtkIdList>::New();<br>
<br>
for (vtkIdType cellId = 0; cellId < numberOfCells; ++cellId)<br>
{<br>
input->GetCellPoints(cellId, ptids);<br>
/*<br>
does not work<br>
input ->GetCellNeighbors(cellId, oPtIds, oCellIds);<br>
neighbours ->SetValue(cellId, static_cast<unsigned int>(oCellIds->GetNumberOfIds()));*/<br>
std::set<vtkIdType> id_set;<br>
<br>
for (vtkIdType ptid = 0; ptid < ptids ->GetNumberOfIds();ptid++)<br>
{<br>
poInput1->GetPointCells(ptids ->GetId(ptid), cellids);<br>
for (vtkIdType cid = 0; cid < cellids ->GetNumberOfIds();cid++)<br>
{<br>
vtkIdType id = cellids ->GetId(cid);<br>
if (id != cellId)<br>
{<br>
id_set.insert(cellids->GetId(cid));<br>
}<br>
}<br>
}<br>
neighbours ->SetValue(cellId, static_cast<unsigned int>( id_set.size()));<br>
}<br>
output->GetCellData()->AddArray(neighbours);<br>
<br>
Von: Will Schroeder [mailto:<a href="mailto:will.schroeder@kitware.com">will.schroeder@kitware.com</a>]<br>
Gesendet: Freitag, 22. Juli 2016 14:09<br>
An: Lodron, Gerald<br>
Cc: VTK Developer (<a href="mailto:vtk-developers@vtk.org">vtk-developers@vtk.org</a>)<br>
Betreff: Re: [vtk-developers] Number of neighbours for each cell<br>
<div class="HOEnZb"><div class="h5"><br>
I don't know of such a filter but it would be easy to put together. Certainly it would be another useful tool in the topological analysis toolbox.<br>
<br>
Question: what is your definition of a neighbor? Connected at a vertex or along an edge? I suppose if we were to write such a filter the definition of a neighbor would be an optional parameter. I also suggest that this be a general filter so the same analysis could be applied to unstructured grids, etc. or to polygonal meshes with other than triangle cells.<br>
<br>
Best,<br>
W<br>
<br>
On Fri, Jul 22, 2016 at 6:51 AM, Lodron, Gerald <<a href="mailto:Gerald.Lodron@joanneum.at">Gerald.Lodron@joanneum.at</a>> wrote:<br>
<br>
<br>
Hi<br>
<br>
I have a mesh (vtkPolyData with all triangles) where i want to visualize the number of neighbouring cells/triangles for each cell/triangle. (I later may want to threshold/filter it with that number to remove “noisy” triangles on border with low number of neighbours)<br>
<br>
Is there a filter for that available?<br>
<br>
Best regards<br>
<br>
------------------------------------------------------------------------------------<br>
Gerald Lodron<br>
<br>
Researcher of Machine Vision Applications Group<br>
DIGITAL - Institute for Information and Communication Technologies<br>
<br>
JOANNEUM RESEARCH Forschungsgesellschaft mbH<br>
Steyrergasse 17, 8010 Graz, AUSTRIA<br>
<br>
phone: <a href="tel:%2B43-316-876-1751" value="+433168761751">+43-316-876-1751</a> <br>
general fax: <a href="tel:%2B43-316-876-1751" value="+433168761751">+43-316-876-1751</a><br>
web: <a href="http://www.joanneum.at/digital" rel="noreferrer" target="_blank">http://www.joanneum.at/digital</a><br>
e-mail: <a href="mailto:gerald.lodron@joanneum.at">gerald.lodron@joanneum.at</a><br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtk-developers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtk-developers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtk-developers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtk-developers</a><br>
<br>
<br>
<br>
<br>
<br>
--<br>
William J. Schroeder, PhD<br>
Kitware, Inc. - Building the World's Technical Computing Software<br>
28 Corporate Drive<br>
Clifton Park, NY 12065<br>
<a href="mailto:will.schroeder@kitware.com">will.schroeder@kitware.com</a><br>
<a href="http://www.kitware.com" rel="noreferrer" target="_blank">http://www.kitware.com</a><br>
<a href="tel:%28518%29%20881-4902" value="+15188814902">(518) 881-4902</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>William J. Schroeder, PhD<br>Kitware, Inc. - Building the World's Technical Computing Software<br>28 Corporate Drive<br>Clifton Park, NY 12065<br><a href="mailto:will.schroeder@kitware.com" target="_blank">will.schroeder@kitware.com</a><br><a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a><br>(518) 881-4902</div></div></div>
</div>