DGtal  0.9.2
DomainAdjacency.h
1 
17 #pragma once
18 
31 #if defined(DomainAdjacency_RECURSES)
32 #error Recursive header files inclusion detected in DomainAdjacency.h
33 #else // defined(DomainAdjacency_RECURSES)
34 
35 #define DomainAdjacency_RECURSES
36 
37 #if !defined DomainAdjacency_h
38 
39 #define DomainAdjacency_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <map>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/base/ConstAlias.h"
47 #include "DGtal/kernel/domains/CDomain.h"
48 #include "DGtal/kernel/domains/DomainPredicate.h"
49 #include "DGtal/topology/CAdjacency.h"
50 #include "DGtal/kernel/sets/DigitalSetSelector.h"
52 
53 namespace DGtal
54 {
55 
57  // template class DomainAdjacency
72  template <typename TDomain, typename TAdjacency>
74  {
77  public:
78 
79  // Required as model of CAdjacency
80  typedef typename TDomain::Space Space;
81  typedef TAdjacency Adjacency;
82  typedef typename TDomain::Point Point;
83 
84  // Required as model of CDomainAdjacency
85  typedef TDomain Domain;
87 
88  // Required by CUndirectedSimpleLocalGraph
89  typedef Point Vertex;
90  typedef typename Space::Size Size;
91  typedef typename DigitalSetSelector< Domain,
93  template <typename Value> struct VertexMap {
94  typedef typename std::map<Vertex, Value> Type;
95  };
96 
97  // ----------------------- Standard services ------------------------------
98  public:
99 
109 
114  DomainAdjacency( const DomainAdjacency & other );
115 
120 
124  const Domain & domain() const;
125 
126  // ----------------------- Adjacency services -----------------------------
127  public:
128 
135  const Predicate & predicate() const;
136 
144  bool isAdjacentTo( const Point & p1, const Point & p2 ) const;
145 
153  bool isProperlyAdjacentTo( const Point & p1, const Point & p2 ) const;
154 
155 // ----------------------- Local graph services --------------------------
156 
160  Size bestCapacity() const;
161 
167  Size degree( const Vertex & v ) const;
168 
180  template <typename OutputIterator>
181  void
182  writeNeighbors( OutputIterator &it ,
183  const Vertex & v ) const;
184 
201  template <typename OutputIterator, typename VertexPredicate>
202  void
203  writeNeighbors( OutputIterator &it ,
204  const Vertex & v,
205  const VertexPredicate & pred) const;
206 
207  // ----------------------- Interface --------------------------------------
208  public:
209 
214  void selfDisplay ( std::ostream & out ) const;
215 
220  bool isValid() const;
221 
222  // ------------------------- Protected Datas ------------------------------
223  private:
224  // ------------------------- Private Datas --------------------------------
225  private:
229  Predicate myPred;
230 
234  const Adjacency & myAdjacency;
235 
236  // ------------------------- Hidden services ------------------------------
237  protected:
238 
243  DomainAdjacency();
244 
245  private:
246 
253  DomainAdjacency & operator= ( const DomainAdjacency & other );
254 
255  // ------------------------- Internals ------------------------------------
256  private:
257 
258  }; // end of class DomainAdjacency
259 
260 
267  template <typename TDomain, typename TAdjacency>
268  std::ostream&
269  operator<< ( std::ostream & out,
270  const DomainAdjacency<TDomain, TAdjacency> & object );
271 
272 } // namespace DGtal
273 
274 
276 // Includes inline functions.
277 #include "DGtal/topology/DomainAdjacency.ih"
278 
279 // //
281 
282 #endif // !defined DomainAdjacency_h
283 
284 #undef DomainAdjacency_RECURSES
285 #endif // else defined(DomainAdjacency_RECURSES)
void selfDisplay(std::ostream &out) const
const Adjacency & myAdjacency
Size bestCapacity() const
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
bool isProperlyAdjacentTo(const Point &p1, const Point &p2) const
std::map< Vertex, Value > Type
DomainAdjacency & operator=(const DomainAdjacency &other)
const Predicate & predicate() const
bool isValid() const
BOOST_CONCEPT_ASSERT((concepts::CDomain< TDomain >))
bool isAdjacentTo(const Point &p1, const Point &p2) const
Aim: The concept CAdjacency defines an elementary adjacency relation between points of a digital spac...
Definition: CAdjacency.h:99
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
Definition: CDomain.h:129
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DigitalSetSelector< Domain, SMALL_DS+HIGH_ITER_DS >::Type VertexSet
functors::DomainPredicate< Domain > Predicate
void writeNeighbors(OutputIterator &it, const Vertex &v) const
DGtal is the top-level namespace which contains all DGtal functions and types.
UnsignedInteger Size
Type used to represent sizes in the digital space.
Definition: SpaceND.h:107
Aim: Automatically defines an adequate digital set type according to the hints given by the user...
const Domain & domain() const
Size degree(const Vertex &v) const
Aim: Given a domain and an adjacency, limits the given adjacency to the specified domain for all adja...