[vtkusers] Question about removeVertex
    planar3d 
    planar3d at gmail.com
       
    Tue Apr 24 01:42:57 EDT 2012
    
    
  
Why doesn't the appended code work? RemoveVertex doesn't seem to be working
for me. I make a pass through all the vertices and remove them when I find a
vertex of degree 0. Then I make the same pass again just to double check and
make sure I can't find any vertices with degree 0 but I do happen to find
them. I am using vtk 5.8.
When you remove a vertex do the vtkIdType (i.e. the unique identifiers for
each vertex) change?
bool removeAllVerticesWithDegree0(vtkSmartPointer<vtkMutableUndirectedGraph>
graph)
{
  // These variables will be reused
  vtkSmartPointer<vtkVertexListIterator> verticesItr =
vtkSmartPointer<vtkVertexListIterator>::New();
  vtkIdType vertexID;
  vtkIdType degree;
  // First remove all vertices of degree 0
  graph->GetVertices(verticesItr);
  while(verticesItr->HasNext())
  {
    // Grab a vertex and look at its degree
    vertexID = verticesItr->Next();
    degree = graph->GetDegree(vertexID);
    if(degree == 0)
    {
      graph->RemoveVertex(vertexID);
    }
  }
  graph->GetVertices(verticesItr);
  while(verticesItr->HasNext())
  {
    // Grab a vertex and look at its degree
    vertexID = verticesItr->Next();
    degree = graph->GetDegree(vertexID);
    if(degree == 0)
    {
      std::cout << "Uh oh. Should have been removed." << endl;
    }
  return true;
}
--
View this message in context: http://vtk.1045678.n5.nabble.com/Question-about-removeVertex-tp5661075p5661075.html
Sent from the VTK - Users mailing list archive at Nabble.com.
    
    
More information about the vtkusers
mailing list