mirror of https://github.com/CGAL/cgal
Copy relative_precision_of_to_double from Lazy_exact_nt to Lazy_alpha_nt_2.
This commit is contained in:
parent
45505a3c68
commit
a3050d2680
|
|
@ -108,6 +108,10 @@ resorting to exact arithmetic). Access to the interval containing the exact valu
|
|||
with `Protected=true`. Access to the exact value is provided through the function
|
||||
`FT::Exact_nt exact() const` where `FT::Exact_nt` depends on the configuration of %CGAL
|
||||
(it is `Gmpq` if `gmp` is available and `Quotient<CGAL::MP_Float>` otherwise).
|
||||
An overload for the function `double to_double(FT)` is also available. Its
|
||||
precision is controlled through `FT::set_relative_precision_of_to_double()` in
|
||||
exactly the same way as with `Lazy_exact_nt<NT>`, so a call to `to_double` may
|
||||
trigger an exact evaluation.
|
||||
It must be noted that an object of type `FT` is valid as long as the alpha shapes class that creates
|
||||
it is valid and has not been modified.
|
||||
For convenience, classical comparison operators are provided for the type `FT`.
|
||||
|
|
|
|||
|
|
@ -186,7 +186,25 @@ class Lazy_alpha_nt_2
|
|||
const Data_vector& data() const{ return input_points;}
|
||||
Data_vector& data(){ return input_points;}
|
||||
|
||||
static double & relative_precision_of_to_double_internal()
|
||||
{
|
||||
CGAL_STATIC_THREAD_LOCAL_VARIABLE(double, relative_precision_of_to_double, 0.00001);
|
||||
return relative_precision_of_to_double;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
static const double & get_relative_precision_of_to_double()
|
||||
{
|
||||
return relative_precision_of_to_double_internal();
|
||||
}
|
||||
|
||||
static void set_relative_precision_of_to_double(double d)
|
||||
{
|
||||
CGAL_assertion((0 < d) & (d < 1));
|
||||
relative_precision_of_to_double_internal() = d;
|
||||
}
|
||||
|
||||
typedef NT_exact Exact_nt;
|
||||
typedef NT_approx Approximate_nt;
|
||||
|
||||
|
|
@ -449,7 +467,17 @@ struct Alpha_nt_selector_2
|
|||
template<class Input_traits, bool mode, class Weighted_tag>
|
||||
double to_double(const internal::Lazy_alpha_nt_2<Input_traits, mode, Weighted_tag>& a)
|
||||
{
|
||||
return to_double(a.approx());
|
||||
double r;
|
||||
if (fit_in_double(a.approx(), r))
|
||||
return r;
|
||||
|
||||
// If it isn't precise enough,
|
||||
// we trigger the exact computation first,
|
||||
// which will refine the approximation.
|
||||
if (!has_smaller_relative_precision(a.approx(), a.get_relative_precision_of_to_double()))
|
||||
a.exact();
|
||||
|
||||
return CGAL_NTS to_double(a.approx());
|
||||
}
|
||||
|
||||
} // namespace CGAL
|
||||
|
|
|
|||
Loading…
Reference in New Issue