33 #include "DGtal/helpers/StdDefs.h"
35 #include "DGtal/base/Common.h"
36 #include "DGtal/kernel/SpaceND.h"
37 #include "DGtal/topology/MetricAdjacency.h"
38 #include "DGtal/topology/CUndirectedSimpleLocalGraph.h"
44 using namespace DGtal;
60 bool testMetricAdjacency()
62 unsigned int nbok = 0;
66 typedef Space3D::Point
Point;
75 trace.
info() <<
" p = " << p << std::endl;
77 back_insert_iterator< vector<Point> > bii6( neigh6 );
78 Adj6::writeNeighbors( bii6, p );
79 nbok += neigh6.size() == 6 ? 1 : 0;
81 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
82 <<
"Card(6-neigh): " << neigh6.size()
83 <<
"== 6 ?" << std::endl;
85 unsigned int nb_correct = 0;
86 for (
unsigned int i = 0; i < neigh6.size(); ++i )
88 if ( Adj6::isProperlyAdjacentTo( p, neigh6[ i ] ) )
90 trace.
info() << neigh6[ i ] <<
"* " << std::endl;
94 trace.
info() << neigh6[ i ] <<
"- " << std::endl;
97 nbok += nb_correct == 6 ? 1 : 0;
99 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
100 <<
"Within, #proper adjacent : " << nb_correct
101 <<
"== 6 ?" << std::endl;
108 trace.
info() <<
" p = " << p << std::endl;
109 vector<Point> neigh18;
110 back_insert_iterator< vector<Point> > bii18( neigh18 );
111 Adj18::writeNeighbors( bii18, p );
112 nbok += neigh18.size() == 18 ? 1 : 0;
114 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
115 <<
"Card(18-neigh): " << neigh18.size()
116 <<
"== 18 ?" << std::endl;
119 for (
unsigned int i = 0; i < neigh18.size(); ++i )
121 if ( Adj18::isProperlyAdjacentTo( p, neigh18[ i ] ) )
123 trace.
info() << neigh18[ i ] <<
"* " << std::endl;
127 trace.
info() << neigh18[ i ] <<
"- " << std::endl;
130 nbok += nb_correct == 18 ? 1 : 0;
132 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
133 <<
"Within, #proper adjacent : " << nb_correct
134 <<
"== 18 ?" << std::endl;
140 trace.
info() <<
" p = " << p << std::endl;
141 vector<Point> neigh26;
142 back_insert_iterator< vector<Point> > bii26( neigh26 );
143 Adj26::writeNeighbors( bii26, p );
144 nbok += neigh26.size() == 26 ? 1 : 0;
146 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
147 <<
"Card(26-neigh): " << neigh26.size()
148 <<
"== 26 ?" << std::endl;
151 for (
unsigned int i = 0; i < neigh26.size(); ++i )
153 if ( Adj26::isProperlyAdjacentTo( p, neigh26[ i ] ) )
155 trace.
info() << neigh26[ i ] <<
"* " << std::endl;
159 trace.
info() << neigh26[ i ] <<
"- " << std::endl;
162 nbok += nb_correct == 26 ? 1 : 0;
164 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
165 <<
"Within, #proper adjacent : " << nb_correct
166 <<
"== 26 ?" << std::endl;
173 bool testLocalGraphModel()
176 unsigned int nbok=0,nb=0;
182 nbok += Adj::bestCapacity() == 72 ? 1 : 0;
184 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
185 <<
"Within, bestCapacity : " << Adj::bestCapacity()
186 <<
"== 72 ?" << std::endl;
198 int main(
int argc,
char** argv )
202 for (
int i = 0; i < argc; ++i )
206 bool res = testMetricAdjacency() && testLocalGraphModel();
207 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;