19 #ifndef itkShapedImageNeighborhoodRange_h
20 #define itkShapedImageNeighborhoodRange_h
27 #include <type_traits>
35 namespace Experimental
92 template<
typename TImage,
93 typename TImageNeighborhoodPixelAccessPolicy = ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy<TImage>>
110 template <
typename T>
111 static int Test(
typename T::PixelAccessParameterType*);
113 template <
typename T>
114 static void Test(...);
119 decltype(Test<TImageNeighborhoodPixelAccessPolicy>(
nullptr)),
120 decltype(Test<TImageNeighborhoodPixelAccessPolicy>())>::value;
124 template <
typename TPolicy,
bool VPolicyHasPixelAccessParameterType = CheckPolicy::HasPixelAccessParameterType>
127 using Type =
typename TPolicy::PixelAccessParameterType;
131 template <
typename TPolicy>
161 template <
bool VIsConst,
typename TDummy =
void>
class PixelProxy {};
165 template <
typename TDummy>
187 const TImageNeighborhoodPixelAccessPolicy& pixelAccessPolicy) ITK_NOEXCEPT
190 m_PixelAccessPolicy{pixelAccessPolicy}
198 m_PixelAccessPolicy{ pixelProxy.m_PixelAccessPolicy}
212 template <
typename TDummy>
237 const TImageNeighborhoodPixelAccessPolicy& pixelAccessPolicy) ITK_NOEXCEPT
240 m_PixelAccessPolicy{pixelAccessPolicy}
270 const auto lhsPixelValue = lhs.m_PixelAccessPolicy.GetPixelValue(lhs.m_ImageBufferPointer);
271 const auto rhsPixelValue = rhs.m_PixelAccessPolicy.GetPixelValue(rhs.m_ImageBufferPointer);
274 lhs.m_PixelAccessPolicy.SetPixelValue(lhs.m_ImageBufferPointer, rhsPixelValue);
275 rhs.m_PixelAccessPolicy.SetPixelValue(rhs.m_ImageBufferPointer, lhsPixelValue);
292 template <
bool VIsConst>
312 using QualifiedPixelType =
typename std::conditional<IsImageTypeConst, const PixelType, PixelType>::type;
365 template <
typename TPixelAccessParameter>
368 static_assert(std::is_same< TPixelAccessParameter, OptionalPixelAccessParameterType>::value,
369 "This helper function should only be used for OptionalPixelAccessParameterType!");
370 static_assert(!std::is_same< TPixelAccessParameter, EmptyPixelAccessParameter>::value,
371 "EmptyPixelAccessParameter indicates that there is no pixel access parameter specified!");
469 assert(lhs.m_ImageBufferPointer == rhs.m_ImageBufferPointer);
470 assert(lhs.m_ImageSize == rhs.m_ImageSize);
471 assert(lhs.m_OffsetTable == rhs.m_OffsetTable);
474 return lhs.m_CurrentOffset == rhs.m_CurrentOffset;
482 return !(lhs == rhs);
489 assert(lhs.m_ImageBufferPointer == rhs.m_ImageBufferPointer);
490 assert(lhs.m_ImageSize == rhs.m_ImageSize);
491 assert(lhs.m_OffsetTable == rhs.m_OffsetTable);
494 return lhs.m_CurrentOffset < rhs.m_CurrentOffset;
541 assert(lhs.m_ImageBufferPointer == rhs.m_ImageBufferPointer);
542 assert(lhs.m_ImageSize == rhs.m_ImageSize);
543 assert(lhs.m_OffsetTable == rhs.m_OffsetTable);
546 return lhs.m_CurrentOffset - rhs.m_CurrentOffset;
593 RegionData() ITK_NOEXCEPT = default;
597 m_Index(imageRegion.GetIndex()),
598 m_Size(imageRegion.GetSize())
608 index1[i] -= index2[i];
662 const std::size_t numberOfNeigborhoodPixels,
677 assert(offsetTable !=
nullptr);
695 template <
typename TContainerOfOffsets>
699 const TContainerOfOffsets& shapeOffsets,
708 optionalPixelAccessParameter
748 return this->
begin();
783 std::size_t
size() const ITK_NOEXCEPT
803 assert(n < this->
size());
804 assert(n <= static_cast<std::size_t>(std::numeric_limits<std::ptrdiff_t>::max()));
807 return this->
begin()[
static_cast<std::ptrdiff_t
>(n)];
QualifiedIterator(QualifiedInternalPixelType *const imageBufferPointer, const ImageSizeType &imageSize, const OffsetType &offsetTable, const NeighborhoodAccessorFunctorType &neighborhoodAccessor, const OptionalPixelAccessParameterType optionalPixelAccessParameter, const IndexType &relativeLocation, const OffsetType *const offset) noexcept
friend void swap(PixelProxy lhs, PixelProxy rhs) noexcept
PixelProxy & operator=(const PixelType &pixelValue) noexcept
TImageNeighborhoodPixelAccessPolicy CreatePixelAccessPolicy(EmptyPixelAccessParameter) const
TImageNeighborhoodPixelAccessPolicy CreatePixelAccessPolicy(const TPixelAccessParameter pixelAccessParameter) const
typename OptionalPixelAccessParameter< TImageNeighborhoodPixelAccessPolicy >::Type OptionalPixelAccessParameterType
std::random_access_iterator_tag iterator_category
const TImageNeighborhoodPixelAccessPolicy m_PixelAccessPolicy
PixelProxy(const PixelProxy< false > &pixelProxy) noexcept
QualifiedPixelType * pointer
unsigned long SizeValueType
void SetLocation(const IndexType &location) noexcept
typename std::conditional< IsImageTypeConst, const PixelType, PixelType >::type QualifiedPixelType
static constexpr bool HasPixelAccessParameterType
QualifiedIterator< false >::reference operator[](const std::vcl_size_t n) const noexcept
QualifiedInternalPixelType * m_ImageBufferPointer
static int Test(typename T::PixelAccessParameterType *)
friend QualifiedIterator operator-(QualifiedIterator it, const difference_type n) noexcept
const OffsetType * m_ShapeOffsets
std::ptrdiff_t difference_type
std::reverse_iterator< iterator > reverse_iterator
typename TImage::RegionType ImageRegionType
friend bool operator!=(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
NeighborhoodAccessorFunctorType m_NeighborhoodAccessor
friend QualifiedIterator operator+(const difference_type n, QualifiedIterator it) noexcept
const_iterator cbegin() const noexcept
void SubtractIndex(IndexType &index1, const IndexType &index2)
reference operator[](const difference_type n) const noexcept
reverse_iterator rend() const noexcept
OptionalPixelAccessParameterType m_OptionalPixelAccessParameter
QualifiedInternalPixelType * m_ImageBufferPointer
typename TImage::InternalPixelType InternalPixelType
QualifiedIterator operator--(int) noexcept
typename std::conditional< IsImageTypeConst, const InternalPixelType, InternalPixelType >::type QualifiedInternalPixelType
bool empty() const noexcept
friend difference_type operator-(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
friend bool operator<(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
const OffsetType * m_CurrentOffset
ImageBaseType::SizeType SizeType
ImageSizeType m_ImageSize
typename TImage::SizeValueType ImageSizeValueType
ImageBaseType::IndexType IndexType
typename TImage::PixelType PixelType
QualifiedIterator(const QualifiedIterator< false > &arg) noexcept
std::vcl_size_t size() const noexcept
static constexpr bool IsImageTypeConst
iterator begin() const noexcept
signed long IndexValueType
iterator end() const noexcept
reverse_iterator rbegin() const noexcept
const_reverse_iterator crend() const noexcept
friend QualifiedIterator & operator-=(QualifiedIterator &it, const difference_type n) noexcept
friend bool operator>=(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
friend class ShapedImageNeighborhoodRange
QualifiedIterator & operator--() noexcept
QualifiedIterator operator++(int) noexcept
PixelProxy & operator=(const PixelProxy &pixelProxy) noexcept
typename std::conditional< VIsConst, const ImageType, ImageType >::type QualifiedImageType
friend QualifiedIterator & operator+=(QualifiedIterator &it, const difference_type n) noexcept
QualifiedIterator()=default
friend QualifiedIterator operator+(QualifiedIterator it, const difference_type n) noexcept
const_reverse_iterator crbegin() const noexcept
friend bool operator>(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
const_iterator cend() const noexcept
reference operator*() const noexcept
ShapedImageNeighborhoodRange(ImageType &image, const IndexType &location, const TContainerOfOffsets &shapeOffsets, const OptionalPixelAccessParameterType optionalPixelAccessParameter={})
const TImageNeighborhoodPixelAccessPolicy m_PixelAccessPolicy
static constexpr ImageDimensionType ImageDimension
typename TImageNeighborhoodPixelAccessPolicy::PixelAccessParameterType Type
typename TImage::SizeType ImageSizeType
typename TImage::IndexType IndexType
typename TImage::NeighborhoodAccessorFunctorType NeighborhoodAccessorFunctorType
InternalPixelType *const m_ImageBufferPointer
friend bool operator==(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
ShapedImageNeighborhoodRange(ImageType &image, const IndexType &location, const OffsetType *const shapeOffsets, const std::vcl_size_t numberOfNeigborhoodPixels, const OptionalPixelAccessParameterType optionalPixelAccessParameter={})
std::vcl_size_t m_NumberOfNeighborhoodPixels
QualifiedIterator & operator=(const QualifiedIterator &) noexcept=default
IndexType m_RelativeLocation
RegionData m_BufferedRegionData
typename std::conditional< IsImageTypeConst, const InternalPixelType, InternalPixelType >::type QualifiedInternalPixelType
friend bool operator<=(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
ImageBaseType::RegionType RegionType
typename TImage::IndexValueType IndexValueType
signed long OffsetValueType
std::reverse_iterator< const_iterator > const_reverse_iterator
QualifiedIterator & operator++() noexcept
const InternalPixelType *const m_ImageBufferPointer
typename TImage::ImageDimensionType ImageDimensionType