------------------------------------------------------------------------------ This method contains a switch statement that calls the correct templated function for the input data type. This method does handle boundary conditions.
| 277 | // templated function for the input data type. This method does handle |
| 278 | // boundary conditions. |
| 279 | void vtkImageGradient::ThreadedRequestData(vtkInformation*, vtkInformationVector** inputVector, |
| 280 | vtkInformationVector*, vtkImageData*** inData, vtkImageData** outData, int outExt[6], |
| 281 | int threadId) |
| 282 | { |
| 283 | // Get the input and output data objects. |
| 284 | vtkImageData* input = inData[0][0]; |
| 285 | vtkImageData* output = outData[0]; |
| 286 | |
| 287 | // The output scalar type must be double to store proper gradients. |
| 288 | auto outScalars = |
| 289 | vtkAOSDataArrayTemplate<double>::FastDownCast(output->GetPointData()->GetScalars()); |
| 290 | if (!outScalars) |
| 291 | { |
| 292 | vtkErrorMacro("Execute: output ScalarType must be double."); |
| 293 | return; |
| 294 | } |
| 295 | |
| 296 | vtkDataArray* inputArray = this->GetInputArrayToProcess(0, inputVector); |
| 297 | if (!inputArray) |
| 298 | { |
| 299 | vtkErrorMacro("No input array was found. Cannot execute"); |
| 300 | return; |
| 301 | } |
| 302 | |
| 303 | // Gradient makes sense only with one input component. This is not |
| 304 | // a Jacobian filter. |
| 305 | if (inputArray->GetNumberOfComponents() != 1) |
| 306 | { |
| 307 | vtkErrorMacro("Execute: input has more than one component. " |
| 308 | "The input to gradient should be a single component image. " |
| 309 | "Think about it. If you insist on using a color image then " |
| 310 | "run it though RGBToHSV then ExtractComponents to get the V " |
| 311 | "components. That's probably what you want anyhow."); |
| 312 | return; |
| 313 | } |
| 314 | |
| 315 | double* scalarsPtr = outScalars->GetPointer(output->GetValueIndexForExtent(outScalars, outExt)); |
| 316 | vtkImageGradientFunctor functor; |
| 317 | if (!vtkArrayDispatch::Dispatch::Execute( |
| 318 | inputArray, functor, this, input, output, scalarsPtr, outExt, threadId)) |
| 319 | { |
| 320 | functor(inputArray, this, input, output, scalarsPtr, outExt, threadId); |
| 321 | } |
| 322 | } |
| 323 | VTK_ABI_NAMESPACE_END |
nothing calls this directly
no test coverage detected