29#if defined(ArrayImageAdapter_RECURSES)
30#error Recursive header files inclusion detected in ArrayImageAdapter.h
33#define ArrayImageAdapter_RECURSES
35#if !defined ArrayImageAdapter_h
37#define ArrayImageAdapter_h
41#include <boost/concept/assert.hpp>
42#include <boost/iterator/iterator_concepts.hpp>
46#include <DGtal/base/Common.h>
47#include <DGtal/images/CConstImage.h>
48#include <DGtal/images/ArrayImageIterator.h>
49#include <DGtal/base/IteratorCompletion.h>
50#include <DGtal/kernel/domains/Linearizer.h>
68 typename TArrayIterator,
71 class ArrayImageAdapter;
113 typename TArrayIterator,
117 :
public IteratorCompletion< ArrayImageAdapter< TArrayIterator, HyperRectDomain<TSpace> > >
125 using Self = ArrayImageAdapter<TArrayIterator, HyperRectDomain<TSpace> >;
127 using Value =
typename std::iterator_traits<ArrayIterator>::value_type;
128 using Reference =
typename std::iterator_traits<ArrayIterator>::reference;
153 : myArrayIterator{nullptr}
165 : myArrayIterator(anArrayIterator)
166 , myFullDomain{ aFullDomain }
167 , myViewDomain{ aViewDomain }
172 "The viewable domain must be included into the full domain."
184 : ArrayImageAdapter( anArrayIterator, aFullDomain, aFullDomain )
198 : ArrayImageAdapter( other.myArrayIterator, other.myFullDomain, aViewDomain )
228 myFullDomain.isInside(
aPoint),
229 "The point is outside the full domain."
232 return myArrayIterator[ Linearizer::getIndex(
aPoint, myFullDomain) ];
244 myFullDomain.isInside(
aPoint),
245 "The point is outside the full domain."
248 myArrayIterator[ Linearizer::getIndex(
aPoint, myFullDomain) ] = aValue;
268 return Iterator{
this, myFullDomain, myViewDomain };
295 return Iterator{
this, myFullDomain, myViewDomain,
true };
304 return ConstIterator{
this, myFullDomain, myViewDomain,
true };
313 return ConstIterator{
this, myFullDomain, myViewDomain,
true };
328 aFullIndex >= 0 &&
static_cast<typename
Domain::Size>(aFullIndex) < myFullDomain.size(),
329 "linearized index out of bounds !"
331 return myArrayIterator[aFullIndex];
343 aFullIndex >= 0 &&
static_cast<typename
Domain::Size>(aFullIndex) < myFullDomain.size(),
344 "linearized index out of bounds !"
346 return myArrayIterator[aFullIndex];
357 out <<
"[ArrayImageAdapter] with full domain " << myFullDomain <<
" and viewable domain " << myViewDomain;
384 typename TArrayIterator,
390 using Self = ArrayImageAdapter<TArrayIterator, TDomain>;
398 class DistanceFunctor
409 : myDomain( anImage->
domain() )
419 myDomain.isInside(
aPoint),
420 "The point is outside the domain !"
440 typename TArrayIterator,
444 operator<< ( std::ostream & out,
const ArrayImageAdapter<TArrayIterator, TDomain> &
object )
446 object.selfDisplay( out );
461 typename TArrayIterator,
464 ArrayImageAdapter< TArrayIterator, TDomain >
467 return { anArrayIterator, aFullDomain, aViewDomain };
479 typename TArrayIterator,
482 ArrayImageAdapter< TArrayIterator, TDomain >
485 return { anArrayIterator, aFullDomain, aFullDomain };
495 typename TDomain =
typename TImage::Domain
499 ArrayImageAdapter<
decltype( ((TImage*)
nullptr)->begin() ), TDomain >
505 return { anImage.begin(), anImage.domain(), aViewDomain };
516 typename TDomain =
typename TImage::Domain
520 ArrayImageAdapter<
decltype( ((TImage*)
nullptr)->begin() ), TDomain >
526 return { anImage.begin(), anImage.domain(), anImage.domain() };
537#undef ArrayImageAdapter_RECURSES
Aim: Image adapter for generic arrays with sub-domain view capability.
ConstIterator cend() const
ArrayImageAdapter(ArrayIterator anArrayIterator, Domain const &aFullDomain, Domain const &aViewDomain)
Value getValue(Point const &aPoint) const
typename IteratorCompletionTraits< Self >::Iterator Iterator
Mutable iterator based on ArrayImageIterator.
typename IteratorCompletionTraits< Self >::ConstIterator ConstIterator
Constant iterator base on ArrayImageIterator.
Domain fullDomain() const
typename std::iterator_traits< ArrayIterator >::value_type Value
The value type stored in the image.
Domain myFullDomain
Definition (full) domain.
TArrayIterator ArrayIterator
The given random-access iterator's type.
typename std::iterator_traits< ArrayIterator >::reference Reference
Mutable reference type.
ConstReference dereference(Point const &, typename Point::Coordinate aFullIndex) const
Reference dereference(Point const &, typename Point::Coordinate aFullIndex)
typename Domain::Integer Integer
Integer type.
typename Domain::Dimension Dimension
Dimension type.
ArrayImageAdapter(Self const &other, Domain const &aViewDomain)
typename Domain::Size Size
Size type.
Domain myViewDomain
Viewable domain.
BOOST_CONCEPT_ASSERT((boost_concepts::RandomAccessTraversalConcept< TArrayIterator >))
typename Domain::Point Point
Point type.
ConstIterator cbegin() const
void setValue(Point const &aPoint, Value aValue)
typename Domain::Vector Vector
Vector type.
ConstIterator end() const
void selfDisplay(std::ostream &out) const
BOOST_STATIC_CONSTANT(Dimension, dimension=Domain::dimension)
Rank of the space.
ArrayIterator myArrayIterator
Pointer to the allocated memory.
ConstIterator begin() const
ArrayImageAdapter(ArrayIterator anArrayIterator, Domain const &aFullDomain)
const Reference ConstReference
Constant reference type.
Aim: Random access iterator over an image given his definition domain and viewable domain.
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
const Point & lowerBound() const
const Point & upperBound() const
Space::Dimension Dimension
Domain myDomain
Stored domain to avoid iterator corruption if domain changed.
typename Self::Difference Difference
Type of the difference between two iterators.
typename Self::Domain Domain
Domain type.
DistanceFunctor(Self const *anImage)
typename Self::Point Point
Point type.
ArrayImageAdapter< TArrayIterator, TDomain > Self
Self type.
Aim: Traits that must be specialized for each IteratorCompletion derived class.
Aim: Class that uses CRTP to add reverse iterators and ranges to a derived class.
bool isLower(const PointVector< dim, OtherComponent, OtherStorage > &p) const
Return true if this point is below a given point.
bool isUpper(const PointVector< dim, OtherComponent, OtherStorage > &p) const
Return true if this point is upper a given point.
DGtal is the top-level namespace which contains all DGtal functions and types.
ArrayImageAdapter< TArrayIterator, TDomain > makeArrayImageAdapterFromIterator(TArrayIterator anArrayIterator, TDomain const &aFullDomain, TDomain const &aViewDomain)
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
ArrayImageAdapter< decltype(((TImage *) nullptr) ->begin()), TDomain > makeArrayImageAdapterFromImage(TImage &anImage, TDomain const &aViewDomain)
Aim: Linearization and de-linearization interface for domains.
Aim: Defines the concept describing a read-only image, which is a refinement of CPointFunctor.
Go to http://www.boost.org/doc/libs/1_52_0/libs/iterator/doc/RandomAccessTraversal....