00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
00115 template<class TImage, class TBoundaryCondition
00116 = ZeroFluxNeumannBoundaryCondition<TImage> >
00117 class ITK_EXPORT ShapedNeighborhoodIterator
00118 : public ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>
00119 {
00120 public:
00122 typedef typename TImage::InternalPixelType InternalPixelType;
00123 typedef typename TImage::PixelType PixelType;
00124
00126 itkStaticConstMacro(Dimension, unsigned int, TImage::ImageDimension);
00127
00129 typedef ShapedNeighborhoodIterator Self;
00130 typedef ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition> Superclass;
00131
00133 typedef typename Superclass::OffsetType OffsetType;
00134 typedef typename OffsetType::OffsetValueType OffsetValueType;
00135 typedef typename Superclass::RadiusType RadiusType;
00136 typedef typename Superclass::SizeType SizeType;
00137 typedef typename Superclass::SizeValueType SizeValueType;
00138 typedef typename Superclass::ConstIterator ConstIterator;
00139 typedef typename Superclass::IndexListType IndexListType;
00140 typedef typename Superclass::BoundaryConditionType BoundaryConditionType;
00141 typedef typename Superclass::ImageBoundaryConditionPointerType
00142 ImageBoundaryConditionPointerType;
00143
00145 typedef TImage ImageType;
00146 typedef typename TImage::RegionType RegionType;
00147 typedef Index<itkGetStaticConstMacro(Dimension)> IndexType;
00148 typedef typename IndexType::IndexValueType IndexValueType;
00149 typedef Neighborhood<PixelType, itkGetStaticConstMacro(Dimension)> NeighborhoodType;
00150
00152 struct Iterator : public ConstIterator
00153 {
00154 Iterator() {}
00155 Iterator(Self *s) : ConstIterator(s) {}
00156
00157 ~Iterator() {}
00158 const Iterator &operator=(const Iterator &o)
00159 {
00160 ConstIterator::operator=(o);
00161 return *this;
00162 }
00163
00164
00165 void Set(const PixelType &v) const
00166 { ConstIterator::ProtectedSet(v); }
00167
00168 };
00169
00171 ShapedNeighborhoodIterator();
00172
00174 virtual ~ShapedNeighborhoodIterator() {}
00175
00177 ShapedNeighborhoodIterator( const ShapedNeighborhoodIterator & );
00178
00181 ShapedNeighborhoodIterator(const SizeType &radius,
00182 const ImageType * ptr,
00183 const RegionType ®ion
00184 ) : Superclass (radius, const_cast<ImageType*>(ptr),
00185 region)
00186 {
00187 m_BeginIterator = Iterator(this);
00188 m_EndIterator = Iterator(this);
00189 m_EndIterator.GoToEnd();
00190 }
00191
00192
00193
00194 Superclass::SetPixel;
00195
00197 Self &operator=(const Self& orig)
00198 { return Superclass::operator=(orig); }
00199
00201 virtual void PrintSelf(std::ostream &, Indent) const;
00202
00205 Iterator &Begin() { return m_BeginIterator; }
00206 Iterator &End() { return m_EndIterator; }
00207
00210 const ConstIterator &End() const
00211 { return m_ConstEndIterator; }
00212
00213 void ClearActiveList()
00214 {
00215 Superclass::ClearActiveList();
00216 m_EndIterator.GoToEnd();
00217 m_BeginIterator.GoToBegin();
00218 }
00219
00220 protected:
00221 void ActivateIndex(const unsigned int n)
00222 {
00223 Superclass::ActivateIndex(n);
00224 m_EndIterator.GoToEnd();
00225 m_BeginIterator.GoToBegin();
00226 }
00227
00228 void DeactivateIndex(const unsigned int n)
00229 {
00230 Superclass::DeactivateIndex(n);
00231 m_EndIterator.GoToEnd();
00232 m_BeginIterator.GoToBegin();
00233 }
00234
00235
00236 Iterator m_EndIterator;
00237 Iterator m_BeginIterator;
00238 };
00239
00240 }
00241
00242
00243 #ifndef ITK_MANUAL_INSTANTIATION
00244 #include "itkShapedNeighborhoodIterator.txx"
00245 #endif
00246
00247 #endif
00248