------------------------------------------------------------------------------
| 234 | |
| 235 | //------------------------------------------------------------------------------ |
| 236 | int vtkImageResize::RequestUpdateExtent( |
| 237 | vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 238 | { |
| 239 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 240 | vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); |
| 241 | |
| 242 | int wholeExt[6]; |
| 243 | int extent[6]; |
| 244 | |
| 245 | outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), extent); |
| 246 | inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), wholeExt); |
| 247 | |
| 248 | // get the interpolator |
| 249 | vtkAbstractImageInterpolator* interpolator = this->GetInternalInterpolator(); |
| 250 | |
| 251 | // set the extent according to the interpolation kernel size: |
| 252 | // first create a matrix to map output to input indices |
| 253 | double elements[16]; |
| 254 | for (int i = 0; i < 3; i++) |
| 255 | { |
| 256 | elements[4 * i + 0] = elements[4 * i + 1] = elements[4 * i + 2] = 0; |
| 257 | elements[4 * i + i] = this->IndexStretch[i]; |
| 258 | elements[4 * i + 3] = this->IndexTranslate[i]; |
| 259 | elements[12 + i] = 0; |
| 260 | } |
| 261 | elements[15] = 1; |
| 262 | // get the kernel size |
| 263 | int supportSize[3]; |
| 264 | interpolator->ComputeSupportSize(elements, supportSize); |
| 265 | |
| 266 | for (int j = 0; j < 3; j++) |
| 267 | { |
| 268 | double range[2]; |
| 269 | range[0] = extent[2 * j] * this->IndexStretch[j] + this->IndexTranslate[j]; |
| 270 | range[1] = extent[2 * j + 1] * this->IndexStretch[j] + this->IndexTranslate[j]; |
| 271 | |
| 272 | extent[2 * j] = VTK_INT_MAX; |
| 273 | extent[2 * j + 1] = VTK_INT_MIN; |
| 274 | |
| 275 | for (int ii = 0; ii < 2; ii++) |
| 276 | { |
| 277 | int kernelSize = supportSize[j]; |
| 278 | int extra = (kernelSize + 1) / 2 - 1; |
| 279 | |
| 280 | // most kernels have even size |
| 281 | if ((kernelSize & 1) == 0) |
| 282 | { |
| 283 | double f; |
| 284 | int k = vtkInterpolationMath::Floor(range[ii], f); |
| 285 | extent[2 * j] = std::min(k - extra, extent[2 * j]); |
| 286 | k += (f != 0); |
| 287 | extent[2 * j + 1] = std::max(k + extra, extent[2 * j + 1]); |
| 288 | } |
| 289 | // else is for kernels with odd size |
| 290 | else |
| 291 | { |
| 292 | int k = vtkInterpolationMath::Round(range[ii]); |
| 293 | if (k < extent[2 * j]) |
nothing calls this directly
no test coverage detected