ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkPathConstIterator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 __itkPathConstIterator_h
19 #define __itkPathConstIterator_h
20 
21 #include "itkImage.h"
22 #include "itkPath.h"
23 
24 namespace itk
25 {
74 template< class TImage, class TPath >
75 class ITK_EXPORT PathConstIterator
76 {
77 public:
78 
81 
86  itkStaticConstMacro(ImageIteratorDimension, unsigned int,
87  TImage::ImageDimension);
88 
90  typedef typename TImage::IndexType IndexType;
91 
93  typedef typename TImage::OffsetType OffsetType;
94 
96  typedef typename TImage::SizeType SizeType;
97 
99  typedef typename TImage::RegionType RegionType;
100 
102  typedef typename TImage::SpacingType SpacingType;
103 
105  typedef typename TImage::PointType PointType;
106 
108  typedef TImage ImageType;
109 
113  typedef typename TImage::PixelContainer PixelContainer;
114  typedef typename PixelContainer::Pointer PixelContainerPointer;
115 
117  typedef typename TImage::InternalPixelType InternalPixelType;
118 
120  typedef typename TImage::PixelType PixelType;
121 
124  typedef typename TImage::AccessorType AccessorType;
125 
127  typedef TPath PathType;
128 
130  typedef typename PathType::InputType PathInputType;
131 
133  typedef typename PathType::OutputType PathOutputType;
134 
136  itkTypeMacro(PathConstIterator, None);
137 
139  static unsigned int GetImageIteratorDimension()
140  {
141  return TImage::ImageDimension;
142  }
143 
145  const PathInputType GetPathPosition()
146  {
147  return m_CurrentPathPosition;
148  }
149 
151  const IndexType GetIndex()
152  {
153  return m_CurrentImageIndex;
154  }
155 
157  const PixelType & Get(void) const
158  {
159  return m_Image->GetPixel(m_CurrentImageIndex);
160  }
161 
165  bool IsAtEnd()
166  {
167  return m_IsAtEnd;
168  }
169 
174  inline virtual void VisitStartIndexAsLastIndexIfClosed(bool flag)
175  {
176  m_VisitStartIndexAsLastIndexIfClosed = flag;
177  }
178 
184  void GoToBegin();
185 
187  void operator++();
188 
191  Self & operator=(const Self & it);
192 
194  PathConstIterator(const ImageType *imagePtr, const PathType *pathPtr);
195 
197  virtual ~PathConstIterator() {}
198 
199 protected: //made protected so other iterators can access
200  // This "constant" is initialized in the constructor
201  OffsetType m_ZeroOffset; // = 0 for all dimensions
202 
204  typename ImageType::ConstWeakPointer m_Image;
205 
207  typename PathType::ConstPointer m_Path;
208 
211 
214 
217 
220 
226 
228  bool m_IsAtEnd;
229 
232 
235 };
236 } // end namespace itk
237 
238 #ifndef ITK_MANUAL_INSTANTIATION
239 #include "itkPathConstIterator.hxx"
240 #endif
241 
242 #endif
243