Commit fe59cbac authored by Zack Galbreath's avatar Zack Galbreath
Browse files

prevent the whole dendrogram from being collapsed

Change-Id: I3393f8f24aa2f511eb10d4208500b86c8d9765d0
parent 34bf4844
......@@ -948,7 +948,8 @@ vtkIdType vtkDendrogramItem::GetClosestVertex(double x, double y)
void vtkDendrogramItem::CollapseSubTree(vtkIdType vertex)
// no removing the root of the tree
if (vertex == this->PrunedTree->GetRoot())
vtkIdType root = this->PrunedTree->GetRoot();
if (vertex == root)
......@@ -963,6 +964,13 @@ void vtkDendrogramItem::CollapseSubTree(vtkIdType vertex)
// how many collapsed leaf nodes exist beneath it.
int numLeavesCollapsed = this->CountLeafNodes(originalId);
// make sure we're not about to collapse away the whole tree
int totalLeaves = this->CountLeafNodes(root);
if (numLeavesCollapsed >= totalLeaves)
// no collapsing of leaf nodes. This should never happen, but it doesn't
// hurt to be safe.
if (numLeavesCollapsed == 0)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment