From 2266c6d01f7ff7b643b8ae9eb7405a9e68b5478a Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 2 May 2024 17:22:56 +0100 Subject: [PATCH 1/3] CORE: Accelerate writing to a stream if precision <= 17 --- CGAL_Core/include/CGAL/CORE/Expr.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CGAL_Core/include/CGAL/CORE/Expr.h b/CGAL_Core/include/CGAL/CORE/Expr.h index e6efa1feb7cf..a1d4a0428080 100644 --- a/CGAL_Core/include/CGAL/CORE/Expr.h +++ b/CGAL_Core/include/CGAL/CORE/Expr.h @@ -346,7 +346,11 @@ class Expr : public RCExpr { /// I/O Stream operator<< inline std::ostream& operator<<(std::ostream& o, const Expr& e) { - o << *(const_cast(&e.getRep())); + if (o.precision() > 17) { + o << *(const_cast(&e.getRep())); + } else { + o << e.doubleValue(); + } return o; } /// I/O Stream operator>> From e27fdffc4c6c1c4f87254fb9269aac94c29b374a Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 3 May 2024 09:48:48 +0100 Subject: [PATCH 2/3] Add a timer and single out two data sets in an #if 0 --- .../test/Straight_skeleton_2/test_sls_offset.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp index 298b612fa79d..450e101fd500 100644 --- a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp +++ b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -32,6 +33,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel EPICK; typedef CGAL::Exact_predicates_exact_constructions_kernel EPECK; typedef CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt EPECK_w_sqrt; +typedef CGAL::Timer Timer; template void test_API() { @@ -936,9 +938,12 @@ void test_offset(const char* filename, int i = 0; for(const FT& ot : offset_times) { + Timer t; + t.start(); std::cout << "Offset #" << i++ << " = " << ot << std::endl; Polygon_with_holes_2_ptr_container offset_poly_with_holes = CGAL::create_interior_skeleton_and_offset_polygons_with_holes_2(ot, p, K()); + std::cout << t.time() << " sec." << std::endl; std::cout << offset_poly_with_holes.size() << " polygons with holes" << std::endl; for(const auto& offp : offset_poly_with_holes) @@ -1159,10 +1164,14 @@ void test_kernel() int main(int, char**) { +#if 1 test_kernel(); test_kernel(); test_kernel(); - +#else + test_offset("data/near_degenerate_0.poly"); + test_offset("data/degenerate20.poly"); +#endif std::cout << "Done!" << std::endl; return EXIT_SUCCESS; From ca4817632ea1aa96c98e434a2dadeb3fde168909 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 15 May 2024 09:19:53 +0100 Subject: [PATCH 3/3] Turn #if 0 into a comment --- .../test/Straight_skeleton_2/test_sls_offset.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp index 450e101fd500..90ed7dc9ef31 100644 --- a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp +++ b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp @@ -1164,14 +1164,14 @@ void test_kernel() int main(int, char**) { -#if 1 test_kernel(); test_kernel(); test_kernel(); -#else - test_offset("data/near_degenerate_0.poly"); - test_offset("data/degenerate20.poly"); -#endif + + // those two are really slow + // test_offset("data/near_degenerate_0.poly"); + // test_offset("data/degenerate20.poly"); + std::cout << "Done!" << std::endl; return EXIT_SUCCESS;