Add possibility to filter on kernels instead of number-types.

This commit is contained in:
Marc Glisse 2011-05-11 10:10:48 +00:00
parent 6eeb2259a4
commit b63f32ccdd
2 changed files with 37 additions and 9 deletions

View File

@ -12,35 +12,57 @@
namespace CGAL {
template<class K1, class K2> class CartesianD_converter {
typedef CartesianD_converter<K1,K2> Self;
typedef typename K1::FT FT1;
typedef typename K2::FT FT2;
typedef NT_converter<FT1, FT2> 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<class T,int i=0> struct result;
template<class T,int i> struct result<Self(T),i>{
//assert that T is an iterator, or better yet make sure
//we don't get here otherwise
#ifdef CGAL_CXX0X
static_assert(is_iterator<T>::value,"OUIN!");
#endif
typedef transforming_iterator<Self,T> type;
};
template<int i> struct result<Self(int),i>{typedef int type;};
template<int i> struct result<Self(Origin),i>{typedef Origin type;};
template<int i> struct result<Self(Null_vector),i>{typedef Null_vector type;};
template<int i> struct result<Self(Object),i>{typedef Object type;};
template<int i> struct result<Self(FT1),i>{typedef FT2 type;};
template<int i> struct result<Self(typename K1::Point),i>{typedef typename K2::Point type;};
template<int i> struct result<Self(typename First_if_different<typename K1::Vector,typename K1::Point>::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<RT1,FT1>::Type const&x)const{return cr(x);}
template<class It>
transforming_iterator<NTc,typename boost::enable_if<is_iterator<It>,It>::type>
transforming_iterator<Self,typename boost::enable_if<is_iterator<It>,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<Construct_cartesian_const_iterator_tag>::type i;
return K2::template Construct<Construct_point_tag>::type()(operator()(i.begin(p)),operator()(i.end(p)));
typename K2::template Construct<Construct_point_tag>::type cp;
return cp(operator()(i.begin(p)),operator()(i.end(p)));
}
typename K2::Vector operator()(typename First_if_different<typename K1::Vector,typename K1::Point>::Type const& p){
typename K2::Vector operator()(typename First_if_different<typename K1::Vector,typename K1::Point>::Type const& p)const{
typename K1::template Construct<Construct_cartesian_const_iterator_tag>::type i;
return K2::template Construct<Construct_vector_tag>::type()(operator()(i.begin(p)),operator()(i.end(p)));
typename K2::template Construct<Construct_vector_tag>::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<typename K1::X>(&obj)) \

View File

@ -2,12 +2,18 @@
#include <CGAL/myeigen.h>
#include <CGAL/Kernel_d/Cartesian_base.h>
#include <CGAL/Kernel_d/Cartesian_filter_NT.h>
#include <CGAL/Kernel_d/Cartesian_filter_K.h>
#include <CGAL/Gmpq.h>
#include <CGAL/Interval_nt.h>
#include <iostream>
typedef CGAL::Cartesian_base_d<double,CGAL::Dimension_tag<2> > K0;
#if 0
typedef CGAL::Cartesian_filter_NT<K0> K1;
//typedef CGAL::Cartesian_change_FT<K0,double> K1;
#elif 1
typedef CGAL::Cartesian_base_d<CGAL::Interval_nt_advanced,CGAL::Dimension_tag<2> > KA;
typedef CGAL::Cartesian_base_d<CGAL::Gmpq,CGAL::Dimension_tag<2> > KE;
typedef CGAL::Cartesian_filter_K<K0,KA,KE> K1;
#endif
typedef K1::Point P;
typedef K1::Vector V;
typedef K1::Segment S;