From 9ee39b46427a8fda920ebbb340b9d993e4f754e6 Mon Sep 17 00:00:00 2001 From: Pedro Machado Manhaes de Castro Date: Fri, 30 Apr 2010 16:41:23 +0000 Subject: [PATCH] qualified result type issues --- .../include/CGAL/Circular_arc_2.h | 18 ++- .../function_objects_on_circle_2.h | 11 +- .../function_objects_polynomial_circular.h | 108 +++++++++++++++++- .../CGAL/Circular_kernel_2/interface_macros.h | 4 + .../include/CGAL/Exact_circular_kernel_2.h | 18 +-- 5 files changed, 142 insertions(+), 17 deletions(-) diff --git a/Circular_kernel_2/include/CGAL/Circular_arc_2.h b/Circular_kernel_2/include/CGAL/Circular_arc_2.h index 6a4857b3e6f..ee2bed0cb12 100644 --- a/Circular_kernel_2/include/CGAL/Circular_arc_2.h +++ b/Circular_kernel_2/include/CGAL/Circular_arc_2.h @@ -149,20 +149,28 @@ public: return typename R::Is_y_monotone_2()(*this); } - Circle_2 + typename Qualified_result_of + ::type + // const Circle_2 & supporting_circle() const { return typename R::Construct_circle_2()(*this); } - const Point_2 & center() const + typename Qualified_result_of + ::type + // const Point_2 & + center() const { - return typename R::Construct_circle_2()(*this).center(); + return typename R::Construct_center_2()(*this); } - const FT & squared_radius() const + typename Qualified_result_of + ::type + // const FT & + squared_radius() const { - return typename R::Construct_circle_2()(*this).squared_radius(); + return typename R::Compute_squared_radius_2()(*this); } Bbox_2 bbox(void) const diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_on_circle_2.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_on_circle_2.h index af56129d737..e757e8b871e 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_on_circle_2.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_on_circle_2.h @@ -51,7 +51,7 @@ namespace CircularFunctors { return construct_circle_2(eq); } - result_type + const result_type& operator() (const Circular_arc_2 & a) const { return (a.rep().supporting_circle()); @@ -61,6 +61,15 @@ namespace CircularFunctors { } // namespace CircularFunctors +#ifndef CGAL_CFG_DONT_OVERLOAD_TOO_MUCH + template < typename K> + struct Qualified_result_of, + typename K::Circular_arc_2> + { + typedef const typename K::Circle_2 & type; + }; +#endif + } // namespace CGAL #endif // CGAL_CIRCULAR_KERNEL_FUNCTION_OBJECTS_ON_CIRCLE_2_H diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h index 552881105d9..00ccb1f6d10 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h @@ -1205,7 +1205,7 @@ namespace CircularFunctors { CGAL_DEPRECATED result_type operator() (const Circular_arc_2 & a) const { - return CK().construct_circle_2_object()(a); + return a.rep().supporting_circle(); } }; @@ -1223,12 +1223,116 @@ namespace CircularFunctors { CGAL_DEPRECATED result_type operator() (const Line_arc_2 & a) const { - return CK().construct_line_2_object()(a); + return a.rep().supporting_line(); } }; #endif + template + class Construct_center_2 + #ifndef CGAL_CFG_MATCHING_BUG_6 + : public CK::Linear_kernel::Construct_center_2 + #endif + { + typedef typename CK::Circular_arc_2 Circular_arc_2; + public: + + #ifndef CGAL_CFG_MATCHING_BUG_6 + typedef typename CK::Linear_kernel::Construct_center_2::result_type result_type; + using CK::Linear_kernel::Construct_center_2::operator(); + #else + + typedef typename CK::Linear_kernel LK; + typedef typename LK::Construct_center_2 LK_Construct_center_2; + typedef typename LK::Point_2 Point_2; + typedef typename LK::Circle_2 Circle_2; + public: + typedef Point_2 result_type; + + const result_type& + operator()( const Circle_2& c) const + { return LK_Construct_center_2()(c); } + + #endif + + const result_type& + operator()(const Circular_arc_2& c) const + { return c.rep().center(); } + + }; + + template + class Compute_squared_radius_2 +#ifndef CGAL_CFG_MATCHING_BUG_6 + : public CK::Linear_kernel::Compute_squared_radius_2 +#endif + { + typedef typename CK::Circular_arc_2 Circular_arc_2; + typedef typename CK::Circle_2 Circle_2; + public: + +#ifndef CGAL_CFG_MATCHING_BUG_6 + typedef typename CK::Linear_kernel::Compute_squared_radius_2::result_type result_type; + using CK::Linear_kernel::Compute_squared_radius_2::operator(); +#else + + typedef typename CK::Linear_kernel LK; + typedef typename LK::Compute_squared_radius_2 LK_Compute_squared_radius_2; + typedef typename LK::FT FT; + typedef typename LK::Point_2 Point_2; + typedef typename LK::Circle_2 Circle_2; + public: + typedef FT result_type; + + const result_type& + operator()( const Circle_2& c) const + { return LK_Compute_squared_radius_2()(c); } + + result_type + operator()( const Point_2& p) const + { return LK_Compute_squared_radius_2()(p); } + + result_type + operator()( const Point_2& p, const Point_2& q) const + { return LK_Compute_squared_radius_2()(p, q); } + + result_type + operator()( const Point_2& p, const Point_2& q, const Point_2& r) const + { return LK_Compute_squared_radius_2(p, q, r); } + +#endif + + const result_type& + operator()(const Circular_arc_2& c) const + { return c.rep().squared_radius(); } + + }; + } // namespace CircularFunctors + +#ifndef CGAL_CFG_DONT_OVERLOAD_TOO_MUCH + template < typename K> + struct Qualified_result_of, + typename K::Circular_arc_2> + { + typedef typename K::Point_2 const & type; + }; + + template < typename K> + struct Qualified_result_of, + typename K::Circular_arc_2> + { + typedef typename K::FT const & type; + }; + + template < typename K> + struct Qualified_result_of, + typename K::Circle_2> + { + typedef typename K::FT const & type; + }; +#endif + } // namespace CGAL #endif // CGAL_CIRCULAR_KERNEL_FUNCTION_OBJECTS_POLYNOMIAL_CIRCULAR_H diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/interface_macros.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/interface_macros.h index ceb1ff65024..1fcea9b2e37 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/interface_macros.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/interface_macros.h @@ -32,6 +32,10 @@ // macros CGAL_Circular_Kernel_pred and CGAL_Circular_Kernel_cons. // And they are #undefed at the end of this file. + CGAL_Circular_Kernel_cons(Compute_squared_radius_2, + compute_squared_radius_2_object) + CGAL_Circular_Kernel_cons(Construct_center_2, + construct_center_2_object) CGAL_Circular_Kernel_cons(Get_equation, get_equation_object) CGAL_Circular_Kernel_cons(Construct_circle_2, diff --git a/Circular_kernel_2/include/CGAL/Exact_circular_kernel_2.h b/Circular_kernel_2/include/CGAL/Exact_circular_kernel_2.h index 29755c5e941..bd1bf666c86 100644 --- a/Circular_kernel_2/include/CGAL/Exact_circular_kernel_2.h +++ b/Circular_kernel_2/include/CGAL/Exact_circular_kernel_2.h @@ -29,17 +29,17 @@ #include #include -/* -TODO: CORRECT THE MAKE_ROOT_OF_2 of GMPq GMPz + +//TODO: CORRECT THE MAKE_ROOT_OF_2 of GMPq GMPz #ifdef CGAL_USE_GMP # include #else -*/ + # include # include -/* + #endif -*/ + // maybe it is better to change to the bbox filtered one //#include @@ -48,15 +48,15 @@ TODO: CORRECT THE MAKE_ROOT_OF_2 of GMPq GMPz CGAL_BEGIN_NAMESPACE namespace internal { -/* + #ifdef CGAL_USE_GMP typedef CGAL::Gmpq NT1; #else -*/ + typedef Quotient NT1; -/* + #endif -*/ + typedef Cartesian Linear_k1; typedef Algebraic_kernel_for_circles_2_2 Algebraic_k1; typedef Circular_kernel_2 CK1;