36 #include <DGtal/base/Common.h>
37 #include <DGtal/base/IteratorCompletion.h>
38 #include <DGtal/kernel/domains/HyperRectDomain.h>
39 #include <DGtal/kernel/domains/Linearizer.h>
40 #include <DGtal/kernel/SpaceND.h>
41 #include <DGtal/images/CImage.h>
47 template <
typename T, DGtal::Dimension N >
54 typedef MyImage<T, N> Self;
66 : myDomain(aDomain), myData( new T[ myDomain.size() ] )
82 return myData[ Linearizer::getIndex(
aPoint, myDomain) ];
94 myData[ Linearizer::getIndex(
aPoint, myDomain) ] = aValue;
104 Self& operator= ( Self
const& other )
106 if (
this != &other )
108 myDomain = other.domain();
110 myData =
new Value[ myDomain.size() ];
111 std::copy( other.begin(), other.end(), begin() );
136 return myData + myDomain.size();
142 return myData + myDomain.size();
159 template <
typename T, Dimension N >
160 class IteratorCompletionTraits< MyImage<T, N> >
163 typedef MyImage<T, N> Self;
167 class DistanceFunctor
172 typedef typename Self::Difference Difference;
174 DistanceFunctor( Self
const* aVector )
175 : myDomain(aVector->
domain())
178 Difference operator() (
Point const&
aPoint )
const
180 return Self::Linearizer::getIndex(
aPoint, myDomain );
198 typedef MyImage<double, 2> My2DImage;
211 for ( My2DImage::Iterator it = image.begin(), it_end = image.end() ; it != it_end; ++it )
217 image.setValue(
Point(1,1), -1 );
221 copy( range.begin(), range.end(), ostream_iterator<Value>( cout,
" " ) );
225 copy( image.rbegin(), image.rend(), ostream_iterator<Value>( cout,
" " ) );
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.
IteratorCompletionTraits< TDerived >::ConstIterator ConstIterator
Constant iterator type.
IteratorCompletionTraits< TDerived >::Iterator Iterator
Mutable iterator type.
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
int main()
[IteratorCompletionTraits]
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Linearization and de-linearization interface for domains.
Aim: Defines the concept describing a read/write image, having an output iterator.
Linearizer< Domain, ColMajorStorage > Linearizer
Image::ConstRange ConstRange
HyperRectDomain< Space > Domain