43 if(input->IsA(
"vtkImageData")) {
44 output->ShallowCopy(input);
45 }
else if(input->IsA(
"vtkPointSet")) {
46 auto outputAsPS = (vtkPointSet *)output;
47 outputAsPS->ShallowCopy(input);
50 points->DeepCopy(outputAsPS->GetPoints());
52 outputAsPS->SetPoints(points);
54 output->DeepCopy(input);
61 const size_t &colAxis,
62 const size_t &rowAxis,
65 auto inputMB = vtkMultiBlockDataSet::SafeDownCast(input);
66 auto inputAsPS = vtkPointSet::SafeDownCast(input);
67 auto inputAsID = vtkImageData::SafeDownCast(input);
70 size_t const n = inputMB->GetNumberOfBlocks();
71 for(
size_t i = 0; i < n; i++)
72 if(!this->
TranslateObject(inputMB->GetBlock(i), colAxis, rowAxis, dw, dh))
75 }
else if(inputAsPS) {
76 size_t const nCoords = inputAsPS->GetNumberOfPoints() * 3;
77 auto points = inputAsPS->GetPoints();
78 auto pointCoords = (
float *)points->GetVoidPointer(0);
79 for(
size_t i = 0; i < nCoords; i += 3) {
80 pointCoords[i + colAxis] += dw;
81 pointCoords[i + rowAxis] += dh;
84 }
else if(inputAsID) {
85 double origin[3] = {0, 0, 0};
88 inputAsID->SetOrigin(origin);
97 vtkInformationVector **inputVector,
98 vtkInformationVector *outputVector) {
102 auto inputMB = vtkMultiBlockDataSet::GetData(inputVector[0]);
103 auto outputMB = vtkMultiBlockDataSet::GetData(outputVector);
112 double maxHeight = 0;
114 size_t const nBlocks = inputMB->GetNumberOfBlocks();
116 this->
printMsg(
"Translating " + std::to_string(nBlocks) +
" object(s)", 0,
119 for(
size_t i = 0; i < nBlocks; i++) {
120 auto block = inputMB->GetBlock(i);
121 if(block->IsA(
"vtkMultiBlockDataSet")) {
122 auto blockAsMB = vtkMultiBlockDataSet::SafeDownCast(block);
123 blockAsMB->GetBounds(bounds);
124 }
else if(block->IsA(
"vtkDataSet")) {
125 auto blockAsDS = vtkDataSet::SafeDownCast(block);
126 blockAsDS->GetBounds(bounds);
128 this->
printErr(
"Unable to determine bounding box of block #"
129 + std::to_string(i) +
" with type "
130 + std::string(block->GetClassName()) +
".");
134 double const blockWidth = bounds[colAxis * 2 + 1] - bounds[colAxis * 2];
135 double const blockHeight = bounds[rowAxis * 2 + 1] - bounds[rowAxis * 2];
136 if(maxWidth < blockWidth)
137 maxWidth = blockWidth;
138 if(maxHeight < blockHeight)
139 maxHeight = blockHeight;
143 maxWidth += maxWidth * this->
GetColGap() / 100.;
144 maxHeight += maxHeight * this->
GetRowGap() / 100.;
149 const size_t nColumns
150 = nRows == 0 ? std::ceil(std::sqrt(nBlocks)) : std::ceil(nBlocks / nRows);
152 for(
size_t i = 0; i < nBlocks; i++) {
154 auto block = inputMB->GetBlock(i);
159 const size_t row = std::floor(i / nColumns);
160 const size_t col = i % nColumns;
163 outBlock, colAxis, rowAxis, col * maxWidth, row * maxHeight)) {
164 this->
printErr(
"Unable to translate block #" + std::to_string(i)
165 +
" of type '" + std::string(outBlock->GetClassName())
170 outputMB->SetBlock(i, outBlock);
173 this->
printMsg(
"Translating " + std::to_string(nBlocks) +
" object(s)", 1,
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)