OTB  6.7.0
Orfeo Toolbox
otbMaskedIteratorDecorator.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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  <TIteratorType,TMaskIteratorType> Self;
45  typedef typename TMaskIteratorType::ImageType MaskType;
46  typedef typename TIteratorType::ImageType ImageType;
47  typedef typename ImageType::IndexType IndexType;
48  typedef typename ImageType::RegionType RegionType;
49  typedef typename ImageType::PixelType PixelType;
50  typedef typename MaskType::PixelType MaskPixelType;
51 
52  // Run-time type information
54 
59  ImageType* image,
60  const RegionType& region);
61 
63  IndexType GetIndex() const;
64 
68  void GoToBegin();
69 
71  void GoToEnd();
72 
74  bool IsAtBegin() const;
75 
77  bool IsAtEnd() const;
78 
81  Self& operator++();
82 
85  Self & operator--();
86 
88  //void Set(const PixelType& value) const;
89 
91  const PixelType& Value(void) const;
92 
93  // Can't wrap all methods because iterator interface is open ended
94  // So provide access to inner iterators:
95 
97  TMaskIteratorType& GetMaskIterator();
98 
100  const TMaskIteratorType& GetMaskIterator() const;
101 
103  TIteratorType& GetImageIterator();
104 
106  const TIteratorType& GetImageIterator() const;
107 
108  const bool& HasMask() const;
109 
110 private:
113  void ComputeMaskedBegin();
114 
115 private:
116  // Inner iterators on the image and mask
117  TMaskIteratorType m_ItMask;
118  TIteratorType m_ItImage;
119 
120  // flag to check if mask is present
121  bool m_UseMask;
122 
123  // Unmasked bounds
124  TMaskIteratorType m_StartMask;
125  TIteratorType m_StartImage;
126 };
127 
128 }
129 
130 #ifndef OTB_MANUAL_INSTANTIATION
132 #endif
133 
134 #endif
itkTypeMacroNoParent(MaskedIteratorDecorator)
itk::Index< Monteverdi_DIMENSION > IndexType
Definition: mvdTypes.h:133
Decorate an iterator to ignore masked pixels.
MaskedIteratorDecorator(MaskType *mask, ImageType *image, const RegionType &region)
const PixelType & Value(void) const
TMaskIteratorType::ImageType MaskType
MaskedIteratorDecorator< TIteratorType, TMaskIteratorType > Self