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);
146 return comp_.vertLower(a, b);
150 template <
typename scalarType>
204 mt_data_.states = std::make_shared<FTMAtomicVector<CurrentState>>(
205 nbLeaves,
comp_.vertHigher);
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
369 if(i >=
mt_data_.superArcs->size()) {
370 std::cout <<
"[Merge Tree] get superArc on bad id :" << i;
371 std::cout <<
" / " <<
mt_data_.superArcs->size() << std::endl;
378#ifndef TTK_ENABLE_KAMIKAZE
379 if(i >=
mt_data_.superArcs->size()) {
380 std::cout <<
"[Merge Tree] get superArc on bad id :" << i;
381 std::cout <<
" / " <<
mt_data_.superArcs->size() << std::endl;
394 return &((*
mt_data_.nodes)[nodeId]);
413#ifndef TTK_ENABLE_KAMIKAZE
415 this->
printErr(
"getLeaves out of bounds: " + std::to_string(
id));
422 inline const std::vector<idNode> &
getRoots()
const {
454 return mt_data_.vert2tree[val] == nullCorresp;
460#ifndef TTK_ENABLE_KAMIKAZE
462 this->
printErr(
"getCorrespondingNode, Vertex: " + std::to_string(val)
464 + std::to_string(
mt_data_.vert2tree[val]));
471#ifndef TTK_ENABLE_KAMIKAZE
474 "getCorrespondingSuperArcId, Vertex: " + std::to_string(val)
475 +
" is not on an arc: " + std::to_string(
mt_data_.vert2tree[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)
const;
623 template <
class dataType>
637 template <
class dataType>
640 template <
class dataType>
660 template <
class dataType>
665 std::tuple<std::vector<idNode>, std::vector<idNode>> &res)
const;
669 std::vector<int> &branchingID,
670 std::vector<std::vector<idNode>> &nodeBranching)
const;
673 std::vector<int> &branchingID)
const;
691 std::vector<idNode> &res)
const;
693 template <
class dataType>
699 template <
class dataType>
703 template <
class dataType>
704 std::tuple<dataType, dataType>
707 template <
class dataType>
710 template <
class dataType>
711 std::tuple<ftm::idNode, ftm::idNode>
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>
735 template <
class dataType>
737 std::vector<std::tuple<ftm::idNode, ftm::idNode, dataType>> &pairs,
740 template <
class dataType>
744 std::vector<std::vector<idNode>> &res)
const;
775 template <
class dataType>
778 template <
class dataType>
783 std::stringstream
printTree(
bool doPrint =
true)
const;
787 template <
class dataType>
789 bool doPrint =
true)
const;
791 template <
class dataType>
793 bool printPairs =
true,
794 bool doPrint =
true)
const;
799 template <
class dataType>
801 bool printPairs =
true,
802 bool doPrint =
true)
const;
815 const idNode last = 0)
const;
817 std::tuple<SimplexId, SimplexId>
834 return std::max(minWorks, 1 + (s / (nbtasks *
threadNumber_)));
874 template <
typename type>
879 template <
typename type>
882 ptr = std::make_shared<FTMAtomicVector<type>>();
886 template <
typename type>
888 auto s = vect.size();
889#ifdef TTK_ENABLE_OPENMP
890#pragma omp parallel for num_threads(threadNumber_) schedule(static)
892 for(
typename std::vector<type>::size_type i = 0; i < s; i++) {
901 template <
typename dataType>
909 auto scalarsT = std::make_shared<ftm::Scalars>();
911 scalarsT->values =
nullptr;
916 auto paramsT = std::make_shared<ftm::Params>();
924 template <
typename T,
typename U>
930 for(
unsigned int i = 0; i <
tree.getNumberOfNodes(); ++i)
935 MergeTree(
const std::shared_ptr<ftm::Scalars> &scalarsT,
936 const std::shared_ptr<std::vector<dataType>> &scalarValuesT,
937 std::shared_ptr<ftm::Params> ¶msT)
946 scalars = std::make_shared<ftm::Scalars>();
952 params = std::make_shared<ftm::Params>();
AbstractTriangulation is an interface class that defines an interface for efficient traversal methods...
virtual int preconditionVertexNeighbors()
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
std::stringstream printMultiPersPairsFromTree(bool useBD=false, bool printPairs=true, bool doPrint=true) const
std::stringstream printMultiPersOriginsVectorFromTree(bool doPrint=true) const
std::tuple< dataType, dataType > getMergedRootBirthDeath() const
void getMultiPersOriginsVectorFromTree(std::vector< std::vector< idNode > > &res) const
Node * getUpperNode(const SuperArc *a)
bool isBranchOrigin(idNode nodeId) const
idCorresp idNode2corr(const idNode id) const
int getNumberOfLeavesFromTree() const
idNode corr2idNode(const idCorresp &corr) const
bool isCorrespondingNode(const SimplexId val) const
int getNumberOfNodeAlone() const
Node * getNode(idNode nodeId) const
std::shared_ptr< Params > params_
void closeOnBackBone(const triangulationType *mesh, SimplexId saddleVert)
std::stringstream printTree(bool doPrint=true) const
idNode getLeave(const idNode id) const
const scalarType & getValue(SimplexId nodeId) const
FTMTree_MT(const std::shared_ptr< Params > ¶ms, const std::shared_ptr< Scalars > &scalars, TreeType type)
std::string printNode(idNode n)
void getChildren(idNode nodeId, std::vector< idNode > &res) const
SuperArc * getSuperArc(idSuperArc i)
Node * getDownNode(const SuperArc *a)
void setScalars(void *local_scalars)
std::tuple< ftm::idNode, ftm::idNode > getBirthDeathNode(idNode nodeId) const
std::tuple< dataType, dataType > getBirthDeathNodeFromIds(idNode nodeId1, idNode nodeId2) const
void createAtomicVector(std::shared_ptr< FTMAtomicVector< type > > &ptr)
void getTreeBranching(std::vector< idNode > &branching, std::vector< int > &branchingID, std::vector< std::vector< idNode > > &nodeBranching) const
std::stringstream printNode2(idNode nodeId, bool doPrint=true) const
idNode getNumberOfNodes() const
bool isMultiPersPair(idNode nodeId) const
void setParent(idNode nodeId, idNode newParentNodeId)
idNode getUpNodeId(const SuperArc *a)
void initVector(std::vector< type > &vect, const type val)
SimplexId getChunkSize(const SimplexId nbVerts=-1, const SimplexId nbtasks=100) const
bool isParentInconsistent(ftm::idNode nodeId) const
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 copyMergeTreeStructure(const FTMTree_MT *tree)
void move(FTMTree_MT &mt)
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
std::stringstream printTreeStats(bool doPrint=true) const
int getNodeLevel(idNode nodeId) const
bool verifyBranchDecompositionInconsistency() const
std::stringstream printTreeScalars(bool printNodeAlone=true, bool doPrint=true) const
void setVertexSoSoffsets(const SimplexId *const sos)
idNode getLowestNode(idNode nodeStart) const
void closeArcsUF(idNode closeNode, UF uf)
ftm::idNode getSecondMaximumPersistenceNode() const
idNode getParentSafe(idNode nodeId) const
void closeAndMergeOnSaddle(const triangulationType *mesh, SimplexId saddleVert)
idNode getLowerNodeId(const SuperArc *a)
void makeAlloc()
clear local data for new computation
SimplexId getNumberOfVertices() const
std::vector< ftm::idNode > getMultiPersOrigins(bool useBD) const
void setNormalizeIds(const bool normalize)
void sortUpArcs(const idNode nid)
void getLevelToNode(std::vector< std::vector< idNode > > &res) const
void getAllNodeLevel(std::vector< int > &res) const
idNode getMergedRootOrigin() const
virtual SimplexId trunkSegmentation(const std::vector< SimplexId > &pendingNodesVerts, const SimplexId begin, const SimplexId stop)
std::stringstream printSubTree(idNode subRoot) const
bool isLower(SimplexId a, SimplexId b) const
dataType getMaximumPersistence() const
int getNumberOfChildren(idNode nodeId) const
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 deleteIthUpArc(idNode nodeId, int arcIth)
const std::vector< idNode > & getRoots() const
dataType getSecondMaximumPersistence() const
int getRealNumberOfNodes() const
void sortLeaves(const bool parallel=false)
idNode getNumberOfLeaves() const
std::tuple< ftm::idNode, ftm::idNode > getMergedRootBirthDeathNode() const
void getLeavesFromTree(std::vector< idNode > &res) const
dataType getNodePersistence(idNode nodeId) const
void build(const triangulationType *mesh, const bool ct)
Compute the merge.
void finalizeSegmentation()
idNode getVertInRange(const std::vector< SimplexId > &range, const SimplexId v, const idNode last=0) const
std::stringstream printPairsFromTree(bool useBD=false, bool printPairs=true, bool doPrint=true) const
void setTreeType(const int local_treeType)
void getBranchOriginsFromThisBranch(idNode node, std::tuple< std::vector< idNode >, std::vector< idNode > > &res) const
bool isNodeOriginDefined(idNode nodeId) const
void sortDownArcs(const idNode nid)
bool isLeaf(idNode nodeId) const
std::tuple< dataType, dataType > getBirthDeathFromIds(idNode nodeId1, idNode nodeId2) const
void deleteNode(idNode nodeId)
int printTime(Timer &t, const std::string &s, const int debugLevel=2) const
void getAllRoots(std::vector< idNode > &res) const
const std::vector< idNode > & getLeaves() const
void setVertexScalars(const scalarType *vals)
bool isRoot(idNode nodeId) const
std::tuple< dataType, dataType > getBirthDeath(idNode nodeId) const
std::stringstream printMergedRoot(bool doPrint=true) const
SimplexId getChunkCount(const SimplexId nbVerts=-1, const SimplexId nbTasks=100) const
void createVector(std::vector< type > &vec)
bool notNeedToNormalize(idNode nodeId) const
bool isNodeIdInconsistent(idNode nodeId) const
SimplexId trunkCTSegmentation(const std::vector< SimplexId > &pendingNodesVerts, const SimplexId begin, const SimplexId stop)
idSuperArc openSuperArc(idNode downNodeId)
int getNumberOfRoot() const
std::shared_ptr< FTMTree_MT > clone() const
SimplexId trunk(const triangulationType *mesh, const bool ct)
idNode getParent(const idNode n)
idNode makeNode(SimplexId vertexId, SimplexId linked=nullVertex)
bool isNodeAlone(idNode nodeId) const
void buildSegmentation()
use vert2tree to compute the segmentation of the fresh built merge tree.
void getPersistencePairsFromTree(std::vector< std::tuple< ftm::idNode, ftm::idNode, dataType > > &pairs, bool useBD) const
const SuperArc * getSuperArc(idSuperArc i) const
void deleteParent(idNode nodeId)
idSuperArc getCorrespondingSuperArcId(const SimplexId val) const
void leafGrowth(const triangulationType *mesh)
bool isImportantPair(idNode nodeId, double threshold, std::vector< double > &excludeLower, std::vector< double > &excludeHigher) const
bool isNodeMerged(idNode nodeId) const
void setValence(const SimplexId v, const SimplexId val)
idSuperArc makeSuperArc(idNode downNodeId, idNode upNodeId)
void updateCorrespondingNode(const SimplexId vert, const idNode node)
void printNodeSS(idNode node, std::stringstream &ss) const
Node * getUpNode(const SuperArc *a)
void preconditionTriangulation(AbstractTriangulation *tri, const bool preproc=true)
void getBranchSubtree(std::vector< idNode > &branching, idNode branchRoot, std::vector< idNode > &res) const
void closeSuperArc(idSuperArc superArcId, idNode upNodeId)
SimplexId getArcSize(const idSuperArc arcId)
bool isHigher(SimplexId a, SimplexId b) const
std::shared_ptr< Scalars > scalars_
void sortArcs()
Sort tree arcs.
void deleteSubtree(idNode nodeId)
bool isThereOnlyOnePersistencePair() const
void setSegmentation(const bool segm)
void initVectStates(const SimplexId nbLeaves)
dataType getBirth(idNode nodeId) const
void updateCorrespondingArc(const SimplexId vert, const idSuperArc arc)
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)
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
void sortUpArcs(const std::function< bool(const idSuperArc, const idSuperArc)> &comp)
idNode getUpNodeId() const
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
std::ostream & operator<<(std::ostream &o, Node const &n)
long long int idCorresp
type used to recover Node/Arc in vert2tree SIGNED ONLY
unsigned int idNode
Node index in vect_nodes_.
TTK base package defining the standard types.
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