DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SetOfSurfels.ih
1 
30 
31 #include <cstdlib>
32 #include <iterator>
33 #include "DGtal/kernel/sets/SetPredicate.h"
34 #include "DGtal/topology/helpers/Surfaces.h"
36 
38 // IMPLEMENTATION of inline methods.
40 
41 //-----------------------------------------------------------------------------
42 template <typename TKSpace, typename TSurfelSet>
43 inline
46 {}
47 //-----------------------------------------------------------------------------
48 template <typename TKSpace, typename TSurfelSet>
49 inline
52  const Surfel & s )
53  : mySurface( aSurface ), myNeighborhood()
54 {
57  s );
58 }
59 //-----------------------------------------------------------------------------
60 template <typename TKSpace, typename TSurfelSet>
61 inline
63 ::Tracker( const Tracker & other )
64  : mySurface( other.mySurface ), myNeighborhood( other.myNeighborhood )
65 {
66 }
67 //-----------------------------------------------------------------------------
68 template <typename TKSpace, typename TSurfelSet>
69 inline
72 ::surface() const
73 {
74  return mySurface;
75 }
76 //-----------------------------------------------------------------------------
77 template <typename TKSpace, typename TSurfelSet>
78 inline
81 {
82  return myNeighborhood.surfel();
83 }
84 //-----------------------------------------------------------------------------
85 template <typename TKSpace, typename TSurfelSet>
86 inline
89 ::orthDir() const
90 {
91  return myNeighborhood.orthDir();
92 }
93 //-----------------------------------------------------------------------------
94 template <typename TKSpace, typename TSurfelSet>
95 inline
96 void
98 ::move( const Surfel & s )
99 {
100  ASSERT( surface().isInside( s ) );
101  myNeighborhood.setSurfel( s );
102 }
103 //-----------------------------------------------------------------------------
104 template <typename TKSpace, typename TSurfelSet>
105 inline
108 ::adjacent( Surfel & s, Dimension d, bool pos ) const
109 {
110  return static_cast<uint8_t>
111  ( myNeighborhood.getAdjacentOnSurfelPredicate( s, surface().surfelPredicate(), d, pos ) );
112 }
113 
115 // ----------------------- Standard services ------------------------------
116 
117 //-----------------------------------------------------------------------------
118 template <typename TKSpace, typename TSurfelSet>
119 inline
121 {
122 }
123 //-----------------------------------------------------------------------------
124 template <typename TKSpace, typename TSurfelSet>
125 inline
127 ( const SetOfSurfels & other )
128  : myKSpace( other.myKSpace ),
129  mySurfelSet( other.mySurfelSet ),
132 {
133 }
134 //-----------------------------------------------------------------------------
135 template <typename TKSpace, typename TSurfelSet>
136 inline
138 ( const KSpace & aKSpace,
139  const Adjacency & adj,
140  SurfelSet aSetOfSurfels )
141  : myKSpace( aKSpace ), mySurfelSet( aSetOfSurfels ),
143  mySurfelAdjacency( adj )
144 {
145 }
146 //-----------------------------------------------------------------------------
147 template <typename TKSpace, typename TSurfelSet>
148 inline
151 {
152  return mySurfelSet;
153 }
154 //-----------------------------------------------------------------------------
155 template <typename TKSpace, typename TSurfelSet>
156 inline
157 const
160 {
161  return mySurfelSet;
162 }
163 //-----------------------------------------------------------------------------
164 template <typename TKSpace, typename TSurfelSet>
165 inline
166 const
169 {
170  return mySurfelAdjacency;
171 }
172 //-----------------------------------------------------------------------------
173 template <typename TKSpace, typename TSurfelSet>
174 inline
177 {
178  return mySurfelAdjacency;
179 }
180 //-----------------------------------------------------------------------------
181 template <typename TKSpace, typename TSurfelSet>
182 inline
183 const
186 {
187  return mySurfelPredicate;
188 }
189 
190 //-----------------------------------------------------------------------------
191 // --------- CDigitalSurfaceContainer realization -------------------------
192 //-----------------------------------------------------------------------------
193 template <typename TKSpace, typename TSurfelSet>
194 inline
197 {
198  return myKSpace;
199 }
200 //-----------------------------------------------------------------------------
201 template <typename TKSpace, typename TSurfelSet>
202 inline
203 bool
205 ( const Surfel & s ) const
206 {
207  return mySurfelPredicate( s );
208 }
209 //-----------------------------------------------------------------------------
210 template <typename TKSpace, typename TSurfelSet>
211 inline
214 {
215  return mySurfelSet.begin();
216 }
217 //-----------------------------------------------------------------------------
218 template <typename TKSpace, typename TSurfelSet>
219 inline
222 {
223  return mySurfelSet.end();
224 }
225 //-----------------------------------------------------------------------------
226 template <typename TKSpace, typename TSurfelSet>
227 inline
230 {
231  return (unsigned int)mySurfelSet.size();
232 }
233 //-----------------------------------------------------------------------------
234 template <typename TKSpace, typename TSurfelSet>
235 inline
236 bool
238 {
239  return mySurfelSet.empty();
240 }
241 //-----------------------------------------------------------------------------
242 template <typename TKSpace, typename TSurfelSet>
243 inline
246 ( const Surfel & s ) const
247 {
248  return new Tracker( *this, s );
249 }
250 //-----------------------------------------------------------------------------
251 template <typename TKSpace, typename TSurfelSet>
252 inline
255 {
256  return UNKNOWN;
257 }
258 
259 // ------------------------- Hidden services ------------------------------
260 
262 // Interface - public :
263 
268 template <typename TKSpace, typename TSurfelSet>
269 inline
270 void
272 {
273  out << "[SetOfSurfels]";
274 }
275 
280 template <typename TKSpace, typename TSurfelSet>
281 inline
282 bool
284 {
285  return true;
286 }
287 
288 
289 
291 // Implementation of inline functions //
292 
293 template <typename TKSpace, typename TSurfelSet>
294 inline
295 std::ostream&
296 DGtal::operator<< ( std::ostream & out,
297  const SetOfSurfels<TKSpace,TSurfelSet> & object )
298 {
299  object.selfDisplay( out );
300  return out;
301 }
302 
303 // //
305 
306