OTB  9.0.0
Orfeo Toolbox
otbUnaryFunctorObjectListBooleanFilter.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 otbUnaryFunctorObjectListBooleanFilter_hxx
22 #define otbUnaryFunctorObjectListBooleanFilter_hxx
23 
25 #include "itkProgressReporter.h"
26 
27 namespace otb
28 {
29 
33 template <class TInputList, class TOutputList, class TFunction>
35 {
36 }
37 
38 template <class TInputList, class TOutputList, class TFunction>
40  itk::ThreadIdType threadId)
41 {
42 
43  InputListPointer inputPtr = this->GetInput();
44  this->m_ObjectListPerThread[threadId] = OutputListType::New();
45 
46  itk::ProgressReporter progress(this, threadId, stopIndex - startIndex);
47 
48  // Define the iterators
49  InputListIterator it = inputPtr->Begin();
50  unsigned int count = 0;
51  while ((count < startIndex) && (it != inputPtr->End()))
52  {
53  ++it;
54  ++count;
55  }
56 
57  while ((count < stopIndex) && (it != inputPtr->End()))
58  {
59  if (m_Functor(it.Get()))
60  {
61  this->m_ObjectListPerThread[threadId]->PushBack(it.Get());
62  }
63 
64  progress.CompletedPixel();
65  ++it;
66  ++count;
67  }
68 }
69 
70 template <class TInputList, class TOutputList, class TFunction>
72 {
73  // copy the lists to the output
74  OutputListPointer outputPtr = this->GetOutput();
75  for (unsigned int i = 0; i < this->m_ObjectListPerThread.size(); ++i)
76  {
77  if (this->m_ObjectListPerThread[i].IsNotNull())
78  {
79  for (OutputListIterator it = this->m_ObjectListPerThread[i]->Begin(); it != this->m_ObjectListPerThread[i]->End(); ++it)
80  {
81  outputPtr->PushBack(it.Get());
82  }
83  }
84  }
85 }
86 
87 } // end namespace otb
88 
89 #endif
otb::UnaryFunctorObjectListBooleanFilter::OutputListIterator
TOutputList::ConstIterator OutputListIterator
Definition: otbUnaryFunctorObjectListBooleanFilter.h:63
otb::UnaryFunctorObjectListBooleanFilter::UnaryFunctorObjectListBooleanFilter
UnaryFunctorObjectListBooleanFilter()
Definition: otbUnaryFunctorObjectListBooleanFilter.hxx:34
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
otb::UnaryFunctorObjectListBooleanFilter::AfterThreadedGenerateData
void AfterThreadedGenerateData() override
Definition: otbUnaryFunctorObjectListBooleanFilter.hxx:71
otb::UnaryFunctorObjectListBooleanFilter::ThreadedGenerateData
void ThreadedGenerateData(unsigned int startIndex, unsigned int stopIndex, itk::ThreadIdType threadId) override
Definition: otbUnaryFunctorObjectListBooleanFilter.hxx:39
otbUnaryFunctorObjectListBooleanFilter.h