TTK
Loading...
Searching...
No Matches
MergeTree.h
Go to the documentation of this file.
1
18
19#pragma once
20
21#include <map>
22#include <numeric>
23#include <queue>
24#include <vector>
25
26#include <Geometry.h>
27#include <Triangulation.h>
28
29#include "DeprecatedDataTypes.h"
30#include "DeprecatedNode.h"
32#include "DeprecatedSuperArc.h"
33#include "ExtendedUF.h"
34
35namespace ttk {
36 namespace cf {
37 class MergeTree : virtual public Debug {
38 friend class ContourForests;
39 friend class ContourForestsTree;
40
41 protected:
42 // global
43 std::shared_ptr<Params> params_;
44 std::shared_ptr<Scalars> scalars_;
45
46 // local
48
49 // storage
50 std::list<ExtendedUnionFind> storageEUF_;
51
52 public:
53 // CONSTRUCT
54 // -----------
55 // {
56
57 // Tree with global data and partition number
58 MergeTree(std::shared_ptr<Params> params,
59 std::shared_ptr<Scalars> scalars,
60 TreeType type,
61 idPartition part = nullPartition);
62
63 ~MergeTree() override;
64
65 //}
66 // --------------------
67 // Init
68 // --------------------
69 // {
70
71 template <typename triangulationType>
72 void initNbScalars(const triangulationType &tri) {
73 scalars_->size = tri->getNumberOfVertices();
74 }
75
77 void initTreeType() {
78 treeData_.treeType = params_->treeType;
79 }
80
83 template <typename scalarType>
84 void sortInput();
85
87 void flush() {
88 treeData_.superArcs.clear();
89 treeData_.nodes.clear();
90 treeData_.leaves.clear();
93 treeData_.vert2tree.clear();
94 treeData_.vert2tree.resize(scalars_->size, nullCorresp);
95 }
96
97 //}
98 // -------------
99 // ACCESSOR
100 // ------------
101 // {
102 //{
103
104 // global
105 // called for the tree used by the wrapper (only).
106 // On this implementation, the warpper communicate with ContourForest
107 // A child class of this one.
108
109 inline int setDebugLevel(const int &local_debugLevel) override {
110 Debug::setDebugLevel(local_debugLevel);
111 params_->debugLevel = local_debugLevel;
112 return 0;
113 }
114
115 inline void setTreeType(const int &local_treeType) {
116 params_->treeType = static_cast<TreeType>(local_treeType);
117 }
118
119 inline void setSimplificationMethod(const int &local_simplifyMethod) {
120 params_->simplifyMethod
121 = static_cast<SimplifMethod>(local_simplifyMethod);
122 }
123
125 const double &local_simplificationThreshold) {
126 params_->simplifyThreshold = local_simplificationThreshold;
127 }
128
129 inline void setScalars(void *local_scalars) {
130 scalars_->values = local_scalars;
131 }
132
134 const bool preproc = true) {
135 if(m && preproc) {
138 }
139 }
140
141 // }
142 // partition
143 // .....................{
144
145 inline idPartition getPartition() const {
146 return treeData_.partition;
147 }
148
149 // }
150 // scalar
151 // .....................{
152
153 template <typename scalarType>
154 inline const scalarType &getValue(const SimplexId &nodeId) const {
155 return (((scalarType *)scalars_->values))[nodeId];
156 }
157
158 template <typename scalarType>
159 inline void setVertexScalars(scalarType *vals) {
160 scalars_->values = (void *)vals;
161 }
162
163 // }
164 // offset
165 // .....................{
166
175 inline void setVertexSoSoffsets(const SimplexId *const offsets) {
176 scalars_->sosOffsets = offsets;
177 }
178
179 // }
180 // arcs
181 // .....................{
182
184 return treeData_.superArcs.size();
185 }
186
188 // Costly ! for dedbug only
189 idSuperArc visibleArc = 0;
190 for(const SuperArc &arc : treeData_.superArcs) {
191 if(arc.isVisible())
192 ++visibleArc;
193 }
194 return visibleArc;
195 }
196
197 inline const std::vector<SuperArc> &getSuperArc() const {
198 // break encapsulation...
199 return treeData_.superArcs;
200 }
201
202 inline SuperArc *getSuperArc(const idSuperArc &i) {
203#ifndef TTK_ENABLE_KAMIKAZE
204 if((size_t)i >= treeData_.superArcs.size()) {
205 std::cout << "[Merge Tree] get superArc on bad id :" << i;
206 std::cout << " / " << treeData_.superArcs.size() << std::endl;
207 }
208#endif
209 return &(treeData_.superArcs[i]);
210 }
211
213 // Costly ! for dedbug only
214 SimplexId res = 0;
215 SuperArc *a = getSuperArc(sa);
216 const auto nbReg = a->getNumberOfRegularNodes();
217 for(SimplexId v = 0; v < nbReg; v++) {
218 if(!a->isMasqued(v))
219 ++res;
220 }
221
222 return res;
223 }
224
225 inline void addCrossingAbove(const idSuperArc &sa) {
226 treeData_.arcsCrossingAbove.emplace_back(sa);
227 }
228
229 // arcsCrossingBelow is not used.
230
231 // }
232 // nodes
233 // .....................{
234
235 inline idNode getNumberOfNodes() const {
236 return treeData_.nodes.size();
237 }
238
239 inline const std::vector<Node> &getNodes() const {
240 // break encapsulation...
241 return treeData_.nodes;
242 }
243
244 inline Node *getNode(const idNode &nodeId) {
245 return &(treeData_.nodes[nodeId]);
246 }
247
248 // }
249 // leaves / root
250 // .....................{
251
253 return treeData_.leaves.size();
254 }
255
256 inline const std::vector<idNode> &getLeaves() const {
257 // break encapsulation...
258 return treeData_.leaves;
259 }
260
261 inline const idNode &getLeave(const idNode &id) const {
262#ifndef TTK_ENABLE_KAMIKAZE
263 if(id > treeData_.leaves.size()) {
264 this->printErr("getLeaves out of bounds: " + std::to_string(id));
265 return treeData_.leaves[0];
266 }
267#endif
268 return treeData_.leaves[id];
269 }
270
271 inline const std::vector<idNode> &getRoots() const {
272 // break encapsulation...
273 return treeData_.roots;
274 }
275
276 // }
277 // vert2tree
278 // .....................{
279
280 inline void setVert2Tree(decltype(treeData_.vert2tree) const &vect2tree) {
281 treeData_.vert2tree = vect2tree;
282 }
283
284 // }
285 // }
286 // --------------------
287 // VERT 2 TREE Special functions
288 // --------------------
289 //{
290
291 // test vertex correpondance
292 // ...........................{
293
294 inline bool isCorrespondingArc(const SimplexId &val) const {
295 return !isCorrespondingNull(val) && treeData_.vert2tree[val] >= 0;
296 }
297
298 inline bool isCorrespondingNode(const SimplexId &val) const {
299 return treeData_.vert2tree[val] < 0;
300 }
301
302 inline bool isCorrespondingNull(const SimplexId &val) const {
303 return treeData_.vert2tree[val] == nullCorresp;
304 }
305
306 //}
307 // Get vertex info
308 // ...........................{
309
310 inline idNode getCorrespondingNodeId(const SimplexId &val) const {
311#ifndef TTK_ENABLE_KAMIKAZE
312 if(!isCorrespondingNode(val)) {
313 this->printErr("getCorrespondingNode, Vertex: " + std::to_string(val)
314 + " is not a node: "
315 + std::to_string(treeData_.vert2tree[val]));
316 }
317#endif
318 return corr2idNode(val);
319 }
320
322#ifndef TTK_ENABLE_KAMIKAZE
323 if(!isCorrespondingArc(val)) {
324 this->printErr(
325 "getCorrespondingSuperArcId, Vertex: " + std::to_string(val)
326 + " is not on an arc: " + std::to_string(treeData_.vert2tree[val]));
327 }
328#endif
329 return treeData_.vert2tree[val];
330 }
331
332 // }
333 // Get vertex corresponding object
334 // ................................{
335
336 inline SuperArc *vertex2SuperArc(const SimplexId &vert) {
338 }
339
340 inline Node *vertex2Node(const SimplexId &vert) {
341 return &(treeData_.nodes[getCorrespondingNodeId(vert)]);
342 }
343
344 // }
345 // Update vertex info
346 // ................................{
347
348 inline void updateCorrespondingArc(const SimplexId &arc,
349 const idSuperArc &val) {
350 treeData_.vert2tree[arc] = val;
351 }
352
353 inline void updateCorrespondingNode(const SimplexId &vert,
354 const idNode &val) {
355 treeData_.vert2tree[vert] = idNode2corr(val);
356 }
357
358 inline idCorresp idNode2corr(const idNode &id) const {
359 // transform idNode to special value for the array : -idNode -1
360 return -static_cast<idCorresp>(id + 1);
361 }
362
363 inline idNode corr2idNode(const idCorresp &corr) const {
364 return static_cast<idNode>(-(treeData_.vert2tree[corr] + 1));
365 }
366
367 // }
368
369 // }
370 // -------------------
371 // Process
372 // -------------------
373 //{
374
375 // build
376 // ..........................{
377
378 // Merge tree processing of a vertex during build
379 template <typename triangulationType>
380 void processVertex(const SimplexId &vertex,
381 std::vector<ExtendedUnionFind *> &vect_baseUF,
382 const bool overlapB,
383 const bool overlapA,
384 const triangulationType &mesh,
386
388 template <typename triangulationType>
389 int build(std::vector<ExtendedUnionFind *> &vect_baseUF,
390 const std::vector<SimplexId> &overlapBefore,
391 const std::vector<SimplexId> &overlapAfter,
392 SimplexId start,
394 const SimplexId &posSeed0,
395 const SimplexId &posSeed1,
396 const triangulationType &mesh);
397
398 // }
399 // Simplify
400 // ...........................{
401
402 // BFS simplification for local CT
403 template <typename scalarType>
405 const SimplexId &podSeed0,
406 const SimplexId &podSeed1,
407 std::list<std::vector<std::pair<SimplexId, bool>>> &storage);
408
409 // BFS simpliciation for global CT
410 template <typename scalarType, typename triangulationType>
412 const SimplexId posSeed0,
413 const SimplexId posSeed1,
414 std::list<std::vector<std::pair<SimplexId, bool>>> &storage,
415 const triangulationType &mesh);
416
417 // Having sorted std::pairs, simplify the current tree
418 // in accordance with threashol, between the two seeds.
419 template <typename scalarType>
421 const SimplexId &posSeed0,
422 const SimplexId &posSeed1,
423 std::list<std::vector<std::pair<SimplexId, bool>>> &storage,
424 const std::vector<std::tuple<SimplexId, SimplexId, scalarType, bool>>
425 &sortedPairs);
426
427 // add this arc in the subtree which is in the parentNode
428 void markThisArc(std::vector<ExtendedUnionFind *> &ufArray,
429 const idNode &curNodeId,
430 const idSuperArc &mergingArcId,
431 const idNode &parentNodeId);
432 // }
433 // PersistencePairs
434 // ...........................{
435
436 template <typename scalarType, typename triangulationType>
438 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs,
439 const triangulationType &mesh);
440
441 template <typename scalarType, typename triangulationType>
443 std::vector<std::tuple<SimplexId, SimplexId, scalarType, bool>> &pairs,
444 const triangulationType &mesh);
445
446 // Construct abstract JT / ST on a CT and fill std::pairs in accordance.
447 // used for global simplification
448 template <typename scalarType, typename triangulationType>
449 void recoverMTPairs(
450 const std::vector<idNode> &sortedNodes,
451 std::vector<std::tuple<SimplexId, SimplexId, scalarType, bool>>
452 &pairsJT,
453 std::vector<std::tuple<SimplexId, SimplexId, scalarType, bool>>
454 &pairsST,
455 const triangulationType &mesh);
456
457 // }
458
459 // }
460 // --------------------------------
461 // Arcs and node manipulations
462 // --------------------------------
463 // {
464
465 // SuperArcs
466 // .......................{
467
468 idSuperArc openSuperArc(const idNode &downNodeId,
469 const bool overlapB,
470 const bool overlapA);
471
472 idSuperArc makeSuperArc(const idNode &downNodeId,
473 const idNode &upNodeId,
474 const bool overlapB,
475 const bool overlapA,
476 std::pair<SimplexId, bool> *vertexList = nullptr,
477 SimplexId vertexSize = -1);
478
479 void closeSuperArc(const idSuperArc &superArcId,
480 const idNode &upNodeId,
481 const bool overlapB,
482 const bool overlapA);
483
484 void hideArc(const idSuperArc &sa);
485
486 void mergeArc(const idSuperArc &sa,
487 const idSuperArc &recept,
488 const bool changeConnectivity = true);
489
491 const std::pair<SimplexId, bool> &seed);
492
494 const std::pair<SimplexId, bool> &seed,
495 const std::vector<idCorresp> &vert2treeOther);
496
497 // is there an external arc linkind node with treeNode in tree
498 bool alreadyExtLinked(const idNode &node,
499 const idPartition &tree,
500 const idNode &treeNode);
501
503
504 // TODO Remove that
505
506 void removeHiddenDownArcs(const idNode &n);
507
508 void removeInternalDownArcs(const idNode &node);
509
511
513
514 // }
515 // Nodes
516 // ...........................{
517
518 idNode makeNode(const SimplexId &vertexId,
519 const SimplexId &linked = nullVertex);
520
521 idNode makeNode(const Node *const n,
522 const SimplexId &linked = nullVertex);
523
524 idSuperArc insertNode(Node *node, const bool segment);
525
526 idSuperArc reverseInsertNode(Node *node, const bool segment);
527
528 inline Node *getDownNode(const SuperArc *a);
529
530 inline Node *getUpNode(const SuperArc *a);
531
532 idNode getParent(const idNode &n);
533
534 void delNode(const idNode &node,
535 std::list<std::vector<std::pair<SimplexId, bool>>> &storage,
536 const std::pair<SimplexId, bool> *mv = nullptr,
537 const SimplexId &nbm = 0);
538
539 void hideNode(const idNode &node);
540
541 // For persistence std::pair on CT
542 // these function allow to make a JT / ST od the CT
543 std::vector<idNode> getNodeNeighbors(const idNode &node);
544
545 std::vector<idNode> getNodeUpNeighbors(const idNode &n);
546
547 std::vector<idNode> getNodeDownNeighbors(const idNode &n);
548
549 // Remove part not in partition
550
551 void hideAndClearArcsAbove(const idNode &baseNode);
552
553 void hideAndClearArcsBelow(const idNode &baseNode, const SimplexId &seed);
554
556 const SimplexId &v);
557
558 // }
559 // Update information
560 // ...........................{
561
562 void updateSegmentation();
563
564 void parallelUpdateSegmentation(const bool ct = false);
565
566 // will disappear
567 void parallelInitNodeValence(const int nbThreadValence);
568
569 // }
570
571 // }
572 // ---------------------------
573 // Operators : print & clone
574 // ---------------------------
575 // {
576
577 // Print
578 void printTree2();
579
580 std::string printArc(const idSuperArc &a) {
581 const SuperArc *sa = getSuperArc(a);
582 std::stringstream res;
583 res << a << ": ";
584 if(sa->getDownCT() == treeData_.partition)
585 res << getNode(sa->getDownNodeId())->getVertexId() << " -- ";
586 else
587 res << "(extern) -- ";
588
589 if(sa->getUpCT() == treeData_.partition)
590 res << getNode(sa->getUpNodeId())->getVertexId();
591 else
592 res << "(extern)";
593
594 res << " \t\t(vis:" << sa->isVisible() << ")";
595 return res.str();
596 }
597
598 std::string printNode(const idNode &n) {
599 const Node *node = getNode(n);
600 std::stringstream res;
601 res << n << " : (";
602 res << node->getVertexId() << ") / ";
603
604 for(idSuperArc i = 0; i < node->getNumberOfUpSuperArcs(); ++i) {
605 if(getSuperArc(node->getUpSuperArcId(i))->isVisible()) {
606 res << "+";
607 } else {
608 res << "-";
609 }
610 res << node->getUpSuperArcId(i) << " ";
611 }
612
613 res << " \\ ";
614
615 for(idSuperArc i = 0; i < node->getNumberOfDownSuperArcs(); ++i) {
616 if(getSuperArc(node->getDownSuperArcId(i))->isVisible()) {
617 res << "+";
618 } else {
619 res << "-";
620 }
621 res << node->getDownSuperArcId(i) << " ";
622 }
623
624 res << "\t\t(vis:" << node->isVisible() << " )";
625 return res.str();
626 }
627
628 // Clone
629 std::shared_ptr<MergeTree> clone() const;
630
631 void clone(const MergeTree *mt);
632
633 void doSwap(MergeTree *mt);
634
635 //}
636
637 protected:
638 // ------------------
639 // Comparisons
640 // -----------------
641 // {
642
643 // Strict
644
645 inline bool isLower(const SimplexId &a, const SimplexId &b) const {
646 return scalars_->isLower(a, b);
647 }
648
649 inline bool isHigher(const SimplexId &a, const SimplexId &b) const {
650 return scalars_->isHigher(a, b);
651 }
652
653 //}
654
655 private:
656 // ------------------
657 // Comparisons
658 // -----------------
659 // {
660 // Compare using the scalar array : only for sort step
661
662 template <typename scalarType>
663 inline bool isLower(const SimplexId &a, const SimplexId &b) const {
664 return ((scalarType *)scalars_->values)[a]
665 < ((scalarType *)scalars_->values)[b]
666 || (((scalarType *)scalars_->values)[a]
667 == ((scalarType *)scalars_->values)[b]
668 && scalars_->sosOffsets[a] < scalars_->sosOffsets[b]);
669 }
670
671 template <typename scalarType>
672 inline bool isHigher(const SimplexId &a, const SimplexId &b) const {
673 return ((scalarType *)scalars_->values)[a]
674 > ((scalarType *)scalars_->values)[b]
675 || (((scalarType *)scalars_->values)[a]
676 == ((scalarType *)scalars_->values)[b]
677 && scalars_->sosOffsets[a] > scalars_->sosOffsets[b]);
678 }
679
680 template <typename scalarType>
681 inline bool isEqLower(const SimplexId &a, const SimplexId &b) const {
682 return ((scalarType *)scalars_->values)[a]
683 < ((scalarType *)scalars_->values)[b]
684 || (((scalarType *)scalars_->values)[a]
685 == ((scalarType *)scalars_->values)[b]
686 && scalars_->sosOffsets[a] <= scalars_->sosOffsets[b]);
687 }
688
689 template <typename scalarType>
690 inline bool isEqHigher(const SimplexId &a, const SimplexId &b) const {
691 return ((scalarType *)scalars_->values)[a]
692 > ((scalarType *)scalars_->values)[b]
693 || (((scalarType *)scalars_->values)[a]
694 == ((scalarType *)scalars_->values)[b]
695 && scalars_->sosOffsets[a] >= scalars_->sosOffsets[b]);
696 }
697
698 // }
699 // ----------------
700 // Simplification
701 // ----------------
702 // {
703
704 // preserve = do no hide it.
705 void hideAndMerge(const idSuperArc &mergingArcId,
706 const idSuperArc &receptacleArcId,
707 const bool preserveDownNode = false);
708
709 // Use BFS from root to find down and up of the receptarc (maintaining
710 // segmentation information)
711 std::tuple<idNode, idNode, SimplexId> createReceptArc(
712 const idNode &root,
713 const idSuperArc &receptArcId,
714 std::vector<ExtendedUnionFind *> &arrayUF,
715 const std::vector<std::pair<idSuperArc, idSuperArc>> &valenceOffsets);
716
717 // during this BFS nodes should have only one arc up/down : find it :
718 idSuperArc newUpArc(const idNode &curNodeId,
719 std::vector<ExtendedUnionFind *> &ufArray);
720
721 idSuperArc newDownArc(const idNode &curNodeId,
722 std::vector<ExtendedUnionFind *> &ufArray);
723
724 // }
725 // --------------
726 // Tool
727 // --------------
728 // {
729 // create a std::pair with relative order : child vertex first
730
731 inline std::pair<SimplexId, SimplexId>
732 reorderEdgeRel(const std::pair<SimplexId, SimplexId> &vert) {
734 if(isHigher(vert.first, vert.second)) {
735 return vert;
736 }
737
738 return std::make_pair(vert.second, vert.first);
739 } // else
740
741 if(isLower(vert.first, vert.second))
742 return vert;
743
744 return std::make_pair(vert.second, vert.first);
745 }
746
747 template <typename triangulationType>
748 bool verifyTree(const triangulationType &mesh);
749
750 // Create a std::pair with the value corresponding to the simplification
751 // method
752
753 template <typename scalarType, typename triangulationType>
754 void addPair(
755 std::vector<std::tuple<SimplexId, SimplexId, scalarType, bool>> &pairs,
756 const SimplexId &orig,
757 const SimplexId &term,
758 const triangulationType &mesh,
759 const bool goUp);
760
761 template <typename scalarType, typename triangulationType>
762 void addPair(
763 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs,
764 const SimplexId &orig,
765 const SimplexId &term,
766 const triangulationType &mesh);
767
768 // }
769 };
770
771 std::ostream &operator<<(std::ostream &o, Node const &n);
772 std::ostream &operator<<(std::ostream &o, SuperArc const &a);
773
774 } // namespace cf
775} // namespace ttk
776
777#include <MergeTreeTemplate.h>
AbstractTriangulation is an interface class that defines an interface for efficient traversal methods...
Legacy backward compatibility.
Definition Debug.h:472
Minimalist debugging class.
Definition Debug.h:88
virtual int setDebugLevel(const int &debugLevel)
Definition Debug.cpp:147
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Definition Debug.h:149
void hideAndClearArcsBelow(const idNode &baseNode, const SimplexId &seed)
void hideArc(const idSuperArc &sa)
void updateCorrespondingNode(const SimplexId &vert, const idNode &val)
Definition MergeTree.h:353
std::list< ExtendedUnionFind > storageEUF_
Definition MergeTree.h:50
const scalarType & getValue(const SimplexId &nodeId) const
Definition MergeTree.h:154
idSuperArc getNumberOfVisibleArcs() const
Definition MergeTree.h:187
idNode makeNode(const SimplexId &vertexId, const SimplexId &linked=nullVertex)
SuperArc * vertex2SuperArc(const SimplexId &vert)
Definition MergeTree.h:336
Node * vertex2Node(const SimplexId &vert)
Definition MergeTree.h:340
idSuperArc insertNode(Node *node, const bool segment)
void delNode(const idNode &node, std::list< std::vector< std::pair< SimplexId, bool > > > &storage, const std::pair< SimplexId, bool > *mv=nullptr, const SimplexId &nbm=0)
int setDebugLevel(const int &local_debugLevel) override
Definition MergeTree.h:109
idNode getNumberOfNodes() const
Definition MergeTree.h:235
const std::vector< Node > & getNodes() const
Definition MergeTree.h:239
idSuperArc openSuperArc(const idNode &downNodeId, const bool overlapB, const bool overlapA)
void sortInput()
if sortedVertices_ is null, define and fill it Also fill the mirror std::vector
int build(std::vector< ExtendedUnionFind * > &vect_baseUF, const std::vector< SimplexId > &overlapBefore, const std::vector< SimplexId > &overlapAfter, SimplexId start, SimplexId end, const SimplexId &posSeed0, const SimplexId &posSeed1, const triangulationType &mesh)
Compute the merge tree using Carr's algorithm.
std::string printArc(const idSuperArc &a)
Definition MergeTree.h:580
std::vector< idNode > getNodeNeighbors(const idNode &node)
SimplexId globalSimplify(const SimplexId posSeed0, const SimplexId posSeed1, std::list< std::vector< std::pair< SimplexId, bool > > > &storage, const triangulationType &mesh)
void doSwap(MergeTree *mt)
std::shared_ptr< Scalars > scalars_
Definition MergeTree.h:44
bool isCorrespondingArc(const SimplexId &val) const
Definition MergeTree.h:294
void initTreeType()
init the type of the current tree from params
Definition MergeTree.h:77
void mergeArc(const idSuperArc &sa, const idSuperArc &recept, const bool changeConnectivity=true)
idNode getParent(const idNode &n)
void removeInternalDownArcs(const idNode &node)
void removeHiddenDownArcs(const idNode &n)
void setVert2Tree(decltype(treeData_.vert2tree) const &vect2tree)
Definition MergeTree.h:280
void setTreeType(const int &local_treeType)
Definition MergeTree.h:115
idSuperArc getNumberOfExternalDownArcs(const idNode &node)
idPartition getPartition() const
Definition MergeTree.h:145
std::shared_ptr< MergeTree > clone() const
void markThisArc(std::vector< ExtendedUnionFind * > &ufArray, const idNode &curNodeId, const idSuperArc &mergingArcId, const idNode &parentNodeId)
void setScalars(void *local_scalars)
Definition MergeTree.h:129
void preconditionTriangulation(AbstractTriangulation *const m, const bool preproc=true)
Definition MergeTree.h:133
void addCrossingAbove(const idSuperArc &sa)
Definition MergeTree.h:225
std::vector< idNode > getNodeUpNeighbors(const idNode &n)
void setSimplificationMethod(const int &local_simplifyMethod)
Definition MergeTree.h:119
idSuperArc getNumberOfSuperArcs() const
Definition MergeTree.h:183
Node * getUpNode(const SuperArc *a)
void processVertex(const SimplexId &vertex, std::vector< ExtendedUnionFind * > &vect_baseUF, const bool overlapB, const bool overlapA, const triangulationType &mesh, DebugTimer &begin)
bool isCorrespondingNode(const SimplexId &val) const
Definition MergeTree.h:298
SimplexId localSimplify(const SimplexId &podSeed0, const SimplexId &podSeed1, std::list< std::vector< std::pair< SimplexId, bool > > > &storage)
idSuperArc reverseInsertNode(Node *node, const bool segment)
SimplexId getVertBelowSeed(const idSuperArc &arc, const std::pair< SimplexId, bool > &seed, const std::vector< idCorresp > &vert2treeOther)
SimplexId simplifyTree(const SimplexId &posSeed0, const SimplexId &posSeed1, std::list< std::vector< std::pair< SimplexId, bool > > > &storage, const std::vector< std::tuple< SimplexId, SimplexId, scalarType, bool > > &sortedPairs)
idNode corr2idNode(const idCorresp &corr) const
Definition MergeTree.h:363
idSuperArc makeSuperArc(const idNode &downNodeId, const idNode &upNodeId, const bool overlapB, const bool overlapA, std::pair< SimplexId, bool > *vertexList=nullptr, SimplexId vertexSize=-1)
std::string printNode(const idNode &n)
Definition MergeTree.h:598
void updateCorrespondingArc(const SimplexId &arc, const idSuperArc &val)
Definition MergeTree.h:348
void setSimplificationThreshold(const double &local_simplificationThreshold)
Definition MergeTree.h:124
bool isHigher(const SimplexId &a, const SimplexId &b) const
Definition MergeTree.h:649
idNode getCorrespondingNodeId(const SimplexId &val) const
Definition MergeTree.h:310
idSuperArc getCorrespondingSuperArcId(const SimplexId &val) const
Definition MergeTree.h:321
void closeSuperArc(const idSuperArc &superArcId, const idNode &upNodeId, const bool overlapB, const bool overlapA)
void flush()
clear local data for new computation
Definition MergeTree.h:87
void hideNode(const idNode &node)
TreeData treeData_
Definition MergeTree.h:47
Node * getDownNode(const SuperArc *a)
const std::vector< idNode > & getLeaves() const
Definition MergeTree.h:256
bool isCorrespondingNull(const SimplexId &val) const
Definition MergeTree.h:302
SimplexId getNumberOfVisibleRegularNode(const idSuperArc &sa)
Definition MergeTree.h:212
void parallelUpdateSegmentation(const bool ct=false)
const idNode & getLeave(const idNode &id) const
Definition MergeTree.h:261
SimplexId getNumberOfLeaves() const
Definition MergeTree.h:252
int computePersistencePairs(std::vector< std::tuple< SimplexId, SimplexId, scalarType > > &pairs, const triangulationType &mesh)
idSuperArc getNumberOfUnmergedDownArcs(const idNode &n)
void setVertexScalars(scalarType *vals)
Definition MergeTree.h:159
SuperArc * getSuperArc(const idSuperArc &i)
Definition MergeTree.h:202
bool isLower(const SimplexId &a, const SimplexId &b) const
Definition MergeTree.h:645
void hideAndClearArcsAbove(const idNode &baseNode)
void initNbScalars(const triangulationType &tri)
Definition MergeTree.h:72
void recoverMTPairs(const std::vector< idNode > &sortedNodes, std::vector< std::tuple< SimplexId, SimplexId, scalarType, bool > > &pairsJT, std::vector< std::tuple< SimplexId, SimplexId, scalarType, bool > > &pairsST, const triangulationType &mesh)
idSuperArc hideAndClearLeadingTo(const idNode &baseNode, const SimplexId &v)
~MergeTree() override
SimplexId insertNodeAboveSeed(const idSuperArc &arc, const std::pair< SimplexId, bool > &seed)
bool alreadyExtLinked(const idNode &node, const idPartition &tree, const idNode &treeNode)
const std::vector< SuperArc > & getSuperArc() const
Definition MergeTree.h:197
void setVertexSoSoffsets(const SimplexId *const offsets)
Definition MergeTree.h:175
const std::vector< idNode > & getRoots() const
Definition MergeTree.h:271
Node * getNode(const idNode &nodeId)
Definition MergeTree.h:244
void parallelInitNodeValence(const int nbThreadValence)
void updateSegmentation()
Definition MergeTree.cpp:44
std::shared_ptr< Params > params_
Definition MergeTree.h:43
std::vector< idNode > getNodeDownNeighbors(const idNode &n)
idCorresp idNode2corr(const idNode &id) const
Definition MergeTree.h:358
SimplexId getVertexId() const
idSuperArc getDownSuperArcId(const idSuperArc &neighborId) const
idSuperArc getNumberOfUpSuperArcs() const
bool isVisible() const
idSuperArc getUpSuperArcId(const idSuperArc &neighborId) const
idSuperArc getNumberOfDownSuperArcs() const
idPartition getDownCT() const
bool isMasqued(const SimplexId &v) const
const idNode & getUpNodeId() const
SimplexId getNumberOfRegularNodes()
const idNode & getDownNodeId() const
idPartition getUpCT() const
std::ostream & operator<<(std::ostream &o, Node const &n)
long long int idCorresp
type used to recover Node/Arc in vert2tree SIGNED ONLY
numThread idPartition
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
unsigned int idNode
Node index in vect_nodes_.
The Topology ToolKit.
int SimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:22
T end(std::pair< T, T > &p)
Definition ripserpy.cpp:483
T begin(std::pair< T, T > &p)
Definition ripserpy.cpp:479
std::vector< idSuperArc > arcsCrossingAbove
std::vector< idNode > leaves
std::vector< Node > nodes
std::vector< SuperArc > superArcs
std::vector< idSuperArc > arcsCrossingBelow
std::vector< idNode > roots
std::vector< idCorresp > vert2tree