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 {
00173 m_BeginIterator =
Iterator(
this);
00174 m_EndIterator =
Iterator(
this);
00175 m_EndIterator.GoToEnd();
00176 }
00177
00179
virtual ~ShapedNeighborhoodIterator() {}
00180
00183 ShapedNeighborhoodIterator(
const SizeType &radius,
00184
const ImageType * ptr,
00185
const RegionType ®ion
00186 ) :
Superclass(radius, const_cast<
ImageType*>(ptr),
00187 region)
00188 {
00189 m_BeginIterator =
Iterator(
this);
00190 m_EndIterator = Iterator(
this);
00191 m_EndIterator.GoToEnd();
00192 }
00193
00194
00195
00196 Superclass::SetPixel;
00197
00199 Self &operator=(
const Self& orig)
00200 {
00201 Superclass::operator=(orig);
00202
00203
00204 m_BeginIterator.GoToBegin();
00205 m_EndIterator.GoToEnd();
00206
return *
this;
00207 }
00208
00210
virtual void PrintSelf(std::ostream &,
Indent) const;
00211
00214 Iterator &Begin() {
return m_BeginIterator; }
00215 Iterator &End() {
return m_EndIterator; }
00216
00219 const ConstIterator &End()
const
00220
{
return m_ConstEndIterator; }
00221
00222
void ClearActiveList()
00223 {
00224 Superclass::ClearActiveList();
00225 m_EndIterator.GoToEnd();
00226 m_BeginIterator.GoToBegin();
00227 }
00228
00229
protected:
00230
00232 ShapedNeighborhoodIterator(
const ShapedNeighborhoodIterator & o);
00233
00234
00235
00236
void ActivateIndex(
const unsigned int n)
00237 {
00238 Superclass::ActivateIndex(n);
00239 m_EndIterator.GoToEnd();
00240 m_BeginIterator.GoToBegin();
00241 }
00242
00243
void DeactivateIndex(
const unsigned int n)
00244 {
00245 Superclass::DeactivateIndex(n);
00246 m_EndIterator.GoToEnd();
00247 m_BeginIterator.GoToBegin();
00248 }
00249
00250
00251 Iterator m_EndIterator;
00252 Iterator m_BeginIterator;
00253 };
00254
00255 }
00256
00257
00258
#ifndef ITK_MANUAL_INSTANTIATION
00259
#include "itkShapedNeighborhoodIterator.txx"
00260
#endif
00261
00262
#endif
00263