18 #ifndef itkConstNeighborhoodIterator_h
19 #define itkConstNeighborhoodIterator_h
49 template <
typename TImage,
typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
51 :
public Neighborhood<typename TImage::InternalPixelType *, TImage::ImageDimension>
55 using InternalPixelType =
typename TImage::InternalPixelType;
59 using DimensionValueType =
unsigned int;
62 static constexpr DimensionValueType
Dimension = TImage::ImageDimension;
112 this->Initialize(radius, ptr, region);
113 for (DimensionValueType i = 0; i <
Dimension; i++)
115 m_InBounds[i] =
false;
117 this->ResetBoundaryCondition();
118 m_NeighborhoodAccessorFunctor = ptr->GetNeighborhoodAccessor();
119 m_NeighborhoodAccessorFunctor.SetBegin(ptr->GetBufferPointer());
125 operator=(
const Self & orig);
129 PrintSelf(std::ostream &,
Indent)
const override;
134 ComputeInternalIndex(
const NeighborIndexType n)
const;
152 const InternalPixelType *
155 return (this->
operator[]((this->
Size()) >> 1));
163 return m_NeighborhoodAccessorFunctor.Get(this->GetCenterPointer());
189 ITK_ITERATOR_VIRTUAL NeighborhoodType
190 GetNeighborhood() const ITK_ITERATOR_FINAL;
193 ITK_ITERATOR_VIRTUAL PixelType
196 if (!m_NeedToUseBoundaryCondition || this->InBounds())
198 return (m_NeighborhoodAccessorFunctor.Get(this->operator[](i)));
204 return this->IndexInBounds(i, internalIndex, offset)
205 ? m_NeighborhoodAccessorFunctor.Get(this->
operator[](i))
206 : m_NeighborhoodAccessorFunctor.BoundaryCondition(internalIndex, offset,
this, m_BoundaryCondition);
214 ITK_ITERATOR_VIRTUAL PixelType
215 GetPixel(NeighborIndexType i,
bool & IsInBounds)
const ITK_ITERATOR_FINAL;
219 ITK_ITERATOR_VIRTUAL PixelType
224 return (this->GetPixel(this->GetNeighborhoodIndex(o), inbounds));
232 ITK_ITERATOR_VIRTUAL PixelType
235 return (this->GetPixel(this->GetNeighborhoodIndex(o), IsInBounds));
241 ITK_ITERATOR_VIRTUAL PixelType
244 return (this->GetPixel(this->GetCenterNeighborhoodIndex() + (i * this->GetStride(axis))));
250 ITK_ITERATOR_VIRTUAL PixelType
251 GetNext(
const unsigned axis)
const ITK_ITERATOR_FINAL
253 return (this->GetPixel(this->GetCenterNeighborhoodIndex() + this->GetStride(axis)));
259 ITK_ITERATOR_VIRTUAL PixelType
262 return (this->GetPixel(this->GetCenterNeighborhoodIndex() - (i * this->GetStride(axis))));
268 ITK_ITERATOR_VIRTUAL PixelType
271 return (this->GetPixel(this->GetCenterNeighborhoodIndex() - this->GetStride(axis)));
279 return (this->GetIndex() + o);
287 return (this->GetIndex() + this->GetOffset(i));
308 GetBoundingBoxAsImageRegion()
const;
325 return m_WrapOffset[n];
329 ITK_ITERATOR_VIRTUAL
void
330 GoToBegin() ITK_ITERATOR_FINAL;
334 ITK_ITERATOR_VIRTUAL
void
335 GoToEnd() ITK_ITERATOR_FINAL;
339 ITK_ITERATOR_VIRTUAL
void
340 Initialize(const
SizeType & radius, const ImageType * ptr, const
RegionType & region) ITK_ITERATOR_FINAL;
344 ITK_ITERATOR_VIRTUAL
bool
345 IsAtBegin() const ITK_ITERATOR_FINAL
347 return (this->GetCenterPointer() == m_Begin);
352 ITK_ITERATOR_VIRTUAL
bool
355 if (this->GetCenterPointer() > m_End)
357 ExceptionObject
e(__FILE__, __LINE__);
358 std::ostringstream msg;
359 msg <<
"In method IsAtEnd, CenterPointer = " << this->GetCenterPointer() <<
" is greater than End = " << m_End
362 e.SetDescription(msg.str().c_str());
365 return (this->GetCenterPointer() == m_End);
444 this->SetLoop(position);
445 this->SetPixelPointers(position);
453 operator+=(
const OffsetType &);
459 operator-=(
const OffsetType &);
486 IndexInBounds(
const NeighborIndexType n, OffsetType & internalIndex, OffsetType & offset)
const;
491 IndexInBounds(
const NeighborIndexType n)
const;
498 ITK_ITERATOR_VIRTUAL
void
501 m_BoundaryCondition = i;
506 ITK_ITERATOR_VIRTUAL
void
509 m_BoundaryCondition = &m_InternalBoundaryCondition;
516 m_InternalBoundaryCondition = c;
520 ImageBoundaryConditionPointerType
523 return m_BoundaryCondition;
530 this->SetNeedToUseBoundaryCondition(
true);
536 this->SetNeedToUseBoundaryCondition(
false);
542 m_NeedToUseBoundaryCondition = b;
548 return m_NeedToUseBoundaryCondition;
552 ITK_ITERATOR_VIRTUAL
void
553 SetRegion(
const RegionType & region) ITK_ITERATOR_FINAL;
558 ITK_ITERATOR_VIRTUAL
void
562 m_IsInBoundsValid =
false;
568 ITK_ITERATOR_VIRTUAL
void
569 SetBound(
const SizeType &) ITK_ITERATOR_FINAL;
575 ITK_ITERATOR_VIRTUAL
void
576 SetPixelPointers(
const IndexType &) ITK_ITERATOR_FINAL;
580 ITK_ITERATOR_VIRTUAL
void
583 m_BeginIndex = start;
588 ITK_ITERATOR_VIRTUAL
void
589 SetEndIndex() ITK_ITERATOR_FINAL;
599 const InternalPixelType * m_Begin;
605 const InternalPixelType * m_End;
635 mutable
bool m_IsInBounds{
false };
640 mutable bool m_IsInBoundsValid{
false };
652 bool m_NeedToUseBoundaryCondition{
false };
658 template <
typename TImage>
668 template <
typename TImage>
669 inline ConstNeighborhoodIterator<TImage>
676 template <
typename TImage>
677 inline ConstNeighborhoodIterator<TImage>
687 #ifndef ITK_MANUAL_INSTANTIATION
688 # include "itkConstNeighborhoodIterator.hxx"