DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TwoStepLocalLengthEstimator.ih
1 
30 
31 #include <cstdlib>
33 
35 // IMPLEMENTATION of inline methods.
37 
39 // ----------------------- Standard services ------------------------------
40 
41 
42 
46 template <typename T>
47 inline
49 {
50 }
51 
52 
53 
55 // Interface - public :
56 
57 
58 
59 template <typename T>
60 inline
61 void
63  const ConstIterator& itb,
64  const ConstIterator& ite,
65  const bool& )
66 {
67  myH = h;
68  myBeginIt = itb;
69  myEndIt = ite;
70  myIsInitBefore = true;
71 }
72 
73 template <typename T>
74 inline
77 {
78  ASSERT(myH > 0);
79  ASSERT(myIsInitBefore);
80  ASSERT(myBeginIt != myEndIt);
81 
82  unsigned int nbDirect=0;
83  unsigned int nbDiag=0;
84 
85  ConstIterator i = myBeginIt, ii = myBeginIt;
86  ++ii;
87 
88  while (( i != myEndIt) && (ii != myEndIt))
89  {
90  if (((*i).second).dot((*ii).second) == 0)
91  nbDiag++;
92  else
93  nbDirect+=2;
94 
95  ++i;
96  if (i == myEndIt)
97  continue;
98  ++i;
99 
100  ++ii;
101  if (ii == myEndIt)
102  continue;
103  ++ii;
104  }
105 
106  if ( i!= myEndIt)
107  nbDirect ++;
108 
109  return (nbDiag*myWeightDiagonal + nbDirect*myWeightDirect)*myH;
110 }
111 
112 
113 
114 
115 
116 
117 
122 template <typename T>
123 inline
124 void
126 {
127  out << "[TwoStepLocalLengthEstimator]";
128  if (myIsInitBefore)
129  out <<" myH="<<myH;
130  else
131  out<< " not initialized";
132 }
133 
138 template <typename T>
139 inline
140 bool
142 {
143  return myIsInitBefore;
144 }
145 
146 
147 
149 // Implementation of inline functions //
150 
151 template <typename T>
152 inline
153 std::ostream&
154 DGtal::operator<< ( std::ostream & out,
155  const TwoStepLocalLengthEstimator<T> & object )
156 {
157  object.selfDisplay( out );
158  return out;
159 }
160 
161 // //
163 
164