21 #ifndef otbUnaryFunctorWithIndexImageFilter_hxx
22 #define otbUnaryFunctorWithIndexImageFilter_hxx
25 #include "itkImageRegionIterator.h"
26 #include "itkProgressReporter.h"
34 template <
class TInputImage,
class TOutputImage,
class TFunction>
37 this->SetNumberOfRequiredInputs(1);
38 this->DynamicMultiThreadingOn();
40 template <
class TInputImage,
class TOutputImage,
class TFunction>
44 Superclass::GenerateInputRequestedRegion();
48 typename Superclass::InputImagePointer inputPtr =
const_cast<TInputImage*
>(this->GetInput());
49 typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
51 if (!inputPtr || !outputPtr)
57 typename TInputImage::RegionType inputRequestedRegion;
58 inputRequestedRegion = inputPtr->GetRequestedRegion();
61 if (inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()))
63 inputPtr->SetRequestedRegion(inputRequestedRegion);
72 inputPtr->SetRequestedRegion(inputRequestedRegion);
75 itk::InvalidRequestedRegionError e(__FILE__, __LINE__);
76 std::ostringstream msg;
77 msg << this->GetNameOfClass() <<
"::GenerateInputRequestedRegion()";
78 e.SetLocation(msg.str());
79 e.SetDescription(
"Requested region is (at least partially) outside the largest possible region.");
80 e.SetDataObject(inputPtr);
88 template <
class TInputImage,
class TOutputImage,
class TFunction>
91 InputImagePointer inputPtr =
dynamic_cast<const TInputImage*
>(ProcessObjectType::GetInput(0));
96 this->CallCopyOutputRegionToInputRegion(inputRegionForThread, outputRegionForThread);
100 itk::ImageRegionIterator<TOutputImage> outputIt(outputPtr, outputRegionForThread);
103 outputIt.GoToBegin();
105 while (!inputIt.IsAtEnd())
107 outputIt.Set(m_Functor(inputIt.Get(), inputIt.GetIndex()));
OutputImageType::RegionType OutputImageRegionType
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
UnaryFunctorWithIndexImageFilter()
void GenerateInputRequestedRegion(void) override
InputImageType::ConstPointer InputImagePointer
OutputImageType::Pointer OutputImagePointer
InputImageType::RegionType InputImageRegionType
itk::ImageRegionConstIteratorWithIndex< TInputImage > IteratorType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.