19 #ifndef itkImageBufferRange_h
20 #define itkImageBufferRange_h
26 #include <type_traits>
37 namespace Experimental
74 template<
typename TImage>
88 std::is_same<PixelType, InternalPixelType>::value &&
89 std::is_same<typename TImage::AccessorType, DefaultPixelAccessor<PixelType>>::value &&
90 std::is_same<AccessorFunctorType, DefaultPixelAccessorFunctor<typename std::remove_const<TImage>::type>>::value;
107 template <
bool VIsConst,
typename TDummy =
void>
class PixelProxy {};
111 template <
typename TDummy>
135 m_InternalPixel{ internalPixel },
136 m_AccessorFunctor(accessorFunctor)
143 m_InternalPixel{ pixelProxy.m_InternalPixel },
144 m_AccessorFunctor{ pixelProxy.m_AccessorFunctor }
151 return m_AccessorFunctor.Get(m_InternalPixel);
158 template <
typename TDummy>
185 m_InternalPixel{ internalPixel },
186 m_AccessorFunctor(accessorFunctor)
193 return m_AccessorFunctor.Get(m_InternalPixel);
199 m_AccessorFunctor.Set(m_InternalPixel, pixelValue);
216 const auto lhsPixelValue = lhs.m_AccessorFunctor.Get(lhs.m_InternalPixel);
217 const auto rhsPixelValue = rhs.m_AccessorFunctor.Get(rhs.m_InternalPixel);
220 lhs.m_AccessorFunctor.Set(lhs.m_InternalPixel, rhsPixelValue);
221 rhs.m_AccessorFunctor.Set(rhs.m_InternalPixel, lhsPixelValue);
238 template <
bool VIsConst>
258 using QualifiedPixelType =
typename std::conditional<IsImageTypeConst, const PixelType, PixelType>::type;
404 return lhs.m_InternalPixelPointer == rhs.m_InternalPixelPointer;
412 return !(lhs == rhs);
419 return lhs.m_InternalPixelPointer < rhs.m_InternalPixelPointer;
466 return lhs.m_InternalPixelPointer - rhs.m_InternalPixelPointer;
525 result.SetPixelAccessor(m_Image.GetPixelAccessor());
526 result.SetBegin(m_Image.ImageType::GetBufferPointer());
550 template <
bool VIsConst>
600 m_NumberOfPixels{ image.ImageType::GetBufferedRegion().GetNumberOfPixels() }
622 return this->
begin();
657 std::size_t
size() const ITK_NOEXCEPT
676 assert(n < this->
size());
677 assert(n <= static_cast<std::size_t>(std::numeric_limits<std::ptrdiff_t>::max()));
680 return this->
begin()[
static_cast<std::ptrdiff_t
>(n)];
688 template<
typename TImage>
691 if (image ==
nullptr)
friend bool operator!=(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
const AccessorFunctorType m_AccessorFunctor
friend class ImageBufferRange
friend bool operator==(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
reference operator[](const difference_type n) const noexcept
static constexpr bool IsImageTypeConst
friend QualifiedIterator & operator-=(QualifiedIterator &it, const difference_type n) noexcept
AccessorFunctorInitializer(ImageType &image) noexcept
typename std::conditional< IsImageTypeConst, const PixelType, PixelType >::type QualifiedPixelType
IteratorInitializer(OptionalAccessorFunctorType optionalAccessorFunctor, QualifiedInternalPixelType *internalPixelPointer) noexcept
unsigned long SizeValueType
reference operator*() const noexcept
typename std::conditional< IsImageTypeConst, const InternalPixelType, InternalPixelType >::type QualifiedInternalPixelType
iterator end() const noexcept
ImageBufferRange(ImageType &image)
QualifiedIterator()=default
typename TImage::AccessorFunctorType AccessorFunctorType
const InternalPixelType & m_InternalPixel
QualifiedPixelType * pointer
QualifiedIterator(const OptionalAccessorFunctorType &accessorFunctor, QualifiedInternalPixelType *const internalPixelPointer) noexcept
friend QualifiedIterator & operator+=(QualifiedIterator &it, const difference_type n) noexcept
QualifiedIterator & operator=(const QualifiedIterator &) noexcept=default
const AccessorFunctorType m_AccessorFunctor
friend bool operator<(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
static constexpr bool UsingPointerAsIterator
reverse_iterator rend() const noexcept
friend QualifiedIterator operator-(QualifiedIterator it, const difference_type n) noexcept
QualifiedInternalPixelType * m_ImageBufferPointer
std::random_access_iterator_tag iterator_category
typename TImage::PixelType PixelType
QualifiedIterator operator--(int) noexcept
InternalPixelType & m_InternalPixel
const_reverse_iterator crend() const noexcept
std::reverse_iterator< iterator > reverse_iterator
QualifiedIterator< false >::reference operator[](const std::vcl_size_t n) const noexcept
std::reverse_iterator< const_iterator > const_reverse_iterator
QualifiedInternalPixelType * m_InternalPixelPointer
QualifiedInternalPixelType * m_InternalPixelPointer
typename std::conditional< UsingPointerAsIterator, QualifiedInternalPixelType *, QualifiedIterator< IsImageTypeConst >>::type iterator
OptionalAccessorFunctorType m_OptionalAccessorFunctor
PixelReferenceWrapper(QualifiedPixelType &pixel, EmptyAccessorFunctor) noexcept
typename TImage::InternalPixelType InternalPixelType
friend bool operator>(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
QualifiedIterator & operator++() noexcept
const_iterator cbegin() const noexcept
std::vcl_size_t size() const noexcept
friend QualifiedIterator operator+(QualifiedIterator it, const difference_type n) noexcept
PixelProxy & operator=(const PixelType &pixelValue) noexcept
const_reverse_iterator crbegin() const noexcept
typename std::conditional< IsImageTypeConst, const InternalPixelType, InternalPixelType >::type QualifiedInternalPixelType
std::ptrdiff_t difference_type
SizeValueType m_NumberOfPixels
QualifiedIterator(const QualifiedIterator< false > &arg) noexcept
QualifiedIterator & operator--() noexcept
friend difference_type operator-(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
typename std::conditional< SupportsDirectPixelAccess, QualifiedPixelType &, PixelProxy< IsImageTypeConst >>::type reference
reverse_iterator rbegin() const noexcept
typename std::conditional< VIsConst, const ImageType, ImageType >::type QualifiedImageType
OptionalAccessorFunctorType m_OptionalAccessorFunctor
typename std::conditional< UsingPointerAsIterator, const InternalPixelType *, QualifiedIterator< true >>::type const_iterator
const_iterator cend() const noexcept
friend QualifiedIterator operator+(const difference_type n, QualifiedIterator it) noexcept
iterator begin() const noexcept
friend bool operator<=(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
static constexpr bool SupportsDirectPixelAccess
bool empty() const noexcept
PixelProxy & operator=(const PixelProxy &pixelProxy) noexcept
QualifiedPixelType & m_Pixel
OptionalAccessorFunctorType m_OptionalAccessorFunctor
ImageBufferRange< TImage > MakeImageBufferRange(TImage *const image)
PixelProxy(const PixelProxy< false > &pixelProxy) noexcept
friend bool operator>=(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
typename std::conditional< SupportsDirectPixelAccess, EmptyAccessorFunctor, AccessorFunctorType >::type OptionalAccessorFunctorType
friend void swap(PixelProxy lhs, PixelProxy rhs) noexcept
QualifiedIterator operator++(int) noexcept