00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkConditionalConstIterator.h,v $ 00005 Language: C++ 00006 Date: $Date: 2007/01/30 20:56:07 $ 00007 Version: $Revision: 1.10 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkConditionalConstIterator_h 00018 #define __itkConditionalConstIterator_h 00019 00020 #include "itkIndex.h" 00021 00022 namespace itk 00023 { 00024 00037 template<class TImage> 00038 class ConditionalConstIterator { 00039 public: 00041 typedef ConditionalConstIterator Self; 00042 00047 itkStaticConstMacro(NDimension, unsigned int, TImage::ImageDimension); 00048 00050 typedef typename TImage::IndexType IndexType; 00051 00053 typedef typename TImage::SizeType SizeType; 00054 00056 typedef typename TImage::RegionType RegionType; 00057 00059 typedef TImage ImageType; 00060 00062 typedef typename TImage::InternalPixelType InternalPixelType; 00063 00065 typedef typename TImage::PixelType PixelType; 00066 00068 virtual bool IsPixelIncluded(const IndexType & index) const = 0; 00069 00072 Self &operator=(const Self& it) 00073 { 00074 m_Image = it.m_Image; // copy the smart pointer 00075 m_Region = it.m_Region; // copy the region 00076 return *this; 00077 } 00078 00080 static unsigned int GetIteratorDimension() 00081 {return TImage::ImageDimension;} 00082 00084 virtual const IndexType GetIndex() = 0; 00085 00087 virtual const PixelType & Get(void) const = 0; 00088 00090 virtual bool IsAtEnd() = 0; 00091 00093 virtual void operator++() = 0; 00094 00096 ConditionalConstIterator(); 00097 00099 virtual ~ConditionalConstIterator(); 00100 00101 protected: //made protected so other iterators can access 00103 //SmartPointer<const ImageType> m_Image; 00104 typename ImageType::ConstWeakPointer m_Image; 00105 00107 RegionType m_Region; 00108 00110 bool m_IsAtEnd; 00111 }; 00112 00113 } // end namespace itk 00114 00115 // Define instantiation macro for this template. 00116 #define ITK_TEMPLATE_ConditionalConstIterator(_, EXPORT, x, y) namespace itk { \ 00117 _(1(class EXPORT ConditionalConstIterator< ITK_TEMPLATE_1 x >)) \ 00118 namespace Templates { typedef ConditionalConstIterator< ITK_TEMPLATE_1 x > \ 00119 ConditionalConstIterator##y; } \ 00120 } 00121 00122 #if ITK_TEMPLATE_EXPLICIT 00123 # include "Templates/itkConditionalConstIterator+-.h" 00124 #endif 00125 00126 #if ITK_TEMPLATE_TXX 00127 # include "itkConditionalConstIterator.txx" 00128 #endif 00129 00130 #endif 00131