DGtal  1.5.beta
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)
35 #define LightExplicitDigitalSurface_RECURSES
36 
37 #if !defined LightExplicitDigitalSurface_h
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 
157 
161  const Surfel & current() const;
164 
170  void move( const Surfel & s );
171 
188  uint8_t adjacent( Surfel & s, Dimension d, bool pos ) const;
189 
190  private:
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;
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 
294 
298 
302  Size nbSurfels() const;
303 
306  bool empty() const;
307 
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 
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;
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)
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
Aim: Transforms a graph visitor into a single pass input range.
NumberTraits< Integer >::UnsignedVersion Size
Type used to represent sizes in the digital space.
std::set< Cell > CellSet
Preferred type for defining a set of Cell(s).
std::set< SCell > SCellSet
Preferred type for defining a set of SCell(s).
uint8_t adjacent(Surfel &s, Dimension d, bool pos) const
Tracker(ConstAlias< DigitalSurfaceContainer > aSurface, const Surfel &s)
const DigitalSurfaceContainer & surface() const
LightExplicitDigitalSurface< TKSpace, TSurfelPredicate > DigitalSurfaceContainer
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
Size degree(const Vertex &v) const
void writeNeighbors(OutputIterator &it, const Vertex &v) const
const Surfel & surfel() const
accessor to starting surfel.
void selfDisplay(std::ostream &out) const
Adjacency & surfelAdjacency()
mutator to surfel adjacency.
Surfel mySurfel
a surfel belonging to the surface.
const SurfelPredicate & surfelPredicate() const
accessor to surfel predicate.
SurfelConstIterator begin() const
SurfelConstIterator end() const
void writeNeighbors(OutputIterator &it, const Vertex &v, const VertexPredicate &pred) const
BOOST_CONCEPT_ASSERT((concepts::CSurfelPredicate< SurfelPredicate >))
LightExplicitDigitalSurface(const LightExplicitDigitalSurface &other)
LightExplicitDigitalSurface & operator=(const LightExplicitDigitalSurface &other)
SurfelAdjacency< KSpace::dimension > Adjacency
SelfVisitorRange::ConstIterator SurfelConstIterator
bool isInside(const Surfel &s) const
const SurfelPredicate & mySurfelPredicate
a reference to the surfel predicate defining the shape.
Adjacency mySurfelAdjacency
the surfel adjacency used to determine neighbors.
const KSpace & space() const
const KSpace & myKSpace
a reference to the cellular space.
KSpace::Size Size
Type for sizes (unsigned integral type).
DigitalSurfaceTracker * newTracker(const Surfel &s) const
GraphVisitorRange< SelfVisitor > SelfVisitorRange
LightExplicitDigitalSurface(ConstAlias< KSpace > aKSpace, ConstAlias< SurfelPredicate > aSP, const Adjacency &adj, const Surfel &s)
TKSpace KSpace
Model of cellular grid space.
LightExplicitDigitalSurface< TKSpace, TSurfelPredicate > Self
Connectedness connectedness() const
const Adjacency & surfelAdjacency() const
accessor to surfel adjacency.
void setSurfel(const Surfel &aSurfel)
mutator to starting surfel.
Tracker myTracker
Internal tracker for visiting surfels.
Z3i::SCell SCell
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
Connectedness
Definition: Topology.h:51
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::uint32_t Dimension
Definition: Common.h:136
KSpace::template SurfelMap< Value >::Type Type
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Aim: Defines a predicate on a surfel.