From b63f32ccdd753195e15f88ccc766e18203dbfdf0 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 11 May 2011 10:10:48 +0000 Subject: [PATCH] Add possibility to filter on kernels instead of number-types. --- .../CGAL/Kernel_d/Cartesian_converter.h | 38 +++++++++++++++---- NewKernel_d/test/NewKernel_d/test.cpp | 8 +++- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h index a9c2948f240..26a1013005e 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h @@ -12,35 +12,57 @@ namespace CGAL { template class CartesianD_converter { + typedef CartesianD_converter Self; typedef typename K1::FT FT1; typedef typename K2::FT FT2; typedef NT_converter NTc; NTc c; // TODO: store a K1 and a K2 and have a suitable constructor public: + // For boost::result_of, used in transforming_iterator + template struct result; + template struct result{ + //assert that T is an iterator, or better yet make sure + //we don't get here otherwise +#ifdef CGAL_CXX0X + static_assert(is_iterator::value,"OUIN!"); +#endif + typedef transforming_iterator type; + }; + template struct result{typedef int type;}; + template struct result{typedef Origin type;}; + template struct result{typedef Null_vector type;}; + template struct result{typedef Object type;}; + template struct result{typedef FT2 type;}; + template struct result{typedef typename K2::Point type;}; + template struct result::Type),i>{typedef typename K2::Vector type;}; + + int operator()(int i)const{return i;} Origin operator()(Origin const&o)const{return o;} Null_vector operator()(Null_vector const&v)const{return v;} FT2 operator()(FT1 const&x)const{return c(x);} //RT2 operator()(typename First_if_different::Type const&x)const{return cr(x);} template - transforming_iterator,It>::type> + transforming_iterator,It>::type> operator()(It const& it)const { - return make_transforming_iterator(it,c); + return make_transforming_iterator(it,*this); } - typename K2::Point operator()(typename K1::Point const& p){ + typename K2::Point operator()(typename K1::Point const& p)const{ typename K1::template Construct::type i; - return K2::template Construct::type()(operator()(i.begin(p)),operator()(i.end(p))); + typename K2::template Construct::type cp; + return cp(operator()(i.begin(p)),operator()(i.end(p))); } - typename K2::Vector operator()(typename First_if_different::Type const& p){ + typename K2::Vector operator()(typename First_if_different::Type const& p)const{ typename K1::template Construct::type i; - return K2::template Construct::type()(operator()(i.begin(p)),operator()(i.end(p))); + typename K2::template Construct::type cv; + return cv(operator()(i.begin(p)),operator()(i.end(p))); } - typename K2::Object_2 - operator()(const typename K1::Object_2 &obj) const + Object + operator()(const Object &obj) const { #define CGAL_Kernel_obj(X) \ if (const typename K1::X * ptr = object_cast(&obj)) \ diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index db0d696196d..763f75b5dbe 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -2,12 +2,18 @@ #include #include #include +#include #include #include #include typedef CGAL::Cartesian_base_d > K0; +#if 0 typedef CGAL::Cartesian_filter_NT K1; -//typedef CGAL::Cartesian_change_FT K1; +#elif 1 +typedef CGAL::Cartesian_base_d > KA; +typedef CGAL::Cartesian_base_d > KE; +typedef CGAL::Cartesian_filter_K K1; +#endif typedef K1::Point P; typedef K1::Vector V; typedef K1::Segment S;