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"
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 nbok += (vectPolygons.at(0).size()==2 && vectPolygons.at(1).size()==2 && vectPolygons.at(0).at(0)==
Z3i::Point(1,2,3)
96 && vectPolygons.at(1).at(1)==
Z3i::Point(0,5,5)) ? 1 : 0;
103 for(
unsigned int i=0; i< vectPolygons2D.size(); i++){
104 std::vector< Z2i::Point > aPolygon2D = vectPolygons2D.at(i);
105 trace.
info() <<
"Polygon " << i <<
": " ;
106 for(
unsigned int j =0; j <aPolygon2D.size(); j++){
107 trace.
info()<<
"Point :" << aPolygon2D.at(j);
111 nbok += (vectPolygons2D.at(0).size()==3 && vectPolygons2D.at(1).size()==3 && vectPolygons2D.at(0).at(0)==
Z2i::Point(1,2)
114 && vectPolygons2D.at(1).at(2)==
Z2i::Point(5,5)) ? 1 : 0;
125int main(
int argc,
char** argv )
129 for (
int i = 0; i < argc; ++i )
135 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
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.
static std::vector< TPoint > getPointsFromFile(const std::string &filename, std::vector< unsigned int > aVectPosition=std::vector< unsigned int >())
static std::vector< std::vector< TPoint > > getPolygonsFromFile(const std::string &filename)
bool testPointListReader()