From 4cd96171e2495a23c779b10df2c1ce4d6130b334 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 26 Oct 2017 15:35:26 +0100 Subject: [PATCH 01/16] Add a static filter for do_intersect(Segment_2, Segment_2) --- Filtered_kernel/include/CGAL/Lazy_kernel.h | 36 +++++++- .../internal/Static_filters/Do_intersect_2.h | 90 +++++++++++++++++++ .../internal/Static_filters/Do_intersect_3.h | 2 +- .../internal/Static_filters/Static_filters.h | 34 ++++--- 4 files changed, 148 insertions(+), 14 deletions(-) create mode 100644 Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_2.h diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index 094c9cff5d5..dbecf93a5d3 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -31,7 +31,8 @@ #include #include #include - +#include +#include #include #include #include @@ -281,6 +282,10 @@ public: #include }; + + + + template < typename EK_, typename AK_, typename E2A_, typename Kernel_ > class Lazy_kernel_base : public Lazy_kernel_generic_base @@ -307,6 +312,35 @@ public: // typedef void Compute_z_3; // to detect where .z() is called // typedef void Construct_point_3; // to detect where the ctor is called + + class Do_intersect_2 { + public: + bool operator()(const Segment_2& s, const Segment_2& t) const + { + internal::Static_filters_predicates::Get_approx get_approx; + typedef Exact_predicates_inexact_constructions_kernel Fit; + typedef typename Fit::Point_2 Fpoint; + typedef typename Fit::Segment_2 Fsegment; + double ssx, ssy, stx, sty, tsx, tsy, ttx, tty; + if(fit_in_double(get_approx(s).source().x(), ssx) && + fit_in_double(get_approx(s).source().y(), ssy) && + fit_in_double(get_approx(s).target().x(), stx) && + fit_in_double(get_approx(s).target().y(), sty) && + fit_in_double(get_approx(t).source().x(), tsx) && + fit_in_double(get_approx(t).source().y(), tsy) && + fit_in_double(get_approx(t).target().x(), ttx) && + fit_in_double(get_approx(t).target().y(), tty)){ + return do_intersect(Fsegment(Fpoint(ssx,ssy), Fpoint(stx,sty)), + Fsegment(Fpoint(tsx,tsy), Fpoint(ttx,tty))); + } + typename Lazy_kernel_generic_base::Do_intersect_2 DI; + return DI(s,t); + } + }; + + Do_intersect_2 do_intersect_2_object() const + { return Do_intersect_2(); } + Assign_2 assign_2_object() const { return Assign_2(); } diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_2.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_2.h new file mode 100644 index 00000000000..132cf8911ae --- /dev/null +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_2.h @@ -0,0 +1,90 @@ +// Copyright (c) 2008 ETH Zurich (Switzerland) +// Copyright (c) 2008-2009 INRIA Sophia-Antipolis (France) +// Copyright (c) 2017 GeometryFactory Sarl (France) +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// +// Author(s) : Andreas Fabri, Laurent Rineau + + +#ifndef CGAL_INTERNAL_STATIC_FILTERS_DO_INTERSECT_2_H +#define CGAL_INTERNAL_STATIC_FILTERS_DO_INTERSECT_2_H + +#include + +namespace CGAL { + +namespace internal { + +namespace Static_filters_predicates { + +template < typename K_base, typename SFK > +class Do_intersect_2 + : public K_base::Do_intersect_2 +{ + typedef typename K_base::Point_2 Point_2; + typedef typename K_base::Segment_2 Segment_2; + typedef typename K_base::Do_intersect_2 Base; + + typedef K_base TA1; + typedef SFK TA2; +public: + + typedef typename Base::result_type result_type; + + +#ifndef CGAL_CFG_MATCHING_BUG_6 + using Base::operator(); +#else // CGAL_CFG_MATCHING_BUG_6 + template + result_type + operator()(const T1& t1, const T2& t2) const + { + return Base()(t1,t2); + } +#endif // CGAL_CFG_MATCHING_BUG_6 + + // The internal::do_intersect(..) function + // only performs orientation tests on the vertices + // of the segment + // By calling the do_intersect function with + // the statically filtered kernel we avoid + // that doubles are put into Interval_nt + // to get taken out again with fit_in_double + result_type + operator()(const Segment_2 &s, const Segment_2& t) const + { + return internal::do_intersect(s,t, SFK()); + } + + result_type + operator()(const Point_2 &p, const Segment_2& t) const + { + return internal::do_intersect(p,t, SFK()); + } + + result_type + operator()(const Segment_2& t, const Point_2 &p) const + { + return internal::do_intersect(p,t, SFK()); + } + +}; +} // Static_filters_predicates +} // internal +} // CGAL +#endif diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h index 59c87955863..5a41130ebb5 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h @@ -83,7 +83,7 @@ public: // of the triangle and the segment // By calling the do_intersect function with // the statically filtered kernel we avoid - // that doubles are put into Inteval_nt + // that doubles are put into Interval_nt // to get taken out again with fit_in_double result_type operator()(const Segment_3 &s, const Triangle_3& t) const diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Static_filters.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Static_filters.h index 01486477b25..1eb5c24f57b 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Static_filters.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Static_filters.h @@ -45,7 +45,8 @@ # define CGAL_NO_COMPARE_X_2_STATIC_FILTERS 1 # define CGAL_NO_IS_DEGENERATE_3_STATIC_FILTERS 1 # define CGAL_NO_ANGLE_3_STATIC_FILTERS 1 -# define CGAL_NO_DO_INTERSECT_3_STATIC_FILTERS 1 +# define CGAL_NO_DO_INTERSECT_STATIC_FILTERS 1 + #endif // CGAL_DISABLE_STATIC_FILTERS_ADDED_2011 @@ -67,9 +68,10 @@ # include #endif // NOT CGAL_NO_ANGLE_3_STATIC_FILTERS -#ifndef CGAL_NO_DO_INTERSECT_3_STATIC_FILTERS +#ifndef CGAL_NO_DO_INTERSECT_STATIC_FILTERS # include -#endif // NOT NOT CGAL_NO_DO_INTERSECT_3_STATIC_FILTERS +# include +#endif // NOT NOT CGAL_NO_DO_INTERSECT_STATIC_FILTERS #include #include @@ -139,9 +141,6 @@ public: typedef Static_filters_predicates::Angle_3 Angle_3; #endif // NOT CGAL_NO_ANGLE_3_STATIC_FILTERS -#ifndef CGAL_NO_DO_INTERSECT_3_STATIC_FILTERS - typedef Static_filters_predicates::Do_intersect_3 Do_intersect_3; -#endif // NOT CGAL_NO_DO_INTERSECT_3_STATIC_FILTERS typedef Static_filters_predicates::Side_of_oriented_circle_2 Side_of_oriented_circle_2; typedef Static_filters_predicates::Side_of_oriented_sphere_3 Side_of_oriented_sphere_3; typedef Static_filters_predicates::Compare_squared_radius_3 Compare_squared_radius_3; @@ -179,6 +178,7 @@ public: Compare_y_2 compare_y_2_object() const { return Compare_y_2(); } + #endif // NOT CGAL_NO_COMPARE_Y_2_STATIC_FILTERS #ifndef CGAL_NO_IS_DEGENERATE_3_STATIC_FILTERS @@ -193,12 +193,6 @@ Compare_y_2 { return Angle_3(); } #endif // NOT CGAL_NO_ANGLE_3_STATIC_FILTERS -#ifndef CGAL_NO_DO_INTERSECT_3_STATIC_FILTERS - Do_intersect_3 - do_intersect_3_object() const - { return Do_intersect_3(); } -#endif // NOT CGAL_NO_DO_INTERSECT_3_STATIC_FILTERS - Side_of_oriented_circle_2 side_of_oriented_circle_2_object() const { return Side_of_oriented_circle_2(); } @@ -261,6 +255,11 @@ public: typedef CartesianKernelFunctors::Compare_xy_3 Compare_xy_3; typedef CartesianKernelFunctors::Compare_xyz_3 Compare_xyz_3; +#ifndef CGAL_NO_DO_INTERSECT_STATIC_FILTERS + typedef Static_filters_predicates::Do_intersect_2 Do_intersect_2; + typedef Static_filters_predicates::Do_intersect_3 Do_intersect_3; +#endif // NOT CGAL_NO_DO_INTERSECT_STATIC_FILTERS + Compare_xy_2 compare_xy_2_object() const { return Compare_xy_2(); } @@ -329,6 +328,17 @@ public: compare_y_at_x_2_object() const { return Compare_y_at_x_2(); } +#ifndef CGAL_NO_DO_INTERSECT_STATIC_FILTERS + Do_intersect_3 + do_intersect_3_object() const + { return Do_intersect_3(); } + + Do_intersect_2 + do_intersect_2_object() const + { return Do_intersect_2(); } + +#endif // NOT CGAL_NO_DO_INTERSECT_STATIC_FILTERS + // The two following are for degenerate cases, so I'll update them later. // // typedef Static_filters_predicates::Coplanar_orientation_3 From 2f95a05e1cdc4ea78de8b46904a6b061ac42db7b Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 27 Oct 2017 15:27:20 +0100 Subject: [PATCH 02/16] make filtering with static filter generic --- .../polygon_set_2_join.cpp | 2 +- Filtered_kernel/include/CGAL/Epic_converter.h | 325 ++++++++++++++++++ Filtered_kernel/include/CGAL/Lazy_kernel.h | 15 +- .../include/CGAL/Static_filtered_predicate.h | 237 +++++++++++++ Kernel_23/include/CGAL/Kernel/Type_mapper.h | 4 + 5 files changed, 579 insertions(+), 4 deletions(-) create mode 100644 Filtered_kernel/include/CGAL/Epic_converter.h create mode 100644 Filtered_kernel/include/CGAL/Static_filtered_predicate.h diff --git a/Boolean_set_operations_2/benchmark/Boolean_set_operations_2/polygon_set_2_join.cpp b/Boolean_set_operations_2/benchmark/Boolean_set_operations_2/polygon_set_2_join.cpp index f0ec4e4a9c2..47dd22b54b6 100644 --- a/Boolean_set_operations_2/benchmark/Boolean_set_operations_2/polygon_set_2_join.cpp +++ b/Boolean_set_operations_2/benchmark/Boolean_set_operations_2/polygon_set_2_join.cpp @@ -76,7 +76,7 @@ void build_segments(std::vector< Segment_2 >& all_segments) for( int i = 0; i < numArrays; ++i ) { - double angle = M_PI * (double)rand() / RAND_MAX; + double angle = CGAL_PI * (double)rand() / RAND_MAX; double scale = 1 + (double)rand() / RAND_MAX; get_rotated_line_array( x0, y0, angle, scale, all_segments ); diff --git a/Filtered_kernel/include/CGAL/Epic_converter.h b/Filtered_kernel/include/CGAL/Epic_converter.h new file mode 100644 index 00000000000..f915ac86226 --- /dev/null +++ b/Filtered_kernel/include/CGAL/Epic_converter.h @@ -0,0 +1,325 @@ + +#ifndef CGAL_EPIC_CONVERTER_H +#define CGAL_EPIC_CONVERTER_H + + +#include +#include + +namespace CGAL { + +template +class Epic_converter { + typedef typename Exact_predicates_inexact_constructions_kernel::Point_2 Point_2; + typedef typename Exact_predicates_inexact_constructions_kernel::Direction_2 Direction_2; + typedef typename Exact_predicates_inexact_constructions_kernel::Vector_2 Vector_2; + typedef typename Exact_predicates_inexact_constructions_kernel::Weighted_point_2 Weighted_point_2; + typedef typename Exact_predicates_inexact_constructions_kernel::Segment_2 Segment_2; + typedef typename Exact_predicates_inexact_constructions_kernel::Line_2 Line_2; + typedef typename Exact_predicates_inexact_constructions_kernel::Ray_2 Ray_2; + typedef typename Exact_predicates_inexact_constructions_kernel::Triangle_2 Triangle_2; + typedef typename Exact_predicates_inexact_constructions_kernel::Circle_2 Circle_2; + typedef typename Exact_predicates_inexact_constructions_kernel::Iso_rectangle_2 Iso_rectangle_2; + + typedef typename Exact_predicates_inexact_constructions_kernel::Line_3 Line_3; + typedef typename Exact_predicates_inexact_constructions_kernel::Plane_3 Plane_3; + typedef typename Exact_predicates_inexact_constructions_kernel::Triangle_3 Triangle_3; + typedef typename Exact_predicates_inexact_constructions_kernel::Tetrahedron_3 Tetrahedron_3; + typedef typename Exact_predicates_inexact_constructions_kernel::Ray_3 Ray_3; + typedef typename Exact_predicates_inexact_constructions_kernel::Point_3 Point_3; + typedef typename Exact_predicates_inexact_constructions_kernel::Direction_3 Direction_3; + typedef typename Exact_predicates_inexact_constructions_kernel::Vector_3 Vector_3; + typedef typename Exact_predicates_inexact_constructions_kernel::Segment_3 Segment_3; + typedef typename Exact_predicates_inexact_constructions_kernel::Weighted_point_3 Weighted_point_3; + typedef typename Exact_predicates_inexact_constructions_kernel::Sphere_3 Sphere_3; + typedef typename Exact_predicates_inexact_constructions_kernel::Circle_3 Circle_3; + typedef typename Exact_predicates_inexact_constructions_kernel::Iso_cuboid_3 Iso_cuboid_3; +public: + + + + std::pair operator()(const typename IK::FT n) const + { + double d; + if(fit_in_double(n,d)){ + return std::make_pair(d,true); + } + return std::make_pair(0,false); + } + + + std::pair operator()(const typename IK::Point_2& p) const + { + double x, y; + if(fit_in_double(p.x(),x) && fit_in_double(p.y(),y)){ + return std::make_pair(Point_2(x,y),true); + } + return std::make_pair(ORIGIN,false); + } + + std::pair operator()(const typename IK::Vector_2& p) const + { + double x, y; + if(fit_in_double(p.x(),x) && fit_in_double(p.y(),y)){ + return std::make_pair(Vector_2(x,y),true); + } + return std::make_pair(Vector_2(0,0),false); + } + + std::pair operator()(const typename IK::Direction_2& p) const + { + double x, y; + if(fit_in_double(p.dx(),x) && fit_in_double(p.dy(),y)){ + return std::make_pair(Direction_2(x,y),true); + } + return std::make_pair(Direction_2(0,0),false); + } + + std::pair operator()(const typename IK::Weighted_point_2& p) const + { + std::pair sp = operator()(p.point()); + std::pair w = operator()(p.weight()); + if(sp.second && w.second){ + return std::make_pair(Weighted_point_2(sp.first,w.first),true); + } + return std::make_pair(Weighted_point_2(ORIGIN,0),false); + } + + std::pair operator()(const typename IK::Segment_2& s) const + { + std::pair sp = operator()(s.source()); + if(! sp.second){ + return std::make_pair(Segment_2(sp.first,sp.first),false); + } + std::pair tp = operator()(s.target()); + if(! tp.second){ + return std::make_pair(Segment_2(tp.first,tp.first),false); + } + return std::make_pair(Segment_2(sp.first,tp.first), true); + } + + std::pair operator()(const typename IK::Line_2& s) const + { + std::pair a = operator()(s.a()), b = operator()(s.b()) , c = operator()(s.c()); + if(a.second && b.second && c.second){ + return std::make_pair(Line_2(a.first, b.first, c.first),true); + } + return std::make_pair(Line_2(0,0,0), false); + } + + std::pair operator()(const typename IK::Ray_2& s) const + { + std::pair sp = operator()(s.source()); + if(! sp.second){ + return std::make_pair(Ray_2(ORIGIN,ORIGIN),false); + } + std::pair tp = operator()(s.second_point()); + if(! tp.second){ + return std::make_pair(Ray_2(ORIGIN,ORIGIN),false); + } + return std::make_pair(Ray_2(sp.first,tp.first), true); + } + + std::pair operator()(const typename IK::Triangle_2& s) const + { + std::pair v0 = operator()(s.vertex(0)); + if(! v0.second){ + return std::make_pair(Triangle_2(ORIGIN, ORIGIN, ORIGIN),false); + } + std::pair v1 = operator()(s.vertex(1)); + if(! v1.second){ + return std::make_pair(Triangle_2(ORIGIN,ORIGIN, ORIGIN),false); + } + std::pair v2 = operator()(s.vertex(2)); + if(! v2.second){ + return std::make_pair(Triangle_2(ORIGIN,ORIGIN, ORIGIN),false); + } + return std::make_pair(Triangle_2(v0.first,v1.first, v2.first), true); + } + + std::pair operator()(const typename IK::Circle_2& s) const + { + std::pair c = operator()(s.center()); + std::pair sr = operator()(s.squared_radius()); + if(c.second && sr.second){ + return std::make_pair(Circle_2(c.first, sr.first, s.orientation()),true); + } + return std::make_pair(Circle_2(ORIGIN, 0, s.orientation()), false); + } + + std::pair operator()(const typename IK::Iso_rectangle_2& s) const + { + std::pair sp = operator()((s.min)()); + if(! sp.second){ + return std::make_pair(Iso_rectangle_2(ORIGIN,ORIGIN),false); + } + std::pair tp = operator()((s.max)()); + if(! tp.second){ + return std::make_pair(Iso_rectangle_2(ORIGIN,ORIGIN),false); + } + return std::make_pair(Iso_rectangle_2(sp.first,tp.first), true); + } + + + std::pair operator()(const typename IK::Line_3& s) const + { + std::pair sp = operator()(s.point()); + if(! sp.second){ + return std::make_pair(Line_3(),false); + } + std::pair tp = operator()(s.to_vector()); + if(! tp.second){ + return std::make_pair(Line_3(ORIGIN,NULL_VECTOR),false); + } + return std::make_pair(Line_3(sp.first,tp.first), true); + } + + std::pair operator()(const typename IK::Plane_3& s) const + { + std::pair a = operator()(s.a()), b = operator()(s.b()) , c = operator()(s.c()) , d = operator()(s.d()); + if(a.second && b.second && c.second && d.second){ + return std::make_pair(Plane_3(a.first, b.first, c.first, d.first),true); + } + return std::make_pair(Plane_3(0,0,0,0), false); + } + + std::pair operator()(const typename IK::Triangle_3& s) const + { + std::pair v0 = operator()(s.vertex(0)); + if(! v0.second){ + return std::make_pair(Triangle_3(ORIGIN, ORIGIN, ORIGIN),false); + } + std::pair v1 = operator()(s.vertex(1)); + if(! v1.second){ + return std::make_pair(Triangle_3(ORIGIN,ORIGIN, ORIGIN),false); + } + std::pair v2 = operator()(s.vertex(2)); + if(! v2.second){ + return std::make_pair(Triangle_3(ORIGIN,ORIGIN, ORIGIN),false); + } + return std::make_pair(Triangle_3(v0.first,v1.first, v2.first), true); + } + + std::pair operator()(const typename IK::Tetrahedron_3& s) const + { + std::pair v0 = operator()(s.vertex(0)); + if(! v0.second){ + return std::make_pair(Tetrahedron_3(ORIGIN, ORIGIN, ORIGIN, ORIGIN),false); + } + std::pair v1 = operator()(s.vertex(1)); + if(! v1.second){ + return std::make_pair(Tetrahedron_3(ORIGIN,ORIGIN, ORIGIN, ORIGIN),false); + } + std::pair v2 = operator()(s.vertex(2)); + if(! v2.second){ + return std::make_pair(Tetrahedron_3(ORIGIN,ORIGIN, ORIGIN, ORIGIN),false); + } + std::pair v3 = operator()(s.vertex(3)); + if(! v3.second){ + return std::make_pair(Tetrahedron_3(ORIGIN,ORIGIN, ORIGIN, ORIGIN),false); + } + return std::make_pair(Tetrahedron_3(v0.first,v1.first, v2.first, v3.first), true); + } + + std::pair operator()(const typename IK::Ray_3& s) const + { + std::pair sp = operator()(s.source()); + if(! sp.second){ + return std::make_pair(Ray_3(ORIGIN,ORIGIN),false); + } + std::pair tp = operator()(s.second_point()); + if(! tp.second){ + return std::make_pair(Ray_3(ORIGIN,ORIGIN),false); + } + return std::make_pair(Ray_3(sp.first,tp.first), true); + } + + std::pair operator()(const typename IK::Point_3& p) const + { + double x, y, z; + if(fit_in_double(p.x(),x) && fit_in_double(p.y(),y) && fit_in_double(p.z(),z)){ + return std::make_pair(Point_3(x,y,z),true); + } + return std::make_pair(ORIGIN,false); + } + + std::pair operator()(const typename IK::Vector_3& p) const + { + double x, y, z; + if(fit_in_double(p.x(),x) && fit_in_double(p.y(),y) && fit_in_double(p.z(),z)){ + return std::make_pair(Vector_3(x,y,z),true); + } + return std::make_pair(Vector_3(0,0,0),false); + } + + std::pair operator()(const typename IK::Direction_3& p) const + { + double x, y, z; + if(fit_in_double(p.dx(),x) && fit_in_double(p.dy(),y) && fit_in_double(p.dz(),z)){ + return std::make_pair(Direction_3(x,y,z),true); + } + return std::make_pair(Direction_3(0,0,0),false); + } + + std::pair operator()(const typename IK::Segment_3& s) const + { + std::pair sp = operator()(s.source()); + if(! sp.second){ + return std::make_pair(Segment_3(sp.first,sp.first),false); + } + std::pair tp = operator()(s.target()); + if(! tp.second){ + return std::make_pair(Segment_3(tp.first,tp.first),false); + } + return std::make_pair(Segment_3(sp.first,tp.first), true); + } + + std::pair operator()(const typename IK::Weighted_point_3& p) const + { + std::pair sp = operator()(p.point()); + std::pair w = operator()(p.weight()); + if(sp.second && w.second){ + return std::make_pair(Weighted_point_3(sp.first,w.first),true); + } + return std::make_pair(Weighted_point_3(ORIGIN,0),false); + } + + std::pair operator()(const typename IK::Sphere_3& s) const + { + std::pair c = operator()(s.center()); + std::pair sr = operator()(s.squared_radius()); + if(c.second && sr.second){ + return std::make_pair(Sphere_3(c.first, sr.first, s.orientation()),true); + } + return std::make_pair(Sphere_3(ORIGIN, 0, s.orientation()), false); + } + + std::pair operator()(const typename IK::Circle_3& s) const + { + std::pair sr = operator()(s.diametral_sphere()); + std::pair c = operator()(s.supporting_plane()); + if(c.second && sr.second){ + return std::make_pair(Circle_3(sr.first, c.first),true); + } + return std::make_pair(Circle_3(), false); + } + + std::pair operator()(const typename IK::Iso_cuboid_3& s) const + { + std::pair sp = operator()((s.min)()); + if(! sp.second){ + return std::make_pair(Iso_cuboid_3(ORIGIN,ORIGIN),false); + } + std::pair tp = operator()((s.max)()); + if(! tp.second){ + return std::make_pair(Iso_cuboid_3(ORIGIN,ORIGIN),false); + } + return std::make_pair(Iso_cuboid_3(sp.first,tp.first), true); + } + + +}; + +} // CGAL + +#endif // CGAL_EPIC_CONVERTER_H diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index dbecf93a5d3..6a053fa4940 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -23,6 +23,7 @@ #include //#include +#include #include #include #include @@ -110,6 +111,8 @@ public: typedef E2A_ E2A; typedef Kernel_ Kernel; + typedef Lazy_kernel_generic_base Self; + // synonym identical to Filtered_kernel typedef AK_ FK; @@ -272,7 +275,7 @@ public: // FIXME TODO : better use a layer of Filtered_kernel on top of everything, // so that semi-static filters are used as well (?). #define CGAL_Kernel_pred(P, Pf) \ - typedef Filtered_predicate P; \ + typedef Static_filtered_predicate, Exact_predicates_inexact_constructions_kernel::P> P; \ P Pf() const { return P(); } #define CGAL_Kernel_cons(C, Cf) \ @@ -312,7 +315,7 @@ public: // typedef void Compute_z_3; // to detect where .z() is called // typedef void Construct_point_3; // to detect where the ctor is called - +#if 0 class Do_intersect_2 { public: bool operator()(const Segment_2& s, const Segment_2& t) const @@ -338,9 +341,15 @@ public: } }; + + typedef Static_filtered_predicate::Do_intersect_2, + typename Exact_predicates_inexact_constructions_kernel::Do_intersect_2> Do_intersect_2; + Do_intersect_2 do_intersect_2_object() const { return Do_intersect_2(); } - +#endif + Assign_2 assign_2_object() const { return Assign_2(); } diff --git a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h new file mode 100644 index 00000000000..427b007456b --- /dev/null +++ b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h @@ -0,0 +1,237 @@ +#ifndef CGAL_STATIC_FILTERED_PREDICATE_H +#define CGAL_STATIC_FILTERED_PREDICATE_H + +#include + +namespace CGAL { + + template +class Static_filtered_predicate { +public: + FP fp; + EpicP epicp; + typedef typename AK::FT IA; + typedef typename FP::result_type result_type; + + template + result_type operator()(const A1& a1) const + { + CGAL::Epic_converter convert; + typedef typename Kernel_traits::type EK; + typedef typename Type_mapper::type T1; + std::pair aa1 = convert(a1.approx()); + if(! aa1.second){ + return fp(a1); + } + + return epicp(aa1.first); + } + + template + result_type operator()(const A1& a1, const Null_vector& v) const + { + CGAL::Epic_converter convert; + typedef typename Kernel_traits::type EK; + typedef typename Type_mapper::type T1; + std::pair aa1 = convert(a1.approx()); + if(! aa1.second){ + return fp(a1, v); + } + + return epicp(aa1.first, v); + } + + template + result_type operator()(const A1& a1, const A2& a2) const + { + CGAL::Epic_converter convert; + typedef typename Kernel_traits::type EK; + typedef typename Type_mapper::type T1; + std::pair aa1 = convert(a1.approx()); + if(! aa1.second){ + return fp(a1, a2); + } + typedef typename Type_mapper::type T2; + std::pair aa2 = convert(a2.approx()); + if(! aa2.second){ + return fp(a1, a2); + } + return epicp(aa1.first, aa2.first); + } + + template + result_type operator()(const A1& a1, const A2& a2, const A3& a3) const + { + CGAL::Epic_converter convert; + typedef typename Kernel_traits::type EK; + typedef typename Type_mapper::type T1; + std::pair aa1 = convert(a1.approx()); + if(! aa1.second){ + return fp(a1, a2, a3); + } + typedef typename Type_mapper::type T2; + std::pair aa2 = convert(a2.approx()); + if(! aa2.second){ + return fp(a1, a2, a3); + } + typedef typename Type_mapper::type T3; + std::pair aa3 = convert(a3.approx()); + if(! aa3.second){ + return fp(a1, a2, a3); + } + return epicp(aa1.first, aa2.first, aa3.first); + } + + + template + result_type operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) const + { + CGAL::Epic_converter convert; + typedef typename Kernel_traits::type EK; + typedef typename Type_mapper::type T1; + std::pair aa1 = convert(a1.approx()); + if(! aa1.second){ + return fp(a1, a2, a3, a4); + } + typedef typename Type_mapper::type T2; + std::pair aa2 = convert(a2.approx()); + if(! aa2.second){ + return fp(a1, a2, a3, a4); + } + typedef typename Type_mapper::type T3; + std::pair aa3 = convert(a3.approx()); + if(! aa3.second){ + return fp(a1, a2, a3, a4); + } + typedef typename Type_mapper::type T4; + std::pair aa4 = convert(a4.approx()); + if(! aa4.second){ + return fp(a1, a2, a3, a4); + } + return epicp(aa1.first, aa2.first, aa3.first, aa4.first); + } + + template + result_type operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) const + { + CGAL::Epic_converter convert; + typedef typename Kernel_traits::type EK; + typedef typename Type_mapper::type T1; + std::pair aa1 = convert(a1.approx()); + if(! aa1.second){ + return fp(a1, a2, a3, a4, a5); + } + typedef typename Type_mapper::type T2; + std::pair aa2 = convert(a2.approx()); + if(! aa2.second){ + return fp(a1, a2, a3, a4, a5); + } + typedef typename Type_mapper::type T3; + std::pair aa3 = convert(a3.approx()); + if(! aa3.second){ + return fp(a1, a2, a3, a4, a5); + } + typedef typename Type_mapper::type T4; + std::pair aa4 = convert(a4.approx()); + if(! aa4.second){ + return fp(a1, a2, a3, a4, a5); + } + typedef typename Type_mapper::type T5; + std::pair aa5 = convert(a5.approx()); + if(! aa5.second){ + return fp(a1, a2, a3, a4, a5); + } + return epicp(aa1.first, aa2.first, aa3.first, aa4.first, aa5.first); + } + + template + result_type operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6) const + { + CGAL::Epic_converter convert; + typedef typename Kernel_traits::type EK; + typedef typename Type_mapper::type T1; + std::pair aa1 = convert(a1.approx()); + if(! aa1.second){ + return fp(a1, a2, a3, a4, a5, a6); + } + typedef typename Type_mapper::type T2; + std::pair aa2 = convert(a2.approx()); + if(! aa2.second){ + return fp(a1, a2, a3, a4, a5, a6); + } + typedef typename Type_mapper::type T3; + std::pair aa3 = convert(a3.approx()); + if(! aa3.second){ + return fp(a1, a2, a3, a4, a5, a6); + } + typedef typename Type_mapper::type T4; + std::pair aa4 = convert(a4.approx()); + if(! aa4.second){ + return fp(a1, a2, a3, a4, a5, a6); + } + typedef typename Type_mapper::type T5; + std::pair aa5 = convert(a5.approx()); + if(! aa5.second){ + return fp(a1, a2, a3, a4, a5, a6); + } + typedef typename Type_mapper::type T6; + std::pair aa6 = convert(a6.approx()); + if(! aa6.second){ + return fp(a1, a2, a3, a4, a5, a6); + } + return epicp(aa1.first, aa2.first, aa3.first, aa4.first, aa5.first, aa6.first); + } + + + template + result_type operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8) const + { + CGAL::Epic_converter convert; + typedef typename Kernel_traits::type EK; + typedef typename Type_mapper::type T1; + std::pair aa1 = convert(a1.approx()); + if(! aa1.second){ + return fp(a1, a2, a3, a4, a5, a6, a7, a8); + } + typedef typename Type_mapper::type T2; + std::pair aa2 = convert(a2.approx()); + if(! aa2.second){ + return fp(a1, a2, a3, a4, a5, a6, a7, a8); + } + typedef typename Type_mapper::type T3; + std::pair aa3 = convert(a3.approx()); + if(! aa3.second){ + return fp(a1, a2, a3, a4, a5, a6, a7, a8); + } + typedef typename Type_mapper::type T4; + std::pair aa4 = convert(a4.approx()); + if(! aa4.second){ + return fp(a1, a2, a3, a4, a5, a6, a7, a8); + } + typedef typename Type_mapper::type T5; + std::pair aa5 = convert(a5.approx()); + if(! aa5.second){ + return fp(a1, a2, a3, a4, a5, a6, a7, a8); + } + typedef typename Type_mapper::type T6; + std::pair aa6 = convert(a6.approx()); + if(! aa6.second){ + return fp(a1, a2, a3, a5, a5, a6, a7, a8); + } + typedef typename Type_mapper::type T7; + std::pair aa7 = convert(a7.approx()); + if(! aa7.second){ + return fp(a1, a2, a3, a5, a5, a6, a7, a8); + } + typedef typename Type_mapper::type T8; + std::pair aa8 = convert(a8.approx()); + if(! aa8.second){ + return fp(a1, a2, a3, a4, a5, a6, a7, a8); + } + return epicp(aa1.first, aa2.first, aa3.first, aa4.first, aa5.first, aa6.first, aa7.first, aa8.first); + } +}; + +} // CGAL + +#endif // CGAL_STATIC_FILTERED_PREDICATE_H diff --git a/Kernel_23/include/CGAL/Kernel/Type_mapper.h b/Kernel_23/include/CGAL/Kernel/Type_mapper.h index 70a6bf77f16..ad5349bfa3d 100644 --- a/Kernel_23/include/CGAL/Kernel/Type_mapper.h +++ b/Kernel_23/include/CGAL/Kernel/Type_mapper.h @@ -102,6 +102,10 @@ BOOST_PP_REPEAT_FROM_TO(1, 10, CGAL_VARIANT_TYPEMAP, _) #include +template < typename K1, typename K2 > +struct Type_mapper_impl < typename K1::FT, K1, K2 > +{ typedef typename K2::FT type; }; + } // internal // This is a tool to obtain the K2::Point_2 from K1 and K1::Point_2. From f7f1e83b0db39c064ae62cade30e4918c0785cd1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 27 Oct 2017 17:17:32 +0100 Subject: [PATCH 03/16] Add license header --- Filtered_kernel/include/CGAL/Epic_converter.h | 19 ++++++++++++++++++ .../include/CGAL/Static_filtered_predicate.h | 20 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Filtered_kernel/include/CGAL/Epic_converter.h b/Filtered_kernel/include/CGAL/Epic_converter.h index f915ac86226..6ee81642880 100644 --- a/Filtered_kernel/include/CGAL/Epic_converter.h +++ b/Filtered_kernel/include/CGAL/Epic_converter.h @@ -1,3 +1,22 @@ +// Copyright (c) 2017 GeometryFactory +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// +// Author(s) : Andreas Fabri, Laurent Rineau #ifndef CGAL_EPIC_CONVERTER_H #define CGAL_EPIC_CONVERTER_H diff --git a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h index 427b007456b..315ec3bd7bc 100644 --- a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h +++ b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h @@ -1,3 +1,23 @@ +// Copyright (c) 2017 GeometryFactory +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// +// Author(s) : Andreas Fabri, Laurent Rineau + #ifndef CGAL_STATIC_FILTERED_PREDICATE_H #define CGAL_STATIC_FILTERED_PREDICATE_H From 7a6200cfa28efce06858e5ab28f851919ae0339b Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Sat, 28 Oct 2017 12:34:47 +0100 Subject: [PATCH 04/16] Deal correctly with Bbox_{2.3} --- Filtered_kernel/include/CGAL/Epic_converter.h | 11 ++++++- .../include/CGAL/Static_filtered_predicate.h | 32 +++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Epic_converter.h b/Filtered_kernel/include/CGAL/Epic_converter.h index 6ee81642880..28e29f24a5e 100644 --- a/Filtered_kernel/include/CGAL/Epic_converter.h +++ b/Filtered_kernel/include/CGAL/Epic_converter.h @@ -51,7 +51,7 @@ class Epic_converter { typedef typename Exact_predicates_inexact_constructions_kernel::Segment_3 Segment_3; typedef typename Exact_predicates_inexact_constructions_kernel::Weighted_point_3 Weighted_point_3; typedef typename Exact_predicates_inexact_constructions_kernel::Sphere_3 Sphere_3; - typedef typename Exact_predicates_inexact_constructions_kernel::Circle_3 Circle_3; + typedef typename Exact_predicates_inexact_constructions_kernel::Circle_3 Circle_3; typedef typename Exact_predicates_inexact_constructions_kernel::Iso_cuboid_3 Iso_cuboid_3; public: @@ -66,6 +66,15 @@ public: return std::make_pair(0,false); } + std::pair operator()(const Bbox_2 b) const + { + return std::make_pair(b,true); + } + + std::pair operator()(const Bbox_3 b) const + { + return std::make_pair(b,true); + } std::pair operator()(const typename IK::Point_2& p) const { diff --git a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h index 315ec3bd7bc..d714cac68ce 100644 --- a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h +++ b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h @@ -67,18 +67,46 @@ public: CGAL::Epic_converter convert; typedef typename Kernel_traits::type EK; typedef typename Type_mapper::type T1; - std::pair aa1 = convert(a1.approx()); + std::pair aa1 = convert(approx(a1)); if(! aa1.second){ return fp(a1, a2); } typedef typename Type_mapper::type T2; - std::pair aa2 = convert(a2.approx()); + std::pair aa2 = convert(approx(a2)); if(! aa2.second){ return fp(a1, a2); } return epicp(aa1.first, aa2.first); } + // We need these two specializations as in general we determine + // the kernel for the template argument A1, and this does not work for Bbox_2 and Bbox_3 + template + result_type operator()(const Bbox_2& bb, const A2& a2) const + { + CGAL::Epic_converter convert; + typedef typename Kernel_traits::type EK; + typedef typename Type_mapper::type T2; + std::pair aa2 = convert(approx(a2)); + if(! aa2.second){ + return fp(bb, a2); + } + return epicp(bb, aa2.first); + } + + template + result_type operator()(const Bbox_3& bb, const A2& a2) const + { + CGAL::Epic_converter convert; + typedef typename Kernel_traits::type EK; + typedef typename Type_mapper::type T2; + std::pair aa2 = convert(approx(a2)); + if(! aa2.second){ + return fp(bb, a2); + } + return epicp(bb, aa2.first); + } + template result_type operator()(const A1& a1, const A2& a2, const A3& a3) const { From 1d332f5de3313a9a4cee348781996131d2eaf207 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 30 Oct 2017 12:28:57 +0100 Subject: [PATCH 05/16] Downcast to Point_2 in order that functions match --- Filtered_kernel/include/CGAL/Lazy_kernel.h | 6 ++++-- .../CGAL/Partition_2/Indirect_edge_compare.h | 20 +++++++++---------- .../CGAL/Partition_2/Indirect_not_less_yx_2.h | 5 +++-- .../CGAL/Partition_2/Partitioned_polygon_2.h | 2 +- .../CGAL/Partition_2/partition_y_monotone_2.h | 11 +++++----- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index 6a053fa4940..86e7751f99d 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -409,10 +409,12 @@ struct Lazy_kernel template struct Lazy_kernel - : public internal::Static_filters< + : public +//internal::Static_filters< Type_equality_wrapper< Lazy_kernel_base< Exact_kernel, Approximate_kernel, E2A, Lazy_kernel > , - Lazy_kernel >, false > + Lazy_kernel > +//, false > { // WARNING: If you change the definition of Lazy_kernel, then you need to // change also the definition of Epeck in diff --git a/Partition_2/include/CGAL/Partition_2/Indirect_edge_compare.h b/Partition_2/include/CGAL/Partition_2/Indirect_edge_compare.h index d161cb29ce2..6f269f2e877 100644 --- a/Partition_2/include/CGAL/Partition_2/Indirect_edge_compare.h +++ b/Partition_2/include/CGAL/Partition_2/Indirect_edge_compare.h @@ -61,19 +61,19 @@ class Indirect_edge_compare ForwardCirculator edge_vtx_2 = edge_vtx_1; edge_vtx_2++; // check for horizontal edge - if (_compare_y_2((*edge_vtx_1), (*edge_vtx_2)) == EQUAL) + if(_compare_y_2((*edge_vtx_1), (*edge_vtx_2)) == EQUAL) { // compare the smaller x and vertex x - if (_compare_x_2(*edge_vtx_1, *edge_vtx_2) == SMALLER) - return _compare_x_2(*edge_vtx_1, *vertex) == LARGER; + if(_compare_x_2(*edge_vtx_1, *edge_vtx_2) == SMALLER) + return _compare_x_2(*edge_vtx_1, *vertex) == LARGER; else - return _compare_x_2(*edge_vtx_2, *vertex) == LARGER; + return _compare_x_2(*edge_vtx_2, *vertex) == LARGER; } else { // construct supporting line for edge Line_2 line = _construct_line_2(*edge_vtx_1, *edge_vtx_2); - return _compare_x_at_y_2(*vertex, line) == SMALLER; + return _compare_x_at_y_2(Point_2(*vertex), line) == SMALLER; } } @@ -122,12 +122,12 @@ class Indirect_edge_compare } else // p and after_p must both be on same side of l_q { - return (_compare_x_at_y_2(*p, l_q) == LARGER); + return (_compare_x_at_y_2(Point_2(*p), l_q) == LARGER); } } - bool q_larger_x = _compare_x_at_y_2(*q, l_p) == SMALLER; - bool after_q_larger_x = _compare_x_at_y_2(*after_q, l_p) == SMALLER; + bool q_larger_x =_compare_x_at_y_2(Point_2(*q), l_p) == SMALLER; + bool after_q_larger_x = _compare_x_at_y_2(Point_2(*after_q), l_p) == SMALLER; if (q_larger_x == after_q_larger_x) return q_larger_x; @@ -136,9 +136,9 @@ class Indirect_edge_compare Line_2 l_q = _construct_line_2(*q, *after_q); if (_is_horizontal_2(l_q)) // p is not horizontal { - return _compare_x_at_y_2((*q), l_p) == LARGER; + return _compare_x_at_y_2(Point_2(*q), l_p) == LARGER; } - return _compare_x_at_y_2((*p), l_q) != SMALLER; + return _compare_x_at_y_2(Point_2(*p), l_q) != SMALLER; } private: diff --git a/Partition_2/include/CGAL/Partition_2/Indirect_not_less_yx_2.h b/Partition_2/include/CGAL/Partition_2/Indirect_not_less_yx_2.h index f59414732e1..200a6152ad7 100644 --- a/Partition_2/include/CGAL/Partition_2/Indirect_not_less_yx_2.h +++ b/Partition_2/include/CGAL/Partition_2/Indirect_not_less_yx_2.h @@ -29,7 +29,8 @@ namespace CGAL { template class Indirect_not_less_yx_2 { - public: +public: + typedef typename Traits::Point_2 Point_2; typedef typename Traits::Less_yx_2 Less_yx_2; Indirect_not_less_yx_2(const Traits& traits) : @@ -38,7 +39,7 @@ class Indirect_not_less_yx_2 template bool operator()( const Iterator& p, const Iterator& q) const - { return less_yx_2( *q, *p); } + { return less_yx_2( Point_2(*q), Point_2(*p)); } private: Less_yx_2 less_yx_2; diff --git a/Partition_2/include/CGAL/Partition_2/Partitioned_polygon_2.h b/Partition_2/include/CGAL/Partition_2/Partitioned_polygon_2.h index 9b44fc3efd5..8c5a0c2b52c 100644 --- a/Partition_2/include/CGAL/Partition_2/Partitioned_polygon_2.h +++ b/Partition_2/include/CGAL/Partition_2/Partitioned_polygon_2.h @@ -277,7 +277,7 @@ private: next = *next_d_it; // return _right_turn(*prev, *vertex_ref, *next); - return _left_turn(*vertex_ref, *prev, *next); + return _left_turn(Point_2(*vertex_ref), Point_2(*prev), Point_2(*next)); } bool diagonal_is_necessary(Circulator diag_ref1, Circulator diag_ref2) diff --git a/Partition_2/include/CGAL/Partition_2/partition_y_monotone_2.h b/Partition_2/include/CGAL/Partition_2/partition_y_monotone_2.h index 2e6b433fe56..a4b9179476a 100644 --- a/Partition_2/include/CGAL/Partition_2/partition_y_monotone_2.h +++ b/Partition_2/include/CGAL/Partition_2/partition_y_monotone_2.h @@ -72,6 +72,7 @@ Partition_y_mono_vertex_type partition_y_mono_vertex_type( BidirectionalCirculator c, const Traits& traits) { + typedef typename Traits::Point_2 Point_2; BidirectionalCirculator previous = c; previous--; BidirectionalCirculator next = c; @@ -89,10 +90,10 @@ Partition_y_mono_vertex_type partition_y_mono_vertex_type( typename Traits::Less_yx_2 less_yx = traits.less_yx_2_object(); typename Traits::Left_turn_2 left_turn = traits.left_turn_2_object(); - if (less_yx(*previous, *c)) + if(less_yx(Point_2(*previous), Point_2(*c))) { - if (less_yx(*next, *c)) // previous and next both less_yx - if (left_turn(*previous, *c, *next)) // interior angle less than pi + if(less_yx(Point_2(*next), Point_2(*c))) // previous and next both less_yx + if(left_turn(Point_2(*previous), Point_2(*c), Point_2(*next))) // interior angle less than pi return PARTITION_Y_MONO_START_VERTEX; else // interior angle greater than pi return PARTITION_Y_MONO_SPLIT_VERTEX; @@ -101,8 +102,8 @@ Partition_y_mono_vertex_type partition_y_mono_vertex_type( } else { - if (less_yx(*c, *next)) // previous and next both not less_yx - if (left_turn(*previous, *c, *next)) // interior angle less than pi + if(less_yx(Point_2(*c), Point_2(*next))) // previous and next both not less_yx + if(left_turn(Point_2(*previous), Point_2(*c), Point_2(*next))) // interior angle less than pi return PARTITION_Y_MONO_END_VERTEX; else // interior angle greater than pi return PARTITION_Y_MONO_MERGE_VERTEX; From a2fc6e18309e0d94ac22bff75a8f652ce11d997c Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 30 Oct 2017 12:55:21 +0100 Subject: [PATCH 06/16] Make Partition_2 work with g++ --- Nef_S2/include/CGAL/Nef_S2/Sphere_circle.h | 3 ++- Nef_S2/include/CGAL/Nef_S2/Sphere_segment.h | 11 ++++++++--- .../include/CGAL/Partition_2/Indirect_edge_compare.h | 12 ++++++------ .../CGAL/Partition_2/Partition_opt_cvx_edge.h | 3 ++- .../include/CGAL/Partition_2/Partitioned_polygon_2.h | 8 ++++---- .../CGAL/Partition_2/partition_approx_convex_2.h | 3 ++- .../CGAL/Partition_2/partition_optimal_convex_2.h | 11 +++++++---- .../CGAL/Partition_2/partition_y_monotone_2.h | 11 ++++++----- .../CGAL/Polygon_2/Polygon_2_algorithms_impl.h | 3 ++- 9 files changed, 39 insertions(+), 26 deletions(-) diff --git a/Nef_S2/include/CGAL/Nef_S2/Sphere_circle.h b/Nef_S2/include/CGAL/Nef_S2/Sphere_circle.h index 7dc5d9442f3..8f01003eb83 100644 --- a/Nef_S2/include/CGAL/Nef_S2/Sphere_circle.h +++ b/Nef_S2/include/CGAL/Nef_S2/Sphere_circle.h @@ -71,7 +71,8 @@ between $p$ and $q$. If $p$ and $q$ are antipodal of each other then we create any great circle that contains $p$ and $q$.}*/ { Point_3 p1(0,0,0), p4 = CGAL::ORIGIN + ((Base*) this)->orthogonal_vector(); if ( p != q.antipode() ) { - if (R_().orientation_3_object()(p1,p,q,p4) != CGAL::POSITIVE ) + if (R_().orientation_3_object()(p1,Point_3(p), + Point_3(q), p4) != CGAL::POSITIVE ) *this = Self(opposite()); } else { /* previous method was: *this = Self(Plane_3(p1,q-p)); diff --git a/Nef_S2/include/CGAL/Nef_S2/Sphere_segment.h b/Nef_S2/include/CGAL/Nef_S2/Sphere_segment.h index 9c8feaadae2..e8a420b186e 100644 --- a/Nef_S2/include/CGAL/Nef_S2/Sphere_segment.h +++ b/Nef_S2/include/CGAL/Nef_S2/Sphere_segment.h @@ -193,13 +193,18 @@ void split_halfcircle(Sphere_segment& s1, bool is_short() const /*{\Mop a segment is short iff it is shorter than a halfcircle.}*/ { - return R().orientation_3_object()(Point_3(0,0,0), source(), target(), - CGAL::ORIGIN + this->ptr()->c_.orthogonal_vector()) + return R().orientation_3_object()(Point_3(0,0,0), + Point_3(source()), + Point_3(target()), + CGAL::ORIGIN + + this->ptr()->c_.orthogonal_vector()) == CGAL::POSITIVE; } bool is_long() const /*{\Mop a segment is long iff it is longer than a halfcircle.}*/ -{ return R().orientation_3_object()(Point_3(0,0,0), source(), target(), +{ return R().orientation_3_object()(Point_3(0,0,0), + Point_3(source()), + Point_3(target()), CGAL::ORIGIN + this->ptr()->c_.orthogonal_vector()) == CGAL::NEGATIVE; } diff --git a/Partition_2/include/CGAL/Partition_2/Indirect_edge_compare.h b/Partition_2/include/CGAL/Partition_2/Indirect_edge_compare.h index 6f269f2e877..b856109fd60 100644 --- a/Partition_2/include/CGAL/Partition_2/Indirect_edge_compare.h +++ b/Partition_2/include/CGAL/Partition_2/Indirect_edge_compare.h @@ -61,13 +61,13 @@ class Indirect_edge_compare ForwardCirculator edge_vtx_2 = edge_vtx_1; edge_vtx_2++; // check for horizontal edge - if(_compare_y_2((*edge_vtx_1), (*edge_vtx_2)) == EQUAL) + if(_compare_y_2(Point_2(*edge_vtx_1), Point_2(*edge_vtx_2)) == EQUAL) { // compare the smaller x and vertex x - if(_compare_x_2(*edge_vtx_1, *edge_vtx_2) == SMALLER) - return _compare_x_2(*edge_vtx_1, *vertex) == LARGER; + if(_compare_x_2(Point_2(*edge_vtx_1), Point_2(*edge_vtx_2)) == SMALLER) + return _compare_x_2(Point_2(*edge_vtx_1), Point_2(*vertex)) == LARGER; else - return _compare_x_2(*edge_vtx_2, *vertex) == LARGER; + return _compare_x_2(Point_2(*edge_vtx_2), Point_2(*vertex)) == LARGER; } else { @@ -110,11 +110,11 @@ class Indirect_edge_compare { Point_2 p_max; Point_2 q_max; - if (_compare_x_2(*p, *after_p) == SMALLER) + if (_compare_x_2(Point_2(*p), Point_2(*after_p)) == SMALLER) p_max = *after_p; else p_max = *p; - if (_compare_x_2(*q, *after_q) == SMALLER) + if (_compare_x_2(Point_2(*q), Point_2(*after_q)) == SMALLER) q_max = *after_q; else q_max = *q; diff --git a/Partition_2/include/CGAL/Partition_2/Partition_opt_cvx_edge.h b/Partition_2/include/CGAL/Partition_2/Partition_opt_cvx_edge.h index 8b9432a4e6e..46fd9024d33 100644 --- a/Partition_2/include/CGAL/Partition_2/Partition_opt_cvx_edge.h +++ b/Partition_2/include/CGAL/Partition_2/Partition_opt_cvx_edge.h @@ -67,7 +67,8 @@ public: _validity = PARTITION_OPT_CVX_NOT_VALID; - Turn_reverser right_turn(left_turn); + Turn_reverser right_turn(left_turn); if (right_turn(p1, p2, p3)) _validity = PARTITION_OPT_CVX_START_VALID; if (right_turn(p4, p5, p6)) { diff --git a/Partition_2/include/CGAL/Partition_2/Partitioned_polygon_2.h b/Partition_2/include/CGAL/Partition_2/Partitioned_polygon_2.h index 8c5a0c2b52c..77817ee49c8 100644 --- a/Partition_2/include/CGAL/Partition_2/Partitioned_polygon_2.h +++ b/Partition_2/include/CGAL/Partition_2/Partitioned_polygon_2.h @@ -47,15 +47,15 @@ public: _vertex(vertex), _prev_v_ref(prev_ref) { - _vertex_orientation = _orientation(*_prev_v_ref, vertex, *next_ref); + _vertex_orientation = _orientation(Point_2(*_prev_v_ref), Point_2(vertex), Point_2(*next_ref)); } bool operator()(Iterator d1, Iterator d2) { - Orientation d1_orientation = _orientation(*_prev_v_ref, _vertex, *d1); - Orientation d2_orientation = _orientation(*_prev_v_ref, _vertex, *d2); - Orientation d1_to_d2 = _orientation(*d1, _vertex, *d2); + Orientation d1_orientation = _orientation(Point_2(*_prev_v_ref), Point_2(_vertex), Point_2(*d1)); + Orientation d2_orientation = _orientation(Point_2(*_prev_v_ref), Point_2(_vertex), Point_2(*d2)); + Orientation d1_to_d2 = _orientation(Point_2(*d1), Point_2(_vertex), Point_2(*d2)); // if both diagonals are on the same side of the line from previous // vertex to this vertex then d1 comes before d2 (in CW order from diff --git a/Partition_2/include/CGAL/Partition_2/partition_approx_convex_2.h b/Partition_2/include/CGAL/Partition_2/partition_approx_convex_2.h index 0fcec830a29..29d14ee2e19 100644 --- a/Partition_2/include/CGAL/Partition_2/partition_approx_convex_2.h +++ b/Partition_2/include/CGAL/Partition_2/partition_approx_convex_2.h @@ -53,8 +53,9 @@ bool partition_appx_cvx_is_edge_through_interior(const Point_2& before_s, { // determine if the edge goes through the interior of the polygon or not typedef typename Traits::Left_turn_2 Left_turn_2; + typedef typename Traits::Point_2 Bare_point_2; Left_turn_2 left_turn = traits.left_turn_2_object(); - Turn_reverser right_turn(left_turn); + Turn_reverser right_turn(left_turn); if (right_turn(before_s, source, after_s)) // concave angle { if (right_turn(before_s, source, target) && diff --git a/Partition_2/include/CGAL/Partition_2/partition_optimal_convex_2.h b/Partition_2/include/CGAL/Partition_2/partition_optimal_convex_2.h index 8ea50ad3f0a..6486c724875 100644 --- a/Partition_2/include/CGAL/Partition_2/partition_optimal_convex_2.h +++ b/Partition_2/include/CGAL/Partition_2/partition_optimal_convex_2.h @@ -209,11 +209,13 @@ bool collinearly_visible(unsigned int edge_num1, unsigned int e_num, const Traits& traits) { typedef typename Traits::Orientation_2 Orientation_2; + typedef typename Traits::Point_2 Point_2; Orientation_2 orientation = traits.orientation_2_object(); if ((e_num == edge_num1+1 || e_num+1 == edge_num2) && edges[edge_num1][edge_num2].is_visible() && - orientation(polygon[edge_num1], polygon[e_num], polygon[edge_num2]) == + orientation(Point_2(polygon[edge_num1]), Point_2(polygon[e_num]), + Point_2(polygon[edge_num2])) == COLLINEAR) return true; else @@ -364,6 +366,7 @@ void make_collinear_vertices_visible(Polygon& polygon, { typedef typename Polygon::size_type size_type; typedef typename Traits::Orientation_2 Orientation_2; + typedef typename Traits::Point_2 Point_2; Orientation_2 orientation = traits.orientation_2_object(); size_type i; @@ -380,7 +383,7 @@ void make_collinear_vertices_visible(Polygon& polygon, j = 1; size_type start_i = 0; while (i > 0 && - orientation(polygon[i], polygon[prev_j], polygon[j]) == COLLINEAR) + orientation(Point_2(polygon[i]), Point_2(polygon[prev_j]), Point_2(polygon[j])) == COLLINEAR) { prev_j = i; start_i = i; @@ -390,7 +393,7 @@ void make_collinear_vertices_visible(Polygon& polygon, prev_j = 1; j = 2; while (j < polygon.size() && - orientation(polygon[i], polygon[prev_j], polygon[j]) == COLLINEAR) + orientation(Point_2(polygon[i]), Point_2(polygon[prev_j]), Point_2(polygon[j])) == COLLINEAR) { i++; prev_j++; @@ -419,7 +422,7 @@ void make_collinear_vertices_visible(Polygon& polygon, prev_j = i+1; j = i+2; while (j < polygon.size() && - orientation(polygon[i], polygon[prev_j], polygon[j]) == + orientation(Point_2(polygon[i]), Point_2(polygon[prev_j]), Point_2(polygon[j])) == COLLINEAR) { j++; diff --git a/Partition_2/include/CGAL/Partition_2/partition_y_monotone_2.h b/Partition_2/include/CGAL/Partition_2/partition_y_monotone_2.h index a4b9179476a..92d0eec4431 100644 --- a/Partition_2/include/CGAL/Partition_2/partition_y_monotone_2.h +++ b/Partition_2/include/CGAL/Partition_2/partition_y_monotone_2.h @@ -83,8 +83,8 @@ Partition_y_mono_vertex_type partition_y_mono_vertex_type( #endif typename Traits::Compare_y_2 compare_y_2 = traits.compare_y_2_object(); - if (compare_y_2(*previous, *c) == EQUAL && - compare_y_2(*next, *c) == EQUAL) + if (compare_y_2(Point_2(*previous), Point_2(*c)) == EQUAL && + compare_y_2(Point_2(*next), Point_2(*c)) == EQUAL) return PARTITION_Y_MONO_COLLINEAR_VERTEX; typename Traits::Less_yx_2 less_yx = traits.less_yx_2_object(); @@ -300,16 +300,17 @@ template bool partition_y_mono_interior_to_right(BidirectionalCirculator c, const Traits& traits) { + typedef typename Traits::Point_2 Point_2; typename Traits::Compare_y_2 compare_y_2 = traits.compare_y_2_object(); - + BidirectionalCirculator previous = c; previous--; - Comparison_result cmp_y = compare_y_2(*previous, *c); + Comparison_result cmp_y = compare_y_2(Point_2(*previous), Point_2(*c)); if (cmp_y == LARGER) return true; BidirectionalCirculator next = c; next++; - if (cmp_y == EQUAL && compare_y_2(*next, *c) == SMALLER) return true; + if (cmp_y == EQUAL && compare_y_2(Point_2(*next), Point_2(*c)) == SMALLER) return true; return false; } diff --git a/Polygon/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h b/Polygon/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h index 03d79f002b7..2ae98e403cc 100644 --- a/Polygon/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h +++ b/Polygon/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h @@ -416,7 +416,8 @@ Orientation orientation_2(ForwardIterator first, // of the points (prev,i,next) will coincide // return the orientation of the triple (prev,i,next) - return traits.orientation_2_object()(*prev, *i, *next); + typedef typename Traits::Point_2 Point; + return traits.orientation_2_object()(Point(*prev), Point(*i), Point(*next)); } } //namespace CGAL From 2b7bd7c4b81a69c5c9709ae361bc0ec6143abb06 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 30 Oct 2017 16:16:25 +0100 Subject: [PATCH 07/16] Fix compilation errors --- .../CGAL/Partition_2/Rotation_tree_2.h | 25 ++++++++++++--- .../Triangulation_indirect_traits_2.h | 29 +++++++++++------ .../Vertex_visibility_graph_2_impl.h | 11 ++++--- .../Polygon_2/Polygon_2_algorithms_impl.h | 31 +++++++++++++++++-- 4 files changed, 76 insertions(+), 20 deletions(-) diff --git a/Partition_2/include/CGAL/Partition_2/Rotation_tree_2.h b/Partition_2/include/CGAL/Partition_2/Rotation_tree_2.h index 9aa9bc64067..1272820344d 100644 --- a/Partition_2/include/CGAL/Partition_2/Rotation_tree_2.h +++ b/Partition_2/include/CGAL/Partition_2/Rotation_tree_2.h @@ -53,7 +53,19 @@ public: typedef typename internal::vector::iterator Self_iterator; typedef typename Traits::Point_2 Point_2; - using internal::vector< Rotation_tree_node_2 >::push_back; + using internal::vector< Rotation_tree_node_2 >::push_back; + + class Less { + typename Traits::Less_xy_2 less; + typedef typename Traits::Point_2 Point; + public: + Less(typename Traits::Less_xy_2 less) : less(less) {} + + template + bool operator()(const Point_like& p1, const Point_like& p2) { + return less(Point(p1), Point(p2)); + } + }; // constructor template @@ -61,9 +73,9 @@ public: { for (ForwardIterator it = first; it != beyond; it++) push_back(*it); - - std::sort(this->begin(), this->end(), - boost::bind(Traits().less_xy_2_object(), _2, _1)); + + Less less (Traits().less_xy_2_object()); + std::sort(this->begin(), this->end(), less); std::unique(this->begin(), this->end()); // front() is the point with the largest x coordinate @@ -166,3 +178,8 @@ private: #include #endif // CGAL_ROTATION_TREE_H + +// For the Emacs editor: +// Local Variables: +// c-basic-offset: 3 +// End: diff --git a/Partition_2/include/CGAL/Partition_2/Triangulation_indirect_traits_2.h b/Partition_2/include/CGAL/Partition_2/Triangulation_indirect_traits_2.h index b21b7297346..6f9eaefdec4 100644 --- a/Partition_2/include/CGAL/Partition_2/Triangulation_indirect_traits_2.h +++ b/Partition_2/include/CGAL/Partition_2/Triangulation_indirect_traits_2.h @@ -57,9 +57,11 @@ private: Circulator _p0, _p1, _p2; }; -template +template class Indirect_compare_x_2 { + typedef typename Traits::Compare_x_2 Compare_x_2; + typedef typename Traits::Point_2 Point; public: Indirect_compare_x_2(const Compare_x_2& compare_x_2) : _compare_x_2(compare_x_2) @@ -68,16 +70,18 @@ public: template Comparison_result operator()(Point_2_ptr p1, Point_2_ptr p2) { - return _compare_x_2(*p1, *p2); + return _compare_x_2(Point(*p1), Point(*p2)); } private: Compare_x_2 _compare_x_2; }; -template +template class Indirect_compare_y_2 { + typedef typename Traits::Compare_y_2 Compare_y_2; + typedef typename Traits::Point_2 Point; public: Indirect_compare_y_2(const Compare_y_2& compare_y_2) : _compare_y_2(compare_y_2) @@ -86,16 +90,18 @@ public: template Comparison_result operator()(Point_2_ptr p1, Point_2_ptr p2) { - return _compare_y_2(*p1, *p2); + return _compare_y_2(Point(*p1), Point(*p2)); } private: Compare_y_2 _compare_y_2; }; -template +template class Indirect_orientation_2 { + typedef typename Traits::Orientation_2 Orientation_2; + typedef typename Traits::Point_2 Point; public: Indirect_orientation_2(const Orientation_2& orientation_2) : _orientation_2(orientation_2) @@ -104,7 +110,7 @@ public: template Orientation operator()(Point_2_ptr p1, Point_2_ptr p2, Point_2_ptr p3) { - return _orientation_2(*p1, *p2, *p3); + return _orientation_2(Point(*p1), Point(*p2), Point(*p3)); } private: @@ -139,9 +145,9 @@ public: typedef Indirect_segment Segment_2; typedef Indirect_triangle Triangle_2; - typedef Indirect_orientation_2 Orientation_2; - typedef Indirect_compare_x_2 Compare_x_2; - typedef Indirect_compare_y_2 Compare_y_2; + typedef Indirect_orientation_2 Orientation_2; + typedef Indirect_compare_x_2 Compare_x_2; + typedef Indirect_compare_y_2 Compare_y_2; typedef Construct_indirect_segment_2 Construct_segment_2; typedef Construct_circulator_2 Construct_point_2; @@ -181,3 +187,8 @@ private: } #endif // CGAL_TRIANGULATION_INDIRECT_TRAITS_2_H + +// For the Emacs editor +// Local Variables: +// c-basic-offset: 3 +// End: diff --git a/Partition_2/include/CGAL/Partition_2/Vertex_visibility_graph_2_impl.h b/Partition_2/include/CGAL/Partition_2/Vertex_visibility_graph_2_impl.h index c063270016e..82f95f7d4ee 100644 --- a/Partition_2/include/CGAL/Partition_2/Vertex_visibility_graph_2_impl.h +++ b/Partition_2/include/CGAL/Partition_2/Vertex_visibility_graph_2_impl.h @@ -227,20 +227,21 @@ Vertex_visibility_graph_2::left_turn_to_parent( Tree_iterator q, Tree& tree) { + typedef typename Traits::Point_2 Point; if (tree.parent_is_p_infinity(q)) { - return (less_xy_2(*p, *q)); + return (less_xy_2(Point(*p), Point(*q))); } - else if (orientation_2(*p, *q, *(*q).parent()) == COLLINEAR && - (collinear_ordered_2(*p, *q, *(*q).parent()) || - collinear_ordered_2(*p, *q, *(*q).parent()))) + else if (orientation_2(Point(*p), Point(*q), Point(*q->parent())) == COLLINEAR && + (collinear_ordered_2(Point(*p), Point(*q), Point(*q->parent())) || + collinear_ordered_2(Point(*p), Point(*q), Point(*q->parent())))) { return true; } else { - return left_turn_2(*p, *q, *(*q).parent()); + return left_turn_2(Point(*p), Point(*q), Point(*q->parent())); } } diff --git a/Polygon/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h b/Polygon/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h index 2ae98e403cc..96f42c39127 100644 --- a/Polygon/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h +++ b/Polygon/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h @@ -52,6 +52,25 @@ bool is_simple_2(ForwardIterator first, return is_simple_polygon(first, last, traits); } +namespace internal { namespace Polygon_2 { + +template +class Compare_vertices { + typedef typename Traits::Less_xy_2 Less_xy_2; + typedef typename Traits::Point_2 Point_2; + Less_xy_2 less; +public: + Compare_vertices(Less_xy_2 less) : less(less) {} + + // `Point_like` derives from `Point_2` + template + bool operator()(const Point_like& p1, const Point_like& p2) { + return less(Point_2(p1), Point_2(p2)); + } +}; // end Compare_vertices + +} // end namespace Polygon_2 +} // end namespace internal //-----------------------------------------------------------------------// // left_vertex_2 @@ -64,7 +83,9 @@ ForwardIterator left_vertex_2(ForwardIterator first, const PolygonTraits&traits) { CGAL_polygon_precondition(first != last); - return std::min_element(first, last, traits.less_xy_2_object()); + internal::Polygon_2::Compare_vertices + less(traits.less_xy_2_object()); + return std::min_element(first, last, less); } //-----------------------------------------------------------------------// @@ -78,7 +99,9 @@ ForwardIterator right_vertex_2(ForwardIterator first, const PolygonTraits &traits) { CGAL_polygon_precondition(first != last); - return std::max_element(first, last, traits.less_xy_2_object()); + internal::Polygon_2::Compare_vertices + less(traits.less_xy_2_object()); + return std::max_element(first, last, less); } //-----------------------------------------------------------------------// @@ -423,3 +446,7 @@ Orientation orientation_2(ForwardIterator first, } //namespace CGAL /// \endcond + +// Local Variables: +// c-basic-offset: 4 +// End: From f175ed670270cdb866e99ac4e08e1974903e6715 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 31 Oct 2017 10:25:36 +0100 Subject: [PATCH 08/16] Fix a runtime error The adaptation of that part of the code was plain wrong. --- Partition_2/include/CGAL/Partition_2/Rotation_tree_2.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Partition_2/include/CGAL/Partition_2/Rotation_tree_2.h b/Partition_2/include/CGAL/Partition_2/Rotation_tree_2.h index 1272820344d..8db783a3915 100644 --- a/Partition_2/include/CGAL/Partition_2/Rotation_tree_2.h +++ b/Partition_2/include/CGAL/Partition_2/Rotation_tree_2.h @@ -55,15 +55,15 @@ public: using internal::vector< Rotation_tree_node_2 >::push_back; - class Less { + class Greater { typename Traits::Less_xy_2 less; typedef typename Traits::Point_2 Point; public: - Less(typename Traits::Less_xy_2 less) : less(less) {} + Greater(typename Traits::Less_xy_2 less) : less(less) {} template bool operator()(const Point_like& p1, const Point_like& p2) { - return less(Point(p1), Point(p2)); + return less(Point(p2), Point(p1)); } }; @@ -74,8 +74,8 @@ public: for (ForwardIterator it = first; it != beyond; it++) push_back(*it); - Less less (Traits().less_xy_2_object()); - std::sort(this->begin(), this->end(), less); + Greater greater (Traits().less_xy_2_object()); + std::sort(this->begin(), this->end(), greater); std::unique(this->begin(), this->end()); // front() is the point with the largest x coordinate From aa03c5b83a82966f4097e3addf1959ba724e0c4c Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 31 Oct 2017 11:05:21 +0100 Subject: [PATCH 09/16] Fix compilation error in Arrangement "Spherical Gaussian Map" --- .../Arr_geodesic_arc_on_sphere_traits_2.h | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geodesic_arc_on_sphere_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geodesic_arc_on_sphere_traits_2.h index 24b4e3f1491..b81a5c86b50 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_geodesic_arc_on_sphere_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_geodesic_arc_on_sphere_traits_2.h @@ -711,7 +711,8 @@ public: typename Kernel::Construct_opposite_direction_3 opposite_3 = kernel->construct_opposite_direction_3_object(); Point_2 tmp1 = opposite_3(p); // pacify msvc 10 - if (!kernel->equal_3_object()(tmp1, r1)) return EQUAL; + if (!kernel->equal_3_object()(Direction_3(tmp1), Direction_3(r1))) + return EQUAL; Sign xsign = Traits::x_sign(p); Sign ysign = Traits::y_sign(p); @@ -778,8 +779,8 @@ public: equal_3(xc1.normal(), xc2.normal())); } - return (equal_3(xc1.left(), xc2.left()) && - equal_3(xc1.right(), xc2.right())); + return (equal_3(Direction_3(xc1.left()), Direction_3(xc2.left())) && + equal_3(Direction_3(xc1.right()), Direction_3(xc2.right()))); } /*! Determines whether the two points are the same. @@ -790,7 +791,7 @@ public: bool operator()(const Point_2& p1, const Point_2& p2) const { const Kernel* kernel = m_traits; - return kernel->equal_3_object()(p1, p2); + return kernel->equal_3_object()(Direction_3(p1), Direction_3(p2)); } }; @@ -1557,8 +1558,8 @@ public: CGAL_precondition_code(const Kernel* kernel = m_traits); CGAL_precondition_code (typename Kernel::Equal_3 equal_3 = kernel->equal_3_object()); - CGAL_precondition(!equal_3(p, source)); - CGAL_precondition(!equal_3(p, target)); + CGAL_precondition(!equal_3(Direction_3(p), Direction_3(source))); + CGAL_precondition(!equal_3(Direction_3(p), Direction_3(target))); xc1.set_normal(xc.normal()); xc1.set_is_vertical(xc.is_vertical()); @@ -2463,7 +2464,8 @@ public: typedef Arr_geodesic_arc_on_sphere_traits_2 Traits; Kernel kernel; - CGAL_precondition(!kernel.equal_3_object()(m_source, m_target)); + CGAL_precondition(!kernel.equal_3_object()(Direction_3(m_source), + Direction_3(m_target))); // Check whether any one of the endpoint coincide with a pole: if (m_source.is_max_boundary()) { @@ -2534,7 +2536,8 @@ public: // The arc is not vertical! set_is_vertical(false); set_is_directed_right(orient == LEFT_TURN); - set_is_full(kernel.equal_3_object()(m_source, m_target)); + set_is_full(kernel.equal_3_object()(Direction_3(m_source), + Direction_3(m_target))); } /*! Construct a full spherical_arc from a plane @@ -2933,7 +2936,8 @@ public: typedef typename Kernel::Direction_3 Direction_3; Kernel kernel; - CGAL_precondition(!kernel.equal_3_object()(source, target)); + CGAL_precondition(!kernel.equal_3_object()(Direction_3(source), + Direction_3(target))); CGAL_precondition(!kernel.equal_3_object() (kernel.construct_opposite_direction_3_object()(source), static_cast(target))); From 30eaf54c98ea20375b605880529aa2b23e3ff970 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 31 Oct 2017 11:40:25 +0100 Subject: [PATCH 10/16] polish --- Filtered_kernel/include/CGAL/Epic_converter.h | 172 +++++++++--------- .../include/CGAL/Static_filtered_predicate.h | 43 +++++ 2 files changed, 129 insertions(+), 86 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Epic_converter.h b/Filtered_kernel/include/CGAL/Epic_converter.h index 28e29f24a5e..89490db2f8b 100644 --- a/Filtered_kernel/include/CGAL/Epic_converter.h +++ b/Filtered_kernel/include/CGAL/Epic_converter.h @@ -85,179 +85,179 @@ public: return std::make_pair(ORIGIN,false); } - std::pair operator()(const typename IK::Vector_2& p) const + std::pair operator()(const typename IK::Vector_2& v) const { double x, y; - if(fit_in_double(p.x(),x) && fit_in_double(p.y(),y)){ + if(fit_in_double(v.x(),x) && fit_in_double(v.y(),y)){ return std::make_pair(Vector_2(x,y),true); } - return std::make_pair(Vector_2(0,0),false); + return std::make_pair(Vector_2(),false); } - std::pair operator()(const typename IK::Direction_2& p) const + std::pair operator()(const typename IK::Direction_2& d) const { double x, y; - if(fit_in_double(p.dx(),x) && fit_in_double(p.dy(),y)){ + if(fit_in_double(d.dx(),x) && fit_in_double(d.dy(),y)){ return std::make_pair(Direction_2(x,y),true); } - return std::make_pair(Direction_2(0,0),false); + return std::make_pair(Direction_2(),false); } - std::pair operator()(const typename IK::Weighted_point_2& p) const + std::pair operator()(const typename IK::Weighted_point_2& wp) const { - std::pair sp = operator()(p.point()); - std::pair w = operator()(p.weight()); + std::pair sp = operator()(wp.point()); + std::pair w = operator()(wp.weight()); if(sp.second && w.second){ return std::make_pair(Weighted_point_2(sp.first,w.first),true); } - return std::make_pair(Weighted_point_2(ORIGIN,0),false); + return std::make_pair(Weighted_point_2(),false); } std::pair operator()(const typename IK::Segment_2& s) const { std::pair sp = operator()(s.source()); if(! sp.second){ - return std::make_pair(Segment_2(sp.first,sp.first),false); + return std::make_pair(Segment_2(),false); } std::pair tp = operator()(s.target()); if(! tp.second){ - return std::make_pair(Segment_2(tp.first,tp.first),false); + return std::make_pair(Segment_2(),false); } return std::make_pair(Segment_2(sp.first,tp.first), true); } - std::pair operator()(const typename IK::Line_2& s) const + std::pair operator()(const typename IK::Line_2& li) const { - std::pair a = operator()(s.a()), b = operator()(s.b()) , c = operator()(s.c()); + std::pair a = operator()(li.a()), b = operator()(li.b()) , c = operator()(li.c()); if(a.second && b.second && c.second){ return std::make_pair(Line_2(a.first, b.first, c.first),true); } - return std::make_pair(Line_2(0,0,0), false); + return std::make_pair(Line_2(), false); } - std::pair operator()(const typename IK::Ray_2& s) const + std::pair operator()(const typename IK::Ray_2& r) const { - std::pair sp = operator()(s.source()); + std::pair sp = operator()(r.source()); if(! sp.second){ - return std::make_pair(Ray_2(ORIGIN,ORIGIN),false); + return std::make_pair(Ray_2(),false); } - std::pair tp = operator()(s.second_point()); + std::pair tp = operator()(r.second_point()); if(! tp.second){ - return std::make_pair(Ray_2(ORIGIN,ORIGIN),false); + return std::make_pair(Ray_2(),false); } return std::make_pair(Ray_2(sp.first,tp.first), true); } - std::pair operator()(const typename IK::Triangle_2& s) const + std::pair operator()(const typename IK::Triangle_2& t) const { - std::pair v0 = operator()(s.vertex(0)); + std::pair v0 = operator()(t.vertex(0)); if(! v0.second){ - return std::make_pair(Triangle_2(ORIGIN, ORIGIN, ORIGIN),false); + return std::make_pair(Triangle_2(),false); } - std::pair v1 = operator()(s.vertex(1)); + std::pair v1 = operator()(t.vertex(1)); if(! v1.second){ - return std::make_pair(Triangle_2(ORIGIN,ORIGIN, ORIGIN),false); + return std::make_pair(Triangle_2(),false); } - std::pair v2 = operator()(s.vertex(2)); + std::pair v2 = operator()(t.vertex(2)); if(! v2.second){ - return std::make_pair(Triangle_2(ORIGIN,ORIGIN, ORIGIN),false); + return std::make_pair(Triangle_2(),false); } return std::make_pair(Triangle_2(v0.first,v1.first, v2.first), true); } - std::pair operator()(const typename IK::Circle_2& s) const + std::pair operator()(const typename IK::Circle_2& ci) const { - std::pair c = operator()(s.center()); - std::pair sr = operator()(s.squared_radius()); + std::pair c = operator()(ci.center()); + std::pair sr = operator()(ci.squared_radius()); if(c.second && sr.second){ - return std::make_pair(Circle_2(c.first, sr.first, s.orientation()),true); + return std::make_pair(Circle_2(c.first, sr.first, ci.orientation()),true); } - return std::make_pair(Circle_2(ORIGIN, 0, s.orientation()), false); + return std::make_pair(Circle_2(), false); } - std::pair operator()(const typename IK::Iso_rectangle_2& s) const + std::pair operator()(const typename IK::Iso_rectangle_2& ir) const { - std::pair sp = operator()((s.min)()); + std::pair sp = operator()((ir.min)()); if(! sp.second){ - return std::make_pair(Iso_rectangle_2(ORIGIN,ORIGIN),false); + return std::make_pair(Iso_rectangle_2(),false); } - std::pair tp = operator()((s.max)()); + std::pair tp = operator()((ir.max)()); if(! tp.second){ - return std::make_pair(Iso_rectangle_2(ORIGIN,ORIGIN),false); + return std::make_pair(Iso_rectangle_2(),false); } return std::make_pair(Iso_rectangle_2(sp.first,tp.first), true); } - std::pair operator()(const typename IK::Line_3& s) const + std::pair operator()(const typename IK::Line_3& li) const { - std::pair sp = operator()(s.point()); + std::pair sp = operator()(li.point()); if(! sp.second){ return std::make_pair(Line_3(),false); } - std::pair tp = operator()(s.to_vector()); + std::pair tp = operator()(li.to_vector()); if(! tp.second){ - return std::make_pair(Line_3(ORIGIN,NULL_VECTOR),false); + return std::make_pair(Line_3(),false); } return std::make_pair(Line_3(sp.first,tp.first), true); } - std::pair operator()(const typename IK::Plane_3& s) const + std::pair operator()(const typename IK::Plane_3& pl) const { - std::pair a = operator()(s.a()), b = operator()(s.b()) , c = operator()(s.c()) , d = operator()(s.d()); + std::pair a = operator()(pl.a()), b = operator()(pl.b()) , c = operator()(pl.c()) , d = operator()(pl.d()); if(a.second && b.second && c.second && d.second){ return std::make_pair(Plane_3(a.first, b.first, c.first, d.first),true); } - return std::make_pair(Plane_3(0,0,0,0), false); + return std::make_pair(Plane_3(), false); } - std::pair operator()(const typename IK::Triangle_3& s) const + std::pair operator()(const typename IK::Triangle_3& t) const { - std::pair v0 = operator()(s.vertex(0)); + std::pair v0 = operator()(t.vertex(0)); if(! v0.second){ - return std::make_pair(Triangle_3(ORIGIN, ORIGIN, ORIGIN),false); + return std::make_pair(Triangle_3(),false); } - std::pair v1 = operator()(s.vertex(1)); + std::pair v1 = operator()(t.vertex(1)); if(! v1.second){ - return std::make_pair(Triangle_3(ORIGIN,ORIGIN, ORIGIN),false); + return std::make_pair(Triangle_3(),false); } - std::pair v2 = operator()(s.vertex(2)); + std::pair v2 = operator()(t.vertex(2)); if(! v2.second){ - return std::make_pair(Triangle_3(ORIGIN,ORIGIN, ORIGIN),false); + return std::make_pair(Triangle_3(),false); } return std::make_pair(Triangle_3(v0.first,v1.first, v2.first), true); } - std::pair operator()(const typename IK::Tetrahedron_3& s) const + std::pair operator()(const typename IK::Tetrahedron_3& t) const { - std::pair v0 = operator()(s.vertex(0)); + std::pair v0 = operator()(t.vertex(0)); if(! v0.second){ - return std::make_pair(Tetrahedron_3(ORIGIN, ORIGIN, ORIGIN, ORIGIN),false); + return std::make_pair(Tetrahedron_3(),false); } - std::pair v1 = operator()(s.vertex(1)); + std::pair v1 = operator()(t.vertex(1)); if(! v1.second){ - return std::make_pair(Tetrahedron_3(ORIGIN,ORIGIN, ORIGIN, ORIGIN),false); + return std::make_pair(Tetrahedron_3(),false); } - std::pair v2 = operator()(s.vertex(2)); + std::pair v2 = operator()(t.vertex(2)); if(! v2.second){ - return std::make_pair(Tetrahedron_3(ORIGIN,ORIGIN, ORIGIN, ORIGIN),false); + return std::make_pair(Tetrahedron_3(),false); } - std::pair v3 = operator()(s.vertex(3)); + std::pair v3 = operator()(t.vertex(3)); if(! v3.second){ - return std::make_pair(Tetrahedron_3(ORIGIN,ORIGIN, ORIGIN, ORIGIN),false); + return std::make_pair(Tetrahedron_3(),false); } return std::make_pair(Tetrahedron_3(v0.first,v1.first, v2.first, v3.first), true); } - std::pair operator()(const typename IK::Ray_3& s) const + std::pair operator()(const typename IK::Ray_3& r) const { - std::pair sp = operator()(s.source()); + std::pair sp = operator()(r.source()); if(! sp.second){ - return std::make_pair(Ray_3(ORIGIN,ORIGIN),false); + return std::make_pair(Ray_3(),false); } - std::pair tp = operator()(s.second_point()); + std::pair tp = operator()(r.second_point()); if(! tp.second){ - return std::make_pair(Ray_3(ORIGIN,ORIGIN),false); + return std::make_pair(Ray_3(),false); } return std::make_pair(Ray_3(sp.first,tp.first), true); } @@ -271,45 +271,45 @@ public: return std::make_pair(ORIGIN,false); } - std::pair operator()(const typename IK::Vector_3& p) const + std::pair operator()(const typename IK::Vector_3& v) const { double x, y, z; - if(fit_in_double(p.x(),x) && fit_in_double(p.y(),y) && fit_in_double(p.z(),z)){ + if(fit_in_double(v.x(),x) && fit_in_double(v.y(),y) && fit_in_double(v.z(),z)){ return std::make_pair(Vector_3(x,y,z),true); } - return std::make_pair(Vector_3(0,0,0),false); + return std::make_pair(Vector_3(),false); } - std::pair operator()(const typename IK::Direction_3& p) const + std::pair operator()(const typename IK::Direction_3& d) const { double x, y, z; - if(fit_in_double(p.dx(),x) && fit_in_double(p.dy(),y) && fit_in_double(p.dz(),z)){ + if(fit_in_double(d.dx(),x) && fit_in_double(d.dy(),y) && fit_in_double(d.dz(),z)){ return std::make_pair(Direction_3(x,y,z),true); } - return std::make_pair(Direction_3(0,0,0),false); + return std::make_pair(Direction_3(),false); } std::pair operator()(const typename IK::Segment_3& s) const { std::pair sp = operator()(s.source()); if(! sp.second){ - return std::make_pair(Segment_3(sp.first,sp.first),false); + return std::make_pair(Segment_3(),false); } std::pair tp = operator()(s.target()); if(! tp.second){ - return std::make_pair(Segment_3(tp.first,tp.first),false); + return std::make_pair(Segment_3(),false); } return std::make_pair(Segment_3(sp.first,tp.first), true); } - std::pair operator()(const typename IK::Weighted_point_3& p) const + std::pair operator()(const typename IK::Weighted_point_3& wp) const { - std::pair sp = operator()(p.point()); - std::pair w = operator()(p.weight()); + std::pair sp = operator()(wp.point()); + std::pair w = operator()(wp.weight()); if(sp.second && w.second){ return std::make_pair(Weighted_point_3(sp.first,w.first),true); } - return std::make_pair(Weighted_point_3(ORIGIN,0),false); + return std::make_pair(Weighted_point_3(),false); } std::pair operator()(const typename IK::Sphere_3& s) const @@ -319,28 +319,28 @@ public: if(c.second && sr.second){ return std::make_pair(Sphere_3(c.first, sr.first, s.orientation()),true); } - return std::make_pair(Sphere_3(ORIGIN, 0, s.orientation()), false); + return std::make_pair(Sphere_3(), false); } - std::pair operator()(const typename IK::Circle_3& s) const + std::pair operator()(const typename IK::Circle_3& ci) const { - std::pair sr = operator()(s.diametral_sphere()); - std::pair c = operator()(s.supporting_plane()); + std::pair sr = operator()(ci.diametral_sphere()); + std::pair c = operator()(ci.supporting_plane()); if(c.second && sr.second){ return std::make_pair(Circle_3(sr.first, c.first),true); } return std::make_pair(Circle_3(), false); } - std::pair operator()(const typename IK::Iso_cuboid_3& s) const + std::pair operator()(const typename IK::Iso_cuboid_3& ic) const { - std::pair sp = operator()((s.min)()); + std::pair sp = operator()((ic.min)()); if(! sp.second){ - return std::make_pair(Iso_cuboid_3(ORIGIN,ORIGIN),false); + return std::make_pair(Iso_cuboid_3(),false); } - std::pair tp = operator()((s.max)()); + std::pair tp = operator()((ic.max)()); if(! tp.second){ - return std::make_pair(Iso_cuboid_3(ORIGIN,ORIGIN),false); + return std::make_pair(Iso_cuboid_3(),false); } return std::make_pair(Iso_cuboid_3(sp.first,tp.first), true); } diff --git a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h index d714cac68ce..245e6c1fb35 100644 --- a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h +++ b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h @@ -230,6 +230,49 @@ public: return epicp(aa1.first, aa2.first, aa3.first, aa4.first, aa5.first, aa6.first); } + template + result_type operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A6& a7) const + { + CGAL::Epic_converter convert; + typedef typename Kernel_traits::type EK; + typedef typename Type_mapper::type T1; + std::pair aa1 = convert(a1.approx()); + if(! aa1.second){ + return fp(a1, a2, a3, a4, a5, a6, a7); + } + typedef typename Type_mapper::type T2; + std::pair aa2 = convert(a2.approx()); + if(! aa2.second){ + return fp(a1, a2, a3, a4, a5, a6, a7); + } + typedef typename Type_mapper::type T3; + std::pair aa3 = convert(a3.approx()); + if(! aa3.second){ + return fp(a1, a2, a3, a4, a5, a6, a7); + } + typedef typename Type_mapper::type T4; + std::pair aa4 = convert(a4.approx()); + if(! aa4.second){ + return fp(a1, a2, a3, a4, a5, a6, a7); + } + typedef typename Type_mapper::type T5; + std::pair aa5 = convert(a5.approx()); + if(! aa5.second){ + return fp(a1, a2, a3, a4, a5, a6, a7); + } + typedef typename Type_mapper::type T6; + std::pair aa6 = convert(a6.approx()); + if(! aa6.second){ + return fp(a1, a2, a3, a4, a5, a6, a7); + } + typedef typename Type_mapper::type T7; + std::pair aa7 = convert(a7.approx()); + if(! aa7.second){ + return fp(a1, a2, a3, a4, a5, a6, a7); + } + return epicp(aa1.first, aa2.first, aa3.first, aa4.first, aa5.first, aa6.first, aa7.first); + } + template result_type operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8) const From d60379266b1ec298aef704903e5e09da7dcfe0ba Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 31 Oct 2017 12:04:48 +0100 Subject: [PATCH 11/16] Revert "Improvement: add static filters to Lazy_kernel" This reverts commit 8eac6ca6507e1650d884aea34a3b66afd9a02c87. Now Epeck automatically falls back to using Epick predicates when the objects have trivial approximations. --- Filtered_kernel/include/CGAL/Lazy_kernel.h | 25 ++----------- .../Static_filters/Compare_squared_radius_3.h | 24 +++++-------- .../internal/Static_filters/Orientation_2.h | 7 ++-- .../internal/Static_filters/Orientation_3.h | 20 +++++------ .../Side_of_oriented_circle_2.h | 11 +++--- .../Side_of_oriented_sphere_3.h | 24 ++++++------- .../internal/Static_filters/Static_filters.h | 35 +++---------------- ...ct_predicates_exact_constructions_kernel.h | 15 -------- 8 files changed, 41 insertions(+), 120 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index 86e7751f99d..a0cc7f53043 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -383,13 +383,6 @@ public: { return Compute_approximate_area_3(); } }; // end class Lazy_kernel_base -#ifndef CGAL_LAZY_KERNEL_USE_STATIC_FILTERS_BY_DEFAULT -# ifdef CGAL_NO_STATIC_FILTERS -# define CGAL_LAZY_KERNEL_USE_STATIC_FILTERS_BY_DEFAULT false -# else -# define CGAL_LAZY_KERNEL_USE_STATIC_FILTERS_BY_DEFAULT true -# endif -#endif template struct Lazy_kernel_without_type_equality @@ -398,23 +391,11 @@ struct Lazy_kernel_without_type_equality template , - class E2A = Cartesian_converter, - bool UseStaticFilters = CGAL_LAZY_KERNEL_USE_STATIC_FILTERS_BY_DEFAULT > + class E2A = Cartesian_converter > struct Lazy_kernel : public Type_equality_wrapper< - Lazy_kernel_base< Exact_kernel, Approximate_kernel, E2A, - Lazy_kernel >, - Lazy_kernel > -{}; - -template -struct Lazy_kernel - : public -//internal::Static_filters< - Type_equality_wrapper< - Lazy_kernel_base< Exact_kernel, Approximate_kernel, E2A, Lazy_kernel > , - Lazy_kernel > -//, false > + Lazy_kernel_base< Exact_kernel, Approximate_kernel, E2A, Lazy_kernel >, + Lazy_kernel > { // WARNING: If you change the definition of Lazy_kernel, then you need to // change also the definition of Epeck in diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Compare_squared_radius_3.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Compare_squared_radius_3.h index d833cdcdc7d..eeec62785c3 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Compare_squared_radius_3.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Compare_squared_radius_3.h @@ -24,7 +24,6 @@ #include #include -#include #include namespace CGAL { namespace internal { namespace Static_filters_predicates { @@ -59,23 +58,18 @@ namespace CGAL { namespace internal { namespace Static_filters_predicates { ) const { CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Compare_squared_radius_3 with 4 points", tmp); - Get_approx get_approx; // Identity functor for all points - // but lazy ones. - Get_approx get_approx_ft; // Identity functor for all FT - // but Lazy ones. - double px, py, pz, qx, qy, qz, rx, ry, rz, sx, sy, sz, alpha; init_double(px, py, pz, qx, qy, qz, rx, ry, rz, sx, sy, sz, alpha, (FT*)(0)); - if( fit_in_double(get_approx(p).x(), px) && fit_in_double(get_approx(p).y(), py) && - fit_in_double(get_approx(p).z(), pz) && - fit_in_double(get_approx(q).x(), qx) && fit_in_double(get_approx(q).y(), qy) && - fit_in_double(get_approx(q).z(), qz) && - fit_in_double(get_approx(r).x(), rx) && fit_in_double(get_approx(r).y(), ry) && - fit_in_double(get_approx(r).z(), rz) && - fit_in_double(get_approx(s).x(), sx) && fit_in_double(get_approx(s).y(), sy) && - fit_in_double(get_approx(s).z(), sz) && - fit_in_double(get_approx_ft(w), alpha) + if( fit_in_double(p.x(), px) && fit_in_double(p.y(), py) && + fit_in_double(p.z(), pz) && + fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) && + fit_in_double(q.z(), qz) && + fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry) && + fit_in_double(r.z(), rz) && + fit_in_double(s.x(), sx) && fit_in_double(s.y(), sy) && + fit_in_double(s.z(), sz) && + fit_in_double(w, alpha) ) { CGAL_BRANCH_PROFILER_BRANCH_1(tmp); diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Orientation_2.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Orientation_2.h index 508813bc336..d33cb279ca0 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Orientation_2.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Orientation_2.h @@ -65,11 +65,10 @@ public: CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Orientation_2", tmp); double px, py, qx, qy, rx, ry; - Get_approx get_approx; - if (fit_in_double(get_approx(p).x(), px) && fit_in_double(get_approx(p).y(), py) && - fit_in_double(get_approx(q).x(), qx) && fit_in_double(get_approx(q).y(), qy) && - fit_in_double(get_approx(r).x(), rx) && fit_in_double(get_approx(r).y(), ry)) + if (fit_in_double(p.x(), px) && fit_in_double(p.y(), py) && + fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) && + fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry)) { CGAL_BRANCH_PROFILER_BRANCH_1(tmp); diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Orientation_3.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Orientation_3.h index eed3bc3e159..5883cd8cdee 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Orientation_3.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Orientation_3.h @@ -23,7 +23,6 @@ #include #include -#include #include namespace CGAL { namespace internal { namespace Static_filters_predicates { @@ -73,19 +72,16 @@ public: { CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Orientation_3", tmp); - Get_approx get_approx; // Identity functor for all points - // but lazy points. - double px, py, pz, qx, qy, qz, rx, ry, rz, sx, sy, sz; - if (fit_in_double(get_approx(p).x(), px) && fit_in_double(get_approx(p).y(), py) && - fit_in_double(get_approx(p).z(), pz) && - fit_in_double(get_approx(q).x(), qx) && fit_in_double(get_approx(q).y(), qy) && - fit_in_double(get_approx(q).z(), qz) && - fit_in_double(get_approx(r).x(), rx) && fit_in_double(get_approx(r).y(), ry) && - fit_in_double(get_approx(r).z(), rz) && - fit_in_double(get_approx(s).x(), sx) && fit_in_double(get_approx(s).y(), sy) && - fit_in_double(get_approx(s).z(), sz)) + if (fit_in_double(p.x(), px) && fit_in_double(p.y(), py) && + fit_in_double(p.z(), pz) && + fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) && + fit_in_double(q.z(), qz) && + fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry) && + fit_in_double(r.z(), rz) && + fit_in_double(s.x(), sx) && fit_in_double(s.y(), sy) && + fit_in_double(s.z(), sz)) { CGAL_BRANCH_PROFILER_BRANCH_1(tmp); diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Side_of_oriented_circle_2.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Side_of_oriented_circle_2.h index 6b456ee39ed..ea34603d019 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Side_of_oriented_circle_2.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Side_of_oriented_circle_2.h @@ -41,15 +41,12 @@ public: { CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Side_of_oriented_circle_2", tmp); - Get_approx get_approx; // Identity functor for all points - // but lazy points. - double px, py, qx, qy, rx, ry, tx, ty; - if (fit_in_double(get_approx(p).x(), px) && fit_in_double(get_approx(p).y(), py) && - fit_in_double(get_approx(q).x(), qx) && fit_in_double(get_approx(q).y(), qy) && - fit_in_double(get_approx(r).x(), rx) && fit_in_double(get_approx(r).y(), ry) && - fit_in_double(get_approx(t).x(), tx) && fit_in_double(get_approx(t).y(), ty)) + if (fit_in_double(p.x(), px) && fit_in_double(p.y(), py) && + fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) && + fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry) && + fit_in_double(t.x(), tx) && fit_in_double(t.y(), ty)) { CGAL_BRANCH_PROFILER_BRANCH_1(tmp); diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Side_of_oriented_sphere_3.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Side_of_oriented_sphere_3.h index baac316deff..0099c5aab19 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Side_of_oriented_sphere_3.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Side_of_oriented_sphere_3.h @@ -23,7 +23,6 @@ #include #include -#include namespace CGAL { namespace internal { namespace Static_filters_predicates { @@ -42,21 +41,18 @@ public: { CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Side_of_oriented_sphere_3", tmp); - Get_approx get_approx; // Identity functor for all points - // but lazy points. - double px, py, pz, qx, qy, qz, rx, ry, rz, sx, sy, sz, tx, ty, tz; - if (fit_in_double(get_approx(p).x(), px) && fit_in_double(get_approx(p).y(), py) && - fit_in_double(get_approx(p).z(), pz) && - fit_in_double(get_approx(q).x(), qx) && fit_in_double(get_approx(q).y(), qy) && - fit_in_double(get_approx(q).z(), qz) && - fit_in_double(get_approx(r).x(), rx) && fit_in_double(get_approx(r).y(), ry) && - fit_in_double(get_approx(r).z(), rz) && - fit_in_double(get_approx(s).x(), sx) && fit_in_double(get_approx(s).y(), sy) && - fit_in_double(get_approx(s).z(), sz) && - fit_in_double(get_approx(t).x(), tx) && fit_in_double(get_approx(t).y(), ty) && - fit_in_double(get_approx(t).z(), tz)) + if (fit_in_double(p.x(), px) && fit_in_double(p.y(), py) && + fit_in_double(p.z(), pz) && + fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) && + fit_in_double(q.z(), qz) && + fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry) && + fit_in_double(r.z(), rz) && + fit_in_double(s.x(), sx) && fit_in_double(s.y(), sy) && + fit_in_double(s.z(), sz) && + fit_in_double(t.x(), tx) && fit_in_double(t.y(), ty) && + fit_in_double(t.z(), tz)) { CGAL_BRANCH_PROFILER_BRANCH_1(tmp); diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Static_filters.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Static_filters.h index 1eb5c24f57b..1f8dbcb882b 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Static_filters.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Static_filters.h @@ -96,28 +96,13 @@ // compiler. g++ 4.0 should be able to cprop the second part... -// Note about the second parameter of Static_filters: -// - if the access to Cartesian exact coordinates is cheap -// (Simple_cartesian, Cartesian), then one can implement predicates that -// just compare coordinates without filtering, using unfiltered -// predicates defined in the namespace CartesianKernelFunctors. -// -// - in the case of Lazy_kernel, where the access to p.x(), for a point p, -// triggers the construction of a Lazy_exact_nt object, one does not want -// to use the functors from the namespace CartesianKernelFunctors. - namespace CGAL { namespace internal { -// Here is the case when has_cheap_access_to_cartesian_coordinates is -// false, used by Lazy_kernel // The K_base argument is supposed to provide exact primitives. -template < typename K_base, - bool has_cheap_access_to_cartesian_coordinates = true> -class Static_filters : public K_base { - - - typedef Static_filters Self; +template < typename K_base > +class Static_filters : public K_base +{ + typedef Static_filters Self; public: #ifndef CGAL_NO_EQUAL_3_STATIC_FILTERS @@ -214,20 +199,8 @@ Compare_y_2 enum { Has_static_filters = true }; -}; // end of class template Static_filters -// Here is the case when has_cheap_access_to_cartesian_coordinates is true, -// the default, used by Filtered_kernel. -// The K_base argument is supposed to provide exact primitives. -template < typename K_base> -class Static_filters // has_cheap_access_to_cartesian_coordinates==true - : public Static_filters -{ - typedef Static_filters Self; - -public: - typedef Static_filters_predicates::Compare_y_at_x_2 Compare_y_at_x_2; // The following do not require filtering as they only do diff --git a/Kernel_23/include/CGAL/Exact_predicates_exact_constructions_kernel.h b/Kernel_23/include/CGAL/Exact_predicates_exact_constructions_kernel.h index 5c2b92a4d1b..355b9740c12 100644 --- a/Kernel_23/include/CGAL/Exact_predicates_exact_constructions_kernel.h +++ b/Kernel_23/include/CGAL/Exact_predicates_exact_constructions_kernel.h @@ -59,20 +59,6 @@ class Epeck #else // no CGAL_DONT_USE_LAZY_KERNEL // Equivalent to Lazy_kernel > -#ifdef CGAL_LAZY_KERNEL_USE_STATIC_FILTERS_BY_DEFAULT -class Epeck - : public internal::Static_filters< - Type_equality_wrapper< - Lazy_kernel_base< Simple_cartesian, - Simple_cartesian, - Cartesian_converter< Simple_cartesian, - Simple_cartesian >, - Epeck>, - Epeck >, false> -{}; - -#else // no CGAL_LAZY_KERNEL_USE_STATIC_FILTERS_BY_DEFAULT - class Epeck : public Type_equality_wrapper< Lazy_kernel_base< Simple_cartesian, @@ -82,7 +68,6 @@ class Epeck Epeck>, Epeck > {}; -#endif // no CGAL_LAZY_KERNEL_USE_STATIC_FILTERS_BY_DEFAULT #endif // no CGAL_DONT_USE_LAZY_KERNEL From 766257d05538971eb083d4af44d814fc610ff1ce Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 9 Nov 2017 12:04:10 +0000 Subject: [PATCH 12/16] indentation fix --- Filtered_kernel/include/CGAL/Static_filtered_predicate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h index 245e6c1fb35..d3d50840425 100644 --- a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h +++ b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h @@ -25,7 +25,7 @@ namespace CGAL { - template +template class Static_filtered_predicate { public: FP fp; From fc14569efe0fc65817f634a283ad5e2c59526e14 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 9 Nov 2017 12:09:47 +0000 Subject: [PATCH 13/16] Remove #if 0 section --- Filtered_kernel/include/CGAL/Lazy_kernel.h | 35 ---------------------- 1 file changed, 35 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index a0cc7f53043..c9b3078bb44 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -314,41 +314,6 @@ public: // typedef void Compute_z_3; // to detect where .z() is called // typedef void Construct_point_3; // to detect where the ctor is called - -#if 0 - class Do_intersect_2 { - public: - bool operator()(const Segment_2& s, const Segment_2& t) const - { - internal::Static_filters_predicates::Get_approx get_approx; - typedef Exact_predicates_inexact_constructions_kernel Fit; - typedef typename Fit::Point_2 Fpoint; - typedef typename Fit::Segment_2 Fsegment; - double ssx, ssy, stx, sty, tsx, tsy, ttx, tty; - if(fit_in_double(get_approx(s).source().x(), ssx) && - fit_in_double(get_approx(s).source().y(), ssy) && - fit_in_double(get_approx(s).target().x(), stx) && - fit_in_double(get_approx(s).target().y(), sty) && - fit_in_double(get_approx(t).source().x(), tsx) && - fit_in_double(get_approx(t).source().y(), tsy) && - fit_in_double(get_approx(t).target().x(), ttx) && - fit_in_double(get_approx(t).target().y(), tty)){ - return do_intersect(Fsegment(Fpoint(ssx,ssy), Fpoint(stx,sty)), - Fsegment(Fpoint(tsx,tsy), Fpoint(ttx,tty))); - } - typename Lazy_kernel_generic_base::Do_intersect_2 DI; - return DI(s,t); - } - }; - - - typedef Static_filtered_predicate::Do_intersect_2, - typename Exact_predicates_inexact_constructions_kernel::Do_intersect_2> Do_intersect_2; - - Do_intersect_2 do_intersect_2_object() const - { return Do_intersect_2(); } -#endif Assign_2 assign_2_object() const From fedeed7f55fb3bb2b80d7a830a9282658e59b43b Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 9 Nov 2017 13:35:11 +0000 Subject: [PATCH 14/16] Respect CGAL_NO_STATIC_FILTERS --- Filtered_kernel/include/CGAL/Lazy_kernel.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index c9b3078bb44..c10db425486 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -274,9 +274,15 @@ public: // We don't touch the predicates. // FIXME TODO : better use a layer of Filtered_kernel on top of everything, // so that semi-static filters are used as well (?). +#ifdef CGAL_NO_STATIC_FILTERS +#define CGAL_Kernel_pred(P, Pf) \ + typedef Filtered_predicate P; \ + P Pf() const { return P(); } +#else #define CGAL_Kernel_pred(P, Pf) \ typedef Static_filtered_predicate, Exact_predicates_inexact_constructions_kernel::P> P; \ P Pf() const { return P(); } +#endif #define CGAL_Kernel_cons(C, Cf) \ typedef typename Select_wrapper::template apply::type C; \ From dcd1e627fd095d8b1f2353180a4b2e8385049608 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 9 Nov 2017 18:23:38 +0000 Subject: [PATCH 15/16] Change the macro name so that one can switch off static filtering for EPEC while keeping it for EPIC --- Filtered_kernel/include/CGAL/Lazy_kernel.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index c10db425486..4546eb69d6e 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -271,10 +271,8 @@ private: public: - // We don't touch the predicates. - // FIXME TODO : better use a layer of Filtered_kernel on top of everything, - // so that semi-static filters are used as well (?). -#ifdef CGAL_NO_STATIC_FILTERS + +#ifdef CGAL_NO_STATIC_FILTERS_FOR_LAZY_KERNEL #define CGAL_Kernel_pred(P, Pf) \ typedef Filtered_predicate P; \ P Pf() const { return P(); } From f169ffacf4d9c6fd471bac5288c0617c2d186ec7 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 7 Dec 2017 14:41:04 +0000 Subject: [PATCH 16/16] Add SPDX License Identifier --- Filtered_kernel/include/CGAL/Epic_converter.h | 1 + Filtered_kernel/include/CGAL/Static_filtered_predicate.h | 1 + .../include/CGAL/internal/Static_filters/Do_intersect_2.h | 1 + 3 files changed, 3 insertions(+) diff --git a/Filtered_kernel/include/CGAL/Epic_converter.h b/Filtered_kernel/include/CGAL/Epic_converter.h index 89490db2f8b..6dc96801973 100644 --- a/Filtered_kernel/include/CGAL/Epic_converter.h +++ b/Filtered_kernel/include/CGAL/Epic_converter.h @@ -14,6 +14,7 @@ // // $URL$ // $Id$ +// SPDX-License-Identifier: LGPL-3.0+ // // // Author(s) : Andreas Fabri, Laurent Rineau diff --git a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h index d3d50840425..b05a4284bdb 100644 --- a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h +++ b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h @@ -14,6 +14,7 @@ // // $URL$ // $Id$ +// SPDX-License-Identifier: LGPL-3.0+ // // // Author(s) : Andreas Fabri, Laurent Rineau diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_2.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_2.h index 132cf8911ae..2deb02212e4 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_2.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_2.h @@ -16,6 +16,7 @@ // // $URL$ // $Id$ +// SPDX-License-Identifier: LGPL-3.0+ // // // Author(s) : Andreas Fabri, Laurent Rineau