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;
453 { m_Loop = p; m_IsInBoundsValid =
false; }
458 virtual void SetBound(
const SizeType &);
464 virtual void SetPixelPointers(
const IndexType &);
469 { m_BeginIndex = start; }
473 virtual void SetEndIndex();
516 mutable bool m_InBounds[Dimension];
542 template<
class TImage >
554 template<
class TImage >
555 inline ConstNeighborhoodIterator< TImage >
559 {
return ( it + ind ); }
561 template<
class TImage >
562 inline ConstNeighborhoodIterator< TImage >
575 #define ITK_TEMPLATE_ConstNeighborhoodIterator(_, EXPORT, TypeX, TypeY) \
578 _( 2 ( class EXPORT ConstNeighborhoodIterator< ITK_TEMPLATE_2 TypeX > ) ) \
579 namespace Templates \
581 typedef ConstNeighborhoodIterator< ITK_TEMPLATE_2 TypeX > \
582 ConstNeighborhoodIterator##TypeY; \
586 #if ITK_TEMPLATE_EXPLICIT
587 #include "Templates/itkConstNeighborhoodIterator+-.h"
591 #include "itkConstNeighborhoodIterator.hxx"