DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
LightExplicitDigitalSurface.h
1 
17 #pragma once
18 
31 #if defined(LightExplicitDigitalSurface_RECURSES)
32 #error Recursive header files inclusion detected in LightExplicitDigitalSurface.h
33 #else // defined(LightExplicitDigitalSurface_RECURSES)
34 
35 #define LightExplicitDigitalSurface_RECURSES
36 
37 #if !defined LightExplicitDigitalSurface_h
38 
39 #define LightExplicitDigitalSurface_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"
50 #include "DGtal/topology/BreadthFirstVisitor.h"
52 
53 namespace DGtal
54 {
55 
57  // template class LightExplicitDigitalSurface
77  template <typename TKSpace, typename TSurfelPredicate>
79  {
80  public:
81 
85  class Tracker
86  {
87  public:
88  // -------------------- associated types --------------------
89  typedef Tracker Self;
92  typedef typename TKSpace::SCell Surfel;
93 
94  // -------------------- inner types --------------------
95  typedef TKSpace KSpace;
97 
98  public:
104  Tracker( const DigitalSurfaceContainer & aSurface,
105  const Surfel & s );
106 
111  Tracker( const Tracker & other );
112 
116  ~Tracker();
117 
119  const DigitalSurfaceContainer & surface() const;
121  const Surfel & current() const;
123  Dimension orthDir() const;
124 
130  void move( const Surfel & s );
131 
148  uint8_t adjacent( Surfel & s, Dimension d, bool pos ) const;
149 
150  private:
157 
158  };
159 
160  // ----------------------- associated types ------------------------------
161  public:
164  typedef TKSpace KSpace;
166  typedef typename KSpace::SCell Surfel;
168  typedef typename KSpace::Size Size;
169  // Model of CSurfelPredicate
170  typedef TSurfelPredicate SurfelPredicate;
171 
172  // BOOST_CONCEPT_ASSERT(( CCellularGridSpaceND< KSpace > ));
174 
175  // ----------------------- other types ------------------------------
176  public:
178  typedef typename KSpace::Cell Cell;
179  typedef typename KSpace::SCell SCell;
180  typedef typename KSpace::CellSet CellSet;
181  typedef typename KSpace::SCellSet SCellSet;
182 
183 
184  // ----------------- UndirectedSimplePreGraph types ------------------
185  typedef Surfel Vertex;
186  typedef SCellSet VertexSet;
187  template <typename Value>
188  struct VertexMap {
189  typedef typename KSpace::template SurfelMap<Value>::Type Type;
190  };
191 
192  // -------------------- specific types ------------------------------
195  typedef typename KSpace::Space Space;
196  typedef typename KSpace::Point Point;
198 
199  // ----------------------- Standard services ------------------------------
200  public:
201 
206 
212 
223  LightExplicitDigitalSurface( const KSpace & aKSpace,
224  const SurfelPredicate & aSP,
225  const Adjacency & adj,
226  const Surfel & s );
227 
229  const Adjacency & surfelAdjacency() const;
233  const SurfelPredicate & surfelPredicate() const;
235  const Surfel & surfel() const;
237  void setSurfel(const Surfel& aSurfel);
238 
239  // --------- CDigitalSurfaceContainer realization -------------------------
240  public:
241 
243  const KSpace & space() const;
248  bool isInside( const Surfel & s ) const;
249 
252  SurfelConstIterator begin() const;
253 
256  SurfelConstIterator end() const;
257 
261  Size nbSurfels() const;
262 
265  bool empty() const;
266 
272  DigitalSurfaceTracker* newTracker( const Surfel & s ) const;
273 
278 
279  // ----------------- CUndirectedSimplePreGraph realization -----------------
280  public:
281 
286  Size degree( const Vertex & v ) const;
287 
300  template <typename OutputIterator>
301  void writeNeighbors( OutputIterator & it,
302  const Vertex & v ) const;
303 
321  template <typename OutputIterator, typename VertexPredicate>
322  void writeNeighbors( OutputIterator & it,
323  const Vertex & v,
324  const VertexPredicate & pred ) const;
325 
334  Size bestCapacity() const;
335 
336 
337  // ----------------------- Interface --------------------------------------
338  public:
339 
344  void selfDisplay ( std::ostream & out ) const;
345 
350  bool isValid() const;
351 
352  // ------------------------- Protected Datas ------------------------------
353  private:
354  // ------------------------- Private Datas --------------------------------
355  private:
357  const KSpace & myKSpace;
366 
367  // ------------------------- Hidden services ------------------------------
368  protected:
369 
370 
371  private:
372 
380 
381  // ------------------------- Internals ------------------------------------
382  private:
383 
384  }; // end of class LightExplicitDigitalSurface
385 
386 
399  template <typename TKSpace, typename TSurfelPredicate>
400  std::ostream&
401  operator<< ( std::ostream & out,
403 
404 } // namespace DGtal
405 
406 
408 // Includes inline functions.
409 #include "DGtal/topology/LightExplicitDigitalSurface.ih"
410 
411 // //
413 
414 #endif // !defined LightExplicitDigitalSurface_h
415 
416 #undef LightExplicitDigitalSurface_RECURSES
417 #endif // else defined(LightExplicitDigitalSurface_RECURSES)