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)));
202 OffsetType internalIndex;
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
221 GetPixel(
const OffsetType & o)
const ITK_ITERATOR_FINAL
225 return (this->GetPixel(this->GetNeighborhoodIndex(o), inbounds));
233 ITK_ITERATOR_VIRTUAL PixelType
234 GetPixel(
const OffsetType & o,
bool & IsInBounds)
const ITK_ITERATOR_FINAL
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 int 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)));
278 GetIndex(
const OffsetType & o)
const ITK_ITERATOR_FINAL
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);
393 ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(
Self);
438 this->SetLoop(position);
439 this->SetPixelPointers(position);
447 operator+=(
const OffsetType &);
453 operator-=(
const OffsetType &);
480 IndexInBounds(
const NeighborIndexType n, OffsetType & internalIndex, OffsetType & offset)
const;
485 IndexInBounds(
const NeighborIndexType n)
const;
492 ITK_ITERATOR_VIRTUAL
void
495 m_BoundaryCondition = i;
500 ITK_ITERATOR_VIRTUAL
void
503 m_BoundaryCondition = &m_InternalBoundaryCondition;
510 m_InternalBoundaryCondition = c;
514 ImageBoundaryConditionPointerType
517 return m_BoundaryCondition;
524 this->SetNeedToUseBoundaryCondition(
true);
530 this->SetNeedToUseBoundaryCondition(
false);
536 m_NeedToUseBoundaryCondition = b;
542 return m_NeedToUseBoundaryCondition;
546 ITK_ITERATOR_VIRTUAL
void
547 SetRegion(
const RegionType & region) ITK_ITERATOR_FINAL;
552 ITK_ITERATOR_VIRTUAL
void
556 m_IsInBoundsValid =
false;
562 ITK_ITERATOR_VIRTUAL
void
563 SetBound(
const SizeType &) ITK_ITERATOR_FINAL;
569 ITK_ITERATOR_VIRTUAL
void
570 SetPixelPointers(
const IndexType &) ITK_ITERATOR_FINAL;
574 ITK_ITERATOR_VIRTUAL
void
577 m_BeginIndex = start;
582 ITK_ITERATOR_VIRTUAL
void
583 SetEndIndex() ITK_ITERATOR_FINAL;
593 const InternalPixelType * m_Begin{
nullptr };
599 const InternalPixelType * m_End{
nullptr };
616 OffsetType m_WrapOffset{ { 0 } };
629 mutable bool m_IsInBounds{
false };
634 mutable bool m_IsInBoundsValid{
false };
646 bool m_NeedToUseBoundaryCondition{
false };
652 template <
typename TImage>
662 template <
typename TImage>
663 inline ConstNeighborhoodIterator<TImage>
670 template <
typename TImage>
671 inline ConstNeighborhoodIterator<TImage>
681 #ifndef ITK_MANUAL_INSTANTIATION
682 # include "itkConstNeighborhoodIterator.hxx"