diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index a563746b053..02ff98ac303 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -100,6 +100,103 @@ struct Lazy_construction2 { return new Lazy_rep_0(); } }; +#if 0 +// Experiment how we can store ranges +template +class Lazy_rep_XXX : + public Lazy_rep< AT, ET, E2A >, private EC +{ + int ld; + mutable std::vector lr; + const EC& ec() const { return *this; } + public: + void update_exact() const { + this->et = new ET(ec()(ld, CGAL::exact(std::begin(lr)), CGAL::exact(std::end(lr)))); + this->at = E2A()(*(this->et)); + lr = std::vector(); // lr.clear(); lr.shrink_to_fit(); generates worse code + } + template + Lazy_rep_XXX(const AC& ac, const EC& ec, int d, Iter const& f, Iter const& e) : + Lazy_rep(ac(d, CGAL::approx(f), CGAL::approx(e))), EC(ec), ld(d), lr(f, e) + { + this->set_depth(1); // ??? Who cares + } +}; +template +class Lazy_rep_YYY : + public Lazy_rep< AT, ET, E2A >, private EC +{ + mutable std::vector lr; + mutable L l; + const EC& ec() const { return *this; } + public: + void update_exact() const { + this->et = new ET(ec()(CGAL::exact(std::begin(lr)), CGAL::exact(std::end(lr)), CGAL::exact(l))); + this->at = E2A()(*(this->et)); + lr = std::vector(); // lr.clear(); lr.shrink_to_fit(); generates worse code + l = L(); + } + template + Lazy_rep_YYY(const AC& ac, const EC& ec, Iter const& f, Iter const& e, L const& ll) : + Lazy_rep(ac(CGAL::approx(f), CGAL::approx(e), CGAL::approx(ll))), EC(ec), lr(f, e), l(ll) + { + this->set_depth(1); // ??? Who cares + } +}; +template +struct Lazy_construction2, LK> { + static const bool Protection = true; + typedef Construct_ttag T; + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename LK::E2A E2A; + typedef typename Get_functor::type AC; + typedef typename Get_functor::type EC; + typedef typename map_result_tag::type result_tag; + typedef typename Get_type::type AT; + typedef typename Get_type::type ET; + typedef typename Get_type::type result_type; + // same as Handle = Lazy< AT, ET, E2A> + typedef typename Get_type::type FT; + + Lazy_construction2(){} + Lazy_construction2(LK const&k):ac(k.approximate_kernel()),ec(k.exact_kernel()){} + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; + + template + std::enable_if_t<(sizeof...(L)>0&&Constructible_from_each::value), result_type> operator()(L const&...l) const { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return new Lazy_rep_n(ac, ec, l...); + } catch (Uncertain_conversion_exception&) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return new Lazy_rep_0(ec(CGAL::exact(l)...)); + } + } + template + std::enable_if_t::value,result_type> operator()(int d, Iter const& f, Iter const& e) const { + typedef typename std::iterator_traits::value_type TT; + return new Lazy_rep_XXX(ac, ec, d, f, e); + } + template + std::enable_if_t::value,result_type> operator()(Iter const& f, Iter const& e, L const&l) const { + typedef typename std::iterator_traits::value_type TT; + return new Lazy_rep_YYY(ac, ec, f, e, l); + } + template + std::enable_if_t::value,result_type> operator()(Iter const& f, Iter const& e) const { + return operator()(std::distance(f, e), f, e); + } + // FIXME: this forces us to have default constructors for all types, try to make its instantiation lazier + result_type operator()() const + { + return new Lazy_rep_0(); + } +}; +#endif template struct Lazy_cartesian_types