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 4e94fcc248d..6587512b759 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 @@ -715,7 +715,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); @@ -782,8 +783,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. @@ -794,7 +795,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)); } }; @@ -1561,8 +1562,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()); @@ -2467,7 +2468,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()) { @@ -2538,7 +2540,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 @@ -2937,7 +2940,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))); 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..6dc96801973 --- /dev/null +++ b/Filtered_kernel/include/CGAL/Epic_converter.h @@ -0,0 +1,354 @@ +// 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$ +// SPDX-License-Identifier: LGPL-3.0+ +// +// +// Author(s) : Andreas Fabri, Laurent Rineau + +#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 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 + { + 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& v) const + { + double x, 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(),false); + } + + std::pair operator()(const typename IK::Direction_2& d) const + { + double x, 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(),false); + } + + std::pair operator()(const typename IK::Weighted_point_2& wp) const + { + 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(),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(),false); + } + std::pair tp = operator()(s.target()); + if(! tp.second){ + 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& li) const + { + 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(), false); + } + + std::pair operator()(const typename IK::Ray_2& r) const + { + std::pair sp = operator()(r.source()); + if(! sp.second){ + return std::make_pair(Ray_2(),false); + } + std::pair tp = operator()(r.second_point()); + if(! tp.second){ + 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& t) const + { + std::pair v0 = operator()(t.vertex(0)); + if(! v0.second){ + return std::make_pair(Triangle_2(),false); + } + std::pair v1 = operator()(t.vertex(1)); + if(! v1.second){ + return std::make_pair(Triangle_2(),false); + } + std::pair v2 = operator()(t.vertex(2)); + if(! v2.second){ + 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& ci) const + { + 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, ci.orientation()),true); + } + return std::make_pair(Circle_2(), false); + } + + std::pair operator()(const typename IK::Iso_rectangle_2& ir) const + { + std::pair sp = operator()((ir.min)()); + if(! sp.second){ + return std::make_pair(Iso_rectangle_2(),false); + } + std::pair tp = operator()((ir.max)()); + if(! tp.second){ + 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& li) const + { + std::pair sp = operator()(li.point()); + if(! sp.second){ + return std::make_pair(Line_3(),false); + } + std::pair tp = operator()(li.to_vector()); + if(! tp.second){ + 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& pl) const + { + 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(), false); + } + + std::pair operator()(const typename IK::Triangle_3& t) const + { + std::pair v0 = operator()(t.vertex(0)); + if(! v0.second){ + return std::make_pair(Triangle_3(),false); + } + std::pair v1 = operator()(t.vertex(1)); + if(! v1.second){ + return std::make_pair(Triangle_3(),false); + } + std::pair v2 = operator()(t.vertex(2)); + if(! v2.second){ + 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& t) const + { + std::pair v0 = operator()(t.vertex(0)); + if(! v0.second){ + return std::make_pair(Tetrahedron_3(),false); + } + std::pair v1 = operator()(t.vertex(1)); + if(! v1.second){ + return std::make_pair(Tetrahedron_3(),false); + } + std::pair v2 = operator()(t.vertex(2)); + if(! v2.second){ + return std::make_pair(Tetrahedron_3(),false); + } + std::pair v3 = operator()(t.vertex(3)); + if(! v3.second){ + 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& r) const + { + std::pair sp = operator()(r.source()); + if(! sp.second){ + return std::make_pair(Ray_3(),false); + } + std::pair tp = operator()(r.second_point()); + if(! tp.second){ + return std::make_pair(Ray_3(),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& v) const + { + double x, y, 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(),false); + } + + std::pair operator()(const typename IK::Direction_3& d) const + { + double x, y, 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(),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(),false); + } + std::pair tp = operator()(s.target()); + if(! tp.second){ + 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& wp) const + { + 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(),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(), false); + } + + std::pair operator()(const typename IK::Circle_3& ci) const + { + 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& ic) const + { + std::pair sp = operator()((ic.min)()); + if(! sp.second){ + return std::make_pair(Iso_cuboid_3(),false); + } + std::pair tp = operator()((ic.max)()); + if(! tp.second){ + return std::make_pair(Iso_cuboid_3(),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 57fd982ddcd..521215d6576 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -24,6 +24,7 @@ #include //#include +#include #include #include #include @@ -32,7 +33,8 @@ #include #include #include - +#include +#include #include #include #include @@ -110,6 +112,8 @@ public: typedef E2A_ E2A; typedef Kernel_ Kernel; + typedef Lazy_kernel_generic_base Self; + // synonym identical to Filtered_kernel typedef AK_ FK; @@ -268,12 +272,16 @@ 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 (?). -#define CGAL_Kernel_pred(P, Pf) \ + +#ifdef CGAL_NO_STATIC_FILTERS_FOR_LAZY_KERNEL +#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; \ @@ -282,6 +290,10 @@ public: #include }; + + + + template < typename EK_, typename AK_, typename E2A_, typename Kernel_ > class Lazy_kernel_base : public Lazy_kernel_generic_base @@ -307,7 +319,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 - + Assign_2 assign_2_object() const { return Assign_2(); } @@ -341,13 +353,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 @@ -356,21 +361,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/Static_filtered_predicate.h b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h new file mode 100644 index 00000000000..b05a4284bdb --- /dev/null +++ b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h @@ -0,0 +1,329 @@ +// 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$ +// SPDX-License-Identifier: LGPL-3.0+ +// +// +// Author(s) : Andreas Fabri, Laurent Rineau + +#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(approx(a1)); + if(! aa1.second){ + return fp(a1, a2); + } + typedef typename Type_mapper::type T2; + 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 + { + 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 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 + { + 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/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 b606705005e..96825ba29ed 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 @@ -25,7 +25,6 @@ #include #include -#include #include namespace CGAL { namespace internal { namespace Static_filters_predicates { @@ -60,23 +59,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/Do_intersect_2.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_2.h new file mode 100644 index 00000000000..2deb02212e4 --- /dev/null +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_2.h @@ -0,0 +1,91 @@ +// 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$ +// SPDX-License-Identifier: LGPL-3.0+ +// +// +// 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 7266f42eea4..f78794de661 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 @@ -84,7 +84,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/Orientation_2.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Orientation_2.h index 1b8b363e2bb..cbfea52723a 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Orientation_2.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Orientation_2.h @@ -66,11 +66,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 51be1a4aaaa..a85eb431919 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Orientation_3.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Orientation_3.h @@ -24,7 +24,6 @@ #include #include -#include #include namespace CGAL { namespace internal { namespace Static_filters_predicates { @@ -74,19 +73,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 74e891d38bb..15049c66537 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 @@ -42,15 +42,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 04b50c12b72..088ddbe77bb 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 @@ -24,7 +24,6 @@ #include #include -#include namespace CGAL { namespace internal { namespace Static_filters_predicates { @@ -43,21 +42,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 d4a6ad25c4d..c9160f266b0 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Static_filters.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Static_filters.h @@ -46,7 +46,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 @@ -68,9 +69,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 @@ -95,28 +97,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 @@ -140,9 +127,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; @@ -180,6 +164,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 @@ -194,12 +179,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(); } @@ -221,20 +200,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 @@ -262,6 +229,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(); } @@ -330,6 +302,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 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 8f61eda8eb5..243563b6049 100644 --- a/Kernel_23/include/CGAL/Exact_predicates_exact_constructions_kernel.h +++ b/Kernel_23/include/CGAL/Exact_predicates_exact_constructions_kernel.h @@ -60,20 +60,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, @@ -83,7 +69,6 @@ class Epeck Epeck>, Epeck > {}; -#endif // no CGAL_LAZY_KERNEL_USE_STATIC_FILTERS_BY_DEFAULT #endif // no CGAL_DONT_USE_LAZY_KERNEL diff --git a/Kernel_23/include/CGAL/Kernel/Type_mapper.h b/Kernel_23/include/CGAL/Kernel/Type_mapper.h index 79e3de86444..a995bd1cf33 100644 --- a/Kernel_23/include/CGAL/Kernel/Type_mapper.h +++ b/Kernel_23/include/CGAL/Kernel/Type_mapper.h @@ -103,6 +103,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. diff --git a/Nef_S2/include/CGAL/Nef_S2/Sphere_circle.h b/Nef_S2/include/CGAL/Nef_S2/Sphere_circle.h index ee07613ab02..c8465667904 100644 --- a/Nef_S2/include/CGAL/Nef_S2/Sphere_circle.h +++ b/Nef_S2/include/CGAL/Nef_S2/Sphere_circle.h @@ -72,7 +72,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 1accadd8bfa..93db6222b67 100644 --- a/Nef_S2/include/CGAL/Nef_S2/Sphere_segment.h +++ b/Nef_S2/include/CGAL/Nef_S2/Sphere_segment.h @@ -194,13 +194,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 3be8c0fe35e..e1289bdf360 100644 --- a/Partition_2/include/CGAL/Partition_2/Indirect_edge_compare.h +++ b/Partition_2/include/CGAL/Partition_2/Indirect_edge_compare.h @@ -62,19 +62,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(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 { // 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; } } @@ -111,11 +111,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; @@ -123,12 +123,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; @@ -137,9 +137,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 96dff5f4ba0..d60384ad459 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 @@ -30,7 +30,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) : @@ -39,7 +40,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/Partition_opt_cvx_edge.h b/Partition_2/include/CGAL/Partition_2/Partition_opt_cvx_edge.h index 30c9b99e981..ccae96e883a 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 @@ -68,7 +68,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 45f901c7e00..ba7ec3982eb 100644 --- a/Partition_2/include/CGAL/Partition_2/Partitioned_polygon_2.h +++ b/Partition_2/include/CGAL/Partition_2/Partitioned_polygon_2.h @@ -48,15 +48,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 @@ -278,7 +278,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/Rotation_tree_2.h b/Partition_2/include/CGAL/Partition_2/Rotation_tree_2.h index 8f3cfb228e4..f9228e36d0b 100644 --- a/Partition_2/include/CGAL/Partition_2/Rotation_tree_2.h +++ b/Partition_2/include/CGAL/Partition_2/Rotation_tree_2.h @@ -54,7 +54,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 Greater { + typename Traits::Less_xy_2 less; + typedef typename Traits::Point_2 Point; + public: + Greater(typename Traits::Less_xy_2 less) : less(less) {} + + template + bool operator()(const Point_like& p1, const Point_like& p2) { + return less(Point(p2), Point(p1)); + } + }; // constructor template @@ -62,9 +74,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)); + + 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 @@ -167,3 +179,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 ba97f1d009f..af1145660f4 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 @@ -58,9 +58,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) @@ -69,16 +71,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) @@ -87,16 +91,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) @@ -105,7 +111,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: @@ -140,9 +146,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; @@ -182,3 +188,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 a0c4adfca53..f0f364c5636 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 @@ -228,20 +228,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/Partition_2/include/CGAL/Partition_2/partition_approx_convex_2.h b/Partition_2/include/CGAL/Partition_2/partition_approx_convex_2.h index f5e35f53323..6f1ebe295b1 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 @@ -54,8 +54,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 14bbe262cb7..32697264193 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 @@ -210,11 +210,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 @@ -365,6 +367,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; @@ -381,7 +384,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; @@ -391,7 +394,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++; @@ -420,7 +423,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 d0a37146e4e..41d488b23f4 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 @@ -73,6 +73,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; @@ -83,17 +84,17 @@ 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(); 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; @@ -102,8 +103,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; @@ -300,16 +301,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 defe9bc72c6..5da65d7fc82 100644 --- a/Polygon/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h +++ b/Polygon/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h @@ -53,6 +53,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 @@ -65,7 +84,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); } //-----------------------------------------------------------------------// @@ -79,7 +100,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); } //-----------------------------------------------------------------------// @@ -417,9 +440,14 @@ 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 /// \endcond + +// Local Variables: +// c-basic-offset: 4 +// End: