ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkConditionalConstIterator.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 __itkConditionalConstIterator_h
00019 #define __itkConditionalConstIterator_h
00020 
00021 #include "itkIndex.h"
00022 
00023 namespace itk
00024 {
00037 template< class TImage >
00038 class ConditionalConstIterator
00039 {
00040 public:
00042   typedef ConditionalConstIterator Self;
00043 
00048   itkStaticConstMacro(NDimension, unsigned int, TImage::ImageDimension);
00049 
00051   typedef typename TImage::IndexType IndexType;
00052 
00054   typedef typename TImage::SizeType SizeType;
00055 
00057   typedef typename TImage::RegionType RegionType;
00058 
00060   typedef TImage ImageType;
00061 
00063   typedef typename TImage::InternalPixelType InternalPixelType;
00064 
00066   typedef typename TImage::PixelType PixelType;
00067 
00069   virtual bool IsPixelIncluded(const IndexType & index) const = 0;
00070 
00073   Self & operator=(const Self & it)
00074   {
00075     m_IsAtEnd = it.m_IsAtEnd; // copy the end flag
00076     m_Image = it.m_Image;     // copy the smart pointer
00077     m_Region = it.m_Region;   // copy the region
00078     return *this;
00079   }
00080 
00082   static unsigned int GetIteratorDimension(void)
00083   {
00084     return Self::NDimension;
00085   }
00086 
00088   virtual const IndexType GetIndex() = 0;
00089 
00091   virtual const PixelType & Get(void) const = 0;
00092 
00094   virtual bool IsAtEnd() = 0;
00095 
00097   virtual void operator++() = 0;
00098 
00100   ConditionalConstIterator();
00101 
00103   virtual ~ConditionalConstIterator();
00104 protected: //made protected so other iterators can access
00105 
00107   //SmartPointer<const ImageType> m_Image;
00108   typename ImageType::ConstWeakPointer m_Image;
00109 
00111   RegionType m_Region;
00112 
00114   bool m_IsAtEnd;
00115 };
00116 } // end namespace itk
00117 
00118 // Define instantiation macro for this template.
00119 #define ITK_TEMPLATE_ConditionalConstIterator(_, EXPORT, TypeX, TypeY)     \
00120   namespace itk                                                            \
00121   {                                                                        \
00122   _( 1 ( class EXPORT ConditionalConstIterator< ITK_TEMPLATE_1 TypeX > ) ) \
00123   namespace Templates                                                      \
00124   {                                                                        \
00125   typedef ConditionalConstIterator< ITK_TEMPLATE_1 TypeX >                 \
00126   ConditionalConstIterator##TypeY;                                       \
00127   }                                                                        \
00128   }
00129 
00130 #if ITK_TEMPLATE_EXPLICIT
00131 //HACK attempt to make static const unsigned ints work  template<class TImage>
00132 // const unsigned int ConditionalConstIterator<TImage>::ImageDimension;
00133 #include "Templates/itkConditionalConstIterator+-.h"
00134 #endif
00135 
00136 #if ITK_TEMPLATE_TXX
00137 #include "itkConditionalConstIterator.hxx"
00138 #endif
00139 
00140 #endif
00141