46 std::shared_ptr<FTMAtomicVector<SuperArc>>
superArcs;
47 std::shared_ptr<FTMAtomicVector<Node>>
nodes;
48 std::shared_ptr<FTMAtomicVector<idNode>>
roots;
60 std::shared_ptr<FTMAtomicVector<CurrentState>>
states;
73#ifdef TTK_ENABLE_FTM_TREE_STATS_TIME
74 std::vector<ActiveTask> activeTasksStats;
77#ifdef TTK_ENABLE_OMP_PRIORITY
99 FTMTree_MT(
const std::shared_ptr<Params> ¶ms,
100 const std::shared_ptr<Scalars> &scalars,
112 const std::shared_ptr<Scalars> &scalars) {
113 this->scalars_ = scalars;
114 this->params_ = params;
115 this->mt_data_.
treeType = params->treeType;
118 template <
class triangulationType>
120 scalars_->size = triangulation->getNumberOfVertices();
127 return this->scalars_->isHigher(a, b);
131 return this->scalars_->isLower(a, b);
136 return this->scalars_->isLower(a, b);
140 return this->scalars_->isHigher(a, b);
150 template <
typename scalarType>
204 mt_data_.
states = std::make_shared<FTMAtomicVector<CurrentState>>(
216 template <
class triangulationType>
217 void build(
const triangulationType *mesh,
const bool ct);
221 template <
class triangulationType>
222 int leafSearch(
const triangulationType *mesh);
226 template <
class triangulationType>
227 void leafGrowth(
const triangulationType *mesh);
229 template <
class triangulationType>
230 void arcGrowth(
const triangulationType *mesh,
234 template <
class triangulationType>
235 std::tuple<bool, bool>
propagate(
const triangulationType *mesh,
239 template <
class triangulationType>
243 template <
class triangulationType>
248 template <
class triangulationType>
279#ifdef TTK_ENABLE_FTM_TREE_STATS_TIME
280 const ActiveTask &getActiveTasks(
const idSuperArc taskId)
const {
281 return (*
mt_data_.activeTasksStats)[taskId];
303 const bool preproc =
true) {
326#ifdef TTK_ENABLE_OMP_PRIORITY
327 inline void setPrior(
void) {
331 inline bool isPrior(
void)
const {
338 template <
typename scalarType>
340 return (((scalarType *)
scalars_->values))[nodeId];
343 template <
typename scalarType>
345 scalars_->values =
static_cast<void *
>(
const_cast<scalarType *
>(vals));
368#ifndef TTK_ENABLE_KAMIKAZE
370 std::cout <<
"[Merge Tree] get superArc on bad id :" << i;
378#ifndef TTK_ENABLE_KAMIKAZE
380 std::cout <<
"[Merge Tree] get superArc on bad id :" << i;
413#ifndef TTK_ENABLE_KAMIKAZE
415 this->
printErr(
"getLeaves out of bounds: " + std::to_string(
id));
422 inline const std::vector<idNode> &
getRoots()
const {
460#ifndef TTK_ENABLE_KAMIKAZE
462 this->
printErr(
"getCorrespondingNode, Vertex: " + std::to_string(val)
471#ifndef TTK_ENABLE_KAMIKAZE
474 "getCorrespondingSuperArcId, Vertex: " + std::to_string(val)
525 std::vector<idNode>
sortedNodes(
const bool parallel =
false);
576 std::shared_ptr<FTMTree_MT>
clone()
const;
590 const std::string &s,
591 const int debugLevel = 2)
const;
614 template <
class dataType>
617 template <
class dataType>
620 std::vector<double> &excludeLower,
621 std::vector<double> &excludeHigher);
623 template <
class dataType>
637 template <
class dataType>
640 template <
class dataType>
660 template <
class dataType>
664 idNode node, std::tuple<std::vector<idNode>, std::vector<idNode>> &res);
667 std::vector<int> &branchingID,
668 std::vector<std::vector<idNode>> &nodeBranching);
671 std::vector<int> &branchingID);
689 std::vector<idNode> &res);
691 template <
class dataType>
697 template <
class dataType>
701 template <
class dataType>
705 template <
class dataType>
708 template <
class dataType>
711 template <
class dataType>
714 template <
class dataType>
717 template <
class dataType>
720 template <
class dataType>
723 template <
class dataType>
726 template <
class dataType>
729 template <
class dataType>
732 template <
class dataType>
734 std::vector<std::tuple<ftm::idNode, ftm::idNode, dataType>> &pairs,
737 template <
class dataType>
741 std::vector<std::vector<idNode>> &res);
772 template <
class dataType>
775 template <
class dataType>
780 std::stringstream
printTree(
bool doPrint =
true);
784 template <
class dataType>
786 bool doPrint =
true);
788 template <
class dataType>
790 bool printPairs =
true,
791 bool doPrint =
true);
796 template <
class dataType>
798 bool printPairs =
true,
799 bool doPrint =
true);
812 const idNode last = 0)
const;
814 std::tuple<SimplexId, SimplexId>
831 return std::max(minWorks, 1 + (s / (nbtasks *
threadNumber_)));
871 template <
typename type>
876 template <
typename type>
879 ptr = std::make_shared<FTMAtomicVector<type>>();
883 template <
typename type>
885 auto s = vect.size();
886#ifdef TTK_ENABLE_OPENMP
887#pragma omp parallel for num_threads(threadNumber_) schedule(static)
889 for(
typename std::vector<type>::size_type i = 0; i < s; i++) {
898 template <
typename dataType>
906 auto scalarsT = std::make_shared<ftm::Scalars>();
908 scalarsT->values =
nullptr;
913 auto paramsT = std::make_shared<ftm::Params>();
921 template <
typename T,
typename U>
932 MergeTree(
const std::shared_ptr<ftm::Scalars> &scalarsT,
933 const std::shared_ptr<std::vector<dataType>> &scalarValuesT,
934 std::shared_ptr<ftm::Params> ¶msT)
943 scalars = std::make_shared<ftm::Scalars>();
949 params = std::make_shared<ftm::Params>();
AbstractTriangulation is an interface class that defines an interface for efficient traversal methods...
virtual int preconditionVertexNeighbors()
Minimalist debugging class.
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
TTK processing package that manage a parallel vecrion of vector.
bool notNeedToNormalize(idNode nodeId)
std::vector< ftm::idNode > getMultiPersOrigins(bool useBD)
std::stringstream printMultiPersPairsFromTree(bool useBD=false, bool printPairs=true, bool doPrint=true)
Node * getUpperNode(const SuperArc *a)
idCorresp idNode2corr(const idNode id) const
idNode corr2idNode(const idCorresp &corr) const
bool isCorrespondingNode(const SimplexId val) const
std::shared_ptr< Params > params_
void closeOnBackBone(const triangulationType *mesh, SimplexId saddleVert)
void getLevelToNode(std::vector< std::vector< idNode > > &res)
idNode getLeave(const idNode id) const
const scalarType & getValue(SimplexId nodeId) const
std::string printNode(idNode n)
bool isNodeIdInconsistent(idNode nodeId)
SuperArc * getSuperArc(idSuperArc i)
Node * getDownNode(const SuperArc *a)
void setScalars(void *local_scalars)
dataType getNodePersistence(idNode nodeId)
void createAtomicVector(std::shared_ptr< FTMAtomicVector< type > > &ptr)
idNode getNumberOfNodes() const
std::stringstream printTreeScalars(bool printNodeAlone=true, bool doPrint=true)
dataType getMaximumPersistence()
void setParent(idNode nodeId, idNode newParentNodeId)
idNode getUpNodeId(const SuperArc *a)
bool isNodeMerged(idNode nodeId)
void initVector(std::vector< type > &vect, const type val)
SimplexId getChunkSize(const SimplexId nbVerts=-1, const SimplexId nbtasks=100) const
int getNumberOfChildren(idNode nodeId)
bool isCorrespondingNull(const SimplexId val) const
void sortInput()
if sortedVertices_ is null, define and fill it
void delNode(idNode node)
SuperArc * vertex2SuperArc(const SimplexId vert)
std::string printArc(idSuperArc a)
Node * vertex2Node(const SimplexId vert)
void move(FTMTree_MT &mt)
std::tuple< dataType, dataType > getBirthDeath(idNode nodeId)
idSuperArc upArcFromVert(const SimplexId v)
std::tuple< SimplexId, SimplexId > getBoundsFromVerts(const std::vector< SimplexId > &nodes) const
int leafSearch(const triangulationType *mesh)
Node * getLowerNode(const SuperArc *a)
idNode getDownNodeId(const SuperArc *a)
void initNbScalars(const triangulationType *triangulation)
idSuperArc insertNode(Node *node, const bool segm=true)
bool isCorrespondingArc(const SimplexId val) const
void setVertexSoSoffsets(const SimplexId *const sos)
std::stringstream printMultiPersOriginsVectorFromTree(bool doPrint=true)
void getTreeBranching(std::vector< idNode > &branching, std::vector< int > &branchingID, std::vector< std::vector< idNode > > &nodeBranching)
void closeArcsUF(idNode closeNode, UF uf)
bool isRoot(idNode nodeId)
std::tuple< ftm::idNode, ftm::idNode > getBirthDeathNode(idNode nodeId)
void closeAndMergeOnSaddle(const triangulationType *mesh, SimplexId saddleVert)
idNode getLowerNodeId(const SuperArc *a)
void getMultiPersOriginsVectorFromTree(std::vector< std::vector< idNode > > &res)
std::stringstream printSubTree(idNode subRoot)
void makeAlloc()
clear local data for new computation
SimplexId getNumberOfVertices() const
bool isParentInconsistent(ftm::idNode nodeId)
void setNormalizeIds(const bool normalize)
void sortUpArcs(const idNode nid)
idNode getParentSafe(idNode nodeId)
void getBranchSubtree(std::vector< idNode > &branching, idNode branchRoot, std::vector< idNode > &res)
bool isNodeOriginDefined(idNode nodeId)
virtual SimplexId trunkSegmentation(const std::vector< SimplexId > &pendingNodesVerts, const SimplexId begin, const SimplexId stop)
bool isLower(SimplexId a, SimplexId b) const
std::tuple< ftm::idNode, ftm::idNode > getMergedRootBirthDeathNode()
void sortNodes()
Sort tree nodes according to vertex order.
std::tuple< bool, bool > propagate(const triangulationType *mesh, CurrentState ¤tState, UF curUF)
idNode getCorrespondingNodeId(const SimplexId val) const
idSuperArc getNumberOfSuperArcs() const
idNode getUpperNodeId(const SuperArc *a)
void printNodeSS(idNode node, std::stringstream &ss)
void deleteIthUpArc(idNode nodeId, int arcIth)
const std::vector< idNode > & getRoots() const
idNode getMergedRootOrigin()
ftm::idNode getSecondMaximumPersistenceNode()
bool verifyBranchDecompositionInconsistency()
void sortLeaves(const bool parallel=false)
int getNodeLevel(idNode nodeId)
idNode getNumberOfLeaves() const
bool isImportantPair(idNode nodeId, double threshold, std::vector< double > &excludeLower, std::vector< double > &excludeHigher)
void getAllRoots(std::vector< idNode > &res)
void build(const triangulationType *mesh, const bool ct)
Compute the merge.
void finalizeSegmentation()
std::stringstream printNode2(idNode nodeId, bool doPrint=true)
idNode getVertInRange(const std::vector< SimplexId > &range, const SimplexId v, const idNode last=0) const
int getNumberOfLeavesFromTree()
void getPersistencePairsFromTree(std::vector< std::tuple< ftm::idNode, ftm::idNode, dataType > > &pairs, bool useBD)
void setTreeType(const int local_treeType)
void sortDownArcs(const idNode nid)
void getChildren(idNode nodeId, std::vector< idNode > &res)
void deleteNode(idNode nodeId)
int printTime(Timer &t, const std::string &s, const int debugLevel=2) const
const std::vector< idNode > & getLeaves() const
void setVertexScalars(const scalarType *vals)
SimplexId getChunkCount(const SimplexId nbVerts=-1, const SimplexId nbTasks=100) const
void createVector(std::vector< type > &vec)
SimplexId trunkCTSegmentation(const std::vector< SimplexId > &pendingNodesVerts, const SimplexId begin, const SimplexId stop)
idSuperArc openSuperArc(idNode downNodeId)
std::shared_ptr< FTMTree_MT > clone() const
SimplexId trunk(const triangulationType *mesh, const bool ct)
bool isMultiPersPair(idNode nodeId)
std::tuple< dataType, dataType > getMergedRootBirthDeath()
std::stringstream printPairsFromTree(bool useBD=false, bool printPairs=true, bool doPrint=true)
idNode getParent(const idNode n)
idNode makeNode(SimplexId vertexId, SimplexId linked=nullVertex)
int getNumberOfNodeAlone()
bool isLeaf(idNode nodeId)
void buildSegmentation()
use vert2tree to compute the segmentation of the fresh built merge tree.
std::tuple< dataType, dataType > getBirthDeathFromIds(idNode nodeId1, idNode nodeId2)
int getRealNumberOfNodes()
const SuperArc * getSuperArc(idSuperArc i) const
void deleteParent(idNode nodeId)
bool isNodeAlone(idNode nodeId)
idSuperArc getCorrespondingSuperArcId(const SimplexId val) const
void leafGrowth(const triangulationType *mesh)
void setValence(const SimplexId v, const SimplexId val)
idSuperArc makeSuperArc(idNode downNodeId, idNode upNodeId)
void updateCorrespondingNode(const SimplexId vert, const idNode node)
bool isBranchOrigin(idNode nodeId)
void copyMergeTreeStructure(FTMTree_MT *tree)
void getBranchOriginsFromThisBranch(idNode node, std::tuple< std::vector< idNode >, std::vector< idNode > > &res)
Node * getUpNode(const SuperArc *a)
void getLeavesFromTree(std::vector< idNode > &res)
void preconditionTriangulation(AbstractTriangulation *tri, const bool preproc=true)
idNode getLowestNode(idNode nodeStart)
Node * getNode(idNode nodeId)
void closeSuperArc(idSuperArc superArcId, idNode upNodeId)
void getAllNodeLevel(std::vector< int > &res)
std::stringstream printTree(bool doPrint=true)
std::stringstream printMergedRoot(bool doPrint=true)
SimplexId getArcSize(const idSuperArc arcId)
bool isHigher(SimplexId a, SimplexId b) const
dataType getSecondMaximumPersistence()
std::shared_ptr< Scalars > scalars_
void sortArcs()
Sort tree arcs.
void deleteSubtree(idNode nodeId)
void setSegmentation(const bool segm)
void initVectStates(const SimplexId nbLeaves)
void updateCorrespondingArc(const SimplexId vert, const idSuperArc arc)
dataType getBirth(idNode nodeId)
bool isThereOnlyOnePersistencePair()
std::stringstream printTreeStats(bool doPrint=true)
void arcGrowth(const triangulationType *mesh, const SimplexId startVert, const SimplexId orig)
std::vector< idNode > sortedNodes(const bool parallel=false)
void setParamsScalars(const std::shared_ptr< Params > ¶ms, const std::shared_ptr< Scalars > &scalars)
std::tuple< dataType, dataType > getBirthDeathNodeFromIds(idNode nodeId1, idNode nodeId2)
void setVert2Tree(decltype(mt_data_.vert2tree) const &vect2tree)
bool compLower(const SimplexId a, const SimplexId b)
void sortDownArcs(const std::function< bool(const idSuperArc, const idSuperArc)> &comp)
idSuperArc getUpSuperArcId(idSuperArc neighborId) const
SimplexId getVertexId() const
void sortUpArcs(const std::function< bool(const idSuperArc, const idSuperArc)> &comp)
idNode getUpNodeId() const
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
long long int idCorresp
type used to recover Node/Arc in vert2tree SIGNED ONLY
std::ostream & operator<<(std::ostream &o, Node const &n)
unsigned int idNode
Node index in vect_nodes_.
int SimplexId
Identifier type for simplices of any dimension.
coefficient_t normalize(const coefficient_t n, const coefficient_t modulus)
T begin(std::pair< T, T > &p)
std::shared_ptr< ftm::Params > params
MergeTree(const std::shared_ptr< ftm::Scalars > &scalarsT, const std::shared_ptr< std::vector< dataType > > &scalarValuesT, std::shared_ptr< ftm::Params > ¶msT)
void copy(const MergeTree< dataType > &mt)
MergeTree(const T scalarsT, U paramsT)
MergeTree(const MergeTree< dataType > &mt)
std::shared_ptr< std::vector< dataType > > scalarsValues
std::shared_ptr< ftm::Scalars > emptyScalars()
MergeTree< dataType > & operator=(const MergeTree< dataType > &mt)
std::shared_ptr< ftm::Params > emptyParams()
std::shared_ptr< ftm::Scalars > scalars
std::shared_ptr< FTMAtomicVector< SuperArc > > superArcs
std::vector< AtomicUF > storage
std::shared_ptr< FTMAtomicVector< CurrentState > > states
std::vector< std::list< std::vector< SimplexId > > > trunkSegments
std::shared_ptr< FTMAtomicVector< Node > > nodes
std::vector< SimplexId > visitOrder
std::vector< UF > propagation
std::vector< idCorresp > vert2tree
std::shared_ptr< FTMAtomicVector< idNode > > roots
std::vector< valence > valences
std::vector< idNode > leaves
std::vector< char > openedNodes