DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Measure.ih
1 
30 
31 #include <cstdlib>
33 
35 // IMPLEMENTATION of inline methods.
37 
39 // ----------------------- Standard services ------------------------------
40 
41 template< typename TSet>
42 inline
43 void
44 DGtal::Measure<TSet>::init(const double h, const TSet &aSet)
45 {
46  myH = h;
47  mySetSize = aSet.size() ;
48  myIsInitBefore = true;
49 }
50 
51 
52 template< typename TSet>
53 inline
56 {
57  ASSERT(myIsInitBefore);
58  ASSERT(myH > 0);
59 
60  double hd = std::pow(myH, (double)TSet::Domain::dimension);
61 
62  return mySetSize/(double)hd;
63 }
64 
65 
69 template < typename TSet>
70 inline
72 {
73  myIsInitBefore = false;
74 }
75 
76 
80 template < typename TSet>
81 inline
83 {
84 }
85 
87 // Interface - public :
88 
93 template < typename TSet>
94 inline
95 void
96 DGtal::Measure<TSet>::selfDisplay ( std::ostream & out ) const
97 {
98  out << "[Measure] ";
99  if (this->isValid())
100  out << " myH="<< myH<<", mySetSize="<< mySetSize;
101  else
102  out <<" (not initialized)";
103 }
104 
109 template < typename TSet>
110 inline
111 bool
113 {
114  return myIsInitBefore;
115 }
116 
117 
118 
120 // Implementation of inline functions //
121 
122 template < typename TSet>
123 inline
124 std::ostream&
125 DGtal::operator<< ( std::ostream & out,
126  const Measure<TSet> & object )
127 {
128  object.selfDisplay( out );
129  return out;
130 }
131 
132 // //
134 
135