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
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
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 ®ion
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
00219
00220 Superclass::SetPixel;
00221 Superclass::SetCenterPixel;
00222
00224 Self &operator=(const Self& orig)
00225 {
00226 Superclass::operator=(orig);
00227
00228
00229 m_BeginIterator.GoToBegin();
00230 m_EndIterator.GoToEnd();
00231 return *this;
00232 }
00233
00235 virtual void PrintSelf(std::ostream &, Indent) const;
00236
00239 Iterator &Begin() { return m_BeginIterator; }
00240 Iterator &End() { return m_EndIterator; }
00241
00244 const ConstIterator &End() const
00245 { return this->m_ConstEndIterator; }
00246
00247 void ClearActiveList()
00248 {
00249 Superclass::ClearActiveList();
00250 m_EndIterator.GoToEnd();
00251 m_BeginIterator.GoToBegin();
00252 }
00253
00254 protected:
00255
00257 ShapedNeighborhoodIterator( const ShapedNeighborhoodIterator & o);
00258
00259
00260
00261 void ActivateIndex(const unsigned int n)
00262 {
00263 Superclass::ActivateIndex(n);
00264 m_EndIterator.GoToEnd();
00265 m_BeginIterator.GoToBegin();
00266 }
00267
00268 void DeactivateIndex(const unsigned int n)
00269 {
00270 Superclass::DeactivateIndex(n);
00271 m_EndIterator.GoToEnd();
00272 m_BeginIterator.GoToBegin();
00273 }
00274
00275
00276 Iterator m_EndIterator;
00277 Iterator m_BeginIterator;
00278 };
00279
00280 }
00281
00282
00283 #ifndef ITK_MANUAL_INSTANTIATION
00284 #include "itkShapedNeighborhoodIterator.txx"
00285 #endif
00286
00287 #endif
00288