Example of a test. To be completed.
51{
52 unsigned int nbok = 0;
53 unsigned int nb = 0;
54
56 typedef std::vector<Point> Container;
57
58
60 OrientationFunctor orientationFunctor;
62 predicate( orientationFunctor );
63
64
65 using namespace functions::Hull2D;
66
68
70 {
71 Container input, output;
72 openGrahamScan( input.begin(), input.end(), back_inserter( output ), predicate );
73 if (output.size() == 0)
74 nbok++;
75 nb++;
76 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
77 }
78
80 {
81 Container input, output;
82 input.push_back(
Point(1,1) );
83 openGrahamScan( input.begin(), input.end(), back_inserter( output ), predicate );
84 if ( (output.size() == 1) &&
85 (output.back() ==
Point(1,1)) )
86 nbok++;
87 nb++;
88 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
89 }
90
92 {
93 Container input, output;
94 input.push_back(
Point(1,1) );
95 input.push_back(
Point(1,2) );
96 openGrahamScan( input.begin(), input.end(), back_inserter( output ), predicate );
97 if ( (output.size() == 2) &&
98 (output.at(0) ==
Point(1,1)) &&
99 (output.at(1) ==
Point(1,2)) )
100 nbok++;
101 nb++;
102 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
103 }
104
106 {
107 Container input, output;
108
109
110 input.push_back(
Point(0,0) );
111 input.push_back(
Point(5,0) );
112 input.push_back(
Point(10,5) );
113 copy( input.begin(), input.end(), ostream_iterator<Point>( cout, " " ) );
114 cout << endl;
115
116 openGrahamScan( input.begin(), input.end(), back_inserter( output ), predicate );
117
118 copy( output.begin(), output.end(), ostream_iterator<Point>( cout, " " ) );
119 cout << endl;
120
121 if ( (output.size() == 3) &&
122 (output.at(0) ==
Point(0,0)) &&
123 (output.at(1) ==
Point(5,0)) &&
124 (output.at(2) ==
Point(10,5)) )
125 nbok++;
126 nb++;
127 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
128
129
130 output.clear();
131 input.at(2) =
Point(10,-5);
132 copy( input.begin(), input.end(), ostream_iterator<Point>( cout, " " ) );
133 cout << endl;
134
135 openGrahamScan( input.begin(), input.end(), back_inserter( output ), predicate );
136
137 copy( output.begin(), output.end(), ostream_iterator<Point>( cout, " " ) );
138 cout << endl;
139
140 if ( (output.size() == 2) &&
141 (output.at(0) ==
Point(0,0)) &&
142 (output.at(1) ==
Point(10,-5)) )
143 nbok++;
144 nb++;
145 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
146 }
147
148 trace.
info() <<
"several points" << endl;
149 {
150 Container input, output;
151 input.push_back(
Point(0,5) );
152 input.push_back(
Point(0,0) );
153 input.push_back(
Point(1,1) );
154 input.push_back(
Point(2,4) );
155 input.push_back(
Point(3,9) );
156 input.push_back(
Point(4,16) );
157 input.push_back(
Point(5,0) );
158
159 openGrahamScan( (input.begin()+1), input.end(), back_inserter( output ), predicate );
160 if ( (output.size() == 2) &&
161 (output.at(0) ==
Point(0,0)) &&
162 (output.at(1) ==
Point(5,0)) )
163 nbok++;
164 nb++;
165 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
166
167 output.clear();
168 openGrahamScan( input.begin(), input.end(), back_inserter( output ), predicate );
169 if ( (output.size() == 3) &&
170 (output.at(0) ==
Point(0,5)) &&
171 (output.at(1) ==
Point(0,0)) &&
172 (output.at(2) ==
Point(5,0)) )
173 nbok++;
174 nb++;
175 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
176
177 }
178
180
182
184 {
185 Container input, output;
187 if (output.size() == 0)
188 nbok++;
189 nb++;
190 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
191 }
192
194 {
195 Container input, output;
196 input.push_back(
Point(1,1) );
198 if ( (output.size() == 1) &&
199 (output.back() ==
Point(1,1)) )
200 nbok++;
201 nb++;
202 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
203 }
204
206 {
207 Container input, output;
208 input.push_back(
Point(1,1) );
209 input.push_back(
Point(1,2) );
211 if ( (output.size() == 2) &&
212 (output.at(0) ==
Point(1,1)) &&
213 (output.at(1) ==
Point(1,2)) )
214 nbok++;
215 nb++;
216 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
217 }
218
220 {
221
222 Container input, output;
223 input.push_back(
Point(0,0) );
224 input.push_back(
Point(5,0) );
225 input.push_back(
Point(10,5) );
226 copy( input.begin(), input.end(), ostream_iterator<Point>( cout, " " ) );
227 cout << endl;
228
230
231 copy( output.begin(), output.end(), ostream_iterator<Point>( cout, " " ) );
232 cout << endl;
233
234 if ( (output.size() == 3) &&
235 (output.at(0) ==
Point(0,0)) &&
236 (output.at(1) ==
Point(5,0)) &&
237 (output.at(2) ==
Point(10,5)) )
238 nbok++;
239 nb++;
240 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
241 }
242
243 trace.
info() <<
"taking into account the first point" << endl;
244 {
245 Container input, output;
246 input.push_back(
Point(0,-1) );
247 input.push_back(
Point(1,0) );
248 input.push_back(
Point(1,5) );
249 input.push_back(
Point(-5,5) );
250 input.push_back(
Point(-5,0) );
251 input.push_back(
Point(-2,1) );
252 copy( input.begin(), input.end(), ostream_iterator<Point>( cout, " " ) );
253 cout << endl;
254
256
257 copy( output.begin(), output.end(), ostream_iterator<Point>( cout, " " ) );
258 cout << endl;
259
260 if ( (output.size() == 5) &&
261 (output.at(0) ==
Point(0,-1)) &&
262 (output.at(1) ==
Point(1,0)) &&
263 (output.at(2) ==
Point(1,5)) &&
264 (output.at(3) ==
Point(-5,5))&&
265 (output.at(4) ==
Point(-5,0)) )
266 nbok++;
267 nb++;
268 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
269 }
270
272
274
276 {
277 Container input, output;
279 if (output.size() == 0)
280 nbok++;
281 nb++;
282 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
283 }
284
286 {
287 Container input, output;
288 input.push_back(
Point(1,1) );
290 if ( (output.size() == 1) &&
291 (output.back() ==
Point(1,1)) )
292 nbok++;
293 nb++;
294 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
295 }
296
298 {
299 Container input, output;
300 input.push_back(
Point(1,1) );
301 input.push_back(
Point(1,2) );
303 if ( (output.size() == 2) &&
304 (output.at(0) ==
Point(1,1)) &&
305 (output.at(1) ==
Point(1,2)) )
306 nbok++;
307 nb++;
308 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
309 }
310
312 {
313
314 Container input, output;
315 input.push_back(
Point(0,0) );
316 input.push_back(
Point(5,0) );
317 input.push_back(
Point(10,5) );
318 copy( input.begin(), input.end(), ostream_iterator<Point>( cout, " " ) );
319 cout << endl;
320
322
323 copy( output.begin(), output.end(), ostream_iterator<Point>( cout, " " ) );
324 cout << endl;
325
326 if ( (output.size() == 3) &&
327 (output.at(0) ==
Point(0,0)) &&
328 (output.at(1) ==
Point(5,0)) &&
329 (output.at(2) ==
Point(10,5)) )
330 nbok++;
331 nb++;
332 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
333 }
334
335 trace.
info() <<
"taking into account the first point" << endl;
336 {
337 Container input, output;
338 input.push_back(
Point(3,2) );
339 input.push_back(
Point(2,2) );
340 input.push_back(
Point(2,1) );
341 input.push_back(
Point(1,1) );
342 input.push_back(
Point(0,1) );
343 input.push_back(
Point(0,0) );
344 input.push_back(
Point(9,0) );
345 input.push_back(
Point(9,6) );
346 input.push_back(
Point(8,6) );
347 input.push_back(
Point(8,5) );
348 input.push_back(
Point(7,5) );
349 input.push_back(
Point(7,4) );
350 input.push_back(
Point(6,4) );
351 input.push_back(
Point(5,4) );
352 input.push_back(
Point(5,3) );
353 input.push_back(
Point(4,3) );
354 input.push_back(
Point(4,2) );
355
356 copy( input.begin(), input.end(), ostream_iterator<Point>( cout, " " ) );
357 cout << endl;
358
360
361 copy( output.begin(), output.end(), ostream_iterator<Point>( cout, " " ) );
362 cout << endl;
363
364 if ( (output.size() == 5) &&
365 (output.at(0) ==
Point(0,0)) &&
366 (output.at(1) ==
Point(9,0)) &&
367 (output.at(2) ==
Point(9,6)) &&
368 (output.at(3) ==
Point(8,6)) &&
369 (output.at(4) ==
Point(0,1)) )
370 nbok++;
371 nb++;
372 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
373 }
374
376
377 return nbok == nb;
378}
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Aim: Implements basic operations that will be used in Point and Vector classes.
Aim: Small adapter to models of COrientationFunctor2. It is a model of concepts::CPointPredicate....
void closedGrahamScanFromAnyPoint(const ForwardIterator &itb, const ForwardIterator &ite, OutputIterator res, const Predicate &aPredicate)
Procedure that retrieves the vertices of the convex hull of a weakly externally visible polygon (WEVP...
void openGrahamScan(const ForwardIterator &itb, const ForwardIterator &ite, OutputIterator res, const Predicate &aPredicate)
Procedure that retrieves the vertices of the convex hull of a weakly externally visible polygon (WEVP...
void closedGrahamScanFromVertex(const ForwardIterator &itb, const ForwardIterator &ite, OutputIterator res, const Predicate &aPredicate)
Procedure that retrieves the vertices of the convex hull of a weakly externally visible polygon (WEVP...