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

itkConstShapedNeighborhoodIterator.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkConstShapedNeighborhoodIterator.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:29:05 $ 00007 Version: $Revision: 1.7 $ 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 __itkConstShapedNeighborhoodIterator_h 00018 #define __itkConstShapedNeighborhoodIterator_h 00019 00020 #include <vector> 00021 #include <list> 00022 #include "itkNeighborhoodIterator.h" 00023 00024 namespace itk { 00025 00040 template<class TImage, class TBoundaryCondition 00041 = ZeroFluxNeumannBoundaryCondition<TImage> > 00042 class ITK_EXPORT ConstShapedNeighborhoodIterator 00043 : private NeighborhoodIterator<TImage, TBoundaryCondition> 00044 { 00045 public: 00047 typedef typename TImage::InternalPixelType InternalPixelType; 00048 typedef typename TImage::PixelType PixelType; 00049 00051 itkStaticConstMacro(Dimension, unsigned int, TImage::ImageDimension); 00052 00054 typedef ConstShapedNeighborhoodIterator Self; 00055 typedef NeighborhoodIterator<TImage, TBoundaryCondition> Superclass; 00056 00058 typedef typename Superclass::OffsetType OffsetType; 00059 typedef typename OffsetType::OffsetValueType OffsetValueType; 00060 typedef typename Superclass::RadiusType RadiusType; 00061 typedef typename Superclass::SizeType SizeType; 00062 typedef typename Superclass::SizeValueType SizeValueType; 00063 00065 typedef TImage ImageType; 00066 typedef typename TImage::RegionType RegionType; 00067 typedef Index<itkGetStaticConstMacro(Dimension)> IndexType; 00068 typedef typename IndexType::IndexValueType IndexValueType; 00069 typedef Neighborhood<PixelType, itkGetStaticConstMacro(Dimension)> NeighborhoodType; 00070 00073 typedef std::list<unsigned int> IndexListType; 00074 00076 typedef TBoundaryCondition BoundaryConditionType; 00077 00079 typedef ImageBoundaryCondition<ImageType> *ImageBoundaryConditionPointerType; 00080 00082 struct ConstIterator 00083 { 00084 ConstIterator() { m_NeighborhoodIterator = 0; } 00085 ConstIterator(Self *s) 00086 { 00087 m_NeighborhoodIterator = s; 00088 this->GoToBegin(); 00089 } 00090 ~ConstIterator() {} 00091 const ConstIterator &operator=(const ConstIterator &o) 00092 { 00093 m_NeighborhoodIterator = o.m_NeighborhoodIterator; 00094 m_ListIterator = o.m_ListIterator; 00095 return *this; 00096 } 00097 00098 ConstIterator(const ConstIterator &o) 00099 { 00100 m_NeighborhoodIterator = o.m_NeighborhoodIterator; 00101 m_ListIterator = o.m_ListIterator; 00102 } 00103 00104 void operator++(int) 00105 { m_ListIterator++; } 00106 00107 void operator--(int) 00108 { m_ListIterator--; } 00109 00110 const ConstIterator &operator++() 00111 { 00112 m_ListIterator++; 00113 return *this; 00114 } 00115 const ConstIterator &operator--() 00116 { 00117 m_ListIterator--; 00118 return *this; 00119 } 00120 00121 bool operator!=(const ConstIterator &o) const 00122 { return m_ListIterator.operator!=(o.m_ListIterator); } 00123 bool operator==(const ConstIterator &o) const 00124 { return m_ListIterator.operator==(o.m_ListIterator); } 00125 00126 bool IsAtEnd() const 00127 { 00128 if (m_ListIterator == m_NeighborhoodIterator->GetActiveIndexList().end()) 00129 { return true; } 00130 else { return false; } 00131 } 00132 00133 void GoToBegin() 00134 { 00135 m_ListIterator = m_NeighborhoodIterator->GetActiveIndexList().begin(); 00136 } 00137 00138 void GoToEnd() 00139 { 00140 m_ListIterator = m_NeighborhoodIterator->GetActiveIndexList().end(); 00141 } 00142 00143 PixelType Get() const 00144 { return m_NeighborhoodIterator->GetPixel(*m_ListIterator); } 00145 00146 OffsetType GetNeighborhoodOffset() const 00147 { return m_NeighborhoodIterator->GetOffset(*m_ListIterator); } 00148 00149 typename IndexListType::value_type GetNeighborhoodIndex() const 00150 { return *m_ListIterator; } 00151 00152 protected: 00153 Self *m_NeighborhoodIterator; 00154 typename IndexListType::const_iterator m_ListIterator; 00155 00156 void ProtectedSet(const PixelType &v) const 00157 { m_NeighborhoodIterator->SetPixel(*m_ListIterator, v); } 00158 }; 00159 00162 const ConstIterator &Begin() const 00163 { return m_ConstBeginIterator; } 00164 00167 const ConstIterator &End() const 00168 { return m_ConstEndIterator; } 00169 00171 ConstShapedNeighborhoodIterator() 00172 { 00173 m_ConstBeginIterator = ConstIterator(this); 00174 m_ConstEndIterator = ConstIterator(this); 00175 m_ConstEndIterator.GoToEnd(); 00176 m_CenterIsActive = false; 00177 } 00178 00180 virtual ~ConstShapedNeighborhoodIterator() { } 00181 00184 ConstShapedNeighborhoodIterator(const SizeType &radius, 00185 const ImageType * ptr, 00186 const RegionType &region 00187 ) : Superclass (radius, const_cast<ImageType*>(ptr), 00188 region) 00189 { 00190 m_ConstBeginIterator = ConstIterator(this); 00191 m_ConstEndIterator = ConstIterator(this); 00192 m_ConstEndIterator.GoToEnd(); 00193 m_CenterIsActive = false; 00194 } 00195 00196 // Expose the following methods from the superclass. This is a restricted 00197 // subset of the methods available for ConstNeighborhoodIterator. 00198 Superclass::GetImagePointer; 00199 Superclass::GetRadius; 00200 Superclass::GetIndex; 00201 Superclass::GetNeighborhoodIndex; 00202 Superclass::GetRegion; 00203 Superclass::GetBeginIndex; 00204 Superclass::GoToBegin; 00205 Superclass::GoToEnd; 00206 Superclass::IsAtBegin; 00207 Superclass::IsAtEnd; 00208 Superclass::GetOffset; 00209 Superclass::operator==; 00210 Superclass::operator!=; 00211 Superclass::operator<; 00212 Superclass::operator>; 00213 Superclass::operator>=; 00214 Superclass::operator<=; 00215 Superclass::operator[]; 00216 Superclass::GetElement; 00217 Superclass::SetLocation; 00218 Superclass::OverrideBoundaryCondition; 00219 Superclass::ResetBoundaryCondition; 00220 Superclass::GetBoundaryCondition; 00221 Superclass::Print; 00222 00223 Superclass::operator-; 00224 00225 Superclass::GetPixel; 00226 00228 Self &operator=(const Self& orig) 00229 { 00230 Superclass::operator=(orig); 00231 m_ActiveIndexList = orig.m_ActiveIndexList; 00232 m_CenterIsActive = orig.m_CenterIsActive; 00233 00234 // Reset begin and end pointers 00235 m_ConstBeginIterator.GoToBegin(); 00236 m_ConstEndIterator.GoToBegin(); 00237 return *this; 00238 } 00239 00241 virtual void PrintSelf(std::ostream &, Indent) const; 00242 00246 virtual void ActivateOffset(const OffsetType& off) 00247 { this->ActivateIndex( Superclass::GetNeighborhoodIndex(off) ); } 00248 virtual void DeactivateOffset(const OffsetType& off) 00249 { this->DeactivateIndex( Superclass::GetNeighborhoodIndex(off) ); } 00250 00252 virtual void ClearActiveList() 00253 { 00254 m_ActiveIndexList.clear(); 00255 m_ConstBeginIterator.GoToBegin(); 00256 m_ConstEndIterator.GoToEnd(); 00257 m_CenterIsActive = false; 00258 } 00259 00261 const IndexListType &GetActiveIndexList() const 00262 { return m_ActiveIndexList; } 00263 00265 typename IndexListType::size_type GetActiveIndexListSize() const 00266 { return m_ActiveIndexList.size(); } 00267 00270 Self &operator++(); 00271 00274 Self &operator--(); 00275 00279 Self &operator+=(const OffsetType &); 00280 00284 Self &operator-=(const OffsetType &); 00285 00286 // Should be protected, but Borland compiler will not allow it. A workaround 00287 // must be found. 00288 Superclass::SetPixel; 00289 protected: 00291 ConstShapedNeighborhoodIterator( const ConstShapedNeighborhoodIterator & ); 00292 // purposely not implemented 00293 00294 friend struct ConstIterator; 00295 00298 // Superclass::SetPixel; 00299 00305 virtual void ActivateIndex(const unsigned int); 00306 virtual void DeactivateIndex(const unsigned int); 00307 00308 bool m_CenterIsActive; 00309 IndexListType m_ActiveIndexList; 00310 ConstIterator m_ConstEndIterator; 00311 ConstIterator m_ConstBeginIterator; 00312 }; 00313 00314 00315 } // namespace itk 00316 00317 00318 #ifndef ITK_MANUAL_INSTANTIATION 00319 #include "itkConstShapedNeighborhoodIterator.txx" 00320 #endif 00321 00322 #endif 00323

Generated at Sat Mar 31 02:16:18 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000