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 ArithmeticalDSSComputer.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 ArithmeticalDSSComputer.h
26 * This file is part of the DGtal library.
29///////////////////////////////////////////////////////////////////////////////
30// IMPLEMENTATION of inline methods.
31///////////////////////////////////////////////////////////////////////////////
33//////////////////////////////////////////////////////////////////////////////
35#include <boost/version.hpp>
36#if BOOST_VERSION < 105800
37#include <boost/math/common_factor_rt.hpp>
39#include <boost/integer/common_factor_rt.hpp>
42//////////////////////////////////////////////////////////////////////////////
48///////////////////////////////////////////////////////////////////////////////
49// Implementation of inline methods //
51//-----------------------------------------------------------------------------
52template <typename TIterator, typename TInteger, unsigned short adjacency>
54DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::
55ArithmeticalDSSComputer()
56 : myDSS( Point(0,0) ), myBegin(), myEnd()
61//-----------------------------------------------------------------------------
62template <typename TIterator, typename TInteger, unsigned short adjacency>
64DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::
65ArithmeticalDSSComputer(const ConstIterator& it)
66 : myDSS( *it ), myBegin(it), myEnd(it)
71//-----------------------------------------------------------------------------
72template <typename TIterator, typename TInteger, unsigned short adjacency>
74void DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::
75init(const ConstIterator& it)
84//-----------------------------------------------------------------------------
85template <typename TIterator, typename TInteger, unsigned short adjacency>
87DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::
88ArithmeticalDSSComputer ( const ArithmeticalDSSComputer<TIterator,TInteger,adjacency> & other )
89 : myDSS(other.myDSS), myBegin(other.myBegin), myEnd(other.myEnd)
93//-----------------------------------------------------------------------------
94template <typename TIterator, typename TInteger, unsigned short adjacency>
96typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>&
97DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::
98operator=( const ArithmeticalDSSComputer<TIterator,TInteger,adjacency> & other )
100 if ( this != &other )
103 myBegin = other.myBegin;
109//-----------------------------------------------------------------------------
110template <typename TIterator, typename TInteger, unsigned short adjacency>
112typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Reverse
113DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>
119//-----------------------------------------------------------------------------
120template <typename TIterator, typename TInteger, unsigned short adjacency>
122typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Self
123DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>
129//-----------------------------------------------------------------------------
130template <typename TIterator, typename TInteger, unsigned short adjacency>
133DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::
134operator==( const ArithmeticalDSSComputer<TIterator,TInteger,adjacency>& other ) const
136 return ( (myBegin == other.myBegin)
137 && (myEnd == other.myEnd)
138 && (myDSS == other.myDSS) );
141//-----------------------------------------------------------------------------
142template <typename TIterator, typename TInteger, unsigned short adjacency>
145DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::
146operator!=( const ArithmeticalDSSComputer<TIterator,TInteger,adjacency> & other ) const
148 return (!(*this == other));
151///////////////////////////////////////////////////////////////////////////////
153///////////////////////////////////////////////////////////////////////////////
154//--------------------------------------------------------------------
155template <typename TIterator, typename TInteger, unsigned short adjacency>
158DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::isExtendableFront()
160 return myDSS.isExtendableFront( *myEnd );
163//--------------------------------------------------------------------
164template <typename TIterator, typename TInteger, unsigned short adjacency>
167DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::isExtendableBack()
169 ConstIterator it = myBegin;
171 return myDSS.isExtendableBack( *it );
174//-----------------------------------------------------------------------------
175template <typename TIterator, typename TInteger, unsigned short adjacency>
178DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::extendFront()
180 if (myDSS.extendFront(*myEnd))
189//--------------------------------------------------------------------
190template <typename TIterator, typename TInteger, unsigned short adjacency>
193DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::extendBack()
195 ConstIterator it = myBegin;
197 if (myDSS.extendBack(*it))
206//--------------------------------------------------------------------
207template <typename TIterator, typename TInteger, unsigned short adjacency>
210DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::retractFront()
212 if (myDSS.retractFront())
221//--------------------------------------------------------------------
222template <typename TIterator, typename TInteger, unsigned short adjacency>
225DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::retractBack()
227 if (myDSS.retractBack())
236///////////////////////////////////////////////////////////////////////////////
238///////////////////////////////////////////////////////////////////////////////
239//-------------------------------------------------------------------------
240template <typename TIterator, typename TInteger, unsigned short adjacency>
242const typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Primitive&
243DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::primitive() const
248//-------------------------------------------------------------------------
249template <typename TIterator, typename TInteger, unsigned short adjacency>
252DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::remainder(const Point & aPoint) const
254 return myDSS.remainder( aPoint );
257//-------------------------------------------------------------------------
258template <typename TIterator, typename TInteger, unsigned short adjacency>
261DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::remainder(const ConstIterator & it) const
263 return remainder(*it);
266//-------------------------------------------------------------------------
267template <typename TIterator, typename TInteger, unsigned short adjacency>
270DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::position(const Point & aPoint) const
272 return myDSS.position( aPoint );
275//-------------------------------------------------------------------------
276template <typename TIterator, typename TInteger, unsigned short adjacency>
279DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::position(const ConstIterator & it) const
281 return position(*it);
284//-------------------------------------------------------------------------
285template <typename TIterator, typename TInteger, unsigned short adjacency>
288DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::isInDSL(const Point & aPoint) const
290 return myDSS.isInDSL( aPoint );
293//-------------------------------------------------------------------------
294template <typename TIterator, typename TInteger, unsigned short adjacency>
297DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::isInDSL(const ConstIterator & it) const
302//-------------------------------------------------------------------------
303template <typename TIterator, typename TInteger, unsigned short adjacency>
306DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::isInDSS(const Point & aPoint) const
308 return myDSS.isInDSS( aPoint );
311//-------------------------------------------------------------------------
312template <typename TIterator, typename TInteger, unsigned short adjacency>
315DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::isInDSS(const ConstIterator & it) const
320//-------------------------------------------------------------------------
321template <typename TIterator, typename TInteger, unsigned short adjacency>
324DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::a() const
329//-------------------------------------------------------------------------
330template <typename TIterator, typename TInteger, unsigned short adjacency>
333DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::b() const
338//-------------------------------------------------------------------------
339template <typename TIterator, typename TInteger, unsigned short adjacency>
342DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::mu() const
347//-------------------------------------------------------------------------
348template <typename TIterator, typename TInteger, unsigned short adjacency>
351DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::omega() const
353 return myDSS.omega();
356//-------------------------------------------------------------------------
357template <typename TIterator, typename TInteger, unsigned short adjacency>
359typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Point
360DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Uf() const
365//-------------------------------------------------------------------------
366template <typename TIterator, typename TInteger, unsigned short adjacency>
368typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Point
369DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Ul() const
374//-------------------------------------------------------------------------
375template <typename TIterator, typename TInteger, unsigned short adjacency>
377typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Point
378DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Lf() const
383//-------------------------------------------------------------------------
384template <typename TIterator, typename TInteger, unsigned short adjacency>
386typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Point
387DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Ll() const
392//-------------------------------------------------------------------------
393template <typename TIterator, typename TInteger, unsigned short adjacency>
395typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Point
396DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::back() const
401//-------------------------------------------------------------------------
402template <typename TIterator, typename TInteger, unsigned short adjacency>
404typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Point
405DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::front() const
407 return myDSS.front();
410//-------------------------------------------------------------------------
411template <typename TIterator, typename TInteger, unsigned short adjacency>
414DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::begin() const
419//-------------------------------------------------------------------------
420template <typename TIterator, typename TInteger, unsigned short adjacency>
423DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::end() const
428//-----------------------------------------------------------------
429template <typename TIterator, typename TInteger, unsigned short adjacency>
432DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::isValid() const
434 return ( (myDSS.isValid())&&(isNotEmpty(myBegin,myEnd)) );
437//-----------------------------------------------------------------
438template <typename TIterator, typename TInteger, unsigned short adjacency>
441DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::selfDisplay ( std::ostream & out) const
443 out << "[ArithmeticalDSSComputer] " << myDSS;