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/math/common_factor_rt.hpp>
36 //////////////////////////////////////////////////////////////////////////////
42 ///////////////////////////////////////////////////////////////////////////////
43 // Implementation of inline methods //
45 //-----------------------------------------------------------------------------
46 template <typename TIterator, typename TInteger, unsigned short adjacency>
48 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::
49 ArithmeticalDSSComputer()
50 : myDSS( Point(0,0) ), myBegin(), myEnd()
55 //-----------------------------------------------------------------------------
56 template <typename TIterator, typename TInteger, unsigned short adjacency>
58 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::
59 ArithmeticalDSSComputer(const ConstIterator& it)
60 : myDSS( *it ), myBegin(it), myEnd(it)
65 //-----------------------------------------------------------------------------
66 template <typename TIterator, typename TInteger, unsigned short adjacency>
68 void DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::
69 init(const ConstIterator& it)
78 //-----------------------------------------------------------------------------
79 template <typename TIterator, typename TInteger, unsigned short adjacency>
81 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::
82 ArithmeticalDSSComputer ( const ArithmeticalDSSComputer<TIterator,TInteger,adjacency> & other )
83 : myDSS(other.myDSS), myBegin(other.myBegin), myEnd(other.myEnd)
87 //-----------------------------------------------------------------------------
88 template <typename TIterator, typename TInteger, unsigned short adjacency>
90 typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>&
91 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::
92 operator=( const ArithmeticalDSSComputer<TIterator,TInteger,adjacency> & other )
97 myBegin = other.myBegin;
103 //-----------------------------------------------------------------------------
104 template <typename TIterator, typename TInteger, unsigned short adjacency>
106 typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Reverse
107 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>
113 //-----------------------------------------------------------------------------
114 template <typename TIterator, typename TInteger, unsigned short adjacency>
116 typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Self
117 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>
123 //-----------------------------------------------------------------------------
124 template <typename TIterator, typename TInteger, unsigned short adjacency>
127 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::
128 operator==( const ArithmeticalDSSComputer<TIterator,TInteger,adjacency>& other ) const
130 return ( (myBegin == other.myBegin)
131 && (myEnd == other.myEnd)
132 && (myDSS == other.myDSS) );
135 //-----------------------------------------------------------------------------
136 template <typename TIterator, typename TInteger, unsigned short adjacency>
139 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::
140 operator!=( const ArithmeticalDSSComputer<TIterator,TInteger,adjacency> & other ) const
142 return (!(*this == other));
145 ///////////////////////////////////////////////////////////////////////////////
147 ///////////////////////////////////////////////////////////////////////////////
148 //--------------------------------------------------------------------
149 template <typename TIterator, typename TInteger, unsigned short adjacency>
152 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::isExtendableFront()
154 return myDSS.isExtendableFront( *myEnd );
157 //--------------------------------------------------------------------
158 template <typename TIterator, typename TInteger, unsigned short adjacency>
161 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::isExtendableBack()
163 ConstIterator it = myBegin;
165 return myDSS.isExtendableBack( *it );
168 //-----------------------------------------------------------------------------
169 template <typename TIterator, typename TInteger, unsigned short adjacency>
172 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::extendFront()
174 if (myDSS.extendFront(*myEnd))
183 //--------------------------------------------------------------------
184 template <typename TIterator, typename TInteger, unsigned short adjacency>
187 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::extendBack()
189 ConstIterator it = myBegin;
191 if (myDSS.extendBack(*it))
200 //--------------------------------------------------------------------
201 template <typename TIterator, typename TInteger, unsigned short adjacency>
204 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::retractFront()
206 if (myDSS.retractFront())
215 //--------------------------------------------------------------------
216 template <typename TIterator, typename TInteger, unsigned short adjacency>
219 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::retractBack()
221 if (myDSS.retractBack())
230 ///////////////////////////////////////////////////////////////////////////////
232 ///////////////////////////////////////////////////////////////////////////////
233 //-------------------------------------------------------------------------
234 template <typename TIterator, typename TInteger, unsigned short adjacency>
236 const typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Primitive&
237 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::primitive() const
242 //-------------------------------------------------------------------------
243 template <typename TIterator, typename TInteger, unsigned short adjacency>
246 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::remainder(const Point & aPoint) const
248 return myDSS.remainder( aPoint );
251 //-------------------------------------------------------------------------
252 template <typename TIterator, typename TInteger, unsigned short adjacency>
255 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::remainder(const ConstIterator & it) const
257 return remainder(*it);
260 //-------------------------------------------------------------------------
261 template <typename TIterator, typename TInteger, unsigned short adjacency>
264 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::position(const Point & aPoint) const
266 return myDSS.position( aPoint );
269 //-------------------------------------------------------------------------
270 template <typename TIterator, typename TInteger, unsigned short adjacency>
273 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::position(const ConstIterator & it) const
275 return position(*it);
278 //-------------------------------------------------------------------------
279 template <typename TIterator, typename TInteger, unsigned short adjacency>
282 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::isInDSL(const Point & aPoint) const
284 return myDSS.isInDSL( aPoint );
287 //-------------------------------------------------------------------------
288 template <typename TIterator, typename TInteger, unsigned short adjacency>
291 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::isInDSL(const ConstIterator & it) const
296 //-------------------------------------------------------------------------
297 template <typename TIterator, typename TInteger, unsigned short adjacency>
300 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::isInDSS(const Point & aPoint) const
302 return myDSS.isInDSS( aPoint );
305 //-------------------------------------------------------------------------
306 template <typename TIterator, typename TInteger, unsigned short adjacency>
309 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::isInDSS(const ConstIterator & it) const
314 //-------------------------------------------------------------------------
315 template <typename TIterator, typename TInteger, unsigned short adjacency>
318 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::a() const
323 //-------------------------------------------------------------------------
324 template <typename TIterator, typename TInteger, unsigned short adjacency>
327 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::b() const
332 //-------------------------------------------------------------------------
333 template <typename TIterator, typename TInteger, unsigned short adjacency>
336 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::mu() const
341 //-------------------------------------------------------------------------
342 template <typename TIterator, typename TInteger, unsigned short adjacency>
345 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::omega() const
347 return myDSS.omega();
350 //-------------------------------------------------------------------------
351 template <typename TIterator, typename TInteger, unsigned short adjacency>
353 typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Point
354 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Uf() const
359 //-------------------------------------------------------------------------
360 template <typename TIterator, typename TInteger, unsigned short adjacency>
362 typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Point
363 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Ul() const
368 //-------------------------------------------------------------------------
369 template <typename TIterator, typename TInteger, unsigned short adjacency>
371 typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Point
372 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Lf() const
377 //-------------------------------------------------------------------------
378 template <typename TIterator, typename TInteger, unsigned short adjacency>
380 typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Point
381 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Ll() const
386 //-------------------------------------------------------------------------
387 template <typename TIterator, typename TInteger, unsigned short adjacency>
389 typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Point
390 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::back() const
395 //-------------------------------------------------------------------------
396 template <typename TIterator, typename TInteger, unsigned short adjacency>
398 typename DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::Point
399 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::front() const
401 return myDSS.front();
404 //-------------------------------------------------------------------------
405 template <typename TIterator, typename TInteger, unsigned short adjacency>
408 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::begin() const
413 //-------------------------------------------------------------------------
414 template <typename TIterator, typename TInteger, unsigned short adjacency>
417 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::end() const
422 //-----------------------------------------------------------------
423 template <typename TIterator, typename TInteger, unsigned short adjacency>
426 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::isValid() const
428 return ( (myDSS.isValid())&&(isNotEmpty(myBegin,myEnd)) );
431 //-----------------------------------------------------------------
432 template <typename TIterator, typename TInteger, unsigned short adjacency>
435 DGtal::ArithmeticalDSSComputer<TIterator,TInteger,adjacency>::selfDisplay ( std::ostream & out) const
437 out << "[ArithmeticalDSSComputer] " << myDSS;
440 ///////////////////////////////////////////////////////////////////////////////
442 ///////////////////////////////////////////////////////////////////////////////
443 //-----------------------------------------------------------------------------
444 template <typename TIterator, typename TInteger>
446 DGtal::StandardDSS4Computer<TIterator,TInteger>::
447 StandardDSS4Computer()
453 //-----------------------------------------------------------------------------
454 template <typename TIterator, typename TInteger>
456 DGtal::StandardDSS4Computer<TIterator,TInteger>::
457 StandardDSS4Computer(const ConstIterator& it)
462 //-----------------------------------------------------------------------------
463 template <typename TIterator, typename TInteger>
465 DGtal::StandardDSS4Computer<TIterator,TInteger>::
466 StandardDSS4Computer ( const StandardDSS4Computer<TIterator,TInteger> & other )
471 //-----------------------------------------------------------------------------
472 template <typename TIterator, typename TInteger>
474 typename DGtal::StandardDSS4Computer<TIterator,TInteger>&
475 DGtal::StandardDSS4Computer<TIterator,TInteger>::
476 operator=( const StandardDSS4Computer<TIterator,TInteger> & other )
479 Super::operator=( other );
483 //-----------------------------------------------------------------------------
484 template <typename TIterator, typename TInteger>
486 DGtal::NaiveDSS8Computer<TIterator,TInteger>::
493 //-----------------------------------------------------------------------------
494 template <typename TIterator, typename TInteger>
496 DGtal::NaiveDSS8Computer<TIterator,TInteger>::
497 NaiveDSS8Computer(const ConstIterator& it)
502 //-----------------------------------------------------------------------------
503 template <typename TIterator, typename TInteger>
505 DGtal::NaiveDSS8Computer<TIterator,TInteger>::
506 NaiveDSS8Computer ( const NaiveDSS8Computer<TIterator,TInteger> & other )
511 //-----------------------------------------------------------------------------
512 template <typename TIterator, typename TInteger>
514 typename DGtal::NaiveDSS8Computer<TIterator,TInteger>&
515 DGtal::NaiveDSS8Computer<TIterator,TInteger>::
516 operator=( const NaiveDSS8Computer<TIterator,TInteger> & other )
519 Super::operator=( other );