diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h new file mode 100644 index 00000000000..fac83a43be0 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -0,0 +1,60 @@ +#ifndef CGAL_KD_CARTESIAN_STATIC_FILTERS_H +#define CGAL_KD_CARTESIAN_STATIC_FILTERS_H +#include +#include +#include // bug, should be included by the next one +#include + +namespace CGAL { +namespace SFA { // static filter adapter +// Note that this would be quite a bit simpler without stateful kernels +template struct Orientation_of_points_2 : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_2); + typedef typename R_::template Type::type Point; + typedef typename R_::Orientation result_type; + typedef typename R_::FT FT; + typedef typename R_::template Functor::type CC; + typedef typename R_::template 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_){} + FT x()const{return c(p,0);} + FT y()const{return c(p,1);} + }; + struct Vector_2 {}; + struct Circle_2 {}; + struct Orientation_2 { + typedef Orientation_of_points_2::result_type result_type; // really? + template result_type operator()(Point_2 const&A, Point_2 const&B, Point_2 const&C)const{ + Point_2 t[3]={&A.p,&B.p,&C.p}; + return Orientation_base(A.r)(t+0,t+3); + } + }; + }; + template result_type operator()(Iter f, Iter e)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::Orientation_2()(P(*this,c,A),P(*this,c,B),P(*this,c,C)); + } +}; +} + +template struct Cartesian_static_filters : public R_ {}; + +template struct Cartesian_static_filters, R_, Derived_> : public R_ { + //TODO: Functor<*,No_filter_tag> + template struct Functor : R_::template Functor {}; + template struct Functor { + typedef SFA::Orientation_of_points_2 type; + }; +}; + +} + +#endif diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index b9674c3c26b..b1cfa392581 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -13,6 +14,7 @@ typedef CGAL::Cartesian_base_d typedef CGAL::Cartesian_base_d > KE; struct RC: public +CGAL::Cartesian_static_filters, // Yes, it is silly to put it there. CGAL::Cartesian_complete_predicates< CGAL::Cartesian_complete_constructors< CGAL::Cartesian_complete_computes< @@ -23,6 +25,7 @@ CGAL::Cartesian_LA_base_d > >, false, RC >, false, RC >, false, RC +>, RC > { RC(){}