38 vtkInformationVector **inputVector,
39 vtkInformationVector *outputVector) {
42 std::vector<std::pair<vtkDataObject *, size_t>> blocks{};
44 auto input = vtkMultiBlockDataSet::GetData(inputVector[0], 0);
47 if(input ==
nullptr || input->GetNumberOfBlocks() == 0) {
52 for(
size_t i = 0; i < input->GetNumberOfBlocks(); ++i) {
53 const auto topLvlBlock
54 = vtkMultiBlockDataSet::SafeDownCast(input->GetBlock(i));
55 if(topLvlBlock ==
nullptr) {
58 for(
size_t j = 0; j < topLvlBlock->GetNumberOfBlocks(); ++j) {
59 blocks.emplace_back(topLvlBlock->GetBlock(j), i);
63 auto outputFlatBlocks = vtkMultiBlockDataSet::GetData(outputVector);
67 this->
printWrn(
"Not a hierarchy of vtkMultiBlockDataSet");
68 outputFlatBlocks->ShallowCopy(input);
73 outputFlatBlocks->SetNumberOfBlocks(blocks.size());
75 for(
size_t i = 0; i < blocks.size(); ++i) {
77 outputFlatBlocks->SetBlock(i, blocks[i].first);
80 vtkNew<vtkUnsignedIntArray> blockId{};
81 blockId->SetName(
"ParentBlockId");
82 blockId->SetNumberOfTuples(1);
83 blockId->SetTuple1(0, blocks[i].second);
85 blocks[i].first->GetFieldData()->AddArray(blockId);