DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DomainAdjacency.ih
1 
30 
31 #include <cstdlib>
33 
35 // IMPLEMENTATION of inline methods.
37 #include "DGtal/topology/MetricAdjacency.h"
39 // ----------------------- Standard services ------------------------------
40 
41 template <typename TDomain, typename TAdjacency>
42 inline
45 {}
46 //------------------------------------------------------------------------------
47 template <typename TDomain, typename TAdjacency>
48 inline
50 ::DomainAdjacency( const Domain & aDomain,
51  const Adjacency & adjacency )
52  : myPred( aDomain ), myAdjacency( adjacency )
53 {
54 }
55 //------------------------------------------------------------------------------
56 template <typename TDomain, typename TAdjacency>
57 inline
60  : myPred( other.myPred ), myAdjacency( other.myAdjacency )
61 {
62 }
63 //------------------------------------------------------------------------------
64 template <typename TDomain, typename TAdjacency>
65 inline
66 const TDomain &
68 ::domain() const
69 {
70  return myPred.domain();
71 }
72 //------------------------------------------------------------------------------
73 template <typename TDomain, typename TAdjacency>
74 inline
77 ::predicate() const
78 {
79  return myPred;
80 }
81 //------------------------------------------------------------------------------
82 template <typename TDomain, typename TAdjacency>
83 inline
84 bool
86 ::isAdjacentTo( const Point & p1, const Point & p2 ) const
87 {
88  ASSERT( myPred( p1 ) );
89  ASSERT( myPred( p2 ) );
90  return isAdjacentTo( p1, p2 );
91 }
92 //------------------------------------------------------------------------------
93 template <typename TDomain, typename TAdjacency>
94 inline
95 bool
97 ::isProperlyAdjacentTo( const Point & p1, const Point & p2 ) const
98 {
99  ASSERT( myPred( p1 ) );
100  ASSERT( myPred( p2 ) );
101  return isProperlyAdjacentTo( p1, p2 );
102 }
103 //------------------------------------------------------------------------------
104 template <typename TDomain, typename TAdjacency>
105 inline
106 void
108 ::selfDisplay ( std::ostream & out ) const
109 {
110  out << "[DomainAdjacency]";
111 }
112 //------------------------------------------------------------------------------
113 template <typename TDomain, typename TAdjacency>
114 inline
115 bool
117 ::isValid() const
118 {
119  return true;
120 }
121 //------------------------------------------------------------------------------
122 template <typename TDomain, typename TAdjacency>
123 inline
124 std::ostream&
125 DGtal::operator<< ( std::ostream & out,
126  const DomainAdjacency<TDomain,TAdjacency> & object )
127 {
128  object.selfDisplay( out );
129  return out;
130 }
131 
133 // ----------------------- Local graph services -----------------------------
134 
138 template <typename TDomain, typename TAdjacency>
139 inline
142 {
143  return myAdjacency.bestCapacity();
144 }
145 
151 template <typename TDomain, typename TAdjacency>
152 inline
155 ( const Vertex & v ) const
156 {
157  return myAdjacency.degree( v );
158 }
159 
171 template <typename TDomain, typename TAdjacency>
172 template <typename OutputIterator>
173 inline
174 void
176 ( OutputIterator &it, const Vertex & v ) const
177 {
178  //myAdjacency.writeProperNeighborhood( v, it, myPred );//writeNeighbors<OutputIterator>( v, it );
179  myAdjacency.writeNeighbors( it, v );
180 }
181 
198 template <typename TDomain, typename TAdjacency>
199 template <typename OutputIterator, typename VertexPredicate>
200 void
202 ( OutputIterator &it, const Vertex & v, const VertexPredicate & pred) const
203 {
204  vector<Vertex> vect;
205  back_insert_iterator< vector<Vertex> > out_it(vect);
206  //myAdjacency.writeProperNeighborhood( vect, out_it, myPred );
207  myAdjacency.writeNeighbors( out_it, v, myPred );
208  for( typename vector<Vertex>::const_iterator cit = vect.begin(); cit != vect.end(); cit ++ )
209  {
210  if( pred(*cit) )
211  {
212  *it++ = *cit;
213  }
214  }
215  //myAdjacency.writeNeighbors<OutputIterator, VertexPredicate>( v, it, pred );
216 }
217 
218 // //
220 
221