ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkPathConstIterator.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkPathConstIterator_h
00019 #define __itkPathConstIterator_h
00020 
00021 #include "itkImage.h"
00022 #include "itkPath.h"
00023 
00024 namespace itk
00025 {
00074 template< class TImage, class TPath >
00075 class ITK_EXPORT PathConstIterator
00076 {
00077 public:
00078 
00080   typedef PathConstIterator Self;
00081 
00086   itkStaticConstMacro(ImageIteratorDimension, unsigned int,
00087                       TImage::ImageDimension);
00088 
00090   typedef typename TImage::IndexType      IndexType;
00091 
00093   typedef typename TImage::OffsetType      OffsetType;
00094 
00096   typedef typename TImage::SizeType      SizeType;
00097 
00099   typedef typename TImage::RegionType RegionType;
00100 
00102   typedef typename TImage::SpacingType SpacingType;
00103 
00105   typedef typename TImage::PointType PointType;
00106 
00108   typedef TImage ImageType;
00109 
00113   typedef typename TImage::PixelContainer  PixelContainer;
00114   typedef typename PixelContainer::Pointer PixelContainerPointer;
00115 
00117   typedef typename TImage::InternalPixelType InternalPixelType;
00118 
00120   typedef typename TImage::PixelType PixelType;
00121 
00124   typedef typename TImage::AccessorType AccessorType;
00125 
00127   typedef TPath PathType;
00128 
00130   typedef typename PathType::InputType PathInputType;
00131 
00133   typedef typename PathType::OutputType PathOutputType;
00134 
00136   itkTypeMacro(PathConstIterator, None);
00137 
00139   static unsigned int GetImageIteratorDimension()
00140   {
00141     return TImage::ImageDimension;
00142   }
00143 
00145   const PathInputType GetPathPosition()
00146   {
00147     return m_CurrentPathPosition;
00148   }
00149 
00151   const IndexType GetIndex()
00152   {
00153     return m_CurrentImageIndex;
00154   }
00155 
00157   const PixelType & Get(void) const
00158   {
00159     return m_Image->GetPixel(m_CurrentImageIndex);
00160   }
00161 
00165   bool IsAtEnd()
00166   {
00167     return m_IsAtEnd;
00168   }
00169 
00174   inline virtual void VisitStartIndexAsLastIndexIfClosed(bool flag)
00175   {
00176     m_VisitStartIndexAsLastIndexIfClosed = flag;
00177   }
00178 
00184   void GoToBegin();
00185 
00187   void operator++();
00188 
00191   Self & operator=(const Self & it);
00192 
00194   PathConstIterator(const ImageType *imagePtr, const PathType  *pathPtr);
00195 
00197   virtual ~PathConstIterator() {}
00198 protected: //made protected so other iterators can access
00199   // This "constant" is initialized in the constructor
00200   OffsetType m_ZeroOffset;  // = 0 for all dimensions
00201 
00203   typename ImageType::ConstWeakPointer m_Image;
00204 
00206   typename PathType::ConstPointer m_Path;
00207 
00209   RegionType m_Region;
00210 
00212   PointType m_ImageOrigin;
00213 
00215   SpacingType m_ImageSpacing;
00216 
00218   const SizeValueType *m_ImageSize;
00219 
00224   bool m_VisitStartIndexAsLastIndexIfClosed;
00225 
00227   bool m_IsAtEnd;
00228 
00230   PathInputType m_CurrentPathPosition;
00231 
00233   IndexType m_CurrentImageIndex;
00234 };
00235 } // end namespace itk
00236 
00237 #ifndef ITK_MANUAL_INSTANTIATION
00238 #include "itkPathConstIterator.hxx"
00239 #endif
00240 
00241 #endif
00242