Commit 349b0875 authored by Zack Galbreath's avatar Zack Galbreath Committed by Code Review
Browse files

Merge topic 'no_whole_tree_collapse' into master

fe59cbac prevent the whole dendrogram from being collapsed
parents eba9e70c fe59cbac
......@@ -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)
{
return;
}
......@@ -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)
{
return;
}
// 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