DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExplicitDigitalSurface.h
1 
17 #pragma once
18 
31 #if defined(ExplicitDigitalSurface_RECURSES)
32 #error Recursive header files inclusion detected in ExplicitDigitalSurface.h
33 #else // defined(ExplicitDigitalSurface_RECURSES)
34 
35 #define ExplicitDigitalSurface_RECURSES
36 
37 #if !defined ExplicitDigitalSurface_h
38 
39 #define ExplicitDigitalSurface_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <vector>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/topology/CSurfelPredicate.h"
47 #include "DGtal/topology/Topology.h"
48 #include "DGtal/topology/SurfelAdjacency.h"
49 #include "DGtal/topology/SurfelNeighborhood.h"
51 
52 namespace DGtal
53 {
54 
56  // template class ExplicitDigitalSurface
79  template <typename TKSpace, typename TSurfelPredicate>
81  {
82  public:
83 
87  class Tracker
88  {
89  public:
90  // -------------------- associated types --------------------
91  typedef Tracker Self;
94  typedef typename TKSpace::SCell Surfel;
95 
96  // -------------------- inner types --------------------
97  typedef TKSpace KSpace;
99 
100  public:
106  Tracker( const DigitalSurfaceContainer & aSurface,
107  const Surfel & s );
108 
113  Tracker( const Tracker & other );
114 
118  ~Tracker();
119 
121  const DigitalSurfaceContainer & surface() const;
123  const Surfel & current() const;
125  Dimension orthDir() const;
126 
132  void move( const Surfel & s );
133 
150  uint8_t adjacent( Surfel & s, Dimension d, bool pos ) const;
151 
152  private:
159 
160  };
161 
162  // ----------------------- associated types ------------------------------
163  public:
166  typedef TKSpace KSpace;
168  typedef typename KSpace::SCell Surfel;
170  typedef typename KSpace::Size Size;
171  // Model of CSurfelPredicate
172  typedef TSurfelPredicate SurfelPredicate;
173 
174  // BOOST_CONCEPT_ASSERT(( CCellularGridSpaceND< KSpace > ));
176 
177  // -------------------- specific types ------------------------------
178  typedef typename std::vector<Surfel> SurfelStorage;
179  typedef typename SurfelStorage::const_iterator SurfelConstIterator;
180  typedef typename KSpace::Space Space;
181  typedef typename KSpace::Point Point;
183 
184  // ----------------------- other types ------------------------------
185  public:
187  typedef typename KSpace::Cell Cell;
188  typedef typename KSpace::SCell SCell;
189  typedef typename KSpace::CellSet CellSet;
190  typedef typename KSpace::SCellSet SCellSet;
191 
192  // ----------------------- Standard services ------------------------------
193  public:
194 
199 
209 
229  ExplicitDigitalSurface( const KSpace & aKSpace,
230  const SurfelPredicate & aSP,
231  const Adjacency & adj,
232  const Surfel & s,
233  bool closed = false );
234 
236  const Adjacency & surfelAdjacency() const;
240  const SurfelPredicate & surfelPredicate() const;
241 
242  // --------- CDigitalSurfaceContainer realization -------------------------
243  public:
244 
246  const KSpace & space() const;
251  bool isInside( const Surfel & s ) const;
252 
255  SurfelConstIterator begin() const;
256 
259  SurfelConstIterator end() const;
260 
263  Size nbSurfels() const;
264 
267  bool empty() const;
268 
274  DigitalSurfaceTracker* newTracker( const Surfel & s ) const;
275 
280 
281  // ----------------------- Interface --------------------------------------
282  public:
283 
288  void selfDisplay ( std::ostream & out ) const;
289 
294  bool isValid() const;
295 
296  // ------------------------- Protected Datas ------------------------------
297  private:
298  // ------------------------- Private Datas --------------------------------
299  private:
301  const KSpace & myKSpace;
308 
309  // ------------------------- Hidden services ------------------------------
310  protected:
321  void computeSurfels( const Surfel & p,
322  bool closed );
323 
324 
325  private:
326 
334 
335  // ------------------------- Internals ------------------------------------
336  private:
337 
338  }; // end of class ExplicitDigitalSurface
339 
340 
353  template <typename TKSpace, typename TSurfelPredicate>
354  std::ostream&
355  operator<< ( std::ostream & out,
357 
358 } // namespace DGtal
359 
360 
362 // Includes inline functions.
363 #include "DGtal/topology/ExplicitDigitalSurface.ih"
364 
365 // //
367 
368 #endif // !defined ExplicitDigitalSurface_h
369 
370 #undef ExplicitDigitalSurface_RECURSES
371 #endif // else defined(ExplicitDigitalSurface_RECURSES)