OTB  9.0.0
Orfeo Toolbox
otbInPlacePassFilter.h
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 otbInPlacePassFilter_h
22 #define otbInPlacePassFilter_h
23 
24 #include "itkInPlaceImageFilter.h"
25 #include "otbImage.h"
26 #include "itkImageRegionIterator.h"
27 
28 namespace otb
29 {
30 
45 template <class TInputImage>
46 class ITK_EXPORT InPlacePassFilter : public itk::InPlaceImageFilter<TInputImage, TInputImage>
47 {
48 public:
50  typedef TInputImage InputImageType;
51 
53  typedef itk::InPlaceImageFilter<InputImageType, InputImageType> Superclass;
54  typedef itk::SmartPointer<Self> Pointer;
55  typedef itk::SmartPointer<const Self> ConstPointer;
56 
58  itkNewMacro(Self);
59 
61  itkTypeMacro(InPlacePassFilter, InPlaceImageFilter);
62 
63 protected:
65  {
66  this->InPlaceOn();
67  }
68 
69  ~InPlacePassFilter() override
70  {
71  }
72 
73  void ThreadedGenerateData(const typename InputImageType::RegionType& outputRegionForThread, itk::ThreadIdType itkNotUsed(threadId)) override
74  {
75  typename InputImageType::ConstPointer input(this->GetInput());
76  typename InputImageType::Pointer output(this->GetOutput());
77  itk::ImageRegionConstIterator<InputImageType> it(input, outputRegionForThread);
78  itk::ImageRegionIterator<InputImageType> oit(output, outputRegionForThread);
79  for (oit.GoToBegin(), it.GoToBegin(); !oit.IsAtEnd() || !it.IsAtEnd(); ++it, ++oit)
80  {
81  oit.Set(it.Get());
82  }
83  }
84 
85 private:
86  InPlacePassFilter(const Self&) = delete;
87  void operator=(const Self&) = delete;
88 };
89 
90 } // End namespace otb
91 
92 #ifndef OTB_MANUAL_INSTANTIATION
93 #endif
94 
95 #endif
otb::InPlacePassFilter::InputImageType
TInputImage InputImageType
Definition: otbInPlacePassFilter.h:50
otbImage.h
otb::InPlacePassFilter::Self
InPlacePassFilter Self
Definition: otbInPlacePassFilter.h:52
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::InPlacePassFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbInPlacePassFilter.h:55
otb::InPlacePassFilter::~InPlacePassFilter
~InPlacePassFilter() override
Definition: otbInPlacePassFilter.h:69
otb::InPlacePassFilter::ThreadedGenerateData
void ThreadedGenerateData(const typename InputImageType::RegionType &outputRegionForThread, itk::ThreadIdType) override
Definition: otbInPlacePassFilter.h:73
otb::InPlacePassFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbInPlacePassFilter.h:54
otb::InPlacePassFilter::InPlacePassFilter
InPlacePassFilter()
Definition: otbInPlacePassFilter.h:64
otb::InPlacePassFilter
This filter has the only purpose to recall regions.
Definition: otbInPlacePassFilter.h:46
otb::InPlacePassFilter::Superclass
itk::InPlaceImageFilter< InputImageType, InputImageType > Superclass
Definition: otbInPlacePassFilter.h:53