32 #include "DGtal/base/Common.h"
33 #include "DGtal/kernel/SpaceND.h"
34 #include "DGtal/kernel/PointVector.h"
35 #include "DGtal/kernel/BasicPointFunctors.h"
36 #include "DGtal/base/ConstIteratorAdapter.h"
37 #include "DGtal/base/Circulator.h"
39 #include <boost/concept_check.hpp>
45 using namespace DGtal;
58 unsigned int nbok = 0;
62 typedef std::vector<Point3>::iterator Iterator3;
74 std::vector<Point3> r;
75 r.push_back(Point3(0,0,0));
76 r.push_back(Point3(1,0,0));
77 r.push_back(Point3(2,0,0));
78 r.push_back(Point3(2,1,0));
79 r.push_back(Point3(2,1,1));
80 r.push_back(Point3(3,1,1));
81 r.push_back(Point3(4,1,1));
82 r.push_back(Point3(4,2,1));
83 r.push_back(Point3(4,2,2));
84 r.push_back(Point3(5,2,2));
85 r.push_back(Point3(6,2,2));
86 r.push_back(Point3(6,3,2));
87 r.push_back(Point3(6,3,3));
88 r.push_back(Point3(6,4,3));
89 r.push_back(Point3(6,4,4));
90 r.push_back(Point3(6,5,4));
93 std::vector<Point2> rtrue;
94 rtrue.push_back(Point2(0,0));
95 rtrue.push_back(Point2(1,0));
96 rtrue.push_back(Point2(2,0));
97 rtrue.push_back(Point2(2,1));
98 rtrue.push_back(Point2(2,1));
99 rtrue.push_back(Point2(3,1));
100 rtrue.push_back(Point2(4,1));
101 rtrue.push_back(Point2(4,2));
102 rtrue.push_back(Point2(4,2));
103 rtrue.push_back(Point2(5,2));
104 rtrue.push_back(Point2(6,2));
105 rtrue.push_back(Point2(6,3));
106 rtrue.push_back(Point2(6,3));
107 rtrue.push_back(Point2(6,4));
108 rtrue.push_back(Point2(6,4));
109 rtrue.push_back(Point2(6,5));
113 trace.
info() <<
"2d points after projection (XY)" << endl;
117 Adapter aitBegin(r.begin(),proj);
118 Adapter ait = aitBegin;
119 Adapter aitEnd(r.end(),proj);
121 for ( ; ait != aitEnd; ++ait)
125 trace.
info() <<
"(" << ait->operator[](0) <<
", " << ait->operator[](1) <<
")" << endl;
129 if ( std::equal( rtrue.begin(), rtrue.end(), aitBegin ) ==
true )
132 trace.
info() << nbok <<
"/" << nb << std::endl;
135 trace.
info() <<
"basic operators (operator==)" << endl;
136 if ( ( ait != aitBegin ) && ( ait == aitEnd ) )
139 trace.
info() << nbok <<
"/" << nb << std::endl;
142 ait = (aitBegin + 3);
145 trace.
info() <<
"random access operators (operator+)" << endl;
146 trace.
info() << *(aitBegin.base()) << *aitBegin << endl;
148 trace.
info() << *(ait.base()) << *ait << endl;
149 if ( ( *ait == Point2(3,1) ) ==
true )
152 trace.
info() << nbok <<
"/" << nb << std::endl;
154 trace.
info() <<
"backward scanning" << endl;
155 std::reverse_iterator<Adapter> raitBegin( aitEnd );
156 if ( std::equal( rtrue.rbegin(), rtrue.rend(), raitBegin ) ==
true )
159 trace.
info() << nbok <<
"/" << nb << std::endl;
161 trace.
info() <<
"circular scanning" << endl;
163 if ( std::equal( rtrue.begin(), rtrue.end(), caitBegin ) ==
true )
166 trace.
info() << nbok <<
"/" << nb << std::endl;
177 int main(
int argc,
char** argv )
181 for (
int i = 0; i < argc; ++i )
187 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
This class adapts any iterator so that operator* returns another element than the one pointed to by t...
Aim: Implements basic operations that will be used in Point and Vector classes.
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Functor that maps a point P of dimension i to a point Q of dimension j. The member myDims is an ...
Go to http://www.sgi.com/tech/stl/RandomAccessIterator.html.
Go to http://www.boost.org/doc/libs/1_52_0/libs/iterator/doc/RandomAccessTraversal....
Go to http://www.boost.org/doc/libs/1_52_0/libs/iterator/doc/ReadableIterator.html.
int main(int argc, char **argv)