DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
LightImplicitDigitalSurface.h
1 
17 #pragma once
18 
31 #if defined(LightImplicitDigitalSurface_RECURSES)
32 #error Recursive header files inclusion detected in LightImplicitDigitalSurface.h
33 #else // defined(LightImplicitDigitalSurface_RECURSES)
34 
35 #define LightImplicitDigitalSurface_RECURSES
36 
37 #if !defined LightImplicitDigitalSurface_h
38 
39 #define LightImplicitDigitalSurface_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <vector>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/kernel/CPointPredicate.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 LightImplicitDigitalSurface
75  template <typename TKSpace, typename TPointPredicate>
77  {
78  public:
79 
83  class Tracker
84  {
85  public:
86  // -------------------- associated types --------------------
87  typedef Tracker Self;
90  typedef typename TKSpace::SCell Surfel;
91 
92  // -------------------- inner types --------------------
93  typedef TKSpace KSpace;
95 
96  public:
102  Tracker( const DigitalSurfaceContainer & aSurface,
103  const Surfel & s );
104 
109  Tracker( const Tracker & other );
110 
114  ~Tracker();
115 
117  const DigitalSurfaceContainer & surface() const;
119  const Surfel & current() const;
121  Dimension orthDir() const;
122 
128  void move( const Surfel & s );
129 
146  uint8_t adjacent( Surfel & s, Dimension d, bool pos ) const;
147 
148  private:
155 
156  };
157 
158  // ----------------------- associated types ------------------------------
159  public:
162  typedef TKSpace KSpace;
164  typedef typename KSpace::SCell Surfel;
166  typedef typename KSpace::Size Size;
167  // Model of CPointPredicate
168  typedef TPointPredicate PointPredicate;
169 
170  // BOOST_CONCEPT_ASSERT(( CCellularGridSpaceND< KSpace > ));
172 
173  // ----------------------- other types ------------------------------
174  public:
176  typedef typename KSpace::Cell Cell;
177  typedef typename KSpace::SCell SCell;
178  typedef typename KSpace::CellSet CellSet;
179  typedef typename KSpace::SCellSet SCellSet;
180 
181 
182  // ----------------- UndirectedSimplePreGraph types ------------------
183  typedef Surfel Vertex;
184  typedef SCellSet VertexSet;
185  template <typename Value>
186  struct VertexMap {
187  typedef typename KSpace::template SurfelMap<Value>::Type Type;
188  };
189 
190  // -------------------- specific types ------------------------------
193  typedef typename KSpace::Space Space;
194  typedef typename KSpace::Point Point;
196 
197  // ----------------------- Standard services ------------------------------
198  public:
199 
204 
210 
221  LightImplicitDigitalSurface( const KSpace & aKSpace,
222  const PointPredicate & aPP,
223  const Adjacency & adj,
224  const Surfel & s );
225 
227  const Adjacency & surfelAdjacency() const;
231  const PointPredicate & pointPredicate() const;
232 
233  // --------- CDigitalSurfaceContainer realization -------------------------
234  public:
235 
237  const KSpace & space() const;
242  bool isInside( const Surfel & s ) const;
243 
246  SurfelConstIterator begin() const;
247 
250  SurfelConstIterator end() const;
251 
255  Size nbSurfels() const;
256 
259  bool empty() const;
260 
266  DigitalSurfaceTracker* newTracker( const Surfel & s ) const;
267 
273 
274  // ----------------- UndirectedSimplePreGraph realization --------------------
275  public:
276 
281  Size degree( const Vertex & v ) const;
282 
295  template <typename OutputIterator>
296  void writeNeighbors( OutputIterator & it,
297  const Vertex & v ) const;
298 
316  template <typename OutputIterator, typename VertexPredicate>
317  void writeNeighbors( OutputIterator & it,
318  const Vertex & v,
319  const VertexPredicate & pred ) const;
320 
329  Size bestCapacity() const;
330 
331 
332  // ----------------------- Interface --------------------------------------
333  public:
334 
339  void selfDisplay ( std::ostream & out ) const;
340 
345  bool isValid() const;
346 
347  // ------------------------- Protected Datas ------------------------------
348  private:
349  // ------------------------- Private Datas --------------------------------
350  private:
352  const KSpace & myKSpace;
361 
362  // ------------------------- Hidden services ------------------------------
363  protected:
364 
365 
366  private:
367 
375 
376  // ------------------------- Internals ------------------------------------
377  private:
378 
379  }; // end of class LightImplicitDigitalSurface
380 
381 
394  template <typename TKSpace, typename TPointPredicate>
395  std::ostream&
396  operator<< ( std::ostream & out,
398 
399 } // namespace DGtal
400 
401 
403 // Includes inline functions.
404 #include "DGtal/topology/LightImplicitDigitalSurface.ih"
405 
406 // //
408 
409 #endif // !defined LightImplicitDigitalSurface_h
410 
411 #undef LightImplicitDigitalSurface_RECURSES
412 #endif // else defined(LightImplicitDigitalSurface_RECURSES)