MCPcopy Create free account
hub / github.com/Kitware/VTK / CollapseSubTree

Method CollapseSubTree

Views/Infovis/vtkDendrogramItem.cxx:938–982  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

936
937//------------------------------------------------------------------------------
938void vtkDendrogramItem::CollapseSubTree(vtkIdType vertex)
939{
940 // no removing the root of the tree
941 vtkIdType root = this->PrunedTree->GetRoot();
942 if (vertex == root)
943 {
944 return;
945 }
946
947 // look up the original ID of the vertex that's being collapsed.
948 vtkIdTypeArray* originalIdArray =
949 vtkArrayDownCast<vtkIdTypeArray>(this->PrunedTree->GetVertexData()->GetArray("OriginalId"));
950 vtkIdType originalId = originalIdArray->GetValue(vertex);
951
952 // use this value as the index to the original (un-reindexed) tree's
953 // "VertexIsPruned" array. Mark that vertex as pruned by recording
954 // how many collapsed leaf nodes exist beneath it.
955 int numLeavesCollapsed = this->CountLeafNodes(originalId);
956
957 // make sure we're not about to collapse away the whole tree
958 int totalLeaves = this->CountLeafNodes(root);
959 if (numLeavesCollapsed >= totalLeaves)
960 {
961 return;
962 }
963
964 // no collapsing of leaf nodes. This should never happen, but it doesn't
965 // hurt to be safe.
966 if (numLeavesCollapsed == 0)
967 {
968 return;
969 }
970
971 vtkUnsignedIntArray* vertexIsPruned =
972 vtkArrayDownCast<vtkUnsignedIntArray>(this->Tree->GetVertexData()->GetArray("VertexIsPruned"));
973 vertexIsPruned->SetValue(originalId, numLeavesCollapsed);
974
975 vtkNew<vtkTree> prunedTreeCopy;
976 prunedTreeCopy->ShallowCopy(this->PrunedTree);
977
978 this->PruneFilter->SetInputData(prunedTreeCopy);
979 this->PruneFilter->SetParentVertex(vertex);
980 this->PruneFilter->Update();
981 this->PrunedTree = this->PruneFilter->GetOutput();
982}
983
984//------------------------------------------------------------------------------
985void vtkDendrogramItem::ExpandSubTree(vtkIdType vertex)

Callers 4

SetTreeMethod · 0.95
MouseDoubleClickEventMethod · 0.95
ExpandSubTreeMethod · 0.95

Calls 10

CountLeafNodesMethod · 0.95
GetVertexDataMethod · 0.80
GetRootMethod · 0.45
GetArrayMethod · 0.45
GetValueMethod · 0.45
SetValueMethod · 0.45
ShallowCopyMethod · 0.45
SetInputDataMethod · 0.45
UpdateMethod · 0.45
GetOutputMethod · 0.45

Tested by

no test coverage detected