diff --git a/ChangeLog.md b/ChangeLog.md index bcfe263b7d..cbd5aeaae7 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -74,6 +74,8 @@ [#1674](https://github.com/DGtal-team/DGtal/pull/1674)) - Fix of `SurfaceMeshWriter::writeIsoLinesOBJ` (Jacques-Olivier Lachaud, [#1701](https://github.com/DGtal-team/DGtal/pull/1701)) + - Fix of the `PointListReader::getPolygonsFromInputStream` (Xun Gong, + [#1708](https://github.com/DGtal-team/DGtal/pull/1708)) - *Examples* - Fix Issue #1675, add missing SymmetricConvexExpander.h file diff --git a/src/DGtal/io/readers/PointListReader.ih b/src/DGtal/io/readers/PointListReader.ih index 8745957a9d..bc5c7d3a19 100644 --- a/src/DGtal/io/readers/PointListReader.ih +++ b/src/DGtal/io/readers/PointListReader.ih @@ -85,10 +85,10 @@ DGtal::PointListReader::getPointsFromInputStream (std::istream &in, std valFromStr >> valConverted; if(!valFromStr.fail()){ for(unsigned int j=0; j< TPoint::dimension; j++){ - if (idx == aVectPosition.at(j) ){ - nbFound++; - p[j]=valConverted; - } + if (idx == aVectPosition.at(j) ){ + nbFound++; + p[j]=valConverted; + } } } } @@ -132,6 +132,7 @@ DGtal::PointListReader::getPolygonsFromInputStream(std::istream & in){ TPoint p; unsigned int index =0; while ( in_str.good() ){ + valStr=""; std::operator>>(in_str, valStr); std::istringstream word_str( valStr ); word_str >> p[index]; diff --git a/tests/io/readers/testPointListReader.cpp b/tests/io/readers/testPointListReader.cpp index e180033ffa..d58fe5651e 100644 --- a/tests/io/readers/testPointListReader.cpp +++ b/tests/io/readers/testPointListReader.cpp @@ -91,9 +91,29 @@ bool testPointListReader() } trace.info()<< std::endl; } - nbok += (vectPolygons.at(0).size()==2 && vectPolygons.at(1).size()==2 && vectPolygons.at(0).at(0)==Z3i::Point(1,2,3) - && vectPolygons.at(0).at(1)==Z3i::Point(4,5,6) && vectPolygons.at(1).at(0)==Z3i::Point(0,0,10) - && vectPolygons.at(1).at(1)==Z3i::Point(0,5,5)) ? 1 : 0; + trace.beginBlock ( "Testing reading special 1 dimension elements (polygon of 1 dimension point)..." ); + + typedef PointVector<1, int> Point1D; + std::vector< std::vector< Point1D > > vectPt1D = PointListReader< Point1D >::getPolygonsFromFile(filenamePoly); + for(unsigned int i=0; i< vectPt1D.size(); i++){ + std::vector< Point1D > aPolygon = vectPt1D.at(i); + trace.info() << "Polygon " << i << ": " ; + for(unsigned int j =0; j