20 template <
class dataType>
25 template <
class dataType>
30 template <
class dataType>
32 bool printNodeAlone =
true) {
33 printTreeScalars<dataType>(&(tree.
tree), printNodeAlone);
36 template <
class dataType>
38 std::vector<ftm::FTMTree_MT *> &treesT) {
41 treesT.push_back(&(t.tree));
44 template <
class dataType>
47 auto newScalarsValues = std::make_shared<std::vector<double>>();
49 newScalarsValues->push_back(
static_cast<double>(val));
50 auto newScalars = std::make_shared<ftm::Scalars>(*mt.
scalars);
55 template <
class dataType>
61 mergeTreeTemplateToDouble<dataType>(mt, newMt);
62 newMts.push_back(newMt);
66 template <
class dataType>
71 newMts.reserve(mts.size());
73 std::vector<MergeTree<double>> newMt;
74 mergeTreesTemplateToDouble<dataType>(mt, newMt);
75 newMts.emplace_back(newMt);
79 template <
class dataType>
82 auto newScalarsValues = std::make_shared<std::vector<dataType>>();
84 newScalarsValues->push_back(
static_cast<dataType
>(val));
85 auto newScalars = std::make_shared<ftm::Scalars>(*mt.
scalars);
90 template <
class dataType>
96 mergeTreeDoubleToTemplate<dataType>(mt, newMt);
97 newMts.push_back(newMt);
101 template <
class dataType>
106 newMts.reserve(mts.size());
107 for(
auto &mt : mts) {
108 std::vector<MergeTree<dataType>> newMt;
109 mergeTreesDoubleToTemplate<dataType>(mt, newMt);
110 newMts.emplace_back(newMt);
124 template <
class dataType>
127 auto scalars = std::make_shared<ftm::Scalars>();
128 scalars->size = scalarSize;
129 scalars->values = (
void *)
nullptr;
132 auto params = std::make_shared<ftm::Params>();
141 template <
class dataType>
143 std::vector<dataType> &scalarsVector) {
145 = std::make_shared<std::vector<dataType>>(scalarsVector);
150 template <
class dataType>
152 std::vector<dataType> &scalarsVector) {
153 scalarsVector.clear();
155 scalarsVector.push_back(tree->
getValue<dataType>(i));
158 template <
class dataType>
160 std::vector<dataType> &scalarsVector) {
161 getTreeScalars<dataType>(&(mergeTree.
tree), scalarsVector);
164 template <
class dataType>
166 bool doSplitMultiPersPairs =
false) {
167 std::vector<dataType> scalarsVector;
168 getTreeScalars<dataType>(tree, scalarsVector);
171 std::vector<ftm::idNode> multiPersOrigins;
172 if(doSplitMultiPersPairs) {
174 for(
ftm::idNode const nodeOrigin : multiPersOrigins) {
175 scalarsVector[nodeOrigin]
177 scalarsVector.push_back(tree->
getValue<dataType>(nodeOrigin));
183 = createEmptyMergeTree<dataType>(scalarsVector.size());
185 setTreeScalars<dataType>(mergeTree, scalarsVector);
191 if(doSplitMultiPersPairs) {
192 for(
ftm::idNode const nodeOrigin : multiPersOrigins) {
203 template <
class dataType>
205 bool doSplitMultiPersPairs =
false) {
206 return copyMergeTree<dataType>(&(mergeTree.
tree), doSplitMultiPersPairs);
210 template <
class dataType>
212 std::vector<int> &nodeCorr,
218 std::vector<dataType> newScalarsVector(newNoNodes, 0);
223 std::vector<std::vector<ftm::idNode>> treeMultiPers;
226 std::queue<ftm::idNode> queue;
227 std::vector<idNode> leaves;
229 for(
auto leaf : leaves)
231 while(!queue.empty()) {
240 if(nodeCorr[nodeOrigin] == -1)
243 nodeOriginIndex = nodeCorr[nodeOrigin];
245 if(nodeCorr[node] == -1)
248 nodeIndex = nodeCorr[node];
250 if(nodeCorr[nodeOrigin] == -1)
254 newScalarsVector[nodeOriginIndex]
255 = tree->
getValue<dataType>(nodeOrigin);
256 newScalarsVector[nodeIndex] = tree->
getValue<dataType>(node);
257 nodeCorr[nodeOrigin] = nodeOriginIndex;
258 nodeCorr[node] = nodeIndex;
264 if(not(tree->
isRoot(node) and node == nodeOrigin))
266 for(
auto nodeMultiPers : treeMultiPers[node])
270 newScalarsVector[nodeCpt + 1]
271 = tree->
getValue<dataType>(nodeOrigin);
272 nodeCorr[nodeOrigin] = nodeCpt + 1;
276 newScalarsVector[nodeCpt] = tree->
getValue<dataType>(node);
277 nodeCorr[node] = nodeCpt;
280 std::vector<idNode> children;
282 for(
idNode const child : children)
287 nodeDone[parent] += 1;
294 auto treeRoot = tree->
getRoot();
296 auto treeNewRoot = treeNew->
getRoot();
298 newScalarsVector[treeNewRootOrigin]
304 setTreeScalars<dataType>(mTreeNew, newScalarsVector);
310 template <
class dataType>
312 std::vector<int> &nodeCorr,
314 mTree = cleanMergeTree<dataType>(&(mTree.
tree), nodeCorr, useBD);
317 template <
class dataType>
319 std::vector<int> nodeCorr;
320 cleanMergeTree<dataType>(mTree, nodeCorr, useBD);
TTK container representing a node of the FTMTree_MT.
std::vector< ftm::idNode > getMultiPersOrigins(bool useBD)
const scalarType & getValue(SimplexId nodeId) const
idNode getNumberOfNodes() const
int getNumberOfChildren(idNode nodeId)
bool isRoot(idNode nodeId)
void getMultiPersOriginsVectorFromTree(std::vector< std::vector< idNode > > &res)
idNode getParentSafe(idNode nodeId)
idNode getMergedRootOrigin()
void getChildren(idNode nodeId, std::vector< idNode > &res)
idNode makeNode(SimplexId vertexId, SimplexId linked=nullVertex)
bool isLeaf(idNode nodeId)
int getRealNumberOfNodes()
bool isNodeAlone(idNode nodeId)
idSuperArc makeSuperArc(idNode downNodeId, idNode upNodeId)
void copyMergeTreeStructure(FTMTree_MT *tree)
void getLeavesFromTree(std::vector< idNode > &res)
Node * getNode(idNode nodeId)
std::stringstream printTree(bool doPrint=true)
std::stringstream printTreeStats(bool doPrint=true)
void setOrigin(SimplexId linked)
SimplexId getOrigin() const
void setTreeScalars(MergeTree< dataType > &mergeTree, std::vector< dataType > &scalarsVector)
MergeTree< dataType > cleanMergeTree(ftm::FTMTree_MT *tree, std::vector< int > &nodeCorr, bool useBD=true)
void mergeTreeTemplateToDouble(MergeTree< dataType > &mt, MergeTree< double > &newMt)
void printTree(MergeTree< dataType > &tree, bool doPrint=true)
void removeSelfLink(FTMTree_MT *tree)
void mergeTreeToFTMTree(std::vector< MergeTree< dataType > > &trees, std::vector< ftm::FTMTree_MT * > &treesT)
MergeTree< dataType > createEmptyMergeTree(int scalarSize)
void printTreeScalars(MergeTree< dataType > &tree, bool printNodeAlone=true)
void printTreesStats(std::vector< ftm::FTMTree_MT * > &trees)
MergeTree< dataType > copyMergeTree(ftm::FTMTree_MT *tree, bool doSplitMultiPersPairs=false)
void mergeTreesDoubleToTemplate(std::vector< MergeTree< double > > &mts, std::vector< MergeTree< dataType > > &newMts)
void printTreeStats(MergeTree< dataType > &tree)
void mergeTreeDoubleToTemplate(MergeTree< double > &mt, MergeTree< dataType > &newMt)
void mergeTreesTemplateToDouble(std::vector< MergeTree< dataType > > &mts, std::vector< MergeTree< double > > &newMts)
unsigned int idNode
Node index in vect_nodes_.
void manageInconsistentArcsMultiParent(FTMTree_MT *tree)
void getTreeScalars(ftm::FTMTree_MT *tree, std::vector< dataType > &scalarsVector)
std::shared_ptr< ftm::Params > params
std::shared_ptr< std::vector< dataType > > scalarsValues
std::shared_ptr< ftm::Scalars > scalars