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 ------------------------------
41 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
43 DGtal::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 //-----------------------------------------------------------------------------
55 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
57 DGtal::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 //-----------------------------------------------------------------------------
72 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
74 DGtal::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 //-----------------------------------------------------------------------------
83 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
85 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>&
86 DGtal::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 //-----------------------------------------------------------------------------
102 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
104 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>
105 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>
108 return DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>(-myA, -myB, -myUpperBound, -myLowerBound,
109 std::make_pair(-mySteps.first, -mySteps.second),
113 //-----------------------------------------------------------------------------
114 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
117 DGtal::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 //-----------------------------------------------------------------------------
128 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
131 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>
132 ::operator==(const ArithmeticalDSL<TCoordinate, TInteger, adjacency>& aOther) const
134 return ( equalsTo(aOther) || equalsTo(aOther.negate()) );
137 //-----------------------------------------------------------------------------
138 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
141 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>
142 ::operator!=(const ArithmeticalDSL<TCoordinate, TInteger, adjacency>& aOther) const
144 return !( operator==(aOther) );
147 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
150 DGtal::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 // ----------------------------------------------------------------------------
177 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
179 typename DGtal::ArithmeticalDSL<TCoordinate,TInteger,adjacency>::Octant
180 DGtal::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 //-----------------------------------------------------------------------------
286 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
288 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::~ArithmeticalDSL()
292 //-----------------------------------------------------------------------------
293 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
296 DGtal::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 //-----------------------------------------------------------------------------
317 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
320 DGtal::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 //-----------------------------------------------------------------------------
343 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
345 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Coordinate
346 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::a() const
351 //-----------------------------------------------------------------------------
352 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
354 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Coordinate
355 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::b() const
360 //-----------------------------------------------------------------------------
361 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
363 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Integer
364 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::mu() const
369 //-----------------------------------------------------------------------------
370 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
372 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Integer
373 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::omega() const
375 return remainder(myShift);
378 //-----------------------------------------------------------------------------
379 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
381 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Position
382 DGtal::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 //-----------------------------------------------------------------------------
389 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
391 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Vector
392 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::shift() const
397 //-----------------------------------------------------------------------------
398 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
400 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Steps
401 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::steps() const
406 //-----------------------------------------------------------------------------
407 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
409 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Integer
410 DGtal::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 //-----------------------------------------------------------------------------
419 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
421 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Integer
422 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::remainder(const Point& aPoint) const
424 return DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::remainder(myA, myB, aPoint);
427 //-----------------------------------------------------------------------------
428 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
430 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Integer
431 DGtal::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 //-----------------------------------------------------------------------------
438 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
440 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Position
441 DGtal::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 //-----------------------------------------------------------------------------
448 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
450 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Point
451 DGtal::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 //-----------------------------------------------------------------------------
469 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
471 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Point
472 DGtal::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 //-----------------------------------------------------------------------------
492 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
495 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::before(const Point& aP1, const Point& aP2) const
497 return ( position( aP1 ) < position( aP2 ) );
500 //-----------------------------------------------------------------------------
501 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
504 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::beforeOrEqual(const Point& aP1, const Point& aP2) const
506 return ( position( aP1 ) <= position( aP2 ) );
509 //-----------------------------------------------------------------------------
510 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
513 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::isInDSL(const Point& aPoint) const
515 Integer r = remainder(aPoint);
516 return ( (r >= myLowerBound)&&(r <= myUpperBound) );
520 //------------------------------------------------------------------------------
521 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
524 DGtal::ArithmeticalDSL<TCoordinate,TInteger,adjacency>::isUpperLeaningPoint(const Point& aPoint) const
526 return (remainder(aPoint)==myLowerBound);
529 //----------------------------------------------------------------------------
530 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
533 DGtal::ArithmeticalDSL<TCoordinate,TInteger,adjacency>::isLowerLeaningPoint(const Point& aPoint) const
535 return (remainder(aPoint)==myUpperBound);
539 //-----------------------------------------------------------------------------
540 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
543 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::operator()(const Point& aPoint) const
545 return isInDSL(aPoint);
548 //-----------------------------------------------------------------------------
549 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
551 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator
552 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::begin(const Point& aPoint) const
554 ASSERT( isInDSL(aPoint) );
555 return ConstIterator(this, aPoint);
558 //-----------------------------------------------------------------------------
559 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
561 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator
562 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::end(const Point& aPoint) const
564 ASSERT( isInDSL(aPoint) );
565 ConstIterator it(this, aPoint);
570 //-----------------------------------------------------------------------------
571 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
573 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstReverseIterator
574 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::rbegin(const Point& aPoint) const
576 ASSERT( isInDSL(aPoint) );
577 return ConstReverseIterator( end(aPoint) );
580 //-----------------------------------------------------------------------------
581 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
583 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstReverseIterator
584 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::rend(const Point& aPoint) const
586 ASSERT( isInDSL(aPoint) );
587 return ConstReverseIterator( begin(aPoint) );
590 //-----------------------------------------------------------------------------
591 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
594 DGtal::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 //-----------------------------------------------------------------------------
602 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
604 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Coordinate
605 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::toCoordinate(const Integer& aI)
607 return DGtal::detail::toCoordinateImpl<Integer, Coordinate>::cast(aI);
610 ///////////////////////////////////////////////////////////////////////////////
611 // Iterators services //
612 ///////////////////////////////////////////////////////////////////////////////
613 //-----------------------------------------------------------------------------
614 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
616 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::ConstIterator()
617 : myDSLPtr(0), myCurrentPoint()
621 //-----------------------------------------------------------------------------
622 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
624 DGtal::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 //-----------------------------------------------------------------------------
634 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
636 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::
637 ConstIterator( const ConstIterator & aOther )
638 : myDSLPtr( aOther.myDSLPtr ), myCurrentPoint( aOther.myCurrentPoint ),
639 myQuantityToAdd( aOther.myQuantityToAdd ),
640 myQuantityToRemove( aOther.myQuantityToRemove ),
641 myCurrentRemainder( aOther.myCurrentRemainder )
645 //-----------------------------------------------------------------------------
646 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
648 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator&
649 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::
650 operator= ( const ConstIterator & aOther )
654 myDSLPtr = aOther.myDSLPtr;
655 myCurrentPoint = aOther.myCurrentPoint;
656 myQuantityToAdd = aOther.myQuantityToAdd;
657 myQuantityToRemove = aOther.myQuantityToRemove;
658 myCurrentRemainder = aOther.myCurrentRemainder;
663 //-----------------------------------------------------------------------------
664 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
666 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::~ConstIterator()
670 //-----------------------------------------------------------------------------
671 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
673 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Integer
674 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::remainder() const
676 return myCurrentRemainder;
679 //-----------------------------------------------------------------------------
680 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
682 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Point const
683 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::dereference() const
685 return myCurrentPoint;
688 //-----------------------------------------------------------------------------
689 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
692 DGtal::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 //-----------------------------------------------------------------------------
707 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
710 DGtal::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 //-----------------------------------------------------------------------------
725 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
728 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator::
729 equal(const ConstIterator& aOther) const
731 ASSERT( myDSLPtr == aOther.myDSLPtr );
732 return myCurrentPoint == aOther.myCurrentPoint;
735 //-----------------------------------------------------------------------------
736 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
739 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator
740 ::advance(const Position& aShift)
742 myCurrentPoint = myDSLPtr->getPoint( myDSLPtr->position(myCurrentPoint) + aShift );
745 //-----------------------------------------------------------------------------
746 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
748 typename DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::Position
749 DGtal::ArithmeticalDSL<TCoordinate, TInteger, adjacency>::ConstIterator
750 ::distance_to(const ConstIterator& aOther) const
752 return ( myDSLPtr->position(aOther.myCurrentPoint) - myDSLPtr->position(myCurrentPoint) );
755 ///////////////////////////////////////////////////////////////////////////////
757 ///////////////////////////////////////////////////////////////////////////////
759 //-----------------------------------------------------------------------------
760 template <typename TCoordinate, typename TI>
762 DGtal::StandardDSL<TCoordinate, TI>::
763 StandardDSL(const Coordinate& aA,
764 const Coordinate& aB,
769 //-----------------------------------------------------------------------------
770 template <typename TCoordinate, typename TI>
772 DGtal::StandardDSL<TCoordinate, TI>::
773 StandardDSL ( const StandardDSL & aOther )
777 //-----------------------------------------------------------------------------
778 template <typename TCoordinate, typename TI>
780 DGtal::StandardDSL<TCoordinate, TI>&
781 DGtal::StandardDSL<TCoordinate, TI>::
782 operator= ( const StandardDSL & aOther )
784 if (this != & aOther)
785 Super::operator=( aOther );
789 //-----------------------------------------------------------------------------
790 template <typename TCoordinate, typename TI>
792 DGtal::NaiveDSL<TCoordinate, TI>::
793 NaiveDSL(const Coordinate& aA,
794 const Coordinate& aB,
799 //-----------------------------------------------------------------------------
800 template <typename TCoordinate, typename TI>
802 DGtal::NaiveDSL<TCoordinate, TI>::
803 NaiveDSL ( const NaiveDSL & aOther )
807 //-----------------------------------------------------------------------------
808 template <typename TCoordinate, typename TI>
810 DGtal::NaiveDSL<TCoordinate, TI>&
811 DGtal::NaiveDSL<TCoordinate, TI>::
812 operator= ( const NaiveDSL & aOther )
814 if (this != & aOther)
815 Super::operator=( aOther );
819 ///////////////////////////////////////////////////////////////////////////////
820 // Implementation of inline functions //
822 template <typename TCoordinate, typename TInteger, unsigned short adjacency>
825 DGtal::operator<< ( std::ostream & out,
826 const ArithmeticalDSL<TCoordinate, TInteger, adjacency> & object )
828 object.selfDisplay( out );
833 ///////////////////////////////////////////////////////////////////////////////