Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkShapedNeighborhoodIterator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkShapedNeighborhoodIterator.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005-10-20 13:25:26 $
00007   Version:   $Revision: 1.12 $
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 __itkShapedNeighborhoodIterator_h
00018 #define __itkShapedNeighborhoodIterator_h
00019 
00020 #include <vector>
00021 #include <list>
00022 #include "itkConstShapedNeighborhoodIterator.h"
00023 
00024 namespace itk {
00025 
00142 template<class TImage,  class TBoundaryCondition
00143                        = ZeroFluxNeumannBoundaryCondition<TImage> >
00144 class ITK_EXPORT ShapedNeighborhoodIterator
00145   :  public ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>
00146 {
00147 public:
00149   typedef typename TImage::InternalPixelType InternalPixelType;
00150   typedef typename TImage::PixelType PixelType;
00151 
00153   itkStaticConstMacro(Dimension, unsigned int, TImage::ImageDimension);
00154 
00156   typedef ShapedNeighborhoodIterator Self;
00157   typedef ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition> Superclass;
00158 
00160   typedef typename Superclass::OffsetType OffsetType;
00161   typedef typename OffsetType::OffsetValueType OffsetValueType;
00162   typedef typename Superclass::RadiusType RadiusType;
00163   typedef typename Superclass::SizeType SizeType;
00164   typedef typename Superclass::SizeValueType SizeValueType;
00165   typedef typename Superclass::ConstIterator ConstIterator;
00166   typedef typename Superclass::IndexListType  IndexListType;
00167   typedef typename Superclass::BoundaryConditionType BoundaryConditionType;
00168   typedef typename Superclass::ImageBoundaryConditionPointerType ImageBoundaryConditionPointerType;
00169   typedef typename Superclass::NeighborhoodType NeighborhoodType;
00170   typedef typename Superclass::IndexType IndexType;
00171   typedef typename Superclass::ImageType ImageType;
00172   typedef typename Superclass::RegionType RegionType;
00173   typedef typename Superclass::IndexValueType IndexValueType;
00174 
00176   struct Iterator : public ConstIterator
00177   {
00178     Iterator() {}
00179     Iterator(Self *s) : ConstIterator(s) {}
00181 
00182     ~Iterator() {}
00183     const Iterator &operator=(const Iterator &o)
00184     {
00185       ConstIterator::operator=(o);
00186       return *this;
00187     }
00188 
00189     // Promote to public
00190     void Set(const PixelType &v) const
00191     { ConstIterator::ProtectedSet(v); }
00192 
00193   };
00194 
00196   ShapedNeighborhoodIterator()
00197   {
00198     m_BeginIterator = Iterator(this);
00199     m_EndIterator = Iterator(this);
00200     m_EndIterator.GoToEnd();
00201   }
00203 
00205   virtual ~ShapedNeighborhoodIterator() {}
00206 
00209   ShapedNeighborhoodIterator(const SizeType &radius,
00210                              const ImageType * ptr,
00211                              const RegionType &region
00212     ) : Superclass(radius, const_cast<ImageType*>(ptr),
00213                    region)
00214   {
00215     m_BeginIterator = Iterator(this);
00216     m_EndIterator = Iterator(this);
00217     m_EndIterator.GoToEnd();
00218   }
00220 
00221   // Expose the following methods from the superclass.  This is a restricted
00222   // subset of the methods available for NeighborhoodIterator.
00223   Superclass::SetPixel;
00224   Superclass::SetCenterPixel;
00225 
00227   Self &operator=(const Self& orig)
00228   {
00229     Superclass::operator=(orig);
00230 
00231     // Reset begin and end pointer locations
00232     m_BeginIterator.GoToBegin();
00233     m_EndIterator.GoToEnd();
00234     return *this;
00235   }
00236 
00238   virtual void PrintSelf(std::ostream &, Indent) const;
00239 
00242   Iterator &Begin() {    return m_BeginIterator;  }
00243   Iterator &End()   {   return m_EndIterator;     }
00245 
00248   const ConstIterator &End() const
00249   {    return this->m_ConstEndIterator;  }
00250 
00251   void ClearActiveList()
00252   {
00253     Superclass::ClearActiveList();
00254     m_EndIterator.GoToEnd();
00255     m_BeginIterator.GoToBegin();
00256   }
00257 
00258 protected:
00259 
00261   ShapedNeighborhoodIterator( const ShapedNeighborhoodIterator & o);
00262   // purposely not implemented
00263 
00264 
00265   void ActivateIndex(const unsigned int n)
00266   {
00267     Superclass::ActivateIndex(n);
00268     m_EndIterator.GoToEnd();
00269     m_BeginIterator.GoToBegin();
00270   }
00271 
00272   void DeactivateIndex(const unsigned int n)
00273   {
00274     Superclass::DeactivateIndex(n);
00275     m_EndIterator.GoToEnd();
00276     m_BeginIterator.GoToBegin();
00277   }
00278 
00279 
00280   Iterator m_EndIterator;
00281   Iterator m_BeginIterator;
00282 };
00283 
00284 } // namespace itk
00285 
00286 
00287 #ifndef ITK_MANUAL_INSTANTIATION
00288 #include "itkShapedNeighborhoodIterator.txx"
00289 #endif
00290 
00291 #endif
00292 
00293 

Generated at Sat Feb 28 13:32:15 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000