mirror of https://github.com/CGAL/cgal
Let us override default predicates for specific dimensions.
This commit is contained in:
parent
58ebdbac51
commit
38f2c13c86
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef CGAL_KD_CARTESIAN_2_H
|
||||
#define CGAL_KD_CARTESIAN_2_H
|
||||
#include <CGAL/functor_tags.h>
|
||||
#include <CGAL/predicates/sign_of_determinant.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace CartesianDKernelFunctors {
|
||||
template <class R_>
|
||||
struct Orientation_of_points_2 : private Store_kernel<R_> {
|
||||
CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_2);
|
||||
typedef typename R_::template Type<Point_tag>::type Point;
|
||||
typedef typename R_::Orientation result_type;
|
||||
typedef typename R_::FT FT;
|
||||
template<class Iter>
|
||||
result_type operator()(Iter f, Iter e)const{
|
||||
typename R_::template Functor<Compute_cartesian_coordinate_tag>::type c(this->kernel());
|
||||
Point const&A=*f;
|
||||
FT const& ax=c(A,0);
|
||||
FT const& ay=c(A,1);
|
||||
Point const&B=*++f;
|
||||
Point const&C=*++f;
|
||||
CGAL_assertion(++f==e);
|
||||
return sign_of_determinant(c(B,0)-ax,c(B,1)-ay,c(C,0)-ax,c(C,1)-ay);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <CGAL/Kernel_d/function_objects_cartesian.h>
|
||||
#include <CGAL/Kernel_d/Segmentd.h>
|
||||
#include <CGAL/Kernel_d/Cartesian_per_dimension.h>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
|
|
@ -16,7 +17,7 @@ BOOST_MPL_HAS_XXX_TRAIT_DEF(Direction)
|
|||
BOOST_MPL_HAS_XXX_TRAIT_DEF(Line)
|
||||
}
|
||||
|
||||
template<class R_,class Derived_> struct Cartesian_define_all_functors
|
||||
template<class R_,class Derived_> struct Cartesian_define_all_functors_
|
||||
: public R_
|
||||
{
|
||||
typedef R_ Kernel_base;
|
||||
|
|
@ -39,6 +40,9 @@ template<class R_,class Derived_> struct Cartesian_define_all_functors
|
|||
|
||||
};
|
||||
|
||||
template<class R_,class Derived_> struct Cartesian_define_all_functors
|
||||
: public Cartesian_per_dimension<typename R_::Default_ambient_dimension,Cartesian_define_all_functors_<R_,Derived_>,Derived_> {};
|
||||
|
||||
template<class R_,bool force_=false> struct Cartesian_complete_types
|
||||
: public R_
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef CGAL_KD_CARTESIAN_PER_DIM_H
|
||||
#define CGAL_KD_CARTESIAN_PER_DIM_H
|
||||
#include <CGAL/functor_tags.h>
|
||||
#include <CGAL/Dimension.h>
|
||||
#include <CGAL/predicates/sign_of_determinant.h>
|
||||
#include <CGAL/Kernel_d/Cartesian_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
template <class Dim_, class R_, class Derived_>
|
||||
struct Cartesian_per_dimension : public R_ {};
|
||||
|
||||
// TODO: we want to put the actual functors in some other file. Maybe name the
|
||||
// classes Orientation_2 to make it easy to typedef them all.
|
||||
template <class R_, class Derived_>
|
||||
struct Cartesian_per_dimension<Dimension_tag<2>,R_,Derived_> : public R_ {
|
||||
typedef R_ Kernel_base;
|
||||
template<class F, class D=void> struct Functor
|
||||
: Kernel_base::template Functor<F,D>
|
||||
{ };
|
||||
|
||||
#define CGAL_override_in_dim2(X) \
|
||||
template<class D> struct Functor<X##_tag,D> { \
|
||||
typedef CartesianDKernelFunctors::X##_2<Derived_> type; \
|
||||
}
|
||||
CGAL_override_in_dim2(Orientation_of_points);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue