OTB  9.0.0
Orfeo Toolbox
otbMaskedIteratorDecorator.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 otbMaskedIteratorDecorator_h
22 #define otbMaskedIteratorDecorator_h
23 
24 #include "itkMacro.h"
25 
26 namespace otb
27 {
28 
39 template <typename TIteratorType, typename TMaskIteratorType = TIteratorType>
41 {
42 public:
44  typedef typename TMaskIteratorType::ImageType MaskType;
45  typedef typename TIteratorType::ImageType ImageType;
46  typedef typename ImageType::IndexType IndexType;
47  typedef typename ImageType::RegionType RegionType;
48  typedef typename ImageType::PixelType PixelType;
49  typedef typename MaskType::PixelType MaskPixelType;
50 
51  // Run-time type information
53 
57  MaskedIteratorDecorator(MaskType* mask, ImageType* image, const RegionType& region);
58 
60  IndexType GetIndex() const;
61 
65  void GoToBegin();
66 
68  void GoToEnd();
69 
71  bool IsAtBegin() const;
72 
74  bool IsAtEnd() const;
75 
78  Self& operator++();
79 
82  Self& operator--();
83 
85  // void Set(const PixelType& value) const;
86 
88  const PixelType& Value(void) const;
89 
90  // Can't wrap all methods because iterator interface is open ended
91  // So provide access to inner iterators:
92 
94  TMaskIteratorType& GetMaskIterator();
95 
97  const TMaskIteratorType& GetMaskIterator() const;
98 
100  TIteratorType& GetImageIterator();
101 
103  const TIteratorType& GetImageIterator() const;
104 
105  const bool& HasMask() const;
106 
107 private:
110  void ComputeMaskedBegin();
111 
112 private:
113  // Inner iterators on the image and mask
114  TMaskIteratorType m_ItMask;
115  TIteratorType m_ItImage;
116 
117  // flag to check if mask is present
118  bool m_UseMask;
119 
120  // Unmasked bounds
121  TMaskIteratorType m_StartMask;
122  TIteratorType m_StartImage;
123 };
124 }
125 
126 #ifndef OTB_MANUAL_INSTANTIATION
128 #endif
129 
130 #endif
otb::MaskedIteratorDecorator::RegionType
ImageType::RegionType RegionType
Definition: otbMaskedIteratorDecorator.h:47
otb::MaskedIteratorDecorator::GetMaskIterator
TMaskIteratorType & GetMaskIterator()
Definition: otbMaskedIteratorDecorator.hxx:160
otb::MaskedIteratorDecorator::operator--
Self & operator--()
Definition: otbMaskedIteratorDecorator.hxx:127
otb::MaskedIteratorDecorator::m_UseMask
bool m_UseMask
Definition: otbMaskedIteratorDecorator.h:118
otb::MaskedIteratorDecorator::GetImageIterator
TIteratorType & GetImageIterator()
Definition: otbMaskedIteratorDecorator.hxx:172
otb::MaskedIteratorDecorator::MaskType
TMaskIteratorType::ImageType MaskType
Definition: otbMaskedIteratorDecorator.h:44
otb::MaskedIteratorDecorator::ComputeMaskedBegin
void ComputeMaskedBegin()
Definition: otbMaskedIteratorDecorator.hxx:191
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::MaskedIteratorDecorator::PixelType
ImageType::PixelType PixelType
Definition: otbMaskedIteratorDecorator.h:48
otb::MaskedIteratorDecorator::MaskedIteratorDecorator
MaskedIteratorDecorator(MaskType *mask, ImageType *image, const RegionType &region)
Definition: otbMaskedIteratorDecorator.hxx:31
otb::MaskedIteratorDecorator::itkTypeMacroNoParent
itkTypeMacroNoParent(MaskedIteratorDecorator)
otbMaskedIteratorDecorator.hxx
otb::MaskedIteratorDecorator::GoToBegin
void GoToBegin()
Definition: otbMaskedIteratorDecorator.hxx:61
otb::MaskedIteratorDecorator
Decorate an iterator to ignore masked pixels.
Definition: otbMaskedIteratorDecorator.h:40
otb::MaskedIteratorDecorator::IsAtBegin
bool IsAtBegin() const
Definition: otbMaskedIteratorDecorator.hxx:87
otb::MaskedIteratorDecorator::m_ItImage
TIteratorType m_ItImage
Definition: otbMaskedIteratorDecorator.h:115
otb::MaskedIteratorDecorator::HasMask
const bool & HasMask() const
Definition: otbMaskedIteratorDecorator.hxx:184
otb::MaskedIteratorDecorator::IsAtEnd
bool IsAtEnd() const
Definition: otbMaskedIteratorDecorator.hxx:97
otb::MaskedIteratorDecorator::Self
MaskedIteratorDecorator< TIteratorType, TMaskIteratorType > Self
Definition: otbMaskedIteratorDecorator.h:43
otb::MaskedIteratorDecorator::GoToEnd
void GoToEnd()
Definition: otbMaskedIteratorDecorator.hxx:74
otb::MaskedIteratorDecorator::m_StartImage
TIteratorType m_StartImage
Definition: otbMaskedIteratorDecorator.h:122
otb::MaskedIteratorDecorator::operator++
Self & operator++()
Definition: otbMaskedIteratorDecorator.hxx:108
otb::MaskedIteratorDecorator::MaskPixelType
MaskType::PixelType MaskPixelType
Definition: otbMaskedIteratorDecorator.h:49
otb::MaskedIteratorDecorator::Value
const PixelType & Value(void) const
Definition: otbMaskedIteratorDecorator.hxx:154
otb::MaskedIteratorDecorator::IndexType
ImageType::IndexType IndexType
Definition: otbMaskedIteratorDecorator.h:46
otb::MaskedIteratorDecorator::m_ItMask
TMaskIteratorType m_ItMask
Definition: otbMaskedIteratorDecorator.h:114
otb::MaskedIteratorDecorator::m_StartMask
TMaskIteratorType m_StartMask
Definition: otbMaskedIteratorDecorator.h:121
otb::MaskedIteratorDecorator::GetIndex
IndexType GetIndex() const
Definition: otbMaskedIteratorDecorator.hxx:55
otb::MaskedIteratorDecorator::ImageType
TIteratorType::ImageType ImageType
Definition: otbMaskedIteratorDecorator.h:45