DGtal  0.9.2
LightImplicitDigitalSurface.h
1 
17 #pragma once
18 
31 #if defined(LightImplicitDigitalSurface_RECURSES)
32 #error Recursive header files inclusion detected in LightImplicitDigitalSurface.h
33 #else // defined(LightImplicitDigitalSurface_RECURSES)
34 
35 #define LightImplicitDigitalSurface_RECURSES
36 
37 #if !defined LightImplicitDigitalSurface_h
38 
39 #define LightImplicitDigitalSurface_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"
51 #include "DGtal/graph/BreadthFirstVisitor.h"
52 #include "DGtal/graph/GraphVisitorRange.h"
54 
55 namespace DGtal
56 {
57 
59  // template class LightImplicitDigitalSurface
114  template <typename TKSpace, typename TPointPredicate>
116  {
117  public:
118 
122  class Tracker
123  {
124  public:
125  // -------------------- associated types --------------------
126  typedef Tracker Self;
129  typedef typename TKSpace::SCell Surfel;
130 
131  // -------------------- inner types --------------------
132  typedef TKSpace KSpace;
134 
135  public:
142  const Surfel & s );
143 
148  Tracker( const Tracker & other );
149 
153  ~Tracker();
154 
156  const DigitalSurfaceContainer & surface() const;
158  const Surfel & current() const;
160  Dimension orthDir() const;
161 
167  void move( const Surfel & s );
168 
185  uint8_t adjacent( Surfel & s, Dimension d, bool pos ) const;
186 
187  private:
193  Neighborhood myNeighborhood;
194 
195  };
196 
197  // ----------------------- associated types ------------------------------
198  public:
201  typedef TKSpace KSpace;
203  typedef typename KSpace::SCell Surfel;
205  typedef typename KSpace::Size Size;
206  // Model of concepts::CPointPredicate
207  typedef TPointPredicate PointPredicate;
208 
209  // BOOST_CONCEPT_ASSERT(( CCellularGridSpaceND< KSpace > ));
211 
212  // ----------------------- other types ------------------------------
213  public:
215  typedef typename KSpace::Cell Cell;
216  typedef typename KSpace::SCell SCell;
217  typedef typename KSpace::CellSet CellSet;
218  typedef typename KSpace::SCellSet SCellSet;
219 
220 
221  // ----------------- UndirectedSimpleLocalGraph types ------------------
222  typedef Surfel Vertex;
223  typedef SCellSet VertexSet;
224  template <typename Value>
225  struct VertexMap {
226  typedef typename KSpace::template SurfelMap<Value>::Type Type;
227  };
228 
229  // -------------------- specific types ------------------------------
233  typedef typename KSpace::Space Space;
234  typedef typename KSpace::Point Point;
236 
237  // ----------------------- Standard services ------------------------------
238  public:
239 
244 
250 
263  const Adjacency & adj,
264  const Surfel & s );
265 
267  const Adjacency & surfelAdjacency() const;
269  Adjacency & surfelAdjacency();
271  const PointPredicate & pointPredicate() const;
272 
273  // --------- CDigitalSurfaceContainer realization -------------------------
274  public:
275 
277  const KSpace & space() const;
282  bool isInside( const Surfel & s ) const;
283 
286  SurfelConstIterator begin() const;
287 
290  SurfelConstIterator end() const;
291 
295  Size nbSurfels() const;
296 
299  bool empty() const;
300 
306  DigitalSurfaceTracker* newTracker( const Surfel & s ) const;
307 
313 
314  // ----------------- UndirectedSimplePreGraph realization --------------------
315  public:
316 
321  Size degree( const Vertex & v ) const;
322 
335  template <typename OutputIterator>
336  void writeNeighbors( OutputIterator & it,
337  const Vertex & v ) const;
338 
356  template <typename OutputIterator, typename VertexPredicate>
357  void writeNeighbors( OutputIterator & it,
358  const Vertex & v,
359  const VertexPredicate & pred ) const;
360 
369  Size bestCapacity() const;
370 
371 
372  // ----------------------- Interface --------------------------------------
373  public:
374 
379  void selfDisplay ( std::ostream & out ) const;
380 
385  bool isValid() const;
386 
387  // ------------------------- Protected Datas ------------------------------
388  private:
389  // ------------------------- Private Datas --------------------------------
390  private:
392  const KSpace & myKSpace;
394  const PointPredicate & myPointPredicate;
396  Adjacency mySurfelAdjacency;
398  Surfel mySurfel;
401 
402  // ------------------------- Hidden services ------------------------------
403  protected:
404 
405 
406  private:
407 
415 
416  // ------------------------- Internals ------------------------------------
417  private:
418 
419  }; // end of class LightImplicitDigitalSurface
420 
421 
434  template <typename TKSpace, typename TPointPredicate>
435  std::ostream&
436  operator<< ( std::ostream & out,
438 
439 } // namespace DGtal
440 
441 
443 // Includes inline functions.
444 #include "DGtal/topology/LightImplicitDigitalSurface.ih"
445 
446 // //
448 
449 #endif // !defined LightImplicitDigitalSurface_h
450 
451 #undef LightImplicitDigitalSurface_RECURSES
452 #endif // else defined(LightImplicitDigitalSurface_RECURSES)
LightImplicitDigitalSurface< TKSpace, TPointPredicate > DigitalSurfaceContainer
TKSpace KSpace
Model of cellular grid space.
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
void selfDisplay(std::ostream &out) const
Size degree(const Vertex &v) const
Tracker(ConstAlias< DigitalSurfaceContainer > aSurface, const Surfel &s)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
uint8_t adjacent(Surfel &s, Dimension d, bool pos) const
DGtal::uint32_t Dimension
Definition: Common.h:113
KSpace::Size Size
Type for sizes (unsigned integral type).
Connectedness connectedness() const
GraphVisitorRange< SelfVisitor > SelfVisitorRange
BOOST_CONCEPT_ASSERT((concepts::CPointPredicate< PointPredicate >))
const KSpace & space() const
LightImplicitDigitalSurface(const LightImplicitDigitalSurface &other)
SurfelConstIterator end() const
KSpace::template SurfelMap< Value >::Type Type
Aim: Defines a predicate on a point.
const PointPredicate & pointPredicate() const
accessor to point predicate.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
LightImplicitDigitalSurface & operator=(const LightImplicitDigitalSurface &other)
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Transforms a graph visitor into a single pass input range.
boost::uint8_t uint8_t
unsigned 8-bit integer.
Definition: BasicTypes.h:59
void writeNeighbors(OutputIterator &it, const Vertex &v) const
LightImplicitDigitalSurface< TKSpace, TPointPredicate > Self
DigitalSurfaceTracker * newTracker(const Surfel &s) const
const PointPredicate & myPointPredicate
a reference to the point predicate defining the shape.
Tracker myTracker
Internal tracker for visiting surfels.
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
const Adjacency & surfelAdjacency() const
accessor to surfel adjacency.
SurfelConstIterator begin() const
KSpace::SCell Surfel
Type for surfels.
SelfVisitorRange::ConstIterator SurfelConstIterator
const DigitalSurfaceContainer & surface() const
Surfel mySurfel
a surfel belonging to the surface.
Connectedness
Definition: Topology.h:50
Adjacency mySurfelAdjacency
the surfel adjacency used to determine neighbors.
SurfelAdjacency< KSpace::dimension > Adjacency
bool isInside(const Surfel &s) const
const KSpace & myKSpace
a reference to the cellular space.