DGtal  0.9.2
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/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"
51 #include "DGtal/graph/BreadthFirstVisitor.h"
52 #include "DGtal/graph/GraphVisitorRange.h"
54 
55 namespace DGtal
56 {
57 
59  // template class LightExplicitDigitalSurface
117  template <typename TKSpace, typename TSurfelPredicate>
119  {
120  public:
121 
125  class Tracker
126  {
127  public:
128  // -------------------- associated types --------------------
129  typedef Tracker Self;
132  typedef typename TKSpace::SCell Surfel;
133 
134  // -------------------- inner types --------------------
135  typedef TKSpace KSpace;
137 
138  public:
145  const Surfel & s );
146 
151  Tracker( const Tracker & other );
152 
156  ~Tracker();
157 
159  const DigitalSurfaceContainer & surface() const;
161  const Surfel & current() const;
163  Dimension orthDir() const;
164 
170  void move( const Surfel & s );
171 
188  uint8_t adjacent( Surfel & s, Dimension d, bool pos ) const;
189 
190  private:
196  Neighborhood myNeighborhood;
197 
198  };
199 
200  // ----------------------- associated types ------------------------------
201  public:
204  typedef TKSpace KSpace;
206  typedef typename KSpace::SCell Surfel;
208  typedef typename KSpace::Size Size;
209  // Model of CSurfelPredicate
210  typedef TSurfelPredicate SurfelPredicate;
211 
212  // BOOST_CONCEPT_ASSERT(( CCellularGridSpaceND< KSpace > ));
214 
215  // ----------------------- other types ------------------------------
216  public:
218  typedef typename KSpace::Cell Cell;
219  typedef typename KSpace::SCell SCell;
220  typedef typename KSpace::CellSet CellSet;
221  typedef typename KSpace::SCellSet SCellSet;
222 
223 
224  // ----------------- UndirectedSimplePreGraph types ------------------
225  typedef Surfel Vertex;
226  typedef SCellSet VertexSet;
227  template <typename Value>
228  struct VertexMap {
229  typedef typename KSpace::template SurfelMap<Value>::Type Type;
230  };
231 
232  // -------------------- specific types ------------------------------
236  typedef typename KSpace::Space Space;
237  typedef typename KSpace::Point Point;
239 
240  // ----------------------- Standard services ------------------------------
241  public:
242 
247 
253 
266  const Adjacency & adj,
267  const Surfel & s );
268 
270  const Adjacency & surfelAdjacency() const;
272  Adjacency & surfelAdjacency();
274  const SurfelPredicate & surfelPredicate() const;
276  const Surfel & surfel() const;
278  void setSurfel(const Surfel& aSurfel);
279 
280  // --------- CDigitalSurfaceContainer realization -------------------------
281  public:
282 
284  const KSpace & space() const;
289  bool isInside( const Surfel & s ) const;
290 
293  SurfelConstIterator begin() const;
294 
297  SurfelConstIterator end() const;
298 
302  Size nbSurfels() const;
303 
306  bool empty() const;
307 
313  DigitalSurfaceTracker* newTracker( const Surfel & s ) const;
314 
319 
320  // ----------------- CUndirectedSimplePreGraph realization -----------------
321  public:
322 
327  Size degree( const Vertex & v ) const;
328 
341  template <typename OutputIterator>
342  void writeNeighbors( OutputIterator & it,
343  const Vertex & v ) const;
344 
362  template <typename OutputIterator, typename VertexPredicate>
363  void writeNeighbors( OutputIterator & it,
364  const Vertex & v,
365  const VertexPredicate & pred ) const;
366 
375  Size bestCapacity() const;
376 
377 
378  // ----------------------- Interface --------------------------------------
379  public:
380 
385  void selfDisplay ( std::ostream & out ) const;
386 
391  bool isValid() const;
392 
393  // ------------------------- Protected Datas ------------------------------
394  private:
395  // ------------------------- Private Datas --------------------------------
396  private:
398  const KSpace & myKSpace;
400  const SurfelPredicate & mySurfelPredicate;
402  Adjacency mySurfelAdjacency;
404  Surfel mySurfel;
407 
408  // ------------------------- Hidden services ------------------------------
409  protected:
410 
411 
412  private:
413 
421 
422  // ------------------------- Internals ------------------------------------
423  private:
424 
425  }; // end of class LightExplicitDigitalSurface
426 
427 
440  template <typename TKSpace, typename TSurfelPredicate>
441  std::ostream&
442  operator<< ( std::ostream & out,
444 
445 } // namespace DGtal
446 
447 
449 // Includes inline functions.
450 #include "DGtal/topology/LightExplicitDigitalSurface.ih"
451 
452 // //
454 
455 #endif // !defined LightExplicitDigitalSurface_h
456 
457 #undef LightExplicitDigitalSurface_RECURSES
458 #endif // else defined(LightExplicitDigitalSurface_RECURSES)
void setSurfel(const Surfel &aSurfel)
mutator to starting surfel.
KSpace::template SurfelMap< Value >::Type Type
const SurfelPredicate & surfelPredicate() const
accessor to surfel predicate.
Surfel mySurfel
a surfel belonging to the surface.
LightExplicitDigitalSurface< TKSpace, TSurfelPredicate > DigitalSurfaceContainer
LightExplicitDigitalSurface & operator=(const LightExplicitDigitalSurface &other)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
DGtal::uint32_t Dimension
Definition: Common.h:113
Connectedness connectedness() const
DigitalSurfaceTracker * newTracker(const Surfel &s) const
BOOST_CONCEPT_ASSERT((concepts::CSurfelPredicate< SurfelPredicate >))
const KSpace & space() const
Tracker myTracker
Internal tracker for visiting surfels.
GraphVisitorRange< SelfVisitor > SelfVisitorRange
SurfelAdjacency< KSpace::dimension > Adjacency
TKSpace KSpace
Model of cellular grid space.
void selfDisplay(std::ostream &out) const
const Surfel & surfel() const
accessor to starting surfel.
LightExplicitDigitalSurface< TKSpace, TSurfelPredicate > Self
Aim: Defines a predicate on a surfel.
const Adjacency & surfelAdjacency() const
accessor to surfel adjacency.
KSpace::SCell Surfel
Type for surfels.
const KSpace & myKSpace
a reference to the cellular space.
SurfelConstIterator end() const
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
SelfVisitorRange::ConstIterator SurfelConstIterator
LightExplicitDigitalSurface(const LightExplicitDigitalSurface &other)
Size degree(const Vertex &v) const
DGtal is the top-level namespace which contains all DGtal functions and types.
uint8_t adjacent(Surfel &s, Dimension d, bool pos) const
Aim: Transforms a graph visitor into a single pass input range.
boost::uint8_t uint8_t
unsigned 8-bit integer.
Definition: BasicTypes.h:59
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
void writeNeighbors(OutputIterator &it, const Vertex &v) const
Adjacency mySurfelAdjacency
the surfel adjacency used to determine neighbors.
const DigitalSurfaceContainer & surface() const
SurfelConstIterator begin() const
bool isInside(const Surfel &s) const
Connectedness
Definition: Topology.h:50
Tracker(ConstAlias< DigitalSurfaceContainer > aSurface, const Surfel &s)
const SurfelPredicate & mySurfelPredicate
a reference to the surfel predicate defining the shape.
KSpace::Size Size
Type for sizes (unsigned integral type).
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels...