2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU Lesser General Public License as
4 * published by the Free Software Foundation, either version 3 of the
5 * License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 * @file ArithmeticalDSL.ih
19 * @author Tristan Roussillon (\c tristan.roussillon@liris.cnrs.fr )
20 * Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
24 * Implementation of inline methods defined in ArithmeticalDSL.h
26 * This file is part of the DGtal library.
30//////////////////////////////////////////////////////////////////////////////
32//////////////////////////////////////////////////////////////////////////////
34///////////////////////////////////////////////////////////////////////////////
35// IMPLEMENTATION of inline methods.
36///////////////////////////////////////////////////////////////////////////////
38///////////////////////////////////////////////////////////////////////////////
39// ----------------------- Standard services ------------------------------
41template <typename TCoordinate, typename TInteger, unsigned short adjacency>
43DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>
44::ArithmeticalDSL(const Coordinate& aA, const Coordinate& aB,
45 const Integer& aLowerBound, const Integer& aUpperBound,
46 const Steps& aSteps, const Vector& aShift)
48 mySteps(aSteps), myShift(aShift),
50 myLowerBound(aLowerBound), myUpperBound(aUpperBound)
54//-----------------------------------------------------------------------------
55template <typename TCoordinate, typename TInteger, unsigned short adjacency>
57DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>
58::ArithmeticalDSL(const Coordinate& aA, const Coordinate& aB,
61 mySteps( DGtal::ArithmeticalDSLKernel<TCoordinate,adjacency>::steps(aA, aB) ),
62 myShift( DGtal::ArithmeticalDSLKernel<TCoordinate,adjacency>::shift(aA, aB) ),
67 if ( (aA != 0)&&(aB !=0 ) )
68 myUpperBound = aMu + remainder( myShift ) - NumberTraits<Integer>::ONE;
71//-----------------------------------------------------------------------------
72template <typename TCoordinate, typename TInteger, unsigned short adjacency>
74DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>
75::ArithmeticalDSL(const ArithmeticalDSL<TCoordinate, TInteger, adjacency>& aOther)
77 mySteps(aOther.mySteps), myShift(aOther.myShift),
78 myA(aOther.myA), myB(aOther.myB),
79 myLowerBound(aOther.myLowerBound), myUpperBound(aOther.myUpperBound)
82//-----------------------------------------------------------------------------
83template <typename TCoordinate, typename TInteger, unsigned short adjacency>
85DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>&
86DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>
87::operator=(const ArithmeticalDSL<TCoordinate, TInteger, adjacency>& aOther)
89 if ( this != &aOther )
93 myLowerBound = aOther.myLowerBound;
94 myUpperBound = aOther.myUpperBound;
95 mySteps = aOther.mySteps;
96 myShift = aOther.myShift;
101//-----------------------------------------------------------------------------
102template <typename TCoordinate, typename TInteger, unsigned short adjacency>
104DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>
105DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>
108 return DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>(-myA, -myB, -myUpperBound, -myLowerBound,
109 std::make_pair(-mySteps.first, -mySteps.second),
113//-----------------------------------------------------------------------------
114template <typename TCoordinate, typename TInteger, unsigned short adjacency>
117DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>
118::equalsTo(const ArithmeticalDSL<TCoordinate, TInteger, adjacency>& aOther) const
120 return ( (myA == aOther.myA) &&
121 (myB == aOther.myB) &&
122 (myLowerBound == aOther.myLowerBound) &&
123 (myUpperBound == aOther.myUpperBound) );
124 //NB: other redondant members are not tested
127//-----------------------------------------------------------------------------
128template <typename TCoordinate, typename TInteger, unsigned short adjacency>
131DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>
132::operator==(const ArithmeticalDSL<TCoordinate, TInteger, adjacency>& aOther) const
134 return ( equalsTo(aOther) || equalsTo(aOther.negate()) );
137//-----------------------------------------------------------------------------
138template <typename TCoordinate, typename TInteger, unsigned short adjacency>
141DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>
142::operator!=(const ArithmeticalDSL<TCoordinate, TInteger, adjacency>& aOther) const
144 return !( operator==(aOther) );
147template <typename TCoordinate, typename TInteger, unsigned short adjacency>
150DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>
151::sameOctant( const ArithmeticalDSL & aOther, typename ArithmeticalDSL<TCoordinate, TInteger,adjacency>::Octant::first_type *theOctant ) const
153 Octant octantThis, octantOther;
155 octantThis = this->octant();
156 octantOther = aOther.octant();
158 if(octantThis.first==octantOther.first || octantThis.first==octantOther.second)
160 *theOctant = octantThis.first;
164 if(octantThis.second==octantOther.first || octantThis.second == octantOther.second)
166 *theOctant = octantThis.second;
176// ----------------------------------------------------------------------------
177template <typename TCoordinate, typename TInteger, unsigned short adjacency>
179typename DGtal::ArithmeticalDSL<TCoordinate,TInteger,adjacency>::Octant
180DGtal::ArithmeticalDSL<TCoordinate,TInteger, adjacency>
185 if (myB== NumberTraits<TInteger>::ZERO)
187 if (myA == NumberTraits<TInteger>::ZERO)
189 res = std::make_pair(-1,-1);
191 else if (myA > NumberTraits<TInteger>::ZERO)
193 res = std::make_pair(1,2);
197 res = std::make_pair(5,6);
200 else if (myB> NumberTraits<TInteger>::ZERO)
202 if (myA == NumberTraits<TInteger>::ZERO)
204 res = std::make_pair(0,7);
206 else if (myA > NumberTraits<TInteger>::ZERO)
210 res = std::make_pair(0,1);
214 res = std::make_pair(0,0);
218 res = std::make_pair(1,1);
225 res = std::make_pair(6,7);
229 res = std::make_pair(7,7);
233 res = std::make_pair(6,6);
239 if (myA == NumberTraits<TInteger>::ZERO)
241 res = std::make_pair(3,4);
243 else if (myA > NumberTraits<TInteger>::ZERO)
247 res = std::make_pair(2,3);
251 res = std::make_pair(3,3);
255 res = std::make_pair(2,2);
262 res = std::make_pair(4,5);
266 res = std::make_pair(4,4);
270 res = std::make_pair(5,5);
285//-----------------------------------------------------------------------------
286template <typename TCoordinate, typename TInteger, unsigned short adjacency>
288DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::~ArithmeticalDSL()
292//-----------------------------------------------------------------------------
293template <typename TCoordinate, typename TInteger, unsigned short adjacency>
296DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::isValid() const
298 bool flagIsValid; //'true' if valid, 'false' otherwise
300 if ( (myA != 0) || (myB != 0) )
302 Integer gcd = IntegerComputer<Coordinate>::staticGcd(myA, myB);
303 if (gcd != NumberTraits<Coordinate>::ONE)
304 flagIsValid = false; //a,b must be relatively prime
305 else if (!checkShiftAndSteps())
306 flagIsValid = false; //redondant parameters must be consistent
311 flagIsValid = false; //a and b cannot be both null
316//-----------------------------------------------------------------------------
317template <typename TCoordinate, typename TInteger, unsigned short adjacency>
320DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::checkShiftAndSteps() const
322 ASSERT( (myA != 0) || (myB != 0) );
324 bool flagIsValid; //'true' if valid, 'false' otherwise
326 if (mySteps != DGtal::ArithmeticalDSLKernel<TCoordinate,adjacency>::steps(myA, myB))
328 else if (myShift != DGtal::ArithmeticalDSLKernel<TCoordinate,adjacency>::shift(myA, myB))
330 else if ( ( (mySteps.second[0] != NumberTraits<Coordinate>::ZERO)
331 ||(mySteps.second[1] != NumberTraits<Coordinate>::ZERO) )
332 &&( (mySteps.first - mySteps.second) != myShift ) )
334 else if ( remainder( myShift ) != (myUpperBound - myLowerBound + NumberTraits<Integer>::ONE) )
342//-----------------------------------------------------------------------------
343template <typename TCoordinate, typename TInteger, unsigned short adjacency>
345typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Coordinate
346DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::a() const
351//-----------------------------------------------------------------------------
352template <typename TCoordinate, typename TInteger, unsigned short adjacency>
354typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Coordinate
355DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::b() const
360//-----------------------------------------------------------------------------
361template <typename TCoordinate, typename TInteger, unsigned short adjacency>
363typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Integer
364DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::mu() const
369//-----------------------------------------------------------------------------
370template <typename TCoordinate, typename TInteger, unsigned short adjacency>
372typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Integer
373DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::omega() const
375 return remainder(myShift);
378//-----------------------------------------------------------------------------
379template <typename TCoordinate, typename TInteger, unsigned short adjacency>
381typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Position
382DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::patternLength() const
384 return ( -static_cast<Position>(myShift[1]) * static_cast<Position>(myB)
385 +static_cast<Position>(myShift[0]) * static_cast<Position>(myA) );
388//-----------------------------------------------------------------------------
389template <typename TCoordinate, typename TInteger, unsigned short adjacency>
391typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Vector
392DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::shift() const
397//-----------------------------------------------------------------------------
398template <typename TCoordinate, typename TInteger, unsigned short adjacency>
400typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Steps
401DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::steps() const
406//-----------------------------------------------------------------------------
407template <typename TCoordinate, typename TInteger, unsigned short adjacency>
409typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Integer
410DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::remainder(const Coordinate& aA,
411 const Coordinate& aB,
414 return static_cast<Integer>(aA) * static_cast<Integer>(aPoint[0])
415 - static_cast<Integer>(aB) * static_cast<Integer>(aPoint[1]);
418//-----------------------------------------------------------------------------
419template <typename TCoordinate, typename TInteger, unsigned short adjacency>
421typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Integer
422DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::remainder(const Point& aPoint) const
424 return DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::remainder(myA, myB, aPoint);
427//-----------------------------------------------------------------------------
428template <typename TCoordinate, typename TInteger, unsigned short adjacency>
430typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Integer
431DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::orthogonalPosition(const Point& aPoint) const
433 return static_cast<Integer>(myB) * static_cast<Integer>(aPoint[0])
434 + static_cast<Integer>(myA) * static_cast<Integer>(aPoint[1]);
437//-----------------------------------------------------------------------------
438template <typename TCoordinate, typename TInteger, unsigned short adjacency>
440typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Position
441DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::position(const Point& aPoint) const
443 return ( -static_cast<Position>(myShift[1]) * static_cast<Position>(aPoint[0])
444 +static_cast<Position>(myShift[0]) * static_cast<Position>(aPoint[1]) );
447//-----------------------------------------------------------------------------
448template <typename TCoordinate, typename TInteger, unsigned short adjacency>
450typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Point
451DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::getPoint() const
453 ASSERT( omega() != NumberTraits<Integer>::ZERO );
455 Integer shiftRemainder = omega();
456 Integer q = ( myLowerBound / shiftRemainder );
457 if ( (myLowerBound >= NumberTraits<Integer>::ZERO)
458 &&(myLowerBound != (q * shiftRemainder)) )
460 Point origin = toCoordinate(q) * myShift;
462 ASSERT( position(origin) == NumberTraits<Position>::ZERO );
463 ASSERT( isInDSL(origin) );
468//-----------------------------------------------------------------------------
469template <typename TCoordinate, typename TInteger, unsigned short adjacency>
471typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Point
472DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::getPoint(const Position& aPosition) const
474 ASSERT( omega() != NumberTraits<Integer>::ZERO );
476 Integer shiftRemainder = omega();
477 Point startingPoint = static_cast<Coordinate>(aPosition) * mySteps.first;
478 Integer bound = (myLowerBound-remainder(startingPoint));
479 Integer q = ( bound / shiftRemainder );
480 if ( (bound >= NumberTraits<Integer>::ZERO)
481 &&(bound != (q * shiftRemainder)) )
483 Point res = startingPoint + (toCoordinate(q) * myShift);
485 ASSERT( position(res) == aPosition );
486 ASSERT( isInDSL(res) );
491//-----------------------------------------------------------------------------
492template <typename TCoordinate, typename TInteger, unsigned short adjacency>
495DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::before(const Point& aP1, const Point& aP2) const
497 return ( position( aP1 ) < position( aP2 ) );
500//-----------------------------------------------------------------------------
501template <typename TCoordinate, typename TInteger, unsigned short adjacency>
504DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::beforeOrEqual(const Point& aP1, const Point& aP2) const
506 return ( position( aP1 ) <= position( aP2 ) );
509//-----------------------------------------------------------------------------
510template <typename TCoordinate, typename TInteger, unsigned short adjacency>
513DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::isInDSL(const Point& aPoint) const
515 Integer r = remainder(aPoint);
516 return ( (r >= myLowerBound)&&(r <= myUpperBound) );
520//------------------------------------------------------------------------------
521template <typename TCoordinate, typename TInteger, unsigned short adjacency>
524DGtal::ArithmeticalDSL<TCoordinate,TInteger,adjacency>::isUpperLeaningPoint(const Point& aPoint) const
526 return (remainder(aPoint)==myLowerBound);
529//----------------------------------------------------------------------------
530template <typename TCoordinate, typename TInteger, unsigned short adjacency>
533DGtal::ArithmeticalDSL<TCoordinate,TInteger,adjacency>::isLowerLeaningPoint(const Point& aPoint) const
535 return (remainder(aPoint)==myUpperBound);
539//-----------------------------------------------------------------------------
540template <typename TCoordinate, typename TInteger, unsigned short adjacency>
543DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::operator()(const Point& aPoint) const
545 return isInDSL(aPoint);
548//-----------------------------------------------------------------------------
549template <typename TCoordinate, typename TInteger, unsigned short adjacency>
551typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator
552DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::begin(const Point& aPoint) const
554 ASSERT( isInDSL(aPoint) );
555 return ConstIterator(this, aPoint);
558//-----------------------------------------------------------------------------
559template <typename TCoordinate, typename TInteger, unsigned short adjacency>
561typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator
562DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::end(const Point& aPoint) const
564 ASSERT( isInDSL(aPoint) );
565 ConstIterator it(this, aPoint);
570//-----------------------------------------------------------------------------
571template <typename TCoordinate, typename TInteger, unsigned short adjacency>
573typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstReverseIterator
574DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::rbegin(const Point& aPoint) const
576 ASSERT( isInDSL(aPoint) );
577 return ConstReverseIterator( end(aPoint) );
580//-----------------------------------------------------------------------------
581template <typename TCoordinate, typename TInteger, unsigned short adjacency>
583typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstReverseIterator
584DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::rend(const Point& aPoint) const
586 ASSERT( isInDSL(aPoint) );
587 return ConstReverseIterator( begin(aPoint) );
590//-----------------------------------------------------------------------------
591template <typename TCoordinate, typename TInteger, unsigned short adjacency>
594DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::selfDisplay ( std::ostream & out ) const
596 out << "[ArithmeticalDSL] ";
597 out << "(" << myA << "," << myB << "," << myLowerBound << "," << omega() << ")" << std::endl;
598 out << "by steps " << mySteps.first << " " << mySteps.second << std::endl;
601//-----------------------------------------------------------------------------
602template <typename TCoordinate, typename TInteger, unsigned short adjacency>
604typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Coordinate
605DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::toCoordinate(const Integer& aI)
607 return DGtal::detail::toCoordinateImpl<Integer, Coordinate>::cast(aI);
610///////////////////////////////////////////////////////////////////////////////
611// Iterators services //
612///////////////////////////////////////////////////////////////////////////////
613//-----------------------------------------------------------------------------
614template <typename TCoordinate, typename TInteger, unsigned short adjacency>
616DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::ConstIterator()
617 : myDSLPtr(0), myCurrentPoint()
621//-----------------------------------------------------------------------------
622template <typename TCoordinate, typename TInteger, unsigned short adjacency>
624DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator
625::ConstIterator( const ArithmeticalDSL* aDSL, const Point& aPoint )
626 : myDSLPtr(aDSL), myCurrentPoint(aPoint)
628 myQuantityToAdd = myDSLPtr->remainder(myDSLPtr->mySteps.first);
629 myQuantityToRemove = myQuantityToAdd - myDSLPtr->remainder(myDSLPtr->mySteps.second);
630 myCurrentRemainder = myDSLPtr->remainder( myCurrentPoint );
633//-----------------------------------------------------------------------------
634template <typename TCoordinate, typename TInteger, unsigned short adjacency>
636DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::
637ConstIterator( const ConstIterator & aOther )
638 : myDSLPtr( aOther.myDSLPtr ), myCurrentPoint( aOther.myCurrentPoint ),
639 myQuantityToAdd( aOther.myQuantityToAdd ),
640 myQuantityToRemove( aOther.myQuantityToRemove ),
641 myCurrentRemainder( aOther.myCurrentRemainder )
645//-----------------------------------------------------------------------------
646template <typename TCoordinate, typename TInteger, unsigned short adjacency>
648typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator&
649DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::
650operator= ( const ConstIterator & aOther )
654 myDSLPtr = aOther.myDSLPtr;
655 myCurrentPoint = aOther.myCurrentPoint;
656 myQuantityToAdd = aOther.myQuantityToAdd;
657 myQuantityToRemove = aOther.myQuantityToRemove;
658 myCurrentRemainder = aOther.myCurrentRemainder;
663//-----------------------------------------------------------------------------
664template <typename TCoordinate, typename TInteger, unsigned short adjacency>
666DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::~ConstIterator()
670//-----------------------------------------------------------------------------
671template <typename TCoordinate, typename TInteger, unsigned short adjacency>
673typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Integer
674DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::remainder() const
676 return myCurrentRemainder;
679//-----------------------------------------------------------------------------
680template <typename TCoordinate, typename TInteger, unsigned short adjacency>
682typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Point const
683DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::dereference() const
685 return myCurrentPoint;
688//-----------------------------------------------------------------------------
689template <typename TCoordinate, typename TInteger, unsigned short adjacency>
692DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::increment()
694 myCurrentRemainder += myQuantityToAdd;
695 if ( myCurrentRemainder <= myDSLPtr->myUpperBound )
697 myCurrentPoint += myDSLPtr->mySteps.first;
701 myCurrentRemainder -= myQuantityToRemove;
702 myCurrentPoint += myDSLPtr->mySteps.second;
706//-----------------------------------------------------------------------------
707template <typename TCoordinate, typename TInteger, unsigned short adjacency>
710DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::decrement()
712 myCurrentRemainder -= myQuantityToAdd;
713 if ( myCurrentRemainder >= myDSLPtr->myLowerBound )
715 myCurrentPoint -= myDSLPtr->mySteps.first;
719 myCurrentRemainder += myQuantityToRemove;
720 myCurrentPoint -= myDSLPtr->mySteps.second;
724//-----------------------------------------------------------------------------
725template <typename TCoordinate, typename TInteger, unsigned short adjacency>
728DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::
729equal(const ConstIterator& aOther) const
731 ASSERT( myDSLPtr == aOther.myDSLPtr );
732 return myCurrentPoint == aOther.myCurrentPoint;
735//-----------------------------------------------------------------------------
736template <typename TCoordinate, typename TInteger, unsigned short adjacency>
739DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator
740::advance(const Position& aShift)
742 myCurrentPoint = myDSLPtr->getPoint( myDSLPtr->position(myCurrentPoint) + aShift );
745//-----------------------------------------------------------------------------
746template <typename TCoordinate, typename TInteger, unsigned short adjacency>
748typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Position
749DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator
750::distance_to(const ConstIterator& aOther) const
752 return ( myDSLPtr->position(aOther.myCurrentPoint) - myDSLPtr->position(myCurrentPoint) );
755///////////////////////////////////////////////////////////////////////////////
757///////////////////////////////////////////////////////////////////////////////
759//-----------------------------------------------------------------------------
760template <typename TCoordinate, typename TI>
762DGtal::StandardDSL<TCoordinate, TI>::
763StandardDSL(const Coordinate& aA,
764 const Coordinate& aB,
769//-----------------------------------------------------------------------------
770template <typename TCoordinate, typename TI>
772DGtal::StandardDSL<TCoordinate, TI>::
773StandardDSL ( const StandardDSL & aOther )
777//-----------------------------------------------------------------------------
778template <typename TCoordinate, typename TI>
780DGtal::StandardDSL<TCoordinate, TI>&
781DGtal::StandardDSL<TCoordinate, TI>::
782operator= ( const StandardDSL & aOther )
784 if (this != & aOther)
785 Super::operator=( aOther );
789//-----------------------------------------------------------------------------
790template <typename TCoordinate, typename TI>
792DGtal::NaiveDSL<TCoordinate, TI>::
793NaiveDSL(const Coordinate& aA,
794 const Coordinate& aB,
799//-----------------------------------------------------------------------------
800template <typename TCoordinate, typename TI>
802DGtal::NaiveDSL<TCoordinate, TI>::
803NaiveDSL ( const NaiveDSL & aOther )
807//-----------------------------------------------------------------------------
808template <typename TCoordinate, typename TI>
810DGtal::NaiveDSL<TCoordinate, TI>&
811DGtal::NaiveDSL<TCoordinate, TI>::
812operator= ( const NaiveDSL & aOther )
814 if (this != & aOther)
815 Super::operator=( aOther );
819///////////////////////////////////////////////////////////////////////////////
820// Implementation of inline functions //
822template <typename TCoordinate, typename TInteger, unsigned short adjacency>
825DGtal::operator<< ( std::ostream & out,
826 const ArithmeticalDSL<TCoordinate, TInteger, adjacency> & object )
828 object.selfDisplay( out );
833///////////////////////////////////////////////////////////////////////////////