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: 2004/12/11 20:29:19 $
00007   Version:   $Revision: 1.8 $
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
00169   ImageBoundaryConditionPointerType;
00170   
00172   typedef TImage ImageType;
00173   typedef typename TImage::RegionType RegionType;
00174   typedef Index<itkGetStaticConstMacro(Dimension)> IndexType;
00175   typedef typename IndexType::IndexValueType IndexValueType;
00176   typedef Neighborhood<PixelType, itkGetStaticConstMacro(Dimension)> NeighborhoodType;
00177 
00179   struct Iterator : public ConstIterator
00180   {
00181     Iterator() {}
00182     Iterator(Self *s) : ConstIterator(s) {}
00183 
00184     ~Iterator() {}
00185     const Iterator &operator=(const Iterator &o)
00186     {
00187       ConstIterator::operator=(o);
00188       return *this;
00189     }
00190     
00191     // Promote to public
00192     void Set(const PixelType &v) const
00193     { ConstIterator::ProtectedSet(v); }
00194 
00195   };
00196   
00198   ShapedNeighborhoodIterator()
00199   {
00200     m_BeginIterator = Iterator(this);
00201     m_EndIterator = Iterator(this);
00202     m_EndIterator.GoToEnd();
00203   }
00204   
00206   virtual ~ShapedNeighborhoodIterator() {}
00207 
00210   ShapedNeighborhoodIterator(const SizeType &radius,
00211                              const ImageType * ptr,
00212                              const RegionType &region
00213     ) : Superclass(radius, const_cast<ImageType*>(ptr),
00214                    region)
00215   {
00216     m_BeginIterator = Iterator(this);
00217     m_EndIterator = Iterator(this);
00218     m_EndIterator.GoToEnd();
00219   }
00220   
00221   // Expose the following methods from the superclass.  This is a restricted
00222   // subset of the methods available for ConstNeighborhoodIterator.
00223   Superclass::SetPixel;
00224   
00226   Self &operator=(const Self& orig)
00227   {
00228     Superclass::operator=(orig);
00229 
00230     // Reset begin and end pointer locations
00231     m_BeginIterator.GoToBegin();
00232     m_EndIterator.GoToEnd();
00233     return *this;
00234   }
00235 
00237   virtual void PrintSelf(std::ostream &, Indent) const;
00238 
00241   Iterator &Begin() {    return m_BeginIterator;  }
00242   Iterator &End()   {   return m_EndIterator;     }
00243 
00246   const ConstIterator &End() const
00247   {    return this->m_ConstEndIterator;  }
00248 
00249   void ClearActiveList()
00250   {
00251     Superclass::ClearActiveList();
00252     m_EndIterator.GoToEnd();
00253     m_BeginIterator.GoToBegin();
00254   }
00255   
00256 protected:
00257 
00259   ShapedNeighborhoodIterator( const ShapedNeighborhoodIterator & o);
00260   // purposely not implemented
00261 
00262 
00263   void ActivateIndex(const unsigned int n)
00264   {
00265     Superclass::ActivateIndex(n);
00266     m_EndIterator.GoToEnd();
00267     m_BeginIterator.GoToBegin();
00268   }
00269 
00270   void DeactivateIndex(const unsigned int n)
00271   {
00272     Superclass::DeactivateIndex(n);
00273     m_EndIterator.GoToEnd();
00274     m_BeginIterator.GoToBegin();
00275   }
00276 
00277   
00278   Iterator m_EndIterator;
00279   Iterator m_BeginIterator;
00280 };
00281 
00282 } // namespace itk
00283 
00284 
00285 #ifndef ITK_MANUAL_INSTANTIATION
00286 #include "itkShapedNeighborhoodIterator.txx"
00287 #endif
00288 
00289 #endif
00290 

Generated at Wed Mar 30 00:10:35 2005 for ITK by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2000