34#include "DGtal/base/Common.h"
35#include "DGtal/kernel/SpaceND.h"
36#include "DGtal/kernel/domains/HyperRectDomain.h"
37#include "DGtal/geometry/curves/FreemanChain.h"
38#include "DGtal/geometry/curves/FP.h"
39#include "DGtal/io/boards/Board2D.h"
41#include "ConfigTest.h"
59 using namespace DGtal;
62 trace.
info() <<
"Reading GridCurve from " << filename << endl;
65 instream.open (filename.c_str(), ifstream::in);
68 typedef int Coordinate;
73 Range r = c.getPointsRange();
77 trace.
info() <<
"Building FP (process digital curve as";
78 trace.
info() << ( (c.isClosed())?
"closed":
"open" ) <<
")" << endl;
84 FP theFP( r.c(), r.c() );
90 FP theFP( r.begin(), r.end() );
97template <
typename Range1,
typename Range2>
98bool compare(
const Range1& pts,
const Range2& groundTruth)
108 return ( (theFP.polygon().size() == groundTruth.size()) &&
109 std::equal(theFP.polygon().begin(), theFP.polygon().end(), groundTruth.begin()) );
114 using namespace DGtal;
123 std::vector<Point> pts, pts2;
124 pts.push_back(
Point(0,0));
125 pts.push_back(
Point(1,0));
126 pts.push_back(
Point(1,1));
127 pts.push_back(
Point(2,1));
128 pts.push_back(
Point(3,1));
129 pts.push_back(
Point(3,0));
130 pts.push_back(
Point(4,0));
131 pts.push_back(
Point(4,1));
132 pts.push_back(
Point(4,2));
133 pts.push_back(
Point(3,2));
134 pts.push_back(
Point(2,2));
135 pts.push_back(
Point(1,2));
136 pts.push_back(
Point(0,2));
137 pts.push_back(
Point(-1,2));
138 pts.push_back(
Point(-2,2));
139 pts.push_back(
Point(-2,1));
140 pts.push_back(
Point(-2,0));
141 pts.push_back(
Point(-1,0));
143 pts2.push_back(
Point(1,1));
144 pts2.push_back(
Point(3,1));
145 pts2.push_back(
Point(3,0));
146 pts2.push_back(
Point(4,0));
147 pts2.push_back(
Point(4,2));
148 pts2.push_back(
Point(-2,2));
149 pts2.push_back(
Point(-2,0));
150 pts2.push_back(
Point(1,0));
156 trace.
info() << nbok <<
" / " << nb << std::endl;
160 std::vector<Point> pts, pts2;
161 pts.push_back(
Point(0,0));
162 pts.push_back(
Point(1,0));
163 pts.push_back(
Point(1,1));
164 pts.push_back(
Point(2,1));
165 pts.push_back(
Point(3,1));
166 pts.push_back(
Point(4,1));
167 pts.push_back(
Point(4,0));
168 pts.push_back(
Point(5,0));
169 pts.push_back(
Point(5,1));
170 for (
int i = 5; i >= -2; --i)
171 pts.push_back(
Point(i,2));
172 pts.push_back(
Point(-2,1));
173 pts.push_back(
Point(-2,0));
174 pts.push_back(
Point(-1,0));
176 pts2.push_back(
Point(1,1));
177 pts2.push_back(
Point(4,1));
178 pts2.push_back(
Point(4,0));
179 pts2.push_back(
Point(5,0));
180 pts2.push_back(
Point(5,2));
181 pts2.push_back(
Point(-2,2));
182 pts2.push_back(
Point(-2,0));
183 pts2.push_back(
Point(1,0));
189 trace.
info() << nbok <<
" / " << nb << std::endl;
193 std::vector<Point> pts, pts2;
194 pts.push_back(
Point(0,0));
195 pts.push_back(
Point(1,0));
196 pts.push_back(
Point(1,1));
197 pts.push_back(
Point(2,1));
198 pts.push_back(
Point(3,1));
199 pts.push_back(
Point(3,2));
200 for (
int i = 3; i >= -2; --i)
201 pts.push_back(
Point(i,3));
202 pts.push_back(
Point(-2,2));
203 pts.push_back(
Point(-2,1));
204 pts.push_back(
Point(-2,0));
205 pts.push_back(
Point(-1,0));
208 pts2.push_back(
Point(1,0));
209 pts2.push_back(
Point(3,1));
210 pts2.push_back(
Point(3,3));
211 pts2.push_back(
Point(-2,3));
212 pts2.push_back(
Point(-2,0));
218 trace.
info() << nbok <<
" / " << nb << std::endl;
222 std::vector<Point> pts, pts2;
223 pts.push_back(
Point(0,0));
224 pts.push_back(
Point(1,0));
225 pts.push_back(
Point(1,1));
226 pts.push_back(
Point(2,1));
227 pts.push_back(
Point(3,1));
228 pts.push_back(
Point(3,2));
229 for (
int i = 3; i >= -1; --i)
230 pts.push_back(
Point(i,3));
231 pts.push_back(
Point(-1,2));
232 pts.push_back(
Point(-1,1));
233 pts.push_back(
Point(-1,0));
236 pts2.push_back(
Point(3,1));
237 pts2.push_back(
Point(3,3));
238 pts2.push_back(
Point(-1,3));
239 pts2.push_back(
Point(-1,0));
240 pts2.push_back(
Point(1,0));
246 trace.
info() << nbok <<
" / " << nb << std::endl;
256int main(
int argc,
char** argv )
258 using namespace DGtal;
261 trace.
info() <<
"Args:";
262 for (
int i = 0; i < argc; ++i )
263 trace.
info() <<
" " << argv[ i ];
264 trace.
info() << endl;
266 string sinus2D4 = testPath +
"samples/sinus2D4.dat";
267 string square = testPath +
"samples/smallSquare.dat";
268 string dss = testPath +
"samples/DSS.dat";
270 bool res =
testFP(sinus2D4)
276 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
Aim: model of CConstBidirectionalRange that adapts any range of elements bounded by two iterators [it...
ConstCirculator c() const
Aim: Computes the faithful polygon (FP) of a range of 4/8-connected 2D Points.
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
bool initFromVectorStream(std::istream &in)
PointsRange getPointsRange() const
bool initFromPointsRange(const TIterator &itb, const TIterator &ite)
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
bool compare(const Range1 &pts, const Range2 &groundTruth)
bool stoppingCriterionTest()
bool testFP(string filename)