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());
191 GetNeighborhood()
const;
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);
216 GetPixel(NeighborIndexType i,
bool & IsInBounds)
const;
225 return (this->GetPixel(this->GetNeighborhoodIndex(o), inbounds));
234 GetPixel(
const OffsetType & o,
bool & IsInBounds)
const
236 return (this->GetPixel(this->GetNeighborhoodIndex(o), IsInBounds));
245 return (this->GetPixel(this->GetCenterNeighborhoodIndex() + (i * this->GetStride(axis))));
254 return (this->GetPixel(this->GetCenterNeighborhoodIndex() + this->GetStride(axis)));
263 return (this->GetPixel(this->GetCenterNeighborhoodIndex() - (i * this->GetStride(axis))));
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];
341 Initialize(
const SizeType & radius,
const ImageType * ptr,
const RegionType & region);
348 return (this->GetCenterPointer() == m_Begin);
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;
495 m_BoundaryCondition = i;
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;
556 m_IsInBoundsValid =
false;
577 m_BeginIndex = start;
593 const InternalPixelType * m_Begin{
nullptr };
596 typename ImageType::ConstWeakPointer m_ConstImage{};
599 const InternalPixelType * m_End{
nullptr };
616 OffsetType m_WrapOffset{ { 0 } };
619 TBoundaryCondition m_InternalBoundaryCondition{};
632 mutable bool m_IsInBounds{
false };
637 mutable bool m_IsInBoundsValid{
false };
646 bool m_NeedToUseBoundaryCondition{
false };
652 template <
typename TImage>
653 inline ConstNeighborhoodIterator<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"