OTB  9.0.0
Orfeo Toolbox
otbUnaryFunctorObjectListFilter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbUnaryFunctorObjectListFilter_hxx
22 #define otbUnaryFunctorObjectListFilter_hxx
23 
25 #include "itkProgressReporter.h"
26 #include "otbMath.h"
27 
28 namespace otb
29 {
30 
34 template <class TInputList, class TOutputList, class TFunction>
36 {
37 }
38 
39 template <class TInputList, class TOutputList, class TFunction>
41  itk::ThreadIdType threadId)
42 {
43 
44  InputListPointer inputPtr = this->GetInput();
45  this->m_ObjectListPerThread[threadId] = OutputListType::New();
46 
47  itk::ProgressReporter progress(this, threadId, stopIndex - startIndex);
48 
49  // Define the iterators
50  InputListIterator it = inputPtr->Begin();
51  unsigned int count = 0;
52  while ((count < startIndex) && (it != inputPtr->End()))
53  {
54  ++it;
55  ++count;
56  }
57 
58  while ((count < stopIndex) && (it != inputPtr->End()))
59  {
60  this->m_ObjectListPerThread[threadId]->PushBack(m_Functor(it.Get()));
61 
62  progress.CompletedPixel();
63  ++it;
64  ++count;
65  }
66 }
67 
68 template <class TInputList, class TOutputList, class TFunction>
70 {
71  // copy the lists to the output
72  OutputListPointer outputPtr = this->GetOutput();
73  for (unsigned int i = 0; i < this->m_ObjectListPerThread.size(); ++i)
74  {
75  if (this->m_ObjectListPerThread[i].IsNotNull())
76  {
77  for (OutputListIterator it = this->m_ObjectListPerThread[i]->Begin(); it != this->m_ObjectListPerThread[i]->End(); ++it)
78  {
79  outputPtr->PushBack(it.Get());
80  }
81  }
82  }
83 }
84 
85 } // end namespace otb
86 
87 #endif
otb::UnaryFunctorObjectListFilter::OutputListIterator
TOutputList::ConstIterator OutputListIterator
Definition: otbUnaryFunctorObjectListFilter.h:63
otb::UnaryFunctorObjectListFilter::ThreadedGenerateData
void ThreadedGenerateData(unsigned int startIndex, unsigned int stopIndex, itk::ThreadIdType threadId) override
Definition: otbUnaryFunctorObjectListFilter.hxx:40
otbUnaryFunctorObjectListFilter.h
otb::UnaryFunctorObjectListFilter::UnaryFunctorObjectListFilter
UnaryFunctorObjectListFilter()
Definition: otbUnaryFunctorObjectListFilter.hxx:35
otbMath.h
otb::UnaryFunctorObjectListFilter::AfterThreadedGenerateData
void AfterThreadedGenerateData() override
Definition: otbUnaryFunctorObjectListFilter.hxx:69
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ObjectListSource::OutputListPointer
TOutputList::Pointer OutputListPointer
Definition: otbObjectListSource.h:65
otb::ObjectListToObjectListFilter::InputListIterator
TInputList::ConstIterator InputListIterator
Definition: otbObjectListToObjectListFilter.h:66
otb::ObjectListToObjectListFilter::InputListPointer
TInputList::ConstPointer InputListPointer
Definition: otbObjectListToObjectListFilter.h:64