59 std::shared_ptr<Scalars> scalars,
71 template <
typename triangulationType>
73 scalars_->size = tri->getNumberOfVertices();
83 template <
typename scalarType>
111 params_->debugLevel = local_debugLevel;
125 const double &local_simplificationThreshold) {
126 params_->simplifyThreshold = local_simplificationThreshold;
134 const bool preproc =
true) {
153 template <
typename scalarType>
155 return (((scalarType *)
scalars_->values))[nodeId];
158 template <
typename scalarType>
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;
226 treeData_.arcsCrossingAbove.emplace_back(sa);
262#ifndef TTK_ENABLE_KAMIKAZE
264 this->
printErr(
"getLeaves out of bounds: " + std::to_string(
id));
271 inline const std::vector<idNode> &
getRoots()
const {
303 return treeData_.vert2tree[val] == nullCorresp;
311#ifndef TTK_ENABLE_KAMIKAZE
313 this->
printErr(
"getCorrespondingNode, Vertex: " + std::to_string(val)
315 + std::to_string(
treeData_.vert2tree[val]));
322#ifndef TTK_ENABLE_KAMIKAZE
325 "getCorrespondingSuperArcId, Vertex: " + std::to_string(val)
326 +
" is not on an arc: " + std::to_string(
treeData_.vert2tree[val]));
379 template <
typename triangulationType>
381 std::vector<ExtendedUnionFind *> &vect_baseUF,
384 const triangulationType &mesh,
388 template <
typename triangulationType>
389 int build(std::vector<ExtendedUnionFind *> &vect_baseUF,
390 const std::vector<SimplexId> &overlapBefore,
391 const std::vector<SimplexId> &overlapAfter,
396 const triangulationType &mesh);
403 template <
typename scalarType>
407 std::list<std::vector<std::pair<SimplexId, bool>>> &storage);
410 template <
typename scalarType,
typename triangulationType>
414 std::list<std::vector<std::pair<SimplexId, bool>>> &storage,
415 const triangulationType &mesh);
419 template <
typename scalarType>
423 std::list<std::vector<std::pair<SimplexId, bool>>> &storage,
424 const std::vector<std::tuple<SimplexId, SimplexId, scalarType, bool>>
428 void markThisArc(std::vector<ExtendedUnionFind *> &ufArray,
431 const idNode &parentNodeId);
436 template <
typename scalarType,
typename triangulationType>
438 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs,
439 const triangulationType &mesh);
441 template <
typename scalarType,
typename triangulationType>
443 std::vector<std::tuple<SimplexId, SimplexId, scalarType, bool>> &pairs,
444 const triangulationType &mesh);
448 template <
typename scalarType,
typename triangulationType>
450 const std::vector<idNode> &sortedNodes,
451 std::vector<std::tuple<SimplexId, SimplexId, scalarType, bool>>
453 std::vector<std::tuple<SimplexId, SimplexId, scalarType, bool>>
455 const triangulationType &mesh);
470 const bool overlapA);
476 std::pair<SimplexId, bool> *vertexList =
nullptr,
482 const bool overlapA);
488 const bool changeConnectivity =
true);
491 const std::pair<SimplexId, bool> &seed);
494 const std::pair<SimplexId, bool> &seed,
495 const std::vector<idCorresp> &vert2treeOther);
535 std::list<std::vector<std::pair<SimplexId, bool>>> &storage,
536 const std::pair<SimplexId, bool> *mv =
nullptr,
582 std::stringstream res;
587 res <<
"(extern) -- ";
594 res <<
" \t\t(vis:" << sa->
isVisible() <<
")";
600 std::stringstream res;
624 res <<
"\t\t(vis:" << node->
isVisible() <<
" )";
629 std::shared_ptr<MergeTree>
clone()
const;
662 template <
typename scalarType>
664 return ((scalarType *)
scalars_->values)[a]
665 < ((scalarType *)
scalars_->values)[b]
666 || (((scalarType *)
scalars_->values)[a]
667 == ((scalarType *)
scalars_->values)[b]
671 template <
typename scalarType>
673 return ((scalarType *)
scalars_->values)[a]
674 > ((scalarType *)
scalars_->values)[b]
675 || (((scalarType *)
scalars_->values)[a]
676 == ((scalarType *)
scalars_->values)[b]
680 template <
typename scalarType>
682 return ((scalarType *)
scalars_->values)[a]
683 < ((scalarType *)
scalars_->values)[b]
684 || (((scalarType *)
scalars_->values)[a]
685 == ((scalarType *)
scalars_->values)[b]
689 template <
typename scalarType>
691 return ((scalarType *)
scalars_->values)[a]
692 > ((scalarType *)
scalars_->values)[b]
693 || (((scalarType *)
scalars_->values)[a]
694 == ((scalarType *)
scalars_->values)[b]
705 void hideAndMerge(
const idSuperArc &mergingArcId,
707 const bool preserveDownNode =
false);
711 std::tuple<idNode, idNode, SimplexId> createReceptArc(
714 std::vector<ExtendedUnionFind *> &arrayUF,
715 const std::vector<std::pair<idSuperArc, idSuperArc>> &valenceOffsets);
719 std::vector<ExtendedUnionFind *> &ufArray);
722 std::vector<ExtendedUnionFind *> &ufArray);
731 inline std::pair<SimplexId, SimplexId>
732 reorderEdgeRel(
const std::pair<SimplexId, SimplexId> &vert) {
734 if(
isHigher(vert.first, vert.second)) {
738 return std::make_pair(vert.second, vert.first);
741 if(
isLower(vert.first, vert.second))
744 return std::make_pair(vert.second, vert.first);
747 template <
typename triangulationType>
748 bool verifyTree(
const triangulationType &mesh);
753 template <
typename scalarType,
typename triangulationType>
755 std::vector<std::tuple<SimplexId, SimplexId, scalarType, bool>> &pairs,
758 const triangulationType &mesh,
761 template <
typename scalarType,
typename triangulationType>
763 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs,
766 const triangulationType &mesh);
int SimplexId
Identifier type for simplices of any dimension.
AbstractTriangulation is an interface class that defines an interface for efficient traversal methods...
virtual int preconditionVertexNeighbors()
virtual int preconditionEdges()
Legacy backward compatibility.
virtual int setDebugLevel(const int &debugLevel)
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
void hideAndClearArcsBelow(const idNode &baseNode, const SimplexId &seed)
void hideArc(const idSuperArc &sa)
void updateCorrespondingNode(const SimplexId &vert, const idNode &val)
std::list< ExtendedUnionFind > storageEUF_
const scalarType & getValue(const SimplexId &nodeId) const
idSuperArc getNumberOfVisibleArcs() const
idNode makeNode(const SimplexId &vertexId, const SimplexId &linked=nullVertex)
SuperArc * vertex2SuperArc(const SimplexId &vert)
Node * vertex2Node(const SimplexId &vert)
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
idNode getNumberOfNodes() const
const std::vector< Node > & getNodes() const
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)
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_
bool isCorrespondingArc(const SimplexId &val) const
void initTreeType()
init the type of the current tree from params
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)
void setTreeType(const int &local_treeType)
idSuperArc getNumberOfExternalDownArcs(const idNode &node)
idPartition getPartition() const
friend class ContourForestsTree
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)
void preconditionTriangulation(AbstractTriangulation *const m, const bool preproc=true)
void addCrossingAbove(const idSuperArc &sa)
std::vector< idNode > getNodeUpNeighbors(const idNode &n)
void setSimplificationMethod(const int &local_simplifyMethod)
idSuperArc getNumberOfSuperArcs() const
friend class ContourForests
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
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
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)
void updateCorrespondingArc(const SimplexId &arc, const idSuperArc &val)
void setSimplificationThreshold(const double &local_simplificationThreshold)
bool isHigher(const SimplexId &a, const SimplexId &b) const
idNode getCorrespondingNodeId(const SimplexId &val) const
idSuperArc getCorrespondingSuperArcId(const SimplexId &val) const
void closeSuperArc(const idSuperArc &superArcId, const idNode &upNodeId, const bool overlapB, const bool overlapA)
void flush()
clear local data for new computation
void hideNode(const idNode &node)
Node * getDownNode(const SuperArc *a)
const std::vector< idNode > & getLeaves() const
bool isCorrespondingNull(const SimplexId &val) const
SimplexId getNumberOfVisibleRegularNode(const idSuperArc &sa)
void parallelUpdateSegmentation(const bool ct=false)
const idNode & getLeave(const idNode &id) const
SimplexId getNumberOfLeaves() const
int computePersistencePairs(std::vector< std::tuple< SimplexId, SimplexId, scalarType > > &pairs, const triangulationType &mesh)
idSuperArc getNumberOfUnmergedDownArcs(const idNode &n)
void setVertexScalars(scalarType *vals)
SuperArc * getSuperArc(const idSuperArc &i)
bool isLower(const SimplexId &a, const SimplexId &b) const
void hideAndClearArcsAbove(const idNode &baseNode)
void initNbScalars(const triangulationType &tri)
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)
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
void setVertexSoSoffsets(const SimplexId *const offsets)
const std::vector< idNode > & getRoots() const
Node * getNode(const idNode &nodeId)
void parallelInitNodeValence(const int nbThreadValence)
void updateSegmentation()
std::shared_ptr< Params > params_
MergeTree(std::shared_ptr< Params > params, std::shared_ptr< Scalars > scalars, TreeType type, idPartition part=nullPartition)
std::vector< idNode > getNodeDownNeighbors(const idNode &n)
idCorresp idNode2corr(const idNode &id) const
SimplexId getVertexId() const
idSuperArc getDownSuperArcId(const idSuperArc &neighborId) const
idSuperArc getNumberOfUpSuperArcs() 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
long long int idCorresp
type used to recover Node/Arc in vert2tree SIGNED ONLY
std::ostream & operator<<(std::ostream &o, Node const &n)
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
unsigned int idNode
Node index in vect_nodes_.
TTK base package defining the standard types.
int SimplexId
Identifier type for simplices of any dimension.
T end(std::pair< T, T > &p)
T begin(std::pair< T, T > &p)