45#include "DGtal/base/Common.h"
46#include "DGtal/base/Exceptions.h"
47#include "DGtal/kernel/SpaceND.h"
48#include "DGtal/kernel/domains/HyperRectDomain.h"
49#include "DGtal/geometry/curves/ArithmeticalDSSComputer.h"
50#include "DGtal/io/boards/Board2D.h"
52#include "DGtal/geometry/curves/CDynamicBidirectionalSegmentComputer.h"
53#include "DGtal/io/boards/CDrawableWithBoard2D.h"
70 typedef std::vector<Point>::iterator Iterator;
73 std::vector<Point> contour;
74 contour.push_back(
Point(0,0));
75 contour.push_back(
Point(1,0));
76 contour.push_back(
Point(1,1));
77 contour.push_back(
Point(2,1));
78 contour.push_back(
Point(2,1));
79 contour.push_back(
Point(3,1));
80 contour.push_back(
Point(3,2));
81 contour.push_back(
Point(4,2));
82 contour.push_back(
Point(5,2));
83 contour.push_back(
Point(6,2));
84 contour.push_back(
Point(6,3));
85 contour.push_back(
Point(6,4));
89 trace.
beginBlock(
"Add points while it is possible and draw the result");
91 DSS4Computer theDSS4Computer;
92 theDSS4Computer.init( contour.begin() );
93 trace.
info() << theDSS4Computer << std::endl;
95 while ( (theDSS4Computer.end() != contour.end())
96 &&(theDSS4Computer.extendFront()) ) {}
98 trace.
info() << theDSS4Computer << std::endl;
100 DSS4Computer::Primitive theDSS4 = theDSS4Computer.primitive();
108 board <<
SetMode(
"PointVector",
"Grid");
110 board <<
SetMode(theDSS4.className(),
"Points")
112 board <<
SetMode(theDSS4.className(),
"BoundingBox")
131 typedef std::vector<Point>::iterator Iterator;
134 std::vector<Point> boundary;
135 boundary.push_back(
Point(0,0));
136 boundary.push_back(
Point(1,1));
137 boundary.push_back(
Point(2,1));
138 boundary.push_back(
Point(3,2));
139 boundary.push_back(
Point(4,2));
140 boundary.push_back(
Point(5,2));
141 boundary.push_back(
Point(6,3));
142 boundary.push_back(
Point(6,4));
145 trace.
beginBlock(
"Add points while it is possible and draw the result");
146 DSS8Computer theDSS8Computer;
147 theDSS8Computer.init( boundary.begin() );
149 trace.
info() << theDSS8Computer << std::endl;
151 while ( (theDSS8Computer.end()!=boundary.end())
152 &&(theDSS8Computer.extendFront()) ) {}
154 trace.
info() << theDSS8Computer << std::endl;
156 DSS8Computer::Primitive theDSS8 = theDSS8Computer.primitive();
164 board <<
SetMode(
"PointVector",
"Both");
166 board <<
SetMode(theDSS8.className(),
"Points")
168 board <<
SetMode(theDSS8.className(),
"BoundingBox")
187 std::vector<Point> contour;
188 contour.push_back(
Point(0,0));
189 contour.push_back(
Point(1,0));
190 contour.push_back(
Point(1,1));
191 contour.push_back(
Point(2,1));
192 contour.push_back(
Point(3,1));
193 contour.push_back(
Point(3,2));
194 contour.push_back(
Point(4,2));
195 contour.push_back(
Point(5,2));
196 contour.push_back(
Point(6,2));
197 contour.push_back(
Point(6,3));
199 typedef std::vector<Point>::const_iterator Iterator;
203 typedef Computer::Primitive Primitive;
205 std::deque<Primitive> v1,v2;
210 trace.
info() <<
"forward scan" << std::endl;
213 c.init( contour.begin() );
214 v1.push_back( c.primitive() );
216 while ( (c.end() != contour.end())
217 &&(c.extendFront()) ) {
218 v1.push_back( c.primitive() );
220 ASSERT(contour.size() == v1.size());
223 trace.
info() <<
"backward scan" << std::endl;
226 rc.init( contour.rbegin() );
228 while ( (rc.end() != contour.rend())
229 &&(rc.extendFront()) )
236 v2.push_front( rc.primitive() );
237 while (rc.retractBack()) {
238 v2.push_front( rc.primitive() );
240 ASSERT(v1.size() == v2.size());
243 trace.
info() <<
"comparison" << std::endl;
246 for (
unsigned int k = 0; k < v1.size(); k++) {
247 if (v1.at(k) != v2.at(k))
249 trace.
info() <<
"DSS :" << k << std::endl;
250 trace.
info() << v1.at(k) << std::endl << v2.at(k) << std::endl;
254 trace.
info() <<
"ok for the " << v1.size() <<
" DSS" << std::endl;
263template<
typename Iterator>
273 while ( (theDSS4.end() != l )
274 &&(theDSS4.extendFront()) ) {}
276 ASSERT( theDSS4.isValid() );
279 bool flagIsInside =
true;
280 for (Iterator i = theDSS4.begin(); i != theDSS4.end(); ++i)
282 if ( !theDSS4.isInDSS(i) )
283 flagIsInside =
false;
286 bool flagIsOutside =
true;
287 for (Iterator i = l; i != ite; ++i)
289 if ( theDSS4.isInDSS(i) )
290 flagIsOutside =
false;
292 return (flagIsInside && flagIsOutside);
302 typedef std::vector<Point>::iterator Iterator;
308 std::vector<Point> contour;
309 contour.push_back(
Point(0,0));
310 contour.push_back(
Point(1,1));
311 contour.push_back(
Point(2,1));
312 contour.push_back(
Point(3,1));
313 contour.push_back(
Point(4,1));
314 contour.push_back(
Point(4,2));
315 contour.push_back(
Point(5,2));
316 contour.push_back(
Point(6,2));
317 contour.push_back(
Point(6,3));
318 contour.push_back(
Point(7,3));
320 std::vector<Point> contour2;
321 contour2.push_back(
Point(0,0));
322 contour2.push_back(
Point(1,-1));
323 contour2.push_back(
Point(2,-1));
324 contour2.push_back(
Point(3,-1));
325 contour2.push_back(
Point(4,-1));
326 contour2.push_back(
Point(4,-2));
327 contour2.push_back(
Point(5,-2));
328 contour2.push_back(
Point(6,-2));
329 contour2.push_back(
Point(6,-3));
330 contour2.push_back(
Point(7,-3));
334 Iterator itb = contour.begin() + 1;
335 Iterator ite = itb + 8;
339 trace.
info() << nbok <<
" / " << nb <<
" quadrants" << std::endl;
348 trace.
info() << nbok <<
" / " << nb <<
" quadrants" << std::endl;
357 trace.
info() << nbok <<
" / " << nb <<
" quadrants" << std::endl;
361 Iterator itb = contour2.begin() + 1;
362 Iterator ite = itb + 8;
366 trace.
info() << nbok <<
" / " << nb <<
" quadrants" << std::endl;
373#ifdef WITH_BIGINTEGER
385 typedef std::vector<Point>::iterator Iterator;
392 std::vector<Point> contour;
393 contour.push_back(
Point(1000000000,1000000000));
394 contour.push_back(
Point(1000000001,1000000000));
395 contour.push_back(
Point(1000000002,1000000000));
396 contour.push_back(
Point(1000000003,1000000000));
397 contour.push_back(
Point(1000000003,1000000001));
398 contour.push_back(
Point(1000000004,1000000001));
399 contour.push_back(
Point(1000000005,1000000001));
400 contour.push_back(
Point(1000000005,1000000002));
403 theDSS4.init( contour.begin() );
404 while ( (theDSS4.end() != contour.end())
405 &&(theDSS4.extendFront()) ) {}
407 trace.
info() << theDSS4 <<
" " << theDSS4.isValid() << std::endl;
411 if( (theDSS4.a() == 2)
413 &&(theDSS4.mu() == mu)
414 &&(theDSS4.omega() == 7) ) {
436 typedef std::vector<Point>::iterator Iterator;
439 std::vector<Point> boundary;
440 boundary.push_back(
Point(10,10));
441 boundary.push_back(
Point(10,11));
442 boundary.push_back(
Point(11,11));
447 theDSS8.init(boundary.begin());
448 std::cerr << theDSS8 << std::endl;
449 theDSS8.extendFront();
450 std::cerr << theDSS8 << std::endl;
451 bool res = ( !theDSS8.extendFront() );
452 std::cerr << theDSS8 << std::endl;
464 typedef std::vector<Point>::iterator Iterator;
475 for (
int i = 0; i < argc; ++i )
488#ifdef WITH_BIGINTEGER
493 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
void init(const ConstIterator &it)
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
std::string className() const
Aim: Implements basic operations that will be used in Point and Vector classes.
This class adapts any bidirectional iterator so that operator++ calls operator-- and vice versa.
void beginBlock(const std::string &keyword="")
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
DGtal is the top-level namespace which contains all DGtal functions and types.
mpz_class BigInteger
Multi-precision integer with GMP implementation.
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Aim: Defines the concept describing a dynamic and bidirectional segment computer, ie....
void testArithmeticalDSSComputerConceptChecking()
bool testExtendRetractFront()
bool testIsInsideForOneQuadrant(const Iterator &k, const Iterator &l, const Iterator &ite)