DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ImplicitDigitalSurface.h
1 
17 #pragma once
18 
31 #if defined(ImplicitDigitalSurface_RECURSES)
32 #error Recursive header files inclusion detected in ImplicitDigitalSurface.h
33 #else // defined(ImplicitDigitalSurface_RECURSES)
34 
35 #define ImplicitDigitalSurface_RECURSES
36 
37 #if !defined ImplicitDigitalSurface_h
38 
39 #define ImplicitDigitalSurface_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"
51 
52 namespace DGtal
53 {
54 
56  // template class ImplicitDigitalSurface
69  template <typename TKSpace, typename TPointPredicate>
71  {
72  public:
73 
77  class Tracker
78  {
79  public:
80  // -------------------- associated types --------------------
81  typedef Tracker Self;
84  typedef typename TKSpace::SCell Surfel;
85 
86  // -------------------- inner types --------------------
87  typedef TKSpace KSpace;
89 
90  public:
96  Tracker( const DigitalSurfaceContainer & aSurface,
97  const Surfel & s );
98 
103  Tracker( const Tracker & other );
104 
108  ~Tracker();
109 
111  const DigitalSurfaceContainer & surface() const;
113  const Surfel & current() const;
115  Dimension orthDir() const;
116 
122  void move( const Surfel & s );
123 
140  uint8_t adjacent( Surfel & s, Dimension d, bool pos ) const;
141 
142  private:
149 
150  };
151 
152  // ----------------------- associated types ------------------------------
153  public:
156  typedef TKSpace KSpace;
158  typedef typename KSpace::SCell Surfel;
160  typedef typename KSpace::Size Size;
161  // Model of CPointPredicate
162  typedef TPointPredicate PointPredicate;
163 
164  // BOOST_CONCEPT_ASSERT(( CCellularGridSpaceND< KSpace > ));
166 
167  // -------------------- specific types ------------------------------
168  typedef typename std::vector<Surfel> SurfelStorage;
169  typedef typename SurfelStorage::const_iterator SurfelConstIterator;
170  typedef typename KSpace::Space Space;
171  typedef typename KSpace::Point Point;
173 
174  // ----------------------- other types ------------------------------
175  public:
177  typedef typename KSpace::Cell Cell;
178  typedef typename KSpace::SCell SCell;
179  typedef typename KSpace::CellSet CellSet;
180  typedef typename KSpace::SCellSet SCellSet;
181 
182  // ----------------------- Standard services ------------------------------
183  public:
184 
189 
199 
219  ImplicitDigitalSurface( const KSpace & aKSpace,
220  const PointPredicate & aPP,
221  const Adjacency & adj,
222  const Surfel & s,
223  bool closed = false );
224 
226  const Adjacency & surfelAdjacency() const;
230  const PointPredicate & pointPredicate() const;
231 
232  // --------- CDigitalSurfaceContainer realization -------------------------
233  public:
234 
236  const KSpace & space() const;
241  bool isInside( const Surfel & s ) const;
242 
245  SurfelConstIterator begin() const;
246 
249  SurfelConstIterator end() const;
250 
253  Size nbSurfels() const;
254 
257  bool empty() const;
258 
264  DigitalSurfaceTracker* newTracker( const Surfel & s ) const;
265 
271 
272  // ----------------------- Interface --------------------------------------
273  public:
274 
279  void selfDisplay ( std::ostream & out ) const;
280 
285  bool isValid() const;
286 
287  // ------------------------- Protected Datas ------------------------------
288  private:
289  // ------------------------- Private Datas --------------------------------
290  private:
292  const KSpace & myKSpace;
299 
300  // ------------------------- Hidden services ------------------------------
301  protected:
312  void computeSurfels( const Surfel & p,
313  bool closed );
314 
315 
316  private:
317 
325 
326  // ------------------------- Internals ------------------------------------
327  private:
328 
329  }; // end of class ImplicitDigitalSurface
330 
331 
344  template <typename TKSpace, typename TPointPredicate>
345  std::ostream&
346  operator<< ( std::ostream & out,
348 
349 } // namespace DGtal
350 
351 
353 // Includes inline functions.
354 #include "DGtal/topology/ImplicitDigitalSurface.ih"
355 
356 // //
358 
359 #endif // !defined ImplicitDigitalSurface_h
360 
361 #undef ImplicitDigitalSurface_RECURSES
362 #endif // else defined(ImplicitDigitalSurface_RECURSES)