ITK  5.4.0
Insight Toolkit
itkPathConstIterator.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  * https://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 itkPathConstIterator_h
19 #define itkPathConstIterator_h
20 
21 #include "itkImage.h"
22 #include "itkPath.h"
23 
24 namespace itk
25 {
74 template <typename TImage, typename TPath>
75 class ITK_TEMPLATE_EXPORT PathConstIterator
76 {
77 public:
78 
81 
86  static constexpr unsigned int ImageIteratorDimension = TImage::ImageDimension;
87 
89  using IndexType = typename TImage::IndexType;
90 
92  using OffsetType = typename TImage::OffsetType;
93 
95  using SizeType = typename TImage::SizeType;
96 
98  using RegionType = typename TImage::RegionType;
99 
101  using SpacingType = typename TImage::SpacingType;
102 
104  using PointType = typename TImage::PointType;
105 
107  using ImageType = TImage;
108 
112  using PixelContainer = typename TImage::PixelContainer;
114 
116  using InternalPixelType = typename TImage::InternalPixelType;
117 
119  using PixelType = typename TImage::PixelType;
120 
123  using AccessorType = typename TImage::AccessorType;
124 
126  using PathType = TPath;
127 
129  using PathInputType = typename PathType::InputType;
130 
132  using PathOutputType = typename PathType::OutputType;
133 
135  itkVirtualGetNameOfClassMacro(PathConstIterator);
136 
138  static unsigned int
140  {
141  return TImage::ImageDimension;
142  }
143 
145  const PathInputType
147  {
148  return m_CurrentPathPosition;
149  }
150 
152  const IndexType
154  {
155  return m_CurrentImageIndex;
156  }
157 
159  const PixelType &
160  Get() const
161  {
162  return m_Image->GetPixel(m_CurrentImageIndex);
163  }
164 
168  bool
169  IsAtEnd() const
170  {
171  return m_IsAtEnd;
172  }
173 
178  inline virtual void
180  {
181  m_VisitStartIndexAsLastIndexIfClosed = flag;
182  }
183 
189  void
190  GoToBegin();
191 
193  void
194  operator++();
195 
198  Self &
199  operator=(const Self & it);
200 
202  PathConstIterator(const ImageType * imagePtr, const PathType * pathPtr);
203 
205  virtual ~PathConstIterator() = default;
206 
207 protected: // made protected so other iterators can access
208  // This "constant" is initialized in the constructor
209  OffsetType m_ZeroOffset{}; // = 0 for all dimensions
210 
212  typename ImageType::ConstWeakPointer m_Image{};
213 
215  typename PathType::ConstPointer m_Path{};
216 
218  RegionType m_Region{};
219 
221  PointType m_ImageOrigin{};
222 
224  SpacingType m_ImageSpacing{};
225 
227  const SizeValueType * m_ImageSize{};
228 
233  bool m_VisitStartIndexAsLastIndexIfClosed{};
234 
236  bool m_IsAtEnd{};
237 
239  PathInputType m_CurrentPathPosition{};
240 
242  IndexType m_CurrentImageIndex{};
243 };
244 } // end namespace itk
245 
246 #ifndef ITK_MANUAL_INSTANTIATION
247 # include "itkPathConstIterator.hxx"
248 #endif
249 
250 #endif
itk::PathConstIterator::GetImageIteratorDimension
static unsigned int GetImageIteratorDimension()
Definition: itkPathConstIterator.h:139
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::PathConstIterator::GetPathPosition
const PathInputType GetPathPosition()
Definition: itkPathConstIterator.h:146
itk::PathConstIterator::SizeType
typename TImage::SizeType SizeType
Definition: itkPathConstIterator.h:95
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::PathConstIterator::PixelContainer
typename TImage::PixelContainer PixelContainer
Definition: itkPathConstIterator.h:112
itk::PathConstIterator::ImageType
TImage ImageType
Definition: itkPathConstIterator.h:107
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itkImage.h
itk::PathConstIterator::PathInputType
typename PathType::InputType PathInputType
Definition: itkPathConstIterator.h:129
itk::PathConstIterator::IndexType
typename TImage::IndexType IndexType
Definition: itkPathConstIterator.h:89
itk::PathConstIterator::PixelContainerPointer
typename PixelContainer::Pointer PixelContainerPointer
Definition: itkPathConstIterator.h:113
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::PathConstIterator::PathType
TPath PathType
Definition: itkPathConstIterator.h:126
itk::PathConstIterator
PathConstIterator iterates (traces) over a path through an image.
Definition: itkPathConstIterator.h:75
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::PathConstIterator::RegionType
typename TImage::RegionType RegionType
Definition: itkPathConstIterator.h:98
itkPath.h
itk::PathConstIterator::PointType
typename TImage::PointType PointType
Definition: itkPathConstIterator.h:104
itk::PathConstIterator::IsAtEnd
bool IsAtEnd() const
Definition: itkPathConstIterator.h:169
itk::PathConstIterator::Get
const PixelType & Get() const
Definition: itkPathConstIterator.h:160
itk::PathConstIterator::PixelType
typename TImage::PixelType PixelType
Definition: itkPathConstIterator.h:119
itk::PathConstIterator::GetIndex
const IndexType GetIndex()
Definition: itkPathConstIterator.h:153
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::PathConstIterator::VisitStartIndexAsLastIndexIfClosed
virtual void VisitStartIndexAsLastIndexIfClosed(bool flag)
Definition: itkPathConstIterator.h:179
itk::PathConstIterator::InternalPixelType
typename TImage::InternalPixelType InternalPixelType
Definition: itkPathConstIterator.h:116
itk::PathConstIterator::SpacingType
typename TImage::SpacingType SpacingType
Definition: itkPathConstIterator.h:101
AddImageFilter
Definition: itkAddImageFilter.h:81
itk::PathConstIterator::AccessorType
typename TImage::AccessorType AccessorType
Definition: itkPathConstIterator.h:123
itk::PathConstIterator::OffsetType
typename TImage::OffsetType OffsetType
Definition: itkPathConstIterator.h:92
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::PathConstIterator::PathOutputType
typename PathType::OutputType PathOutputType
Definition: itkPathConstIterator.h:132