From f65405a32f5769c343ffd20cd8c098d5773ac0db Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 21 Sep 2020 15:21:35 +0200 Subject: [PATCH 1/9] Windows, FPU.h: replace `_control_fp` by SSE2 intrisics Fix #2135 --- Number_types/include/CGAL/FPU.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index 1ed1d728d34..afed10051f8 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -75,8 +75,8 @@ extern "C" { // Pure and safe SSE2 mode (g++ -mfpmath=sse && (-msse2 || -march=pentium4)) // can be detected by : // TODO : see what Intel and VC++ have to say about this. -#if defined __FLT_EVAL_METHOD__ && defined __SSE2_MATH__ && \ - (__FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 1) +#if defined _M_X64 || ( defined __FLT_EVAL_METHOD__ && defined __SSE2_MATH__ && \ + (__FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 1) ) # define CGAL_SAFE_SSE2 # include #endif @@ -90,7 +90,7 @@ extern "C" { #if !defined CGAL_IA_NO_X86_OVER_UNDER_FLOW_PROTECT && \ (((defined __i386__ || defined __x86_64__) && !defined CGAL_SAFE_SSE2) \ || defined __ia64__ \ - || defined _M_IX86 || defined _M_X64 || defined _M_IA64 \ + || defined _M_IX86 || defined _M_IA64 \ || (defined FLT_EVAL_METHOD && FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1)) # define CGAL_FPU_HAS_EXCESS_PRECISION #endif From a886ecbd71e146c90338cd40078601d7825a325d Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 29 Sep 2020 09:14:11 +0200 Subject: [PATCH 2/9] Fix a warning in an inelegant code - `std::cerr` is already unbufferized, and `std::flush` does nothing on it, - and anyway, `std::endl` calls `std::flush`. --- Nef_2/include/CGAL/Nef_2/debug.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Nef_2/include/CGAL/Nef_2/debug.h b/Nef_2/include/CGAL/Nef_2/debug.h index ff850cdf052..ce77dc610c6 100644 --- a/Nef_2/include/CGAL/Nef_2/debug.h +++ b/Nef_2/include/CGAL/Nef_2/debug.h @@ -59,8 +59,7 @@ #ifndef NDEBUG #define CGAL_NEF_TRACEN(t) if((debugthread%CGAL_NEF_DEBUG)==0) \ - std::cerr<< " "< Date: Tue, 29 Sep 2020 09:50:43 +0200 Subject: [PATCH 3/9] Init li and lt to fix warning --- Triangulation_2/include/CGAL/Triangulation_2.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Triangulation_2/include/CGAL/Triangulation_2.h b/Triangulation_2/include/CGAL/Triangulation_2.h index afd701535e2..f4576363305 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2.h @@ -2972,9 +2972,9 @@ exact_locate(const Point& p, Face_handle start) const #endif // no CGAL_NO_STRUCTURAL_FILTERING { + li = 4; //general init to avoid warnings. + lt = OUTSIDE_AFFINE_HULL; //same if (dimension() < 0) { - lt = OUTSIDE_AFFINE_HULL; - li = 4; // li should not be used in this case return Face_handle(); } if( dimension() == 0) { @@ -2983,10 +2983,6 @@ exact_locate(const Point& p, if (xy_equal(p,finite_vertex()->face()->vertex(0)->point())){ lt = VERTEX ; } - else{ - lt = OUTSIDE_AFFINE_HULL; - } - li = 4; // li should not be used in this case return Face_handle(); } if(dimension() == 1){ From c6077ca87a91fe38d94f3f5013da67882ef52c1c Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 29 Sep 2020 12:06:15 +0200 Subject: [PATCH 4/9] Remove _known fiom intersection line_2/line_2 --- .../CGAL/Intersections_2/Line_2_Line_2.h | 12 +++++------- .../include/CGAL/Intersections_2/Line_2_Ray_2.h | 17 +++++++++-------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Intersections_2/include/CGAL/Intersections_2/Line_2_Line_2.h b/Intersections_2/include/CGAL/Intersections_2/Line_2_Line_2.h index 8ddaaf9bf5b..d95ddec8f2a 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Line_2_Line_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Line_2_Line_2.h @@ -36,10 +36,10 @@ namespace internal { template class Line_2_Line_2_pair { public: - enum Intersection_results {NO_INTERSECTION, POINT, LINE}; + enum Intersection_results {NOT_COMPUTED_YET, NO_INTERSECTION, POINT, LINE}; Line_2_Line_2_pair(typename K::Line_2 const *line1, typename K::Line_2 const *line2) - : _line1(line1), _line2(line2), _known(false) {} + : _line1(line1), _line2(line2), _result(NOT_COMPUTED_YET) {} Intersection_results intersection_type() const; @@ -48,7 +48,6 @@ public: protected: typename K::Line_2 const* _line1; typename K::Line_2 const * _line2; - mutable bool _known; mutable Intersection_results _result; mutable typename K::Point_2 _intersection_point; }; @@ -141,11 +140,10 @@ typename Line_2_Line_2_pair::Intersection_results Line_2_Line_2_pair::intersection_type() const { typedef typename K::RT RT; - if (_known) + if (_result != NOT_COMPUTED_YET) return _result; RT nom1, nom2, denom; // The non const this pointer is used to cast away const. - _known = true; denom = _line1->a()*_line2->b() - _line2->a()*_line1->b(); if (denom == RT(0)) { if (RT(0) == (_line1->a()*_line2->c() - _line2->a()*_line1->c()) && @@ -180,7 +178,7 @@ template typename K::Point_2 Line_2_Line_2_pair::intersection_point() const { - if (!_known) + if (_result == NOT_COMPUTED_YET) intersection_type(); CGAL_kernel_assertion(_result == POINT); return _intersection_point; @@ -190,7 +188,7 @@ template typename K::Line_2 Line_2_Line_2_pair::intersection_line() const { - if (!_known) + if (_result == NOT_COMPUTED_YET) intersection_type(); CGAL_kernel_assertion(_result == LINE); return *_line1; diff --git a/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h b/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h index bfd102da8de..68ac85b8f9f 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h @@ -35,10 +35,13 @@ namespace internal { template class Ray_2_Line_2_pair { public: - enum Intersection_results {NO_INTERSECTION, POINT, RAY}; + enum Intersection_results {NOT_COMPUTED_YET, NO_INTERSECTION, POINT, RAY}; + typedef typename K::FT FT; Ray_2_Line_2_pair(typename K::Ray_2 const *ray, typename K::Line_2 const *line) - : _ray(ray), _line(line), _known(false) {} + : _ray(ray), _line(line), _result(NOT_COMPUTED_YET), + _intersection_point(typename K::Point_2(FT(0), FT(0))) + {} Intersection_results intersection_type() const; @@ -47,7 +50,6 @@ public: protected: typename K::Ray_2 const * _ray; typename K::Line_2 const * _line; - mutable bool _known; mutable Intersection_results _result; mutable typename K::Point_2 _intersection_point; }; @@ -94,7 +96,7 @@ intersection(const typename K::Line_2 &line, const typename K::Ray_2 &ray, const K& k) { - return internal::intersection(ray, line, k); + return internal::intersection(ray, line, k); } @@ -115,10 +117,9 @@ template typename Ray_2_Line_2_pair::Intersection_results Ray_2_Line_2_pair::intersection_type() const { - if (_known) + if (_result != NOT_COMPUTED_YET) return _result; // The non const this pointer is used to cast away const. - _known = true; const typename K::Line_2 &l1 = _ray->supporting_line(); Line_2_Line_2_pair linepair(&l1, _line); switch ( linepair.intersection_type()) { @@ -142,7 +143,7 @@ template typename K::Point_2 Ray_2_Line_2_pair::intersection_point() const { - if (!_known) + if (_result == NOT_COMPUTED_YET) intersection_type(); CGAL_kernel_assertion(_result == POINT); return _intersection_point; @@ -152,7 +153,7 @@ template typename K::Ray_2 Ray_2_Line_2_pair::intersection_ray() const { - if (!_known) + if (_result == NOT_COMPUTED_YET) intersection_type(); CGAL_kernel_assertion(_result == RAY); return *_ray; From bdd69b5982d3ee332ef758ce5800b3fdc6bdb085 Mon Sep 17 00:00:00 2001 From: Maxime GIMENO Date: Tue, 29 Sep 2020 12:42:02 +0200 Subject: [PATCH 5/9] Replace K::Point_2(0,0) with ORIGIN Co-authored-by: Laurent Rineau --- Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h b/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h index 68ac85b8f9f..a88d529e145 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h @@ -40,7 +40,7 @@ public: Ray_2_Line_2_pair(typename K::Ray_2 const *ray, typename K::Line_2 const *line) : _ray(ray), _line(line), _result(NOT_COMPUTED_YET), - _intersection_point(typename K::Point_2(FT(0), FT(0))) + _intersection_point(ORIGIN) {} Intersection_results intersection_type() const; From c33bd6ac363c5f2523d0ff43cbeb7f46858b04a9 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 29 Sep 2020 17:08:29 +0200 Subject: [PATCH 6/9] Fix ORIGIN --- Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h b/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h index a88d529e145..a6dec7ec7a9 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h @@ -40,7 +40,7 @@ public: Ray_2_Line_2_pair(typename K::Ray_2 const *ray, typename K::Line_2 const *line) : _ray(ray), _line(line), _result(NOT_COMPUTED_YET), - _intersection_point(ORIGIN) + _intersection_point(typename K::Point_2(ORIGIN)) {} Intersection_results intersection_type() const; From 8c5725a1d017265f199cb43e2e0ceb86cdb16122 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 30 Sep 2020 08:59:06 +0200 Subject: [PATCH 7/9] Fix missing constructor in kernel example --- Kernel_23/examples/Kernel_23/MyPointC2.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Kernel_23/examples/Kernel_23/MyPointC2.h b/Kernel_23/examples/Kernel_23/MyPointC2.h index de1c7ee6cd6..8040b9abe87 100644 --- a/Kernel_23/examples/Kernel_23/MyPointC2.h +++ b/Kernel_23/examples/Kernel_23/MyPointC2.h @@ -21,6 +21,13 @@ public: *(vec+1) = 0; } + MyPointC2(const CGAL::Origin &) + :col(0) + { + *vec = 0; + *(vec+1) = 0; + } + MyPointC2(const double x, const double y, int c = 0) : col(c) From 2549b589730a7643bb0c1daf42c3ace071867687 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 30 Sep 2020 09:58:12 +0200 Subject: [PATCH 8/9] fix warnings on switch --- Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h | 1 + .../include/CGAL/Intersections_2/Segment_2_Segment_2.h | 1 + .../include/CGAL/Intersections_2/internal/Straight_2.h | 1 + 3 files changed, 3 insertions(+) diff --git a/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h b/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h index a6dec7ec7a9..5d052dca5d2 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h @@ -124,6 +124,7 @@ Ray_2_Line_2_pair::intersection_type() const Line_2_Line_2_pair linepair(&l1, _line); switch ( linepair.intersection_type()) { case Line_2_Line_2_pair::NO_INTERSECTION: + default: _result = NO_INTERSECTION; break; case Line_2_Line_2_pair::POINT: diff --git a/Intersections_2/include/CGAL/Intersections_2/Segment_2_Segment_2.h b/Intersections_2/include/CGAL/Intersections_2/Segment_2_Segment_2.h index 663361e4eb9..ba3d8b9567c 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Segment_2_Segment_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Segment_2_Segment_2.h @@ -308,6 +308,7 @@ Segment_2_Segment_2_pair::intersection_type() const Line_2_Line_2_pair linepair(&l1, &l2); switch ( linepair.intersection_type()) { case Line_2_Line_2_pair::NO_INTERSECTION: + default: _result = NO_INTERSECTION; break; case Line_2_Line_2_pair::POINT: diff --git a/Intersections_2/include/CGAL/Intersections_2/internal/Straight_2.h b/Intersections_2/include/CGAL/Intersections_2/internal/Straight_2.h index 47424bb3122..fa63e699475 100644 --- a/Intersections_2/include/CGAL/Intersections_2/internal/Straight_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/internal/Straight_2.h @@ -275,6 +275,7 @@ cut_right_off(typename K::Line_2 const & cutter) Line_2_Line_2_pair pair(&support_, &cutter); switch (pair.intersection_type()) { case Line_2_Line_2_pair::NO_INTERSECTION: + default: if (cutter.has_on_negative_side(support_.point())) bound_state_ = LINE_EMPTY; break; From e169490c78b5ff3e88d1b5a231ab02d66fffff5b Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 30 Sep 2020 10:03:30 +0200 Subject: [PATCH 9/9] Replace fix for Point_2(Origin) --- .../include/CGAL/Intersections_2/Line_2_Ray_2.h | 2 +- Kernel_23/examples/Kernel_23/MyPointC2.h | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h b/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h index 5d052dca5d2..eada9a07ec2 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Line_2_Ray_2.h @@ -40,7 +40,7 @@ public: Ray_2_Line_2_pair(typename K::Ray_2 const *ray, typename K::Line_2 const *line) : _ray(ray), _line(line), _result(NOT_COMPUTED_YET), - _intersection_point(typename K::Point_2(ORIGIN)) + _intersection_point(K().construct_point_2_object()(ORIGIN)) {} Intersection_results intersection_type() const; diff --git a/Kernel_23/examples/Kernel_23/MyPointC2.h b/Kernel_23/examples/Kernel_23/MyPointC2.h index 8040b9abe87..e4b2f3ff0ce 100644 --- a/Kernel_23/examples/Kernel_23/MyPointC2.h +++ b/Kernel_23/examples/Kernel_23/MyPointC2.h @@ -21,14 +21,6 @@ public: *(vec+1) = 0; } - MyPointC2(const CGAL::Origin &) - :col(0) - { - *vec = 0; - *(vec+1) = 0; - } - - MyPointC2(const double x, const double y, int c = 0) : col(c) {