DGtal  1.5.beta
Simple2x2DetComputer.ih
1 /**
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.
6  *
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.
11  *
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/>.
14  *
15  **/
16 
17 /**
18  * @file Simple2x2DetComputer.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
21  *
22  * @date 2013/11/18
23  *
24  * Implementation of inline methods defined in Simple2x2DetComputer.h
25  *
26  * This file is part of the DGtal library.
27  */
28 
29 
30 //////////////////////////////////////////////////////////////////////////////
31 #include <cstdlib>
32 //////////////////////////////////////////////////////////////////////////////
33 
34 ///////////////////////////////////////////////////////////////////////////////
35 // IMPLEMENTATION of inline methods.
36 ///////////////////////////////////////////////////////////////////////////////
37 
38 ///////////////////////////////////////////////////////////////////////////////
39 // ---------------------------------------------------------------------------
40 template <typename TI, typename TO>
41 inline
42 DGtal::Simple2x2DetComputer<TI,TO>::Simple2x2DetComputer()
43  : myA (NumberTraits<ResultInteger>::ZERO),
44  myB (NumberTraits<ResultInteger>::ZERO),
45  myAY (NumberTraits<ResultInteger>::ZERO),
46  myBX (NumberTraits<ResultInteger>::ZERO)
47 {
48 }
49 
50 // ---------------------------------------------------------------------------
51 template <typename TI, typename TO>
52 inline
53 DGtal::Simple2x2DetComputer<TI,TO>::Simple2x2DetComputer(const DGtal::Simple2x2DetComputer<TI,TO>& aOther)
54  : myA (aOther.myA),
55  myB (aOther.myB),
56  myAY (aOther.myAY),
57  myBX (aOther.myBX)
58 {
59 }
60 
61 // ---------------------------------------------------------------------------
62 template <typename TI, typename TO>
63 inline
64 DGtal::Simple2x2DetComputer<TI,TO>&
65 DGtal::Simple2x2DetComputer<TI,TO>::operator=(const DGtal::Simple2x2DetComputer<TI,TO>& aOther)
66 {
67  if (this != &aOther)
68  {
69  myA = aOther.myA;
70  myB = aOther.myB;
71  myAY = aOther.myAY;
72  myBX = aOther.myBX;
73  }
74  return *this;
75 }
76 
77 // ---------------------------------------------------------------------------
78 template <typename TI, typename TO>
79 inline
80 DGtal::Simple2x2DetComputer<TI,TO>::~Simple2x2DetComputer()
81 {
82 }
83 
84 // ---------------------------------------------------------------------------
85 template <typename TI, typename TO>
86 inline
87 void
88 DGtal::Simple2x2DetComputer<TI,TO>::init(const ArgumentInteger& aA, const ArgumentInteger& aB)
89 {
90  myA = static_cast<ResultInteger>(aA);
91  myB = static_cast<ResultInteger>(aB);
92 }
93 
94 // ---------------------------------------------------------------------------
95 template <typename TI, typename TO>
96 inline
97 typename DGtal::Simple2x2DetComputer<TI,TO>::ResultInteger
98 DGtal::Simple2x2DetComputer<TI,TO>::operator()(const ArgumentInteger& aX, const ArgumentInteger& aY) const
99 {
100  myAY = myA * static_cast<ResultInteger>(aY);
101  myBX = myB * static_cast<ResultInteger>(aX);
102  return myAY - myBX;
103 }
104 
105 // ---------------------------------------------------------------------------
106 template <typename TI, typename TO>
107 inline
108 typename DGtal::Simple2x2DetComputer<TI,TO>::ResultInteger
109 DGtal::Simple2x2DetComputer<TI,TO>::operator()(const ArgumentInteger& aA, const ArgumentInteger& aB,
110  const ArgumentInteger& aX, const ArgumentInteger& aY)
111 {
112  init(aA,aB);
113  return operator()(aX, aY);
114 }
115 
116 // ---------------------------------------------------------------------------
117 template <typename TI, typename TO>
118 inline
119 void
120 DGtal::Simple2x2DetComputer<TI,TO>::selfDisplay ( std::ostream & out ) const
121 {
122  out << "[Simple2x2DetComputer]";
123 }
124 
125 // ---------------------------------------------------------------------------
126 template <typename TI, typename TO>
127 inline
128 bool
129 DGtal::Simple2x2DetComputer<TI,TO>::isValid() const
130 {
131  return true;
132 }
133 
134 
135 
136 ///////////////////////////////////////////////////////////////////////////////
137 // Implementation of inline functions //
138 
139 template <typename TI, typename TO>
140 inline
141 std::ostream&
142 DGtal::operator<< ( std::ostream & out,
143  const Simple2x2DetComputer<TI,TO> & object )
144 {
145  object.selfDisplay( out );
146  return out;
147 }
148 
149 // //
150 ///////////////////////////////////////////////////////////////////////////////
151 
152