[vtk-developers] Number of neighbours for each cell

Lodron, Gerald Gerald.Lodron at joanneum.at
Fri Jul 22 08:25:58 EDT 2016


In my case the definition would be an edge, but yes it would be useful to define that as parameter….

I already found a maybe not beautiful algorithm for vertices, not edges, may you want to reuse it as initial code:

       vtkSmartPointer<vtkUnsignedIntArray> neighbours = vtkSmartPointer<vtkUnsignedIntArray>::New();
        neighbours ->SetName("NumberOfNeighbours");
        neighbours ->SetNumberOfValues(numberOfCells);

        vtkSmartPointer<vtkIdList> cellPointIds = vtkSmartPointer<vtkIdList>::New();

        vtkSmartPointer<vtkIdList> ptids = vtkSmartPointer<vtkIdList>::New();
        vtkSmartPointer<vtkIdList> cellids = vtkSmartPointer<vtkIdList>::New();

        for (vtkIdType cellId = 0; cellId < numberOfCells; ++cellId)
        {
            input->GetCellPoints(cellId, ptids);
            /*
            does not work
            input ->GetCellNeighbors(cellId, oPtIds, oCellIds);
            neighbours ->SetValue(cellId, static_cast<unsigned int>(oCellIds->GetNumberOfIds()));*/
            std::set<vtkIdType> id_set;

            for (vtkIdType ptid = 0; ptid < ptids ->GetNumberOfIds();ptid++)
            {
                poInput1->GetPointCells(ptids ->GetId(ptid), cellids);
                for (vtkIdType cid = 0; cid < cellids ->GetNumberOfIds();cid++)
                {
                    vtkIdType id = cellids ->GetId(cid);
                    if (id != cellId)
                    {
                        id_set.insert(cellids->GetId(cid));
                    }
                }
            }
            neighbours ->SetValue(cellId, static_cast<unsigned int>( id_set.size()));
        }
        output->GetCellData()->AddArray(neighbours);

Von: Will Schroeder [mailto:will.schroeder at kitware.com] 
Gesendet: Freitag, 22. Juli 2016 14:09
An: Lodron, Gerald
Cc: VTK Developer (vtk-developers at vtk.org)
Betreff: Re: [vtk-developers] Number of neighbours for each cell

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.

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.

Best,
W

On Fri, Jul 22, 2016 at 6:51 AM, Lodron, Gerald <Gerald.Lodron at joanneum.at> wrote:
 
 
Hi
 
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)
 
Is there a filter for that available?
 
Best regards
 
------------------------------------------------------------------------------------
Gerald Lodron
 
Researcher of Machine Vision Applications Group
DIGITAL - Institute for Information and Communication Technologies
 
JOANNEUM RESEARCH Forschungsgesellschaft mbH
Steyrergasse 17, 8010 Graz, AUSTRIA
 
phone:   +43-316-876-1751   
general fax: +43-316-876-1751
web: http://www.joanneum.at/digital
e-mail: gerald.lodron at joanneum.at
 
 
 

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtk-developers





-- 
William J. Schroeder, PhD
Kitware, Inc. - Building the World's Technical Computing Software
28 Corporate Drive
Clifton Park, NY 12065
will.schroeder at kitware.com
http://www.kitware.com
(518) 881-4902


More information about the vtk-developers mailing list