DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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/kernel/domains/CDomain.h"
47 #include "DGtal/kernel/domains/DomainPredicate.h"
48 #include "DGtal/topology/CAdjacency.h"
49 #include "DGtal/kernel/sets/DigitalSetSelector.h"
51 
52 namespace DGtal
53 {
54 
56  // template class DomainAdjacency
71  template <typename TDomain, typename TAdjacency>
73  {
76  public:
77 
78  // Required as model of CAdjacency
79  typedef typename TDomain::Space Space;
80  typedef TAdjacency Adjacency;
81  typedef typename TDomain::Point Point;
82 
83  // Required as model of CDomainAdjacency
84  typedef TDomain Domain;
86 
87  // Required by CUndirectedSimpleLocalGraph
88  typedef Point Vertex;
89  typedef typename Space::Size Size;
90  typedef typename DigitalSetSelector< Domain,
92  template <typename Value> struct VertexMap {
93  typedef typename std::map<Vertex, Value> Type;
94  };
95 
96  // ----------------------- Standard services ------------------------------
97  public:
98 
107  DomainAdjacency( const Domain & aDomain, const Adjacency & adjacency );
108 
113  DomainAdjacency( const DomainAdjacency & other );
114 
119 
123  const Domain & domain() const;
124 
125  // ----------------------- Adjacency services -----------------------------
126  public:
127 
134  const Predicate & predicate() const;
135 
143  bool isAdjacentTo( const Point & p1, const Point & p2 ) const;
144 
152  bool isProperlyAdjacentTo( const Point & p1, const Point & p2 ) const;
153 
154 // ----------------------- Local graph services --------------------------
155 
159  Size bestCapacity() const;
160 
166  Size degree( const Vertex & v ) const;
167 
179  template <typename OutputIterator>
180  void
181  writeNeighbors( OutputIterator &it ,
182  const Vertex & v ) const;
183 
200  template <typename OutputIterator, typename VertexPredicate>
201  void
202  writeNeighbors( OutputIterator &it ,
203  const Vertex & v,
204  const VertexPredicate & pred) const;
205 
206  // ----------------------- Interface --------------------------------------
207  public:
208 
213  void selfDisplay ( std::ostream & out ) const;
214 
219  bool isValid() const;
220 
221  // ------------------------- Protected Datas ------------------------------
222  private:
223  // ------------------------- Private Datas --------------------------------
224  private:
229 
234 
235  // ------------------------- Hidden services ------------------------------
236  protected:
237 
242  DomainAdjacency();
243 
244  private:
245 
252  DomainAdjacency & operator= ( const DomainAdjacency & other );
253 
254  // ------------------------- Internals ------------------------------------
255  private:
256 
257  }; // end of class DomainAdjacency
258 
259 
266  template <typename TDomain, typename TAdjacency>
267  std::ostream&
268  operator<< ( std::ostream & out,
269  const DomainAdjacency<TDomain, TAdjacency> & object );
270 
271 } // namespace DGtal
272 
273 
275 // Includes inline functions.
276 #include "DGtal/topology/DomainAdjacency.ih"
277 
278 // //
280 
281 #endif // !defined DomainAdjacency_h
282 
283 #undef DomainAdjacency_RECURSES
284 #endif // else defined(DomainAdjacency_RECURSES)