DGtal  0.9.2
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/base/ConstAlias.h"
47 #include "DGtal/topology/CSurfelPredicate.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 ExplicitDigitalSurface
80  template <typename TKSpace, typename TSurfelPredicate>
82  {
83  public:
84 
88  class Tracker
89  {
90  public:
91  // -------------------- associated types --------------------
92  typedef Tracker Self;
95  typedef typename TKSpace::SCell Surfel;
96 
97  // -------------------- inner types --------------------
98  typedef TKSpace KSpace;
100 
101  public:
108  const Surfel & s );
109 
114  Tracker( const Tracker & other );
115 
119  ~Tracker();
120 
122  const DigitalSurfaceContainer & surface() const;
124  const Surfel & current() const;
126  Dimension orthDir() const;
127 
133  void move( const Surfel & s );
134 
151  uint8_t adjacent( Surfel & s, Dimension d, bool pos ) const;
152 
153  private:
159  Neighborhood myNeighborhood;
160 
161  };
162 
163  // ----------------------- associated types ------------------------------
164  public:
167  typedef TKSpace KSpace;
169  typedef typename KSpace::SCell Surfel;
171  typedef typename KSpace::Size Size;
172  // Model of CSurfelPredicate
173  typedef TSurfelPredicate SurfelPredicate;
174 
175  // BOOST_CONCEPT_ASSERT(( CCellularGridSpaceND< KSpace > ));
177 
178  // -------------------- specific types ------------------------------
179  typedef typename std::vector<Surfel> SurfelStorage;
180  typedef typename SurfelStorage::const_iterator SurfelConstIterator;
181  typedef typename KSpace::Space Space;
182  typedef typename KSpace::Point Point;
184 
185  // ----------------------- other types ------------------------------
186  public:
188  typedef typename KSpace::Cell Cell;
189  typedef typename KSpace::SCell SCell;
190  typedef typename KSpace::CellSet CellSet;
191  typedef typename KSpace::SCellSet SCellSet;
192 
193  // ----------------------- Standard services ------------------------------
194  public:
195 
200 
210 
231  const SurfelPredicate & aSP,
232  const Adjacency & adj,
233  const Surfel & s,
234  bool closed = false );
235 
237  const Adjacency & surfelAdjacency() const;
239  Adjacency & surfelAdjacency();
241  const SurfelPredicate & surfelPredicate() const;
242 
243  // --------- CDigitalSurfaceContainer realization -------------------------
244  public:
245 
247  const KSpace & space() const;
252  bool isInside( const Surfel & s ) const;
253 
256  SurfelConstIterator begin() const;
257 
260  SurfelConstIterator end() const;
261 
264  Size nbSurfels() const;
265 
268  bool empty() const;
269 
275  DigitalSurfaceTracker* newTracker( const Surfel & s ) const;
276 
281 
282  // ----------------------- Interface --------------------------------------
283  public:
284 
289  void selfDisplay ( std::ostream & out ) const;
290 
295  bool isValid() const;
296 
297  // ------------------------- Protected Datas ------------------------------
298  private:
299  // ------------------------- Private Datas --------------------------------
300  private:
302  const KSpace & myKSpace;
304  const SurfelPredicate & mySurfelPredicate;
306  Adjacency mySurfelAdjacency;
308  SurfelStorage mySurfels;
309 
310  // ------------------------- Hidden services ------------------------------
311  protected:
322  void computeSurfels( const Surfel & p,
323  bool closed );
324 
325 
326  private:
327 
335 
336  // ------------------------- Internals ------------------------------------
337  private:
338 
339  }; // end of class ExplicitDigitalSurface
340 
341 
354  template <typename TKSpace, typename TSurfelPredicate>
355  std::ostream&
356  operator<< ( std::ostream & out,
358 
359 } // namespace DGtal
360 
361 
363 // Includes inline functions.
364 #include "DGtal/topology/ExplicitDigitalSurface.ih"
365 
366 // //
368 
369 #endif // !defined ExplicitDigitalSurface_h
370 
371 #undef ExplicitDigitalSurface_RECURSES
372 #endif // else defined(ExplicitDigitalSurface_RECURSES)
DigitalSurfaceTracker * newTracker(const Surfel &s) const
const SurfelPredicate & mySurfelPredicate
a reference to the surfel predicate defining the shape.
BOOST_CONCEPT_ASSERT((concepts::CSurfelPredicate< SurfelPredicate >))
Adjacency mySurfelAdjacency
the surfel adjacency used to determine neighbors.
SurfelConstIterator begin() const
ExplicitDigitalSurface(const ExplicitDigitalSurface &other)
SurfelAdjacency< KSpace::dimension > Adjacency
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
const Adjacency & surfelAdjacency() const
accessor to surfel adjacency.
DGtal::uint32_t Dimension
Definition: Common.h:113
const KSpace & myKSpace
a reference to the cellular space.
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels...
SurfelStorage mySurfels
a vector storing all the surfels of the boundary.
SurfelConstIterator end() const
TKSpace KSpace
Model of cellular grid space.
bool isInside(const Surfel &s) const
Aim: Defines a predicate on a surfel.
ExplicitDigitalSurface< TKSpace, TSurfelPredicate > DigitalSurfaceContainer
const DigitalSurfaceContainer & surface() const
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
ExplicitDigitalSurface & operator=(const ExplicitDigitalSurface &other)
ExplicitDigitalSurface< TKSpace, TSurfelPredicate > Self
SurfelStorage::const_iterator SurfelConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
boost::uint8_t uint8_t
unsigned 8-bit integer.
Definition: BasicTypes.h:59
const KSpace & space() const
Connectedness connectedness() const
KSpace::Size Size
Type for sizes (unsigned integral type).
KSpace::SCell Surfel
Type for surfels.
Connectedness
Definition: Topology.h:50
uint8_t adjacent(Surfel &s, Dimension d, bool pos) const
const DigitalSurfaceContainer & mySurface
void computeSurfels(const Surfel &p, bool closed)
SurfelNeighborhood< KSpace > Neighborhood
Tracker(ConstAlias< DigitalSurfaceContainer > aSurface, const Surfel &s)
const SurfelPredicate & surfelPredicate() const
accessor to point predicate.
void selfDisplay(std::ostream &out) const