ITK  5.2.0
Insight Toolkit
itkLineConstIterator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkLineConstIterator_h
19 #define itkLineConstIterator_h
20 
21 #include "itkIndex.h"
22 #include "itkImage.h"
23 
24 namespace itk
25 {
55 template <typename TImage>
56 class ITK_TEMPLATE_EXPORT LineConstIterator
57 {
58 public:
59 
62 
67  static constexpr unsigned int ImageIteratorDimension = TImage::ImageDimension;
68 
70  using IndexType = typename TImage::IndexType;
71 
73  using OffsetType = typename TImage::OffsetType;
74 
76  using SizeType = typename TImage::SizeType;
77 
79  using RegionType = typename TImage::RegionType;
80 
82  using SpacingType = typename TImage::SpacingType;
83 
85  using PointType = typename TImage::PointType;
86 
88  using ImageType = TImage;
89 
93  using PixelContainer = typename TImage::PixelContainer;
94  using PixelContainerPointer = typename PixelContainer::Pointer;
95 
97  using InternalPixelType = typename TImage::InternalPixelType;
98 
100  using PixelType = typename TImage::PixelType;
101 
104  using AccessorType = typename TImage::AccessorType;
105 
107  itkTypeMacroNoParent(LineConstIterator);
108 
110  static unsigned int
112  {
113  return TImage::ImageDimension;
114  }
115 
117  const IndexType
119  {
120  return m_CurrentImageIndex;
121  }
122 
124  const PixelType
125  Get() const
126  {
127  return m_Image->GetPixel(m_CurrentImageIndex);
128  }
129 
131  bool
132  IsAtEnd() const
133  {
134  return m_IsAtEnd;
135  }
136 
138  void
139  GoToBegin();
140 
142  void
143  operator++();
144 
147  Self &
148  operator=(const Self & it);
149 
151  LineConstIterator(const ImageType * imagePtr, const IndexType & firstIndex, const IndexType & lastIndex);
152 
154  virtual ~LineConstIterator() = default;
155 
156 protected: // made protected so other iterators can access
158  typename ImageType::ConstWeakPointer m_Image;
159 
162 
164  bool m_IsAtEnd;
165 
170  IndexType m_EndIndex; // one past the end of the line in the m_MainDirection
171 
173  // The dimension with the largest difference between start and end
174  unsigned int m_MainDirection;
175 
176  // Accumulated error for the other dimensions
178 
179  // Increment for the error for each step. Two times the difference between
180  // start and end
182 
183  // If enough is accumulated for a dimension, the index has to be
184  // incremented. Will be the number of pixels in the line
186 
187  // Direction of increment. -1 or 1
189 
190  // After an overflow, the accumulated error is reduced again. Will be
191  // two times the number of pixels in the line
193 };
194 } // end namespace itk
195 
196 #ifndef ITK_MANUAL_INSTANTIATION
197 # include "itkLineConstIterator.hxx"
198 #endif
199 
200 #endif
itk::LineConstIterator::m_AccumulateError
IndexType m_AccumulateError
Definition: itkLineConstIterator.h:177
itk::LineConstIterator::m_Region
RegionType m_Region
Definition: itkLineConstIterator.h:161
itk::LineConstIterator::SizeType
typename TImage::SizeType SizeType
Definition: itkLineConstIterator.h:76
itk::LineConstIterator::PixelContainerPointer
typename PixelContainer::Pointer PixelContainerPointer
Definition: itkLineConstIterator.h:94
itk::LineConstIterator::IsAtEnd
bool IsAtEnd() const
Definition: itkLineConstIterator.h:132
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::LineConstIterator::PixelType
typename TImage::PixelType PixelType
Definition: itkLineConstIterator.h:100
itk::LineConstIterator::PointType
typename TImage::PointType PointType
Definition: itkLineConstIterator.h:85
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::LineConstIterator::GetImageIteratorDimension
static unsigned int GetImageIteratorDimension()
Definition: itkLineConstIterator.h:111
itkImage.h
itk::LineConstIterator::SpacingType
typename TImage::SpacingType SpacingType
Definition: itkLineConstIterator.h:82
itk::LineConstIterator::m_MainDirection
unsigned int m_MainDirection
Definition: itkLineConstIterator.h:174
itk::LineConstIterator
An iterator that walks a Bresenham line through an ND image with read-only access to pixels.
Definition: itkLineConstIterator.h:56
itk::LineConstIterator::GetIndex
const IndexType GetIndex()
Definition: itkLineConstIterator.h:118
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::LineConstIterator::RegionType
typename TImage::RegionType RegionType
Definition: itkLineConstIterator.h:79
itk::LineConstIterator::m_IsAtEnd
bool m_IsAtEnd
Definition: itkLineConstIterator.h:164
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::LineConstIterator::m_LastIndex
IndexType m_LastIndex
Definition: itkLineConstIterator.h:169
itk::LineConstIterator::Get
const PixelType Get() const
Definition: itkLineConstIterator.h:125
itk::LineConstIterator::PixelContainer
typename TImage::PixelContainer PixelContainer
Definition: itkLineConstIterator.h:93
itk::LineConstIterator::OffsetType
typename TImage::OffsetType OffsetType
Definition: itkLineConstIterator.h:73
itk::LineConstIterator::AccessorType
typename TImage::AccessorType AccessorType
Definition: itkLineConstIterator.h:104
itkIndex.h
itk::LineConstIterator::InternalPixelType
typename TImage::InternalPixelType InternalPixelType
Definition: itkLineConstIterator.h:97
itk::LineConstIterator::ImageType
TImage ImageType
Definition: itkLineConstIterator.h:88
itk::LineConstIterator::m_Image
ImageType::ConstWeakPointer m_Image
Definition: itkLineConstIterator.h:158
itk::LineConstIterator::m_EndIndex
IndexType m_EndIndex
Definition: itkLineConstIterator.h:170
itk::LineConstIterator::m_CurrentImageIndex
IndexType m_CurrentImageIndex
Definition: itkLineConstIterator.h:167
itk::LineConstIterator::m_StartIndex
IndexType m_StartIndex
Definition: itkLineConstIterator.h:168
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::LineConstIterator::m_IncrementError
IndexType m_IncrementError
Definition: itkLineConstIterator.h:181
itk::LineConstIterator::m_MaximalError
IndexType m_MaximalError
Definition: itkLineConstIterator.h:185
itk::LineConstIterator::m_OverflowIncrement
IndexType m_OverflowIncrement
Definition: itkLineConstIterator.h:188
itk::LineConstIterator::m_ReduceErrorAfterIncrement
IndexType m_ReduceErrorAfterIncrement
Definition: itkLineConstIterator.h:192
itk::LineConstIterator::IndexType
typename TImage::IndexType IndexType
Definition: itkLineConstIterator.h:70