9 vtkUnstructuredGrid *treeNodes,
10 std::vector<int> &treeNodeCorr,
11 vtkDataSet *treeSegmentation,
16 std::vector<std::tuple<std::string, std::vector<int>>> &customIntArrays,
17 std::vector<std::tuple<std::string, std::vector<double>>>
19 bool outputSegmentation,
20 double mixtureCoefficient,
21 bool isPersistenceDiagram,
22 bool convertToDiagram,
30 if(not isPersistenceDiagram)
37 for(
auto &tup : customIntArrays)
38 visuMakerBary.addCustomIntArray(std::get<0>(tup), std::get<1>(tup));
39 for(
auto &tup : customDoubleArrays)
40 visuMakerBary.addCustomArray(std::get<0>(tup), std::get<1>(tup));
48 if(outputSegmentation) {
64 std::vector<vtkUnstructuredGrid *> &treesNodesT,
65 std::vector<std::vector<int>> &treesNodeCorr,
66 std::vector<vtkDataSet *> &treesSegmentationT,
68 std::vector<std::vector<std::tuple<std::string, std::vector<int>>>>
70 std::vector<std::vector<std::tuple<std::string, std::vector<double>>>>
72 double mixtureCoefficient,
73 bool isPersistenceDiagram,
74 bool convertToDiagram,
79 if(not isPersistenceDiagram) {
82 bool outputSegmentation
83 = !treesSegmentationT.empty() and treesSegmentationT[0];
85 if(outputSegmentation) {
89 for(
unsigned int i = 0; i < trees.size(); ++i) {
90 if(trees[i]->tree.template getMaximumPersistence<float>() == 0) {
94 vtkUnstructuredGrid *treeNodes =
nullptr;
95 vtkDataSet *treeSegmentation =
nullptr;
96 std::vector<int> treeNodeCorr;
97 if(outputSegmentation) {
98 treeSegmentation = treesSegmentationT[i];
100 if(i < treesNodesT.size()) {
101 treeNodes = treesNodesT[i];
102 treeNodeCorr = treesNodeCorr[i];
106 makeOneOutput(*(trees[i]), treeNodes, treeNodeCorr, treeSegmentation,
107 vtkOutputNode, vtkOutputArc, vtkOutputSegmentation, i,
108 customIntArrays[i], customDoubleArrays[i],
109 outputSegmentation, mixtureCoefficient,
110 isPersistenceDiagram, convertToDiagram, debugLevel);
111 allNodes->SetBlock(i - shift, vtkOutputNode);
112 if(not isPersistenceDiagram)
113 allArcs->SetBlock(i - shift, vtkOutputArc);
114 if(outputSegmentation)
115 allSegs->SetBlock(i - shift, vtkOutputSegmentation);
117 if(not isPersistenceDiagram) {
118 output->SetNumberOfBlocks(2);
119 output->SetBlock(0, allNodes);
120 output->SetBlock(1, allArcs);
121 if(outputSegmentation)
122 output->SetBlock(2, allSegs);
124 if(not outputSegmentation) {
125 output->ShallowCopy(allNodes);
127 output->SetNumberOfBlocks(2);
128 output->SetBlock(0, allNodes);
129 output->SetBlock(1, allSegs);
136 std::vector<vtkUnstructuredGrid *> &treesNodesT,
137 std::vector<std::vector<int>> &treesNodeCorr,
139 std::vector<std::vector<std::tuple<std::string, std::vector<int>>>>
141 std::vector<std::vector<std::tuple<std::string, std::vector<double>>>>
143 double mixtureCoefficient,
144 bool isPersistenceDiagram,
145 bool convertToDiagram,
147 std::vector<vtkDataSet *> treesSegmentationT;
148 makeManyOutput(trees, treesNodesT, treesNodeCorr, treesSegmentationT,
149 output, customIntArrays, customDoubleArrays,
150 mixtureCoefficient, isPersistenceDiagram, convertToDiagram,
157 std::vector<std::vector<std::tuple<std::string, std::vector<int>>>>
159 std::vector<std::vector<std::tuple<std::string, std::vector<double>>>>
161 double mixtureCoefficient,
162 bool isPersistenceDiagram,
163 bool convertToDiagram,
165 std::vector<vtkUnstructuredGrid *> treesNodesT;
166 std::vector<std::vector<int>> treesNodeCorr;
167 makeManyOutput(trees, treesNodesT, treesNodeCorr, output, customIntArrays,
168 customDoubleArrays, mixtureCoefficient,
169 isPersistenceDiagram, convertToDiagram, debugLevel);
174 double mixtureCoefficient,
175 bool isPersistenceDiagram,
176 bool convertToDiagram,
178 std::vector<std::vector<std::tuple<std::string, std::vector<int>>>>
179 customIntArrays(trees.size());
180 std::vector<std::vector<std::tuple<std::string, std::vector<double>>>>
181 customDoubleArrays(trees.size());
182 makeManyOutput(trees, output, customIntArrays, customDoubleArrays,
183 mixtureCoefficient, isPersistenceDiagram, convertToDiagram,
187 void computeTrackingInformation(
188 std::vector<mtu::TorchMergeTree<float>> &origins,
189 std::vector<mtu::TorchMergeTree<float>> &originsPrime,
190 std::vector<std::vector<ttk::ftm::idNode>> &originsMatchingVectorT,
191 std::vector<std::vector<ttk::ftm::idNode>> &invOriginsMatchingVectorT,
192 bool isPersistenceDiagram,
193 std::vector<std::vector<ttk::ftm::idNode>> &originsMatchingVector,
194 std::vector<std::vector<double>> &originsPersPercent,
195 std::vector<std::vector<double>> &originsPersDiff,
196 std::vector<double> &originPersPercent,
197 std::vector<double> &originPersDiff,
198 std::vector<int> &originPersistenceOrder) {
199 unsigned int originsMatchingSize = originsMatchingVectorT.size();
200 originsMatchingVector.resize(originsMatchingSize);
201 originsPersPercent.resize(originsMatchingSize);
202 originsPersDiff.resize(originsMatchingSize);
203 for(
unsigned int l = 0; l < originsMatchingSize; ++l) {
204 auto &tree2 = (l == 0 ? originsPrime[0] : originsPrime[l]);
205 originsMatchingVector[l] = invOriginsMatchingVectorT[l];
207 for(
unsigned int i = 0; i < originsMatchingVector[l].size(); ++i)
208 if(originsMatchingVector[l][i]
209 < originsMatchingVector[l - 1].size())
210 originsMatchingVector[l][i]
211 = originsMatchingVector[l - 1][originsMatchingVector[l][i]];
213 originsPersPercent[l].resize(tree2.mTree.tree.getNumberOfNodes());
214 originsPersDiff[l].resize(tree2.mTree.tree.getNumberOfNodes());
215 for(
unsigned int i = 0; i < originsMatchingVector[l].size(); ++i) {
216 if(originsMatchingVector[l][i]
217 >= origins[0].mTree.tree.getNumberOfNodes())
219 auto pers = origins[0].mTree.tree.template getNodePersistence<float>(
220 originsMatchingVector[l][i]);
222 = tree2.mTree.tree.template getNodePersistence<float>(i);
223 originsPersPercent[l][i] = treePers * 100 / pers;
224 originsPersDiff[l][i] = treePers - pers;
228 originPersPercent.resize(origins[0].mTree.tree.getNumberOfNodes());
229 originPersDiff.resize(origins[0].mTree.tree.getNumberOfNodes());
230 std::vector<ttk::ftm::idNode> originMatchingVector;
231 for(
unsigned int l = 0; l < originsMatchingSize; ++l) {
232 std::vector<ttk::ftm::idNode> &originMatchingVectorT
233 = originsMatchingVectorT[l];
235 originMatchingVector = originMatchingVectorT;
237 for(
unsigned int i = 0; i < originMatchingVector.size(); ++i)
238 if(originMatchingVector[i] < originMatchingVectorT.size())
239 originMatchingVector[i]
240 = originMatchingVectorT[originMatchingVector[i]];
243 unsigned int l2 = originsMatchingSize - 1;
244 for(
unsigned int i = 0; i < originMatchingVector.size(); ++i) {
245 if(originMatchingVector[i] < originsPersDiff[l2].size()) {
247 = originsPersPercent[l2][originMatchingVector[i]];
248 originPersDiff[i] = originsPersDiff[l2][originMatchingVector[i]];
252 originPersistenceOrder.resize(
253 origins[0].mTree.tree.getNumberOfNodes(), -1);
254 std::vector<std::tuple<ttk::ftm::idNode, ttk::ftm::idNode, float>>
256 bool useBD = isPersistenceDiagram;
257 origins[0].mTree.tree.template getPersistencePairsFromTree<float>(
259 for(
unsigned int j = 0; j < pairsBary.size(); ++j) {
260 int index = pairsBary.size() - 1 - j;
261 originPersistenceOrder[std::get<0>(pairsBary[j])] = index;
262 originPersistenceOrder[std::get<1>(pairsBary[j])] = index;
266 void computeCustomArrays(
267 std::vector<std::vector<mtu::TorchMergeTree<float>>> &recs,
268 std::vector<std::vector<double>> &persCorrelationMatrix,
269 std::vector<std::vector<std::vector<ttk::ftm::idNode>>>
270 &invDataMatchingVectorT,
271 std::vector<std::vector<ttk::ftm::idNode>> &invReconstMatchingVectorT,
272 std::vector<std::vector<ttk::ftm::idNode>> &originsMatchingVector,
273 std::vector<std::vector<ttk::ftm::idNode>> &originsMatchingVectorT,
274 std::vector<std::vector<double>> &originsPersPercent,
275 std::vector<std::vector<double>> &originsPersDiff,
276 std::vector<int> &originPersistenceOrder,
279 std::vector<std::vector<std::tuple<std::string, std::vector<int>>>>
281 std::vector<std::vector<std::tuple<std::string, std::vector<double>>>>
282 &customDoubleArrays) {
283 unsigned int originsMatchingSize = originsMatchingVectorT.size();
284 unsigned int dataMatchingSize = invDataMatchingVectorT.size();
285 unsigned int lShifted = l + lShift;
286 std::vector<std::vector<ttk::ftm::idNode>> matchingVectors(recs.size());
287 std::vector<std::vector<double>> dataPersPercent, dataPersDiff;
288 std::vector<std::vector<int>> dataOriginPersOrder;
289 std::vector<std::vector<std::vector<double>>> dataCorrelation;
290 if(lShifted < dataMatchingSize) {
291 for(
unsigned int i = 0; i < recs.size(); ++i) {
292 matchingVectors[i] = invDataMatchingVectorT[lShifted][i];
294 for(
unsigned int j = 0; j < matchingVectors[i].size(); ++j)
295 if(matchingVectors[i][j]
296 < originsMatchingVector[lShifted - 1].size())
297 matchingVectors[i][j]
298 = originsMatchingVector[lShifted - 1][matchingVectors[i][j]];
302 if(lShifted == 0 or lShifted == dataMatchingSize - 1) {
303 dataPersPercent.resize(recs.size());
304 dataPersDiff.resize(recs.size());
305 for(
unsigned int i = 0; i < recs.size(); ++i) {
306 dataPersPercent[i].resize(recs[i][l].mTree.tree.getNumberOfNodes());
307 dataPersDiff[i].resize(recs[i][l].mTree.tree.getNumberOfNodes());
308 std::vector<ttk::ftm::idNode> matchingVector;
310 matchingVector = matchingVectors[i];
311 for(
unsigned int l2 = 0; l2 < originsMatchingSize; ++l2) {
312 std::vector<ttk::ftm::idNode> &originMatchingVector
313 = originsMatchingVectorT[l2];
314 for(
unsigned int j = 0; j < matchingVector.size(); ++j)
315 if(matchingVector[j] < originMatchingVector.size())
316 matchingVector[j] = originMatchingVector[matchingVector[j]];
319 matchingVector = invDataMatchingVectorT[lShifted][i];
321 unsigned int l2 = originsMatchingSize - 1;
322 for(
unsigned int j = 0; j < matchingVector.size(); ++j) {
323 if(matchingVector[j] < originsPersDiff[l2].size()) {
324 dataPersDiff[i][j] = originsPersDiff[l2][matchingVector[j]];
325 dataPersPercent[i][j] = originsPersPercent[l2][matchingVector[j]];
331 dataCorrelation.resize(recs.size());
332 for(
unsigned int i = 0; i < recs.size(); ++i) {
333 dataCorrelation[i].resize(persCorrelationMatrix[0].size());
334 for(
unsigned int j = 0; j < persCorrelationMatrix[0].size(); ++j) {
335 dataCorrelation[i][j].resize(
336 recs[i][l].mTree.tree.getNumberOfNodes());
337 for(
unsigned int k = 0; k < matchingVectors[i].size(); ++k) {
338 if(matchingVectors[i][k] < persCorrelationMatrix.size())
339 dataCorrelation[i][j][k]
340 = persCorrelationMatrix[matchingVectors[i][k]][j];
347 if(lShifted == 0 or lShifted == dataMatchingSize - 1
348 or l == recs[0].size() - 1) {
349 dataOriginPersOrder.resize(recs.size());
350 for(
unsigned int i = 0; i < recs.size(); ++i) {
351 std::vector<ttk::ftm::idNode> &matchingVector = matchingVectors[i];
352 if(l == recs[0].size() - 1) {
353 matchingVector = invReconstMatchingVectorT[i];
354 std::vector<ttk::ftm::idNode> &matchingVectorT
355 = invDataMatchingVectorT[0][i];
356 for(
unsigned int j = 0; j < matchingVector.size(); ++j)
357 if(matchingVector[j] < matchingVectorT.size())
358 matchingVector[j] = matchingVectorT[matchingVector[j]];
360 dataOriginPersOrder[i].resize(
361 recs[i][l].mTree.tree.getNumberOfNodes());
362 for(
unsigned int j = 0; j < matchingVector.size(); ++j) {
363 if(matchingVector[j] < originPersistenceOrder.size())
364 dataOriginPersOrder[i][j]
365 = originPersistenceOrder[matchingVector[j]];
367 dataOriginPersOrder[i][j] = -1;
372 for(
unsigned int i = 0; i < recs.size(); ++i) {
373 if(lShifted < dataMatchingSize) {
374 std::vector<int> customArrayMatching;
375 for(
auto &e : matchingVectors[i])
376 customArrayMatching.emplace_back(e);
377 std::string name{
"OriginTrueNodeId"};
378 customIntArrays[i].emplace_back(
379 std::make_tuple(name, customArrayMatching));
380 if(lShifted == 0 or lShifted == dataMatchingSize - 1) {
381 std::string name2{
"OriginPersPercent"};
382 customDoubleArrays[i].emplace_back(
383 std::make_tuple(name2, dataPersPercent[i]));
384 std::string name3{
"OriginPersDiff"};
385 customDoubleArrays[i].emplace_back(
386 std::make_tuple(name3, dataPersDiff[i]));
389 for(
unsigned int j = 0; j < dataCorrelation[i].size(); ++j) {
391 dataCorrelation[i].size(), j);
392 customDoubleArrays[i].emplace_back(
393 std::make_tuple(name2, dataCorrelation[i][j]));
397 if(lShifted == 0 or lShifted == dataMatchingSize - 1
398 or l == recs[0].size() - 1) {
399 std::string name4{
"OriginPersOrder"};
400 customIntArrays[i].emplace_back(
401 std::make_tuple(name4, dataOriginPersOrder[i]));
void setTreesSegmentation(std::vector< vtkDataSet * > &segmentation)
void copyPointData(vtkUnstructuredGrid *treeNodes, std::vector< int > &nodeCorrT)
void setVtkOutputSegmentation(vtkDataSet *vtkSegmentation)
void setTreesNodeCorrMesh(std::vector< std::vector< int > > &nodeCorrMesh)
void setOutputSegmentation(bool b)
void setPlanarLayout(bool b)
void setOutputTreeNodeId(int doOutput)
void makeTreesOutput(FTMTree_MT *tree1)
void setShiftMode(int mode)
void setConvertedToDiagram(bool converted)
void setISampleOffset(int offset)
void setIsPDSadMax(bool isSadMax)
void setVtkOutputArc(vtkUnstructuredGrid *vtkArc)
void setIsPersistenceDiagram(bool isPD)
void setVtkOutputNode(vtkUnstructuredGrid *vtkNode)
void setTreesNodes(std::vector< vtkUnstructuredGrid * > &nodes)
virtual int setDebugLevel(const int &debugLevel)
std::string getTableCorrelationPersName(int noAxes, int axeNum)