qualified result type issues

This commit is contained in:
Pedro Machado Manhaes de Castro 2010-04-30 16:41:23 +00:00
parent 3147e41e61
commit 9ee39b4642
5 changed files with 142 additions and 17 deletions

View File

@ -149,20 +149,28 @@ public:
return typename R::Is_y_monotone_2()(*this); return typename R::Is_y_monotone_2()(*this);
} }
Circle_2 typename Qualified_result_of
<typename R::Construct_circle_2,Circular_arc_2>::type
// const Circle_2 &
supporting_circle() const supporting_circle() const
{ {
return typename R::Construct_circle_2()(*this); return typename R::Construct_circle_2()(*this);
} }
const Point_2 & center() const typename Qualified_result_of
<typename R::Construct_center_2,Circular_arc_2>::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
<typename R::Compute_squared_radius_2, Circular_arc_2>::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 Bbox_2 bbox(void) const

View File

@ -51,7 +51,7 @@ namespace CircularFunctors {
return construct_circle_2<CK>(eq); return construct_circle_2<CK>(eq);
} }
result_type const result_type&
operator() (const Circular_arc_2 & a) const operator() (const Circular_arc_2 & a) const
{ {
return (a.rep().supporting_circle()); return (a.rep().supporting_circle());
@ -61,6 +61,15 @@ namespace CircularFunctors {
} // namespace CircularFunctors } // namespace CircularFunctors
#ifndef CGAL_CFG_DONT_OVERLOAD_TOO_MUCH
template < typename K>
struct Qualified_result_of<CircularFunctors::Construct_circle_2<K>,
typename K::Circular_arc_2>
{
typedef const typename K::Circle_2 & type;
};
#endif
} // namespace CGAL } // namespace CGAL
#endif // CGAL_CIRCULAR_KERNEL_FUNCTION_OBJECTS_ON_CIRCLE_2_H #endif // CGAL_CIRCULAR_KERNEL_FUNCTION_OBJECTS_ON_CIRCLE_2_H

View File

@ -1205,7 +1205,7 @@ namespace CircularFunctors {
CGAL_DEPRECATED result_type operator() (const Circular_arc_2 & a) const 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 CGAL_DEPRECATED result_type operator() (const Line_arc_2 & a) const
{ {
return CK().construct_line_2_object()(a); return a.rep().supporting_line();
} }
}; };
#endif #endif
template <typename CK>
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 <typename CK>
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 } // namespace CircularFunctors
#ifndef CGAL_CFG_DONT_OVERLOAD_TOO_MUCH
template < typename K>
struct Qualified_result_of<CircularFunctors::Construct_center_2<K>,
typename K::Circular_arc_2>
{
typedef typename K::Point_2 const & type;
};
template < typename K>
struct Qualified_result_of<CircularFunctors::Compute_squared_radius_2<K>,
typename K::Circular_arc_2>
{
typedef typename K::FT const & type;
};
template < typename K>
struct Qualified_result_of<CircularFunctors::Compute_squared_radius_2<K>,
typename K::Circle_2>
{
typedef typename K::FT const & type;
};
#endif
} // namespace CGAL } // namespace CGAL
#endif // CGAL_CIRCULAR_KERNEL_FUNCTION_OBJECTS_POLYNOMIAL_CIRCULAR_H #endif // CGAL_CIRCULAR_KERNEL_FUNCTION_OBJECTS_POLYNOMIAL_CIRCULAR_H

View File

@ -32,6 +32,10 @@
// macros CGAL_Circular_Kernel_pred and CGAL_Circular_Kernel_cons. // macros CGAL_Circular_Kernel_pred and CGAL_Circular_Kernel_cons.
// And they are #undefed at the end of this file. // 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, CGAL_Circular_Kernel_cons(Get_equation,
get_equation_object) get_equation_object)
CGAL_Circular_Kernel_cons(Construct_circle_2, CGAL_Circular_Kernel_cons(Construct_circle_2,

View File

@ -29,17 +29,17 @@
#include <CGAL/Algebraic_kernel_for_circles_2_2.h> #include <CGAL/Algebraic_kernel_for_circles_2_2.h>
#include <CGAL/Circular_kernel_2.h> #include <CGAL/Circular_kernel_2.h>
/*
TODO: CORRECT THE MAKE_ROOT_OF_2 of GMPq GMPz //TODO: CORRECT THE MAKE_ROOT_OF_2 of GMPq GMPz
#ifdef CGAL_USE_GMP #ifdef CGAL_USE_GMP
# include <CGAL/Gmpq.h> # include <CGAL/Gmpq.h>
#else #else
*/
# include <CGAL/MP_Float.h> # include <CGAL/MP_Float.h>
# include <CGAL/Quotient.h> # include <CGAL/Quotient.h>
/*
#endif #endif
*/
// maybe it is better to change to the bbox filtered one // maybe it is better to change to the bbox filtered one
//#include <CGAL/Lazy_circular_kernel_2.h> //#include <CGAL/Lazy_circular_kernel_2.h>
@ -48,15 +48,15 @@ TODO: CORRECT THE MAKE_ROOT_OF_2 of GMPq GMPz
CGAL_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE
namespace internal { namespace internal {
/*
#ifdef CGAL_USE_GMP #ifdef CGAL_USE_GMP
typedef CGAL::Gmpq NT1; typedef CGAL::Gmpq NT1;
#else #else
*/
typedef Quotient<MP_Float> NT1; typedef Quotient<MP_Float> NT1;
/*
#endif #endif
*/
typedef Cartesian<NT1> Linear_k1; typedef Cartesian<NT1> Linear_k1;
typedef Algebraic_kernel_for_circles_2_2<NT1> Algebraic_k1; typedef Algebraic_kernel_for_circles_2_2<NT1> Algebraic_k1;
typedef Circular_kernel_2<Linear_k1, Algebraic_k1> CK1; typedef Circular_kernel_2<Linear_k1, Algebraic_k1> CK1;