DGtal  0.9.2
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/base/ConstAlias.h"
47 #include "DGtal/kernel/CPointPredicate.h"
48 #include "DGtal/topology/Topology.h"
49 #include "DGtal/topology/SurfelAdjacency.h"
50 #include "DGtal/topology/SurfelNeighborhood.h"
52 
53 namespace DGtal
54 {
55 
57  // template class ImplicitDigitalSurface
70  template <typename TKSpace, typename TPointPredicate>
72  {
73  public:
74 
78  class Tracker
79  {
80  public:
81  // -------------------- associated types --------------------
82  typedef Tracker Self;
85  typedef typename TKSpace::SCell Surfel;
86 
87  // -------------------- inner types --------------------
88  typedef TKSpace KSpace;
90 
91  public:
98  const Surfel & s );
99 
104  Tracker( const Tracker & other );
105 
109  ~Tracker();
110 
112  const DigitalSurfaceContainer & surface() const;
114  const Surfel & current() const;
116  Dimension orthDir() const;
117 
123  void move( const Surfel & s );
124 
141  uint8_t adjacent( Surfel & s, Dimension d, bool pos ) const;
142 
143  private:
149  Neighborhood myNeighborhood;
150 
151  };
152 
153  // ----------------------- associated types ------------------------------
154  public:
157  typedef TKSpace KSpace;
159  typedef typename KSpace::SCell Surfel;
161  typedef typename KSpace::Size Size;
162  // Model of concepts::CPointPredicate
163  typedef TPointPredicate PointPredicate;
164 
167 
168  // -------------------- specific types ------------------------------
169  typedef typename std::vector<Surfel> SurfelStorage;
170  typedef typename SurfelStorage::const_iterator SurfelConstIterator;
171  typedef typename KSpace::Space Space;
172  typedef typename KSpace::Point Point;
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  // ----------------------- Standard services ------------------------------
184  public:
185 
190 
200 
222  const Adjacency & adj,
223  const Surfel & s,
224  bool closed = false );
225 
227  const Adjacency & surfelAdjacency() const;
229  Adjacency & surfelAdjacency();
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 
254  Size nbSurfels() const;
255 
258  bool empty() const;
259 
265  DigitalSurfaceTracker* newTracker( const Surfel & s ) const;
266 
272 
273  // ----------------------- Interface --------------------------------------
274  public:
275 
280  void selfDisplay ( std::ostream & out ) const;
281 
286  bool isValid() const;
287 
288  // ------------------------- Protected Datas ------------------------------
289  private:
290  // ------------------------- Private Datas --------------------------------
291  private:
293  const KSpace & myKSpace;
295  const PointPredicate & myPointPredicate;
297  Adjacency mySurfelAdjacency;
299  SurfelStorage mySurfels;
300 
301  // ------------------------- Hidden services ------------------------------
302  protected:
313  void computeSurfels( const Surfel & p,
314  bool closed );
315 
316 
317  private:
318 
326 
327  // ------------------------- Internals ------------------------------------
328  private:
329 
330  }; // end of class ImplicitDigitalSurface
331 
332 
345  template <typename TKSpace, typename TPointPredicate>
346  std::ostream&
347  operator<< ( std::ostream & out,
349 
350 } // namespace DGtal
351 
352 
354 // Includes inline functions.
355 #include "DGtal/topology/ImplicitDigitalSurface.ih"
356 
357 // //
359 
360 #endif // !defined ImplicitDigitalSurface_h
361 
362 #undef ImplicitDigitalSurface_RECURSES
363 #endif // else defined(ImplicitDigitalSurface_RECURSES)
SurfelStorage::const_iterator SurfelConstIterator
SurfelConstIterator end() const
const PointPredicate & myPointPredicate
a reference to the point predicate defining the shape.
SurfelNeighborhood< KSpace > Neighborhood
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
Connectedness connectedness() const
DGtal::uint32_t Dimension
Definition: Common.h:113
const Adjacency & surfelAdjacency() const
accessor to surfel adjacency.
const PointPredicate & pointPredicate() const
accessor to point predicate.
const DigitalSurfaceContainer & surface() const
TKSpace KSpace
Model of cellular grid space.
const KSpace & space() const
SurfelAdjacency< KSpace::dimension > Adjacency
ImplicitDigitalSurface & operator=(const ImplicitDigitalSurface &other)
Tracker(ConstAlias< DigitalSurfaceContainer > aSurface, const Surfel &s)
bool isInside(const Surfel &s) const
Aim: Defines a predicate on a point.
uint8_t adjacent(Surfel &s, Dimension d, bool pos) const
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
ImplicitDigitalSurface< TKSpace, TPointPredicate > Self
ImplicitDigitalSurface(const ImplicitDigitalSurface &other)
DigitalSurfaceTracker * newTracker(const Surfel &s) const
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< KSpace >))
DGtal is the top-level namespace which contains all DGtal functions and types.
void selfDisplay(std::ostream &out) const
boost::uint8_t uint8_t
unsigned 8-bit integer.
Definition: BasicTypes.h:59
Adjacency mySurfelAdjacency
the surfel adjacency used to determine neighbors.
ImplicitDigitalSurface< TKSpace, TPointPredicate > DigitalSurfaceContainer
SurfelStorage mySurfels
a vector storing all the surfels of the boundary.
SurfelConstIterator begin() const
void computeSurfels(const Surfel &p, bool closed)
Aim: This concept describes a cellular grid space in nD. In these spaces obtained by cartesian produc...
const KSpace & myKSpace
a reference to the cellular space.
const DigitalSurfaceContainer & mySurface
Connectedness
Definition: Topology.h:50
KSpace::Size Size
Type for sizes (unsigned integral type).
KSpace::SCell Surfel
Type for surfels.
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...