diff --git a/Straight_skeleton_2/include/CGAL/constructions/Straight_skeleton_cons_ftC2.h b/Straight_skeleton_2/include/CGAL/constructions/Straight_skeleton_cons_ftC2.h index d4d05542ddf..f309be34fea 100644 --- a/Straight_skeleton_2/include/CGAL/constructions/Straight_skeleton_cons_ftC2.h +++ b/Straight_skeleton_2/include/CGAL/constructions/Straight_skeleton_cons_ftC2.h @@ -24,7 +24,15 @@ namespace CGAL_SS_i { #ifdef CGAL_USE_CORE -inline CORE::BigFloat MP_Float_to_BigFloat( MP_Float const& b ) + +template +inline CORE::BigFloat to_BigFloat( NT const& n ) +{ + return CORE::BigFloat( CGAL::to_double(n) ) ; +} + +template<> +inline CORE::BigFloat to_BigFloat( MP_Float const& b ) { if (b.is_zero()) return CORE::BigFloat::getZero(); @@ -51,53 +59,21 @@ inline CORE::BigFloat MP_Float_to_BigFloat( MP_Float const& b ) return d * CORE::BigFloat::exp2( static_cast(exp * log_limb) ); } + + #endif -template -inline NT inexact_sqrt( NT const& n ) -{ - return CGAL_NTS sqrt(n); -} -inline MP_Float inexact_sqrt( MP_Float const& n ) -{ - CGAL_precondition(n > 0); - -#ifdef CGAL_USE_CORE - - CORE::BigFloat nn = MP_Float_to_BigFloat(n); - CORE::BigFloat s = CORE::sqrt(nn); - return s.doubleValue(); - -#else - - double nn = CGAL_NTS to_double(n); - - if ( !CGAL_NTS is_valid(nn) || ! CGAL_NTS is_finite(nn) ) - nn = std::numeric_limits::max BOOST_PREVENT_MACRO_SUBSTITUTION () ; - - CGAL_precondition(nn > 0); - - return CGAL_NTS sqrt(nn); -#endif - -} - -inline Quotient inexact_sqrt( Quotient const& q ) -{ - CGAL_precondition(q > 0); - return Quotient(CGAL_SS_i::inexact_sqrt(q.numerator()*q.denominator()), q.denominator() ); -} template -inline Lazy_exact_nt inexact_sqrt( Lazy_exact_nt const& n ) +inline NT inexact_sqrt_implementation( NT const& n, CGAL::Null_functor no_sqrt ) { #ifdef CGAL_USE_CORE - CORE::BigFloat nn = CGAL::to_double(n) ; + CORE::BigFloat nn = to_BigFloat(n) ; CORE::BigFloat s = CORE::sqrt(nn); - return Lazy_exact_nt(s.doubleValue()); + return NT(s.doubleValue()); #else @@ -110,11 +86,32 @@ inline Lazy_exact_nt inexact_sqrt( Lazy_exact_nt const& n ) double s = CGAL_NTS sqrt(nn); - return Lazy_exact_nt(s); + return NT(s); #endif } +template +inline NT inexact_sqrt_implementation( NT const& n, Sqrt sqrt_f ) +{ + return sqrt_f(n); +} + +template +inline NT inexact_sqrt( NT const& n ) +{ + typedef CGAL::Algebraic_structure_traits AST; + typedef typename AST::Sqrt Sqrt; + return inexact_sqrt_implementation(n,Sqrt()); +} + +inline Quotient inexact_sqrt( Quotient const& q ) +{ + CGAL_precondition(q > 0); + return Quotient(CGAL_SS_i::inexact_sqrt(q.numerator()*q.denominator()), q.denominator() ); +} + + // Given an oriented 2D straight line segment 'e', computes the normalized coefficients (a,b,c) of the // supporting line. // POSTCONDITION: [a,b] is the leftward normal _unit_ (a�+b�=1) vector.