[vtkusers] Missing Neighbors in VTKPolyData

Martin Klemm martin.klemm at hs-offenburg.de
Mon Dec 2 02:33:20 EST 2013


I am currently working on a function that passes through all cells of a 
triangulated power crust surface. Depending on the normal of the cell it 
is classified as valid or invalid. The algorithm works except of a 
problem that occurs in certain cells.

For my algorithm I use GetCellEdgeNeighbors of vtkPolyData to receive 
the edge neighbors of a cell. On a closed surface there should be three 
neighbors for a triangle. However, some triangles just have two neighbors.

Then I checked the point neighbors which shows the same result. There 
are no coincident neighbors on this "weird" edge.

Then I rendered the neighbors and the current cell as you can see here:


Moreover I print the point neighbors:
curCell = 719
point neighbors first point: 719 1151 1153
point neighbors second point: 714 715 719 721 722 7
point neighbors third point: 719 720 721 1151 1152

It looks like that even there are neighbors they are not linked to each 
other. And it seems like there are more neighbors than the renderwindow 
really shows. Could that be because there are really small triangles 
that you cannot really see in the renderer? Do you have any suggestions 
how to improve this situation?

And here is my function to get the neighbors of a specified cell:

  * \brief Gets the neighbors of a specified cell (triangle)
  * \param inputTriangles The input cells (triangles)
  * \param cellId The specified ID of the cell
  * \param neighbors A list with the neighbors of the specified cell
  * \warning You have to call vtkTriangleFilter before using this function.
  * \todo Figure out how it is possible that on a closed surface a 
triangle can have less than three
  * neighbors.
void SurfaceReconstructScreen::GetCellNeighbors(vtkPolyData* inputTriangles,
                                                 vtkIdType cellId,
                                                 bool debug)
    //clear result list

    //build links in order to use getcellneighbors

    vtkSmartPointer<vtkIdList> cellPointIds = 
    inputTriangles->GetCellPoints(cellId, cellPointIds);

    for(vtkIdType i = 0; i < cellPointIds->GetNumberOfIds(); i++)
       vtkSmartPointer<vtkIdList> idList = 
       vtkIdType firstPoint;
       vtkIdType secondPoint;

       //add one of the edge points
       firstPoint = cellPointIds->GetId(i);

       //add the other edge point
       if(i+1 == cellPointIds->GetNumberOfIds())
          secondPoint = cellPointIds->GetId(0);
          secondPoint = cellPointIds->GetId(i + 1);

       //get the neighbors of the cell
       vtkSmartPointer<vtkIdList> neighborCellIds = 

       inputTriangles->GetCellEdgeNeighbors(cellId, firstPoint, 
secondPoint, neighborCellIds);

       for(vtkIdType j = 0; j < neighborCellIds->GetNumberOfIds(); j++)

More information about the vtkusers mailing list