DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DSSLengthEstimator.ih
1 
33 
34 #include <cstdlib>
36 
38 // IMPLEMENTATION of inline methods.
40 
42 // ----------------------- Standard services ------------------------------
43 
47 template <typename T>
48 inline
50 {
51  myIsInitBefore = false;
52 }
53 
57 template <typename T>
58 inline
60 {
61 }
62 
63 
64 
66 // Interface - public :
67 
68 
69 
70 template <typename T>
71 inline
72 void
74  const ConstIterator& itb, const ConstIterator& ite, const bool& isClosed)
75 {
76  myH = h;
77  myIsInitBefore = true;
78  myRep.clear();
79 
80  //segments into DSS
81  DSSComputer computer;
82  deprecated::GreedyDecomposition<DSSComputer> decomposition ( itb, ite, computer, isClosed );
83 
84  //computes the resulting polygonal representation
86  for ( ; segIt != decomposition.end(); ++segIt ) {
87  myRep.push_back( *segIt.getBack() );
88  }
89  //last point
90  ConstIterator i( segIt.getFront() );
91  myRep.push_back(*--i);
92 }
93 
94 template <typename T>
95 inline
98 {
99  ASSERT(myH > 0);
100  ASSERT(myIsInitBefore);
101 
102  Quantity val = 0;
103 
104  if (myRep.size() > 1) {
105 
106  typename std::vector<Point>::const_iterator i = myRep.begin();
107  typename std::vector<Point>::const_iterator j = i;
108  ++j;
109  for ( ; j != myRep.end(); ++i, ++j) {
110  Vector v( *j - *i );
111  val += v.norm(Vector::L_2);
112  }
113 
114  }
115 
116  return val*myH;
117 }
118 
119 
120 
121 
122 
127 template <typename T>
128 inline
129 void
130 DGtal::DSSLengthEstimator<T>::selfDisplay ( std::ostream & out ) const
131 {
132  out << "[DSSLengthEstimator]";
133  if (myIsInitBefore)
134  out <<" myH="<<myH;
135  else
136  out<< " not initialized";
137 }
138 
143 template <typename T>
144 inline
145 bool
147 {
148  return myIsInitBefore;
149 }
150 
151 
152 
154 // Implementation of inline functions //
155 
156 template <typename T>
157 inline
158 std::ostream&
159 DGtal::operator<< ( std::ostream & out,
160  const DSSLengthEstimator<T> & object )
161 {
162  object.selfDisplay( out );
163  return out;
164 }
165 
166 // //
168 
169