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()->SetNumberOfThreads(this->GetNumberOfThreads());
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>
128 itk::ThreadIdType threadId, threadCount;
129 unsigned int total, start, stop;
130 unsigned int requestedElements;
132 threadId = ((itk::MultiThreader::ThreadInfoStruct*)(arg))->ThreadID;
133 threadCount = ((itk::MultiThreader::ThreadInfoStruct*)(arg))->NumberOfThreads;
134 str = (ThreadStruct*)(((itk::MultiThreader::ThreadInfoStruct*)(arg))->UserData);
136 requestedElements = str->Filter->GetInput()->Size();
137 total = str->Filter->SplitRequestedRegion(threadId, threadCount, requestedElements, start, stop);
139 if (threadId <
static_cast<itk::ThreadIdType
>(total))
146 str->Filter->ThreadedGenerateData(start, stop, threadId);
156 return ITK_THREAD_RETURN_VALUE;
162 template <
class TInputList,
class TOutputList>
165 Superclass::PrintSelf(os, indent);