Skip to content

Commit

Permalink
[PlanarLayout] fix persistence array
Browse files Browse the repository at this point in the history
  • Loading branch information
MatPont committed Oct 2, 2023
1 parent 92aee47 commit 9b9c8ba
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions core/vtk/ttkPlanarGraphLayout/ttkMergeTreeVisualization.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,8 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization {
// Node fields
vtkNew<vtkIntArray> criticalType{};
criticalType->SetName(ttk::PersistenceCriticalTypeName);
vtkNew<vtkFloatArray> persistenceNode{};
persistenceNode->SetName("Persistence");
vtkNew<vtkDoubleArray> persistenceNode{};
persistenceNode->SetName(ttk::PersistenceName);
vtkNew<vtkIntArray> clusterIDNode{};
clusterIDNode->SetName("ClusterID");
vtkNew<vtkIntArray> isDummyNode{};
Expand Down Expand Up @@ -692,8 +692,6 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization {
vtkNew<vtkIntArray> persistenceBaryOrderNode{};
persistenceBaryOrderNode->SetName("PersistenceBarycenterOrder");

vtkNew<vtkDoubleArray> pairPersistenceNode{};
pairPersistenceNode->SetName(ttk::PersistenceName);
vtkNew<vtkDoubleArray> pairBirthNode{};
pairBirthNode->SetName(ttk::PersistenceBirthName);

Expand All @@ -715,8 +713,8 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization {
customStringArrays.size());

// Arc fields
vtkNew<vtkFloatArray> persistenceArc{};
persistenceArc->SetName("Persistence");
vtkNew<vtkDoubleArray> persistenceArc{};
persistenceArc->SetName(ttk::PersistenceName);
vtkNew<vtkIntArray> clusterIDArc{};
clusterIDArc->SetName("ClusterID");
vtkNew<vtkIntArray> isImportantPairsArc{};
Expand Down Expand Up @@ -750,8 +748,6 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization {
pairType->SetName(ttk::PersistencePairTypeName);
vtkNew<vtkIntArray> pairIsFinite{};
pairIsFinite->SetName(ttk::PersistenceIsFinite);
vtkNew<vtkDoubleArray> pairPersistence{};
pairPersistence->SetName(ttk::PersistenceName);
vtkNew<vtkDoubleArray> pairBirth{};
pairBirth->SetName(ttk::PersistenceBirthName);

Expand Down Expand Up @@ -1194,11 +1190,17 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization {
// Add arc persistence
printMsg(
"// Push arc persistence", ttk::debug::Priority::VERBOSE);
idNode const nodeToGetPers = nodeBranching;
idNode const nodeToGetPers
= (isPersistenceDiagram ? node : nodeBranching);
double const persToAdd
= trees[i]->getNodePersistence<dataType>(nodeToGetPers);
persistenceArc->InsertNextTuple1(persToAdd);

// Add birth
auto birthDeath
= trees[i]->getBirthDeath<dataType>(nodeToGetPers);
pairBirth->InsertNextTuple1(std::get<0>(birthDeath));

// Add arc persistence barycenter and order
if(clusteringOutput and ShiftMode != 1) {
idNode const nodeToGet = nodeBranching;
Expand Down Expand Up @@ -1236,12 +1238,6 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization {
// Add pairIdentifier
pairIdentifier->InsertNextTuple1(treeSimplexId[node]);

// Add birth and death
auto birthDeath = trees[i]->getBirthDeath<dataType>(node);
pairBirth->InsertNextTuple1(std::get<0>(birthDeath));
pairPersistence->InsertNextTuple1(std::get<1>(birthDeath)
- std::get<0>(birthDeath));

// Add isMinMaxPair
bool const isMinMaxPair
= (trees[i]->isRoot(node) and not trees[i]->isLeaf(node))
Expand Down Expand Up @@ -1374,6 +1370,10 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization {
persistenceNode->InsertNextTuple1(
trees[i]->getNodePersistence<dataType>(node));

// Add birth
auto birthDeath = trees[i]->getBirthDeath<dataType>(node);
pairBirthNode->InsertNextTuple1(std::get<0>(birthDeath));

// Add node persistence barycenter
if(clusteringOutput and ShiftMode != 1) {
if(treeMatching[node] < allBaryBranchingID[c].size()) {
Expand All @@ -1399,12 +1399,6 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization {
// Add isInterpolatedTree
isInterpolatedTreeNode->InsertNextTuple1(isInterpolatedTree);

// Add birth and death
auto birthDeath = trees[i]->getBirthDeath<dataType>(node);
pairBirthNode->InsertNextTuple1(std::get<0>(birthDeath));
pairPersistenceNode->InsertNextTuple1(std::get<1>(birthDeath)
- std::get<0>(birthDeath));

// Add isImportantPair
bool isImportant = false;
isImportant = trees[i]->isImportantPair<dataType>(
Expand Down Expand Up @@ -1462,7 +1456,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization {

pairIdentifier->InsertNextTuple1(-1);
pairType->InsertNextTuple1(-1);
pairPersistence->InsertNextTuple1(-1);
persistenceArc->InsertNextTuple1(-1);
pairIsFinite->InsertNextTuple1(0);
pairBirth->InsertNextTuple1(0);

Expand Down Expand Up @@ -1575,7 +1569,6 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization {
if(!treesNodes.empty() and ShiftMode != 1)
vtkOutputNode->GetPointData()->AddArray(coordinates);
}
vtkOutputNode->GetPointData()->AddArray(pairPersistenceNode);
vtkOutputNode->GetPointData()->AddArray(pairBirthNode);

// - Manage arc output
Expand Down Expand Up @@ -1613,7 +1606,6 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization {
vtkArcs->GetCellData()->AddArray(pairType);
vtkArcs->GetCellData()->AddArray(pairIsFinite);
}
vtkArcs->GetCellData()->AddArray(pairPersistence);
vtkArcs->GetCellData()->AddArray(pairBirth);
if(vtkOutputArc == vtkOutputNode)
vtkArcs->GetPointData()->ShallowCopy(vtkOutputNode->GetPointData());
Expand Down

0 comments on commit 9b9c8ba

Please sign in to comment.