32 #include "DGtal/base/Common.h"
33 #include "DGtal/io/readers/PointListReader.h"
34 #include "DGtal/helpers/StdDefs.h"
35 #include "DGtal/geometry/curves/FreemanChain.h"
37 #include "ConfigTest.h"
42 using namespace DGtal;
54 unsigned int nbok = 0;
58 std::string filename = testPath +
"samples/pointList1.pl";
59 std::vector<unsigned int> vectPos;
64 for(
unsigned int k=0;k < vectPoints.size(); k++){
65 trace.
info() <<
" pt: "<< vectPoints.at(k)<< endl;
67 nbok += (vectPoints.size()==4) ? 1 : 0;
69 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "<< std::endl;
73 std::string filenameFC = testPath +
"samples/freemanChainSample.fc";
75 for(
unsigned int i=0; i< vectFC.size(); i++){
77 trace.
info() <<
"Freeman chain " << i <<
": " << fc.
x0 <<
" " << fc.
y0 <<
" " << fc.
chain << endl;
79 nbok += (vectFC.size()==5) ? 1 : 0;
84 std::string filenamePoly = testPath +
"samples/polygons.dat";
86 for(
unsigned int i=0; i< vectPolygons.size(); i++){
87 std::vector< Z3i::Point > aPolygon = vectPolygons.at(i);
89 for(
unsigned int j =0; j <aPolygon.size(); j++){
90 trace.
info()<<
"Point :" << aPolygon.at(j);
94 trace.
beginBlock (
"Testing reading special 1 dimension elements (polygon of 1 dimension point)..." );
98 for(
unsigned int i=0; i< vectPt1D.size(); i++){
99 std::vector< Point1D > aPolygon = vectPt1D.at(i);
100 trace.
info() <<
"Polygon " << i <<
": " ;
101 for(
unsigned int j =0; j <aPolygon.size(); j++){
102 trace.
info()<<
"Point :" << aPolygon.at(j);
106 Point1D p1, p2, p3, p4, p5, p6; p1[0]=1; p2[0]=2; p3[0]=3; p4[0]=4; p5[0]=5; p6[0]=6;
107 Point1D p7, p8, p9, p10, p11, p12; p7[0]=0; p8[0]=0; p9[0]=10; p10[0]=0; p11[0]=5; p12[0]=5;
109 nbok += (vectPt1D.at(0).size()==6 && vectPt1D.at(1).size()==6 && vectPt1D.at(0).at(0) == p1 &&
110 vectPt1D.at(0).at(1)==p2 && vectPt1D.at(0).at(2) == p3 && vectPt1D.at(0).at(3) == p4
111 && vectPt1D.at(0).at(4)==p5 && vectPt1D.at(0).at(5)==p6
112 && vectPt1D.at(1).at(0)==p7
113 && vectPt1D.at(1).at(1)==p8 && vectPt1D.at(1).at(2)==p9 && vectPt1D.at(1).at(3)==p10
114 && vectPt1D.at(1).at(4)==p11 && vectPt1D.at(1).at(5)==p12);
123 for(
unsigned int i=0; i< vectPolygons2D.size(); i++){
124 std::vector< Z2i::Point > aPolygon2D = vectPolygons2D.at(i);
125 trace.
info() <<
"Polygon " << i <<
": " ;
126 for(
unsigned int j =0; j <aPolygon2D.size(); j++){
127 trace.
info()<<
"Point :" << aPolygon2D.at(j);
131 nbok += (vectPolygons2D.at(0).size()==3 && vectPolygons2D.at(1).size()==3 && vectPolygons2D.at(0).at(0)==
Z2i::Point(1,2)
134 && vectPolygons2D.at(1).at(2)==
Z2i::Point(5,5)) ? 1 : 0;
145 int main(
int argc,
char** argv )
149 for (
int i = 0; i < argc; ++i )
155 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
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: Implements method to read a set of points represented in each line of a file.
int main(int argc, char **argv)
bool testPointListReader()