DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GaussDigitizer.ih
1 
30 
31 #include <cstdlib>
32 #include <cmath>
33 #include "DGtal/kernel/NumberTraits.h"
35 
37 // IMPLEMENTATION of inline methods.
39 
41 // ----------------------- Standard services ------------------------------
42 
43 //-----------------------------------------------------------------------------
44 template <typename TSpace, typename TEuclideanShape>
45 inline
47 {
48 }
49 //-----------------------------------------------------------------------------
50 template <typename TSpace, typename TEuclideanShape>
51 inline
53  : myEShape( 0 )
54 {}
55 //-----------------------------------------------------------------------------
56 template <typename TSpace, typename TEuclideanShape>
57 inline
60 operator=( const GaussDigitizer & other )
61 {
62  if ( this != &other )
63  {
64  myEShape = other.myEShape;
65  myPointEmbedder = other.myPointEmbedder;
66  myLowerPoint = other.myLowerPoint;
67  myUpperPoint = other.myUpperPoint;
68  }
69  return *this;
70 }
71 //-----------------------------------------------------------------------------
72 template <typename TSpace, typename TEuclideanShape>
73 inline
74 void
76 ::attach( const EuclideanShape & shape )
77 {
78  myEShape = &shape;
79 }
80 //-----------------------------------------------------------------------------
81 template <typename TSpace, typename TEuclideanShape>
82 inline
83 void
85 ::init( const RealPoint & xLow, const RealPoint & xUp,
86  typename RealVector::Component gridStep )
87 {
88  myPointEmbedder.init( gridStep );
89  myLowerPoint = myPointEmbedder.floor( xLow );
90  myUpperPoint = myPointEmbedder.ceil( xUp );
91 }
92 //-----------------------------------------------------------------------------
93 template <typename TSpace, typename TEuclideanShape>
94 inline
95 void
97 ::init( const RealPoint & xLow, const RealPoint & xUp,
98  const RealVector & aGridSteps )
99 {
100  myPointEmbedder.init( aGridSteps );
101  myLowerPoint = myPointEmbedder.floor( xLow );
102  myUpperPoint = myPointEmbedder.ceil( xUp );
103 }
104 
105 //-----------------------------------------------------------------------------
106 template <typename TSpace, typename TEuclideanShape>
107 inline
111 {
112  return myPointEmbedder;
113 }
114 //-----------------------------------------------------------------------------
115 template <typename TSpace, typename TEuclideanShape>
116 inline
119 ::getDomain() const
120 {
121  return Domain( getLowerBound(), getUpperBound() );
122 }
123 
124 //-----------------------------------------------------------------------------
125 template <typename TSpace, typename TEuclideanShape>
126 inline
129 ::floor( const RealPoint & p ) const
130 {
131  return myPointEmbedder.floor( p );
132 }
133 //-----------------------------------------------------------------------------
134 template <typename TSpace, typename TEuclideanShape>
135 inline
138 ::ceil( const RealPoint & p ) const
139 {
140  return myPointEmbedder.ceil( p );
141 }
142 //-----------------------------------------------------------------------------
143 template <typename TSpace, typename TEuclideanShape>
144 inline
147 ::round( const RealPoint & p ) const
148 {
149  return myPointEmbedder.round( p );
150 }
151 //-----------------------------------------------------------------------------
152 template <typename TSpace, typename TEuclideanShape>
153 inline
156 ::embed( const Point & p ) const
157 {
158  return myPointEmbedder.embed( p );
159 }
160 //-----------------------------------------------------------------------------
161 template <typename TSpace, typename TEuclideanShape>
162 inline
163 bool
165 ::operator()( const Point & p ) const
166 {
167  ASSERT( myEShape != 0 );
168  return (myEShape->orientation( embed( p ) ) == INSIDE);
169 }
170 //-----------------------------------------------------------------------------
171 template <typename TSpace, typename TEuclideanShape>
172 inline
176 {
177  return myLowerPoint;
178 }
179 //-----------------------------------------------------------------------------
180 template <typename TSpace, typename TEuclideanShape>
181 inline
185 {
186  return myUpperPoint;
187 }
188 //-----------------------------------------------------------------------------
189 template <typename TSpace, typename TEuclideanShape>
190 inline
194 {
195  return getUpperBound() - getLowerBound();
196 }
197 //-----------------------------------------------------------------------------
198 template <typename TSpace, typename TEuclideanShape>
199 inline
202 ::gridSteps() const
203 {
204  return myPointEmbedder.gridSteps();
205 }
206 
207 
209 // Interface - public :
210 
215 template <typename TSpace, typename TEuclideanShape>
216 inline
217 void
219 {
220  out << "[GaussDigitizer]";
221 }
222 
227 template <typename TSpace, typename TEuclideanShape>
228 inline
229 bool
231 {
232  return true;
233 }
234 
235 
236 
238 // Implementation of inline functions //
239 
240 template <typename TSpace, typename TEuclideanShape>
241 inline
242 std::ostream&
243 DGtal::operator<< ( std::ostream & out,
245 {
246  object.selfDisplay( out );
247  return out;
248 }
249 
250 // //
252 
253