21 #ifndef otbObjectListToObjectListFilter_hxx
22 #define otbObjectListToObjectListFilter_hxx
25 #include "itkProgressReporter.h"
33 template <
class TInputList,
class TOutputList>
36 this->SetNumberOfRequiredInputs(1);
39 template <
class TInputList,
class TOutputList>
43 this->itk::ProcessObject::SetNthInput(0,
const_cast<InputListType*
>(input));
46 template <
class TInputList,
class TOutputList>
49 if (this->GetNumberOfInputs() < 1)
54 return static_cast<const TInputList*
>(this->itk::ProcessObject::GetInput(0));
57 template <
class TInputList,
class TOutputList>
59 unsigned int& startIndex,
unsigned int& stopIndex)
61 startIndex =
static_cast<unsigned int>(std::floor(requestedElements *
static_cast<double>(threadId) /
static_cast<double>(threadCount) + 0.5));
62 stopIndex =
static_cast<unsigned int>(std::floor(requestedElements *
static_cast<double>(threadId + 1) /
static_cast<double>(threadCount) + 0.5));
63 if (stopIndex > requestedElements)
64 stopIndex = requestedElements;
75 template <
class TInputList,
class TOutputList>
81 this->BeforeThreadedGenerateData();
92 this->GetMultiThreader()->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());
93 this->GetMultiThreader()->SetSingleMethod(this->ThreaderCallback, &str);
96 this->GetMultiThreader()->SingleMethodExecute();
100 this->AfterThreadedGenerateData();
103 template <
class TInputList,
class TOutputList>
106 this->AllocateOutputs();
109 template <
class TInputList,
class TOutputList>
117 std::ostringstream message;
118 message <<
"itk::ERROR: " << this->GetNameOfClass() <<
"(" <<
this <<
"): "
119 <<
"Subclass should override this method!!!";
120 itk::ExceptionObject e_(__FILE__, __LINE__, message.str(), ITK_LOCATION);
124 template <
class TInputList,
class TOutputList>
125 itk::ITK_THREAD_RETURN_TYPE
130 itk::ThreadIdType threadId, threadCount;
131 unsigned int total, start, stop;
132 unsigned int requestedElements;
134 threadId = ((itk::MultiThreaderBase::WorkUnitInfo *) (arg))->WorkUnitID;
135 threadCount = ((itk::MultiThreaderBase::WorkUnitInfo *) (arg))->NumberOfWorkUnits;
136 str = (
ThreadStruct *) (((itk::MultiThreaderBase::WorkUnitInfo *) (arg))->UserData);
138 requestedElements = str->
Filter->GetInput()->Size();
139 total = str->
Filter->SplitRequestedRegion(threadId, threadCount, requestedElements, start, stop);
141 if (threadId <
static_cast<itk::ThreadIdType
>(total))
148 str->
Filter->ThreadedGenerateData(start, stop, threadId);
158 return itk::ITK_THREAD_RETURN_DEFAULT_VALUE;
164 template <
class TInputList,
class TOutputList>
167 Superclass::PrintSelf(os, indent);
TOutputList::Pointer OutputListPointer
const InputListType * GetInput(void)
virtual void ThreadedGenerateData(unsigned int startIndex, unsigned int stopIndex, itk::ThreadIdType threadId)
void GenerateData(void) override
void PrintSelf(std::ostream &os, itk::Indent indent) const override
virtual int SplitRequestedRegion(itk::ThreadIdType threadId, int threadCount, unsigned int requestedElements, unsigned int &startIndex, unsigned int &stopIndex)
virtual void SetInput(const InputListType *input)
ObjectListToObjectListFilter()
std::vector< OutputListPointer > OutputListForThreadType
static itk::ITK_THREAD_RETURN_TYPE ThreaderCallback(void *arg)
virtual void BeforeThreadedGenerateData()
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.