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/06/01 12:58:02 $
00007   Version:   $Revision: 1.9 $
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) {}
00180 
00181     ~Iterator() {}
00182     const Iterator &operator=(const Iterator &o)
00183     {
00184       ConstIterator::operator=(o);
00185       return *this;
00186     }
00187 
00188     // Promote to public
00189     void Set(const PixelType &v) const
00190     { ConstIterator::ProtectedSet(v); }
00191 
00192   };
00193 
00195   ShapedNeighborhoodIterator()
00196   {
00197     m_BeginIterator = Iterator(this);
00198     m_EndIterator = Iterator(this);
00199     m_EndIterator.GoToEnd();
00200   }
00201 
00203   virtual ~ShapedNeighborhoodIterator() {}
00204 
00207   ShapedNeighborhoodIterator(const SizeType &radius,
00208                              const ImageType * ptr,
00209                              const RegionType &region
00210     ) : Superclass(radius, const_cast<ImageType*>(ptr),
00211                    region)
00212   {
00213     m_BeginIterator = Iterator(this);
00214     m_EndIterator = Iterator(this);
00215     m_EndIterator.GoToEnd();
00216   }
00217 
00218   // Expose the following methods from the superclass.  This is a restricted
00219   // subset of the methods available for ConstNeighborhoodIterator.
00220   Superclass::SetPixel;
00221 
00223   Self &operator=(const Self& orig)
00224   {
00225     Superclass::operator=(orig);
00226 
00227     // Reset begin and end pointer locations
00228     m_BeginIterator.GoToBegin();
00229     m_EndIterator.GoToEnd();
00230     return *this;
00231   }
00232 
00234   virtual void PrintSelf(std::ostream &, Indent) const;
00235 
00238   Iterator &Begin() {    return m_BeginIterator;  }
00239   Iterator &End()   {   return m_EndIterator;     }
00240 
00243   const ConstIterator &End() const
00244   {    return this->m_ConstEndIterator;  }
00245 
00246   void ClearActiveList()
00247   {
00248     Superclass::ClearActiveList();
00249     m_EndIterator.GoToEnd();
00250     m_BeginIterator.GoToBegin();
00251   }
00252 
00253 protected:
00254 
00256   ShapedNeighborhoodIterator( const ShapedNeighborhoodIterator & o);
00257   // purposely not implemented
00258 
00259 
00260   void ActivateIndex(const unsigned int n)
00261   {
00262     Superclass::ActivateIndex(n);
00263     m_EndIterator.GoToEnd();
00264     m_BeginIterator.GoToBegin();
00265   }
00266 
00267   void DeactivateIndex(const unsigned int n)
00268   {
00269     Superclass::DeactivateIndex(n);
00270     m_EndIterator.GoToEnd();
00271     m_BeginIterator.GoToBegin();
00272   }
00273 
00274 
00275   Iterator m_EndIterator;
00276   Iterator m_BeginIterator;
00277 };
00278 
00279 } // namespace itk
00280 
00281 
00282 #ifndef ITK_MANUAL_INSTANTIATION
00283 #include "itkShapedNeighborhoodIterator.txx"
00284 #endif
00285 
00286 #endif
00287 

Generated at Tue Aug 30 16:46:16 2005 for ITK by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2000