18 #ifndef __itkConstNeighborhoodIterator_h
19 #define __itkConstNeighborhoodIterator_h
49 template<
class TImage,
class TBoundaryCondition =
50 ZeroFluxNeumannBoundaryCondition< TImage > >
52 public Neighborhood< typename TImage::InternalPixelType *,
53 TImage::ImageDimension >
61 itkStaticConstMacro(Dimension,
unsigned int, TImage::ImageDimension);
74 typedef typename Superclass::SizeType
SizeType;
92 typedef typename ImageType::NeighborhoodAccessorFunctorType
116 const RegionType & region)
118 this->Initialize(radius, ptr, region);
119 for (
unsigned int i = 0; i < Dimension; i++ )
120 { m_InBounds[i] =
false; }
121 this->ResetBoundaryCondition();
122 m_NeighborhoodAccessorFunctor = ptr->GetNeighborhoodAccessor();
123 m_NeighborhoodAccessorFunctor.SetBegin( ptr->GetBufferPointer() );
128 Self & operator=(
const Self & orig);
131 virtual void PrintSelf(std::ostream &,
Indent)
const;
135 OffsetType ComputeInternalIndex(NeighborIndexType n)
const;
144 {
return m_Bound[n]; }
147 const InternalPixelType * GetCenterPointer()
const
148 {
return ( this->
operator[]( ( this->
Size() ) >> 1 ) ); }
153 {
return m_NeighborhoodAccessorFunctor.Get( this->GetCenterPointer() ); }
157 {
return m_ConstImage; }
166 virtual NeighborhoodType GetNeighborhood()
const;
171 if ( !m_NeedToUseBoundaryCondition )
173 return ( m_NeighborhoodAccessorFunctor.Get( this->operator[](i) ) );
176 return this->GetPixel(i, inbounds);
185 virtual PixelType GetPixel(NeighborIndexType i,
bool & IsInBounds)
const;
193 return ( this->GetPixel(this->GetNeighborhoodIndex(o), inbounds) );
202 bool & IsInBounds)
const
203 {
return ( this->
GetPixel(this->GetNeighborhoodIndex(o), IsInBounds) ); }
210 return ( this->GetPixel( this->GetCenterNeighborhoodIndex()
211 + ( i * this->GetStride(axis) ) ) );
219 return ( this->GetPixel( this->GetCenterNeighborhoodIndex()
220 + this->GetStride(axis) ) );
228 return ( this->GetPixel( this->GetCenterNeighborhoodIndex()
229 - ( i * this->GetStride(axis) ) ) );
235 virtual PixelType GetPrevious(
const unsigned axis)
const
237 return ( this->GetPixel( this->GetCenterNeighborhoodIndex()
238 - this->GetStride(axis) ) );
244 {
return ( this->
GetIndex() + o ); }
249 {
return ( this->
GetIndex() + this->GetOffset(i) ); }
252 RegionType GetRegion()
const
258 {
return m_BeginIndex; }
262 RegionType GetBoundingBoxAsImageRegion()
const;
266 {
return m_WrapOffset; }
274 {
return m_WrapOffset[n]; }
279 virtual void GoToBegin();
283 virtual void GoToEnd();
287 virtual void Initialize(
const SizeType & radius,
const ImageType *ptr,
288 const RegionType & region);
292 virtual bool IsAtBegin()
const
293 {
return ( this->GetCenterPointer() == m_Begin ); }
297 virtual bool IsAtEnd()
const
299 if ( this->GetCenterPointer() > m_End )
302 std::ostringstream msg;
303 msg <<
"In method IsAtEnd, CenterPointer = " << this->GetCenterPointer()
304 <<
" is greater than End = " << m_End
310 return ( this->GetCenterPointer() == m_End );
329 bool operator==(
const Self & it)
const
341 bool operator<(
const Self & it)
const
347 bool operator<=(
const Self & it)
const
353 bool operator>(
const Self & it)
const
359 bool operator>=(
const Self & it)
const
368 this->SetLoop(position);
369 this->SetPixelPointers(position);
376 Self & operator+=(
const OffsetType &);
381 Self & operator-=(
const OffsetType &);
385 {
return m_Loop - b.
m_Loop; }
390 bool InBounds()
const;
403 bool IndexInBounds(NeighborIndexType n, OffsetType & internalIndex, OffsetType & offset )
const;
410 virtual void OverrideBoundaryCondition(
const
412 { m_BoundaryCondition = i; }
416 virtual void ResetBoundaryCondition()
417 { m_BoundaryCondition = &m_InternalBoundaryCondition; }
420 void SetBoundaryCondition(
const TBoundaryCondition & c)
421 { m_InternalBoundaryCondition = c; }
425 {
return m_BoundaryCondition; }
428 void NeedToUseBoundaryConditionOn()
430 this->SetNeedToUseBoundaryCondition(
true);
433 void NeedToUseBoundaryConditionOff()
435 this->SetNeedToUseBoundaryCondition(
false);
438 void SetNeedToUseBoundaryCondition(
bool b)
440 m_NeedToUseBoundaryCondition = b;
443 bool GetNeedToUseBoundaryCondition()
const
445 return m_NeedToUseBoundaryCondition;
449 virtual void SetRegion(
const RegionType & region);
456 { m_Loop = p; m_IsInBoundsValid =
false; }
461 virtual void SetBound(
const SizeType &);
467 virtual void SetPixelPointers(
const IndexType &);
472 { m_BeginIndex = start; }
476 virtual void SetEndIndex();
519 mutable bool m_InBounds[Dimension];
545 template<
class TImage >
557 template<
class TImage >
558 inline ConstNeighborhoodIterator< TImage >
562 {
return ( it + ind ); }
564 template<
class TImage >
565 inline ConstNeighborhoodIterator< TImage >
577 #ifndef ITK_MANUAL_INSTANTIATION
578 #include "itkConstNeighborhoodIterator.hxx"