27 std::vector<AtomicUF> nodesUF_;
31 std::vector<idNode> customTreeLeaves;
32 bool useCustomTree =
false;
39 template <
typename scalarType>
41 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs,
50 template <
typename scalarType>
53 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs);
55 template <
typename scalarType>
58 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs);
63 nodesUF_[parentNode].find()->addArcToClose(toAdd);
67 return nodesUF_[current].find()->getOpenedArcs().size();
70 template <
typename scalarType>
74 scalarType minVal = tree->
getValue<scalarType>(minVert);
77 for(
const auto nodeid : uf->getOpenedArcs()) {
79 const scalarType tmpVal = tree->
getValue<scalarType>(vtmp);
81 and ((!isJt and tmpVal > minVal) or (isJt and tmpVal < minVal)))
82 or (not useCustomTree and tree->
compLower(vtmp, minVert))) {
92 nodesUF_[current].find()->clearOpenedArcs();
95 template <
typename scalarType>
98 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs,
103 const scalarType curVal = (not useCustomTree)
104 ? getValue<scalarType>(curVert)
105 : tree->
getValue<scalarType>(curVert);
108 const SimplexId tmpVert = nodesUF_[nodeid].find()->getExtrema();
111 const scalarType tmpVal = (not useCustomTree)
112 ? getValue<scalarType>(tmpVert)
113 : tree->
getValue<scalarType>(tmpVert);
114 if((useCustomTree and tmpVal < curVal)
115 or (not useCustomTree and
scalars_->isLower(tmpVert, curVert))) {
116 pairs.emplace_back(tmpVert, curVert, curVal - tmpVal);
118 pairs.emplace_back(tmpVert, curVert, tmpVal - curVal);
127template <
typename scalarType>
129 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs,
137 nbLeaves = customTreeLeaves.size();
145 pairs.reserve(nbLeaves);
148 nodesUF_.resize(nbNodes);
150 for(
idNode nid = 0; nid < nbNodes; ++nid) {
154 computePairs<scalarType>(tree, pairs);
155 sortPairs<scalarType>(tree, pairs);
158template <
typename scalarType>
161 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs) {
162 auto getParentNode = [&](
const idNode current) {
167 ::std::queue<idNode> toSee;
170 auto &vectLeaves = (not useCustomTree) ? tree->
getLeaves() : customTreeLeaves;
171 for(
auto nid : vectLeaves) {
175 while(!toSee.empty()) {
176 const idNode current = toSee.front();
180 createPairs<scalarType>(current, pairs, tree, ftm::nullVertex);
181 clearPendingNodes(current);
184 clearPendingNodes(current);
187 const idNode parentNode = getParentNode(current);
188 addPendingNode(parentNode, current);
190 if(countPendingNode(parentNode)
193 = getMostPersistVert<scalarType>(parentNode, tree);
194 createPairs<scalarType>(parentNode, pairs, tree, mostPersist);
195 nodesUF_[parentNode].find()->setExtrema(mostPersist);
196 toSee.push(parentNode);
201template <
typename scalarType>
204 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs) {
205 auto comp = [&](
const std::tuple<SimplexId, SimplexId, scalarType> a,
206 const std::tuple<SimplexId, SimplexId, scalarType> b) {
207 return std::get<2>(a) < std::get<2>(b);
210 sort(pairs.begin(), pairs.end(), comp);
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
FTMAtomicVector< idSuperArc > & getOpenedArcs()
SimplexId getExtrema() const
static AtomicUF * makeUnion(AtomicUF *uf0, AtomicUF *uf1)
void computePersistencePairs(std::vector< std::tuple< SimplexId, SimplexId, scalarType > > &pairs, const bool jt)
void clearPendingNodes(const idNode current)
void setCustomTree(ftm::FTMTree_MT *cTree)
void computePairs(ftm::FTMTree_MT *tree, std::vector< std::tuple< SimplexId, SimplexId, scalarType > > &pairs)
idNode countPendingNode(const idNode current)
void sortPairs(ftm::FTMTree_MT *tree, std::vector< std::tuple< SimplexId, SimplexId, scalarType > > &pairs)
void createPairs(const idNode current, std::vector< std::tuple< SimplexId, SimplexId, scalarType > > &pairs, ftm::FTMTree_MT *tree, const SimplexId mp)
SimplexId getMostPersistVert(const idNode current, ftm::FTMTree_MT *tree)
void addPendingNode(const idNode parentNode, const idNode toAdd)
FTMTree_MT * getSplitTree()
FTMTree_MT * getJoinTree()
const scalarType & getValue(SimplexId nodeId) const
SuperArc * getSuperArc(idSuperArc i)
idNode getNumberOfNodes() const
idNode getNumberOfLeaves() const
const std::vector< idNode > & getLeaves() const
void getLeavesFromTree(std::vector< idNode > &res)
Node * getNode(idNode nodeId)
std::shared_ptr< Scalars > scalars_
bool compLower(const SimplexId a, const SimplexId b)
TTK processing package that efficiently computes the contour tree of scalar data and more (data segme...
idSuperArc getUpSuperArcId(idSuperArc neighborId) const
idSuperArc getNumberOfDownSuperArcs() const
SimplexId getVertexId() const
idSuperArc getNumberOfUpSuperArcs() const
idNode getUpNodeId() const
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
unsigned int idNode
Node index in vect_nodes_.
int SimplexId
Identifier type for simplices of any dimension.