From abe216b73d920f0bfaae5a79842e2a1a5b6345ba Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 17 Feb 2022 08:43:30 +0000 Subject: [PATCH 1/3] PSP: ofstream -> sstream --- .../test_deprecated_io_point_set.cpp | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp b/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp index c968c046eec..a1ca1a5ecc1 100644 --- a/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp +++ b/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point_3; @@ -86,10 +86,13 @@ int main() ps.push_back(Point_3(0,1,0)); ps.push_back(Point_3(0,0,1)); + std::string input; + //LAS #ifdef CGAL_LINKED_WITH_LASLIB + { - std::ofstream os("tmp1.las", std::ios::binary); + std::ostringsteam os(std::ios::binary); ok = CGAL::write_las_points_with_properties(os, points, CGAL::make_las_point_writer(CGAL::First_of_pair_property_map()), std::make_pair(GetRedMap(),CGAL::LAS_property::R()), @@ -98,12 +101,14 @@ int main() std::make_pair(GetAlphaMap(), CGAL::LAS_property::I()) ); assert(ok); + os.flush(); + input = os.str(); } { points.clear(); - std::ifstream is("tmp1.las", std::ios::binary); + std::istringstream is(input, std::ios::binary); ok = CGAL::read_las_points_with_properties(is, std::back_inserter (points), CGAL::make_las_point_reader(CGAL::First_of_pair_property_map()), std::make_tuple(CGAL::Second_of_pair_property_map(), @@ -118,14 +123,16 @@ int main() } { - std::ofstream os("tmp2.las", std::ios_base::binary); + std::ostringstream os(std::ios_base::binary); CGAL::write_las_points(os, ps, CGAL::parameters::all_default()); assert(ok); + os.flush(); + input = os.str(); } { ps.clear(); - std::ifstream is("tmp2.las", std::ios::binary); + std::istringstream is(input, std::ios::binary); ok = CGAL::read_las_points(is, std::back_inserter (ps),CGAL::parameters::all_default()); assert(ok); assert(ps.size() == 3); @@ -134,7 +141,7 @@ int main() //PLY { - std::ofstream os("tmp1.ply"); + std::ostringstream os; assert(os.good()); ok = CGAL::write_ply_points_with_properties(os, points, CGAL::make_ply_point_writer (CGAL::First_of_pair_property_map()), @@ -145,10 +152,12 @@ int main() ); assert(! os.fail()); assert(ok); + os.flush(); + input = os.str(); } { - std::ifstream is("tmp1.ply"); + std::istringstream is(input); assert(is.good()); points.clear(); ok = CGAL::read_ply_points_with_properties(is, std::back_inserter (points), @@ -166,15 +175,17 @@ int main() } { - std::ofstream os("tmp2.ply"); + std::ostringstream os; assert(os.good()); ok = CGAL::write_ply_points(os, ps, CGAL::parameters::all_default()); assert(! os.fail()); assert(ok); + os.flush(); + input = os.str(); } { - std::ifstream is("tmp2.ply"); + std::istringstream is(input); assert(is.good()); ps.clear(); ok = CGAL::read_ply_points(is, std::back_inserter (ps), @@ -186,15 +197,17 @@ int main() //OFF { - std::ofstream os("tmp.off"); + std::ostringstream os; assert(os.good()); ok = CGAL::write_off_points(os, ps, CGAL::parameters::all_default()); assert(! os.fail()); assert(ok); + os.flush(); + input = os.str(); } { - std::ifstream is("tmp.off"); + std::istringstream is(input); assert(is.good()); ps.clear(); ok = CGAL::read_off_points(is, std::back_inserter (ps), @@ -206,15 +219,17 @@ int main() //XYZ { - std::ofstream os("tmp.xyz"); + std::ostringstream os; assert(os.good()); ok = CGAL::write_xyz_points(os, ps, CGAL::parameters::all_default()); assert(! os.fail()); assert(ok); + os.flush(); + input = os.str(); } { - std::ifstream is("tmp.xyz"); + std::istringstream is(input); assert(is.good()); ps.clear(); ok = CGAL::read_xyz_points(is, std::back_inserter (ps), From 740d34234f7bc288b6277ca8dbac751ad1aa9f84 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 17 Feb 2022 08:54:52 +0000 Subject: [PATCH 2/3] delete trailing whitespace --- .../Point_set_processing_3/test_deprecated_io_point_set.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp b/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp index a1ca1a5ecc1..81bf1bd48a6 100644 --- a/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp +++ b/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp @@ -90,7 +90,7 @@ int main() //LAS #ifdef CGAL_LINKED_WITH_LASLIB - + { std::ostringsteam os(std::ios::binary); ok = CGAL::write_las_points_with_properties(os, points, From 435e6d690f2e6f07c73f918415d6057c6d7ff1c1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 22 Feb 2022 08:11:51 +0000 Subject: [PATCH 3/3] Fix typo (leading to a compilation error) --- .../Point_set_processing_3/test_deprecated_io_point_set.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp b/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp index 81bf1bd48a6..9727d28968a 100644 --- a/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp +++ b/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp @@ -92,7 +92,7 @@ int main() #ifdef CGAL_LINKED_WITH_LASLIB { - std::ostringsteam os(std::ios::binary); + std::ostringstream os(std::ios::binary); ok = CGAL::write_las_points_with_properties(os, points, CGAL::make_las_point_writer(CGAL::First_of_pair_property_map()), std::make_pair(GetRedMap(),CGAL::LAS_property::R()),