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