49 vtkInformationVector **inputVector,
50 vtkInformationVector *outputVector) {
54 std::vector<vtkUnstructuredGrid *> inputDiagrams;
56 auto nBlocks = inputVector[0]->GetNumberOfInformationObjects();
57 std::vector<vtkMultiBlockDataSet *> blocks(nBlocks);
60 this->
printWrn(
"Only dealing with the first two MultiBlockDataSets");
65 std::array<size_t, 2> nInputs{0, 0};
67 for(
int i = 0; i < nBlocks; ++i) {
68 blocks[i] = vtkMultiBlockDataSet::GetData(inputVector[0], i);
69 if(blocks[i] !=
nullptr) {
70 nInputs[i] = blocks[i]->GetNumberOfBlocks();
71 for(
size_t j = 0; j < nInputs[i]; ++j) {
72 inputDiagrams.emplace_back(
73 vtkUnstructuredGrid::SafeDownCast(blocks[i]->GetBlock(j)));
78 if(nInputs[0] + nInputs[1] == 0) {
84 const int nDiags = inputDiagrams.size();
87 for(
const auto vtu : inputDiagrams) {
89 this->
printErr(
"Input diagrams are not all vtkUnstructuredGrid");
95 auto diagramsDistTable = vtkTable::GetData(outputVector);
97 std::vector<ttk::DiagramType> intermediateDiagrams(nDiags);
99 for(
int i = 0; i < nDiags; i++) {
100 auto &diag{intermediateDiagrams[i]};
101 const auto ret =
VTUToDiagram(diag, inputDiagrams[i], *
this);
103 this->
printErr(
"Could not read Persistence Diagram");
108 const auto diagramsDistMat = this->
execute(intermediateDiagrams, nInputs);
112 = [](std::string &colName,
const size_t numberCols,
const size_t colIdx) {
113 std::string
const max{std::to_string(numberCols - 1)};
114 std::string
const cur{std::to_string(colIdx)};
115 std::string
const zer(max.size() - cur.size(),
'0');
116 colName.append(zer).append(cur);
119 const auto nTuples = nInputs[1] == 0 ? nInputs[0] : nInputs[1];
122 for(
size_t i = 0; i < diagramsDistMat.size(); ++i) {
123 std::string name{
"Diagram"};
124 zeroPad(name, diagramsDistMat.size(), i);
126 vtkNew<vtkDoubleArray> col{};
127 col->SetNumberOfTuples(nTuples);
128 col->SetName(name.c_str());
129 for(
size_t j = 0; j < diagramsDistMat[i].size(); ++j) {
130 col->SetTuple1(j, diagramsDistMat[i][j]);
132 diagramsDistTable->AddColumn(col);
136 vtkNew<vtkFieldData> inputFdA{};
138 for(
const auto diag : inputDiagrams) {
139 const auto fd{diag->GetFieldData()};
140 for(
int i = 0; i < fd->GetNumberOfArrays(); ++i) {
141 const auto array{fd->GetAbstractArray(i)};
142 if(array->IsA(
"vtkDataArray") || array->IsA(
"vtkStringArray")) {
143 inputFdA->AddArray(array);
149 vtkNew<vtkFieldData> outputFda{};
150 outputFda->DeepCopy(inputFdA);
152 for(
int i = 0; i < outputFda->GetNumberOfArrays(); ++i) {
153 const auto array{outputFda->GetAbstractArray(i)};
154 array->SetNumberOfTuples(inputDiagrams.size());
155 const auto name{array->GetName()};
156 for(
size_t j = 0; j < inputDiagrams.size(); ++j) {
157 const auto fd{inputDiagrams[j]->GetFieldData()};
158 const auto inputArray{fd->GetAbstractArray(name)};
159 if(inputArray !=
nullptr) {
160 array->SetTuple(j, 0, inputArray);
162 if(array->IsA(
"vtkDataArray")) {
163 vtkDataArray::SafeDownCast(array)->SetTuple1(j, NAN);
164 }
else if(array->IsA(
"vtkStringArray")) {
165 vtkStringArray::SafeDownCast(array)->SetValue(j,
"");
170 diagramsDistTable->AddColumn(array);