234 vtkInformationVector *outputVector,
240 auto output_barycenter = vtkMultiBlockDataSet::GetData(outputVector, 0);
241 auto output_coef = vtkTable::GetData(outputVector, 1);
242 auto output_geodVector = vtkTable::GetData(outputVector, 2);
243 auto output_corrMatrix = vtkTable::GetData(outputVector, 3);
252 output_barycenter->SetNumberOfBlocks(noBlockBary);
258 int const noBlock = (inputTrees2.size() == 0 ? 1 : 2);
259 vtkBlockNodes->SetNumberOfBlocks(noBlock);
260 vtkBlockArcs->SetNumberOfBlocks(noBlock);
261 output_barycenter->SetBlock(0, vtkBlockNodes);
262 output_barycenter->SetBlock(1, vtkBlockArcs);
266 mergeTreeDoubleToTemplate(
barycenter_, barycenterT);
267 makeBarycenterOutput<dataType>(barycenterT, 0, output_barycenter);
269 if(inputTrees2.size() != 0
274 makeBarycenterOutput<dataType>(barycenter2T, 1, output_barycenter);
282 vtkNew<vtkIntArray> treeIDArray{};
283 treeIDArray->SetName(
"TreeID");
284 treeIDArray->SetNumberOfTuples(inputTrees.size());
285 for(
unsigned int i = 0; i < inputTrees.size(); ++i) {
286 treeIDArray->SetTuple1(i, i);
288 output_coef->AddColumn(treeIDArray);
290 for(
unsigned int t = 0; t < 2; ++t) {
291 for(
unsigned int i = 0; i < (*allTs[t]).size(); ++i) {
292 vtkNew<vtkDoubleArray> tArray{};
293 auto size = (*allTs[t]).size();
294 std::string
const name
297 tArray->SetName(name.c_str());
298 tArray->SetNumberOfTuples(inputTrees.size());
299 for(
unsigned int j = 0; j < (*allTs[t])[i].size(); ++j)
300 tArray->SetTuple1(j, (*allTs[t])[i][j]);
301 output_coef->AddColumn(tArray);
307 for(
unsigned int b = 0; b < inputTrees[0]->GetNumberOfBlocks(); ++b) {
308 vtkNew<vtkFieldData> fd{};
309 fd->CopyStructure(inputTrees[0]->GetBlock(b)->GetFieldData());
310 fd->SetNumberOfTuples(inputTrees.size());
311 for(
size_t i = 0; i < inputTrees.size(); ++i) {
312 fd->SetTuple(i, 0, inputTrees[i]->GetBlock(b)->GetFieldData());
316 for(
int i = 0; i < fd->GetNumberOfArrays(); ++i) {
317 auto array = fd->GetAbstractArray(i);
318 array->SetName(array->GetName());
319 output_coef->AddColumn(array);
324 std::vector<std::string> paramNames;
326 for(
auto paramName : paramNames) {
327 vtkNew<vtkDoubleArray> array{};
328 array->SetName(paramName.c_str());
330 output_coef->GetFieldData()->AddArray(array);
336 std::vector<std::vector<std::vector<std::vector<double>>> *> vectors{
338 unsigned int maxSize =
vS_[0].size();
339 if(inputTrees2.size() != 0
345 for(
unsigned int v = 0; v < vectors.size(); ++v) {
346 auto vector = vectors[v];
347 for(
unsigned int i = 0; i < (*vector).size(); ++i)
348 for(
unsigned int k = 0; k < 2; ++k) {
349 vtkNew<vtkDoubleArray> vectorArray{};
350 bool const isSecondInput = (v >= 2);
352 (*vector).size(), i, v % 2, k, isSecondInput);
353 vectorArray->SetName(name.c_str());
354 vectorArray->SetNumberOfTuples(maxSize);
355 for(
unsigned int j = 0; j < (*vector)[i].size(); ++j)
356 vectorArray->SetTuple1(j, (*vector)[i][j][k]);
357 for(
unsigned int j = (*vector)[i].size(); j < maxSize; ++j)
358 vectorArray->SetTuple1(j, std::nan(
""));
359 output_geodVector->AddColumn(vectorArray);
370 for(
unsigned int j = 0; j < noCols; ++j) {
371 vtkNew<vtkDoubleArray> corrArray{}, persArray{};
373 corrArray->SetName(name.c_str());
374 corrArray->SetNumberOfTuples(noRows);
376 persArray->SetName(name2.c_str());
377 persArray->SetNumberOfTuples(noRows);
378 for(
unsigned int i = 0; i < noRows; ++i) {
382 output_corrMatrix->AddColumn(corrArray);
383 output_corrMatrix->AddColumn(persArray);
387 std::vector<std::vector<ttk::ftm::idNode>> matchingMatrix;
391 for(
unsigned int j = 0; j < inputTrees.size(); ++j)
394 = intermediateDTrees[j]
395 .tree.getNode(intermediateDTrees[j].tree.getRoot())
397 for(
unsigned int j = 0; j < inputTrees.size(); ++j) {
398 vtkNew<vtkIntArray> corrArray{};
400 corrArray->SetName(name.c_str());
401 corrArray->SetNumberOfTuples(noRows);
402 for(
unsigned int i = 0; i < noRows; ++i)
403 corrArray->SetTuple1(i, (
int)matchingMatrix[i][j]);
404 output_corrMatrix->AddColumn(corrArray);
408 vtkNew<vtkIntArray> baryNodeId{};
409 baryNodeId->SetName(
"BaryNodeId");
410 baryNodeId->SetNumberOfTuples(noRows);
411 for(
unsigned int i = 0; i < noRows; ++i)
412 baryNodeId->SetTuple1(i, i);
413 output_corrMatrix->AddColumn(baryNodeId);
416 vtkNew<vtkIntArray> baryNodeIsLeaf{};
417 baryNodeIsLeaf->SetName(
"BaryNodeIsLeaf");
418 baryNodeIsLeaf->SetNumberOfTuples(noRows);
419 for(
unsigned int i = 0; i < noRows; ++i)
421 output_corrMatrix->AddColumn(baryNodeIsLeaf);
424 vtkNew<vtkDoubleArray> baryNodePers{};
425 baryNodePers->SetName(
"BaryNodePers");
426 baryNodePers->SetNumberOfTuples(noRows);
427 for(
unsigned int i = 0; i < noRows; ++i) {
428 auto nodePers =
barycenter_.
tree.template getNodePersistence<double>(i);
429 baryNodePers->SetTuple1(i, nodePers);
431 output_corrMatrix->AddColumn(baryNodePers);
434 std::vector<std::vector<int>> treesOrder(intermediateDTrees.size());
435 for(
unsigned int i = 0; i < intermediateDTrees.size(); ++i) {
436 treesOrder[i].resize(intermediateDTrees[i].tree.getNumberOfNodes());
437 std::vector<std::tuple<ttk::ftm::idNode, ttk::ftm::idNode, double>> pairs;
438 intermediateDTrees[i].tree.template getPersistencePairsFromTree<double>(
440 for(
unsigned int j = 0; j < pairs.size(); ++j) {
441 int const index = pairs.size() - 1 - j;
442 treesOrder[i][std::get<0>(pairs[j])] = index;
443 treesOrder[i][std::get<1>(pairs[j])] = index;
447 vtkNew<vtkDoubleArray> treesPersOrder{};
448 treesPersOrder->SetName(
"TreesPersOrder");
449 treesPersOrder->SetNumberOfTuples(noRows);
450 for(
unsigned int i = 0; i < noRows; ++i) {
451 int minIndex = std::numeric_limits<int>::max();
452 for(
unsigned int j = 0; j < intermediateDTrees.size(); ++j) {
453 if(
int(matchingMatrix[i][j]) != -1)
454 minIndex = std::min(minIndex, treesOrder[j][matchingMatrix[i][j]]);
456 treesPersOrder->SetTuple1(i, minIndex);
458 output_corrMatrix->AddColumn(treesPersOrder);