From ece8478a904413a466a0bd90e8a4d7f4c33f8bc3 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 31 Dec 2020 16:23:31 +0100 Subject: [PATCH] static filter for 2d Side_of_oriented_sphere --- .../NewKernel_d/Cartesian_static_filters.h | 70 +++++++++++++------ 1 file changed, 49 insertions(+), 21 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h index 507e4144694..24b35fb4969 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h @@ -15,37 +15,46 @@ #include #include // bug, should be included by the next one #include +#include #include namespace CGAL { namespace SFA { // static filter adapter // Note that this would be quite a bit simpler without stateful kernels +template struct Adapter_2 { + typedef typename Get_type::type Point; + typedef typename Get_functor::type CC; + typedef typename Get_functor::type Orientation_base; + typedef typename Get_functor::type Side_of_oriented_circle_base; + struct Point_2 { + R_ const&r; CC const&c; Point const& p; + Point_2(R_ const&r_, CC const&c_, Point const&p_):r(r_),c(c_),p(p_){} + decltype(auto) x()const{return c(p,0);} + decltype(auto) y()const{return c(p,1);} + }; + struct Vector_2 {}; + struct Circle_2 {}; + struct Orientation_2 { + typedef typename Get_type::type result_type; + auto operator()(Point_2 const&A, Point_2 const&B, Point_2 const&C)const{ + Point const* t[3]={&A.p,&B.p,&C.p}; + return Orientation_base(A.r)(make_transforming_iterator(t+0),make_transforming_iterator(t+3)); + } + }; + struct Side_of_oriented_circle_2 { + typedef typename Get_type::type result_type; + auto operator()(Point_2 const&A, Point_2 const&B, Point_2 const&C, Point_2 const&D)const{ + Point const* t[3]={&A.p,&B.p,&C.p}; + return Side_of_oriented_circle_base(A.r)(make_transforming_iterator(t+0),make_transforming_iterator(t+3),D.p); + } + }; +}; template struct Orientation_of_points_2 : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_2) typedef typename Get_type::type Point; typedef typename Get_type::type result_type; - typedef typename Get_type::type FT; typedef typename Get_functor::type CC; - typedef typename Get_functor::type Orientation_base; - // TODO: Move this out for easy reuse - struct Adapter { - struct Point_2 { - R_ const&r; CC const&c; Point const& p; - Point_2(R_ const&r_, CC const&c_, Point const&p_):r(r_),c(c_),p(p_){} - // use result_of instead? - typename CC::result_type x()const{return c(p,0);} - typename CC::result_type y()const{return c(p,1);} - }; - struct Vector_2 {}; - struct Circle_2 {}; - struct Orientation_2 { - typedef typename Orientation_of_points_2::result_type result_type; - result_type operator()(Point_2 const&A, Point_2 const&B, Point_2 const&C)const{ - Point const* t[3]={&A.p,&B.p,&C.p}; - return Orientation_base(A.r)(make_transforming_iterator(t+0),make_transforming_iterator(t+3)); - } - }; - }; + typedef Adapter_2 Adapter; template result_type operator()(Iter f, Iter CGAL_assertion_code(e))const{ CC c(this->kernel()); Point const& A=*f; @@ -56,6 +65,22 @@ template struct Orientation_of_points_2 : private Store_k return typename internal::Static_filters_predicates::Orientation_2()(P(this->kernel(),c,A),P(this->kernel(),c,B),P(this->kernel(),c,C)); } }; +template struct Side_of_oriented_sphere_2 : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Side_of_oriented_sphere_2) + typedef typename Get_type::type Point; + typedef typename Get_type::type result_type; + typedef typename Get_functor::type CC; + typedef Adapter_2 Adapter; + template result_type operator()(Iter f, Iter CGAL_assertion_code(e), Point const& D)const{ + CC c(this->kernel()); + Point const& A=*f; + Point const& B=*++f; + Point const& C=*++f; + CGAL_assertion(++f==e); + typedef typename Adapter::Point_2 P; + return typename internal::Static_filters_predicates::Side_of_oriented_circle_2()(P(this->kernel(),c,A),P(this->kernel(),c,B),P(this->kernel(),c,C),P(this->kernel(),c,D)); + } +}; } template @@ -80,6 +105,9 @@ struct Cartesian_static_filters, R_, Derived_> : public R_ { // >::type type; }; + template struct Functor { + typedef SFA::Side_of_oriented_sphere_2 type; + }; }; }