From ad8fea230197a8d5279a65dd14e3ecbd445aa1cb Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 9 Dec 2020 15:45:43 +0100 Subject: [PATCH] Fix read_LAS test --- .../include/CGAL/IO/read_off_points.h | 4 +- .../test_read_write_point_set.cpp | 43 ++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/Point_set_processing_3/include/CGAL/IO/read_off_points.h b/Point_set_processing_3/include/CGAL/IO/read_off_points.h index 1d4182cf431..5c06ffcefdc 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_off_points.h @@ -168,8 +168,8 @@ bool read_OFF(std::istream& is, double nx,ny,nz; if (iss >> iformat(x) >> iformat(y) >> iformat(z)) { - FT fx(x), fy(y), fz(z); - Point point(fx, fy, fz); + //the extra `()` seem to fix a very strange bug. Without them, the put() won't compile. + Point point((FT(x)), (FT(y)), (FT(z))); Vector normal = CGAL::NULL_VECTOR; // ... + normal... if (iss >> iformat(nx)) diff --git a/Point_set_processing_3/test/Point_set_processing_3/test_read_write_point_set.cpp b/Point_set_processing_3/test/Point_set_processing_3/test_read_write_point_set.cpp index fa99dbbdddb..9b41a439b14 100644 --- a/Point_set_processing_3/test/Point_set_processing_3/test_read_write_point_set.cpp +++ b/Point_set_processing_3/test/Point_set_processing_3/test_read_write_point_set.cpp @@ -255,7 +255,48 @@ CGAL_DEF_TEST_POINTS_FUNCTION(XYZ, "xyz") CGAL_DEF_TEST_POINTS_FUNCTION(OFF, "off") CGAL_DEF_TEST_POINTS_FUNCTION(PLY, "ply") #ifdef CGAL_LINKED_WITH_LASLIB -CGAL_DEF_TEST_POINTS_FUNCTION(LAS, "las") +void test_points_LAS(const std::string& s) +{ + std::cout << "Test points: " << s << " extension: LAS "<< std::endl; + std::vector ps; + bool ok = CGAL::read_LAS(s, std::back_inserter(ps)); + assert(ok); + ps.clear(); + ok = CGAL::read_LAS(s.c_str(), std::back_inserter(ps)); + assert(ok); + ps.clear(); + std::ifstream in(s, std::ios::binary); + ok = CGAL::read_LAS(in, std::back_inserter(ps)); + assert(ok); + const char* ext = "las"; + std::string fname = "tmp."; + fname.append(ext); + ok = CGAL::write_LAS(fname, ps); + assert(ok); + ok = CGAL::write_LAS(fname, ps, CGAL::parameters::stream_precision(10)); + assert(ok); + ok = CGAL::write_LAS(fname.c_str(), ps); + assert(ok); + ok = CGAL::write_LAS(fname.c_str(), ps, CGAL::parameters::stream_precision(10)); + assert(ok); + std::ofstream out(fname, std::ios::binary); + ok = CGAL::write_LAS(out, ps); + assert(ok); + std::ofstream out2(fname, std::ios::binary); + ok = CGAL::write_LAS(out2, ps, CGAL::parameters::stream_precision(10)); + assert(ok); + std::vector ps2; + std::ifstream is(fname, std::ios::binary); + ok = CGAL::read_LAS(is, std::back_inserter(ps2)); + assert(ok); + assert(points_are_equal(ps, ps2)); + ok = CGAL::write_points(fname, ps2); + assert(ok); + ps2.clear(); + ok = CGAL::read_points(fname, std::back_inserter(ps2)); + assert(ok); + assert(points_are_equal(ps, ps2)); + } #endif #undef CGAL_DEF_INITIALIZE_ID_FUCNTION