DGtal  1.4.beta
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)
35 #define ExplicitDigitalSurface_RECURSES
36 
37 #if !defined ExplicitDigitalSurface_h
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 
120 
124  const Surfel & current() const;
127 
133  void move( const Surfel & s );
134 
151  uint8_t adjacent( Surfel & s, Dimension d, bool pos ) const;
152 
153  private:
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;
242 
243  // --------- CDigitalSurfaceContainer realization -------------------------
244  public:
245 
247  const KSpace & space() const;
252  bool isInside( const Surfel & s ) const;
253 
257 
261 
264  Size nbSurfels() const;
265 
268  bool empty() const;
269 
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;
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)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
ExplicitDigitalSurface< TKSpace, TSurfelPredicate > DigitalSurfaceContainer
SurfelNeighborhood< KSpace > Neighborhood
Tracker(ConstAlias< DigitalSurfaceContainer > aSurface, const Surfel &s)
const DigitalSurfaceContainer & surface() const
uint8_t adjacent(Surfel &s, Dimension d, bool pos) const
const DigitalSurfaceContainer & mySurface
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
DigitalSurfaceTracker * newTracker(const Surfel &s) const
void selfDisplay(std::ostream &out) const
const KSpace & space() const
ExplicitDigitalSurface & operator=(const ExplicitDigitalSurface &other)
SurfelStorage mySurfels
a vector storing all the surfels of the boundary.
const Adjacency & surfelAdjacency() const
accessor to surfel adjacency.
BOOST_CONCEPT_ASSERT((concepts::CSurfelPredicate< SurfelPredicate >))
KSpace::SCell Surfel
Type for surfels.
KSpace::Size Size
Type for sizes (unsigned integral type).
ExplicitDigitalSurface(ConstAlias< KSpace > aKSpace, const SurfelPredicate &aSP, const Adjacency &adj, const Surfel &s, bool closed=false)
const KSpace & myKSpace
a reference to the cellular space.
ExplicitDigitalSurface< TKSpace, TSurfelPredicate > Self
bool isInside(const Surfel &s) const
SurfelAdjacency< KSpace::dimension > Adjacency
const SurfelPredicate & mySurfelPredicate
a reference to the surfel predicate defining the shape.
Connectedness connectedness() const
SurfelConstIterator begin() const
SurfelConstIterator end() const
Adjacency & surfelAdjacency()
mutator to surfel adjacency.
const SurfelPredicate & surfelPredicate() const
accessor to point predicate.
void computeSurfels(const Surfel &p, bool closed)
Adjacency mySurfelAdjacency
the surfel adjacency used to determine neighbors.
SurfelStorage::const_iterator SurfelConstIterator
TKSpace KSpace
Model of cellular grid space.
ExplicitDigitalSurface(const ExplicitDigitalSurface &other)
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).
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
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Aim: Defines a predicate on a surfel.