18 #ifndef itkConstNeighborhoodIterator_h
19 #define itkConstNeighborhoodIterator_h
50 template <
typename TImage,
typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
52 :
public Neighborhood<typename TImage::InternalPixelType *, TImage::ImageDimension>
56 using InternalPixelType =
typename TImage::InternalPixelType;
60 using DimensionValueType =
unsigned int;
63 static constexpr DimensionValueType
Dimension = TImage::ImageDimension;
113 this->Initialize(radius, ptr, region);
114 for (DimensionValueType i = 0; i <
Dimension; i++)
116 m_InBounds[i] =
false;
118 this->ResetBoundaryCondition();
119 m_NeighborhoodAccessorFunctor = ptr->GetNeighborhoodAccessor();
120 m_NeighborhoodAccessorFunctor.SetBegin(ptr->GetBufferPointer());
126 operator=(
const Self & orig);
130 PrintSelf(std::ostream &,
Indent)
const override;
135 ComputeInternalIndex(
const NeighborIndexType n)
const;
153 const InternalPixelType *
156 return (this->
operator[]((this->
Size()) >> 1));
164 return m_NeighborhoodAccessorFunctor.Get(this->GetCenterPointer());
190 ITK_ITERATOR_VIRTUAL NeighborhoodType
191 GetNeighborhood() const ITK_ITERATOR_FINAL;
194 ITK_ITERATOR_VIRTUAL PixelType
197 if (!m_NeedToUseBoundaryCondition || this->InBounds())
199 return (m_NeighborhoodAccessorFunctor.Get(this->operator[](i)));
205 return this->IndexInBounds(i, internalIndex, offset)
206 ? m_NeighborhoodAccessorFunctor.Get(this->
operator[](i))
207 : m_NeighborhoodAccessorFunctor.BoundaryCondition(internalIndex, offset,
this, m_BoundaryCondition);
215 ITK_ITERATOR_VIRTUAL PixelType
216 GetPixel(NeighborIndexType i,
bool & IsInBounds)
const ITK_ITERATOR_FINAL;
220 ITK_ITERATOR_VIRTUAL PixelType
225 return (this->GetPixel(this->GetNeighborhoodIndex(o), inbounds));
233 ITK_ITERATOR_VIRTUAL PixelType
236 return (this->GetPixel(this->GetNeighborhoodIndex(o), IsInBounds));
242 ITK_ITERATOR_VIRTUAL PixelType
245 return (this->GetPixel(this->GetCenterNeighborhoodIndex() + (i * this->GetStride(axis))));
251 ITK_ITERATOR_VIRTUAL PixelType
252 GetNext(
const unsigned axis)
const ITK_ITERATOR_FINAL
254 return (this->GetPixel(this->GetCenterNeighborhoodIndex() + this->GetStride(axis)));
260 ITK_ITERATOR_VIRTUAL PixelType
263 return (this->GetPixel(this->GetCenterNeighborhoodIndex() - (i * this->GetStride(axis))));
269 ITK_ITERATOR_VIRTUAL PixelType
272 return (this->GetPixel(this->GetCenterNeighborhoodIndex() - this->GetStride(axis)));
280 return (this->GetIndex() + o);
288 return (this->GetIndex() + this->GetOffset(i));
309 GetBoundingBoxAsImageRegion()
const;
326 return m_WrapOffset[n];
330 ITK_ITERATOR_VIRTUAL
void
331 GoToBegin() ITK_ITERATOR_FINAL;
335 ITK_ITERATOR_VIRTUAL
void
336 GoToEnd() ITK_ITERATOR_FINAL;
340 ITK_ITERATOR_VIRTUAL
void
341 Initialize(const
SizeType & radius, const ImageType * ptr, const
RegionType & region) ITK_ITERATOR_FINAL;
345 ITK_ITERATOR_VIRTUAL
bool
346 IsAtBegin() const ITK_ITERATOR_FINAL
348 return (this->GetCenterPointer() == m_Begin);
353 ITK_ITERATOR_VIRTUAL
bool
356 if (this->GetCenterPointer() > m_End)
358 ExceptionObject
e(__FILE__, __LINE__);
359 std::ostringstream msg;
360 msg <<
"In method IsAtEnd, CenterPointer = " << this->GetCenterPointer() <<
" is greater than End = " << m_End
363 e.SetDescription(msg.str().c_str());
366 return (this->GetCenterPointer() == m_End);
445 this->SetLoop(position);
446 this->SetPixelPointers(position);
454 operator+=(
const OffsetType &);
460 operator-=(
const OffsetType &);
487 IndexInBounds(
const NeighborIndexType n, OffsetType & internalIndex, OffsetType & offset)
const;
492 IndexInBounds(
const NeighborIndexType n)
const;
499 ITK_ITERATOR_VIRTUAL
void
502 m_BoundaryCondition = i;
507 ITK_ITERATOR_VIRTUAL
void
510 m_BoundaryCondition = &m_InternalBoundaryCondition;
517 m_InternalBoundaryCondition = c;
521 ImageBoundaryConditionPointerType
524 return m_BoundaryCondition;
531 this->SetNeedToUseBoundaryCondition(
true);
537 this->SetNeedToUseBoundaryCondition(
false);
543 m_NeedToUseBoundaryCondition = b;
549 return m_NeedToUseBoundaryCondition;
553 ITK_ITERATOR_VIRTUAL
void
554 SetRegion(
const RegionType & region) ITK_ITERATOR_FINAL;
559 ITK_ITERATOR_VIRTUAL
void
563 m_IsInBoundsValid =
false;
569 ITK_ITERATOR_VIRTUAL
void
570 SetBound(
const SizeType &) ITK_ITERATOR_FINAL;
576 ITK_ITERATOR_VIRTUAL
void
577 SetPixelPointers(
const IndexType &) ITK_ITERATOR_FINAL;
581 ITK_ITERATOR_VIRTUAL
void
584 m_BeginIndex = start;
589 ITK_ITERATOR_VIRTUAL
void
590 SetEndIndex() ITK_ITERATOR_FINAL;
600 const InternalPixelType * m_Begin;
606 const InternalPixelType * m_End;
636 mutable
bool m_IsInBounds{
false };
641 mutable bool m_IsInBoundsValid{
false };
653 bool m_NeedToUseBoundaryCondition{
false };
659 template <
typename TImage>
669 template <
typename TImage>
670 inline ConstNeighborhoodIterator<TImage>
677 template <
typename TImage>
678 inline ConstNeighborhoodIterator<TImage>
688 #ifndef ITK_MANUAL_INSTANTIATION
689 # include "itkConstNeighborhoodIterator.hxx"