More types and functors from the Kernel_d concept.

This commit is contained in:
Marc Glisse 2012-09-19 14:37:44 +00:00
parent 879d16096e
commit 7daca6fb9b
8 changed files with 207 additions and 16 deletions

View File

@ -7,6 +7,9 @@
#include <CGAL/Kernel_d/Types/Sphere.h> #include <CGAL/Kernel_d/Types/Sphere.h>
#include <CGAL/Kernel_d/Types/Hyperplane.h> #include <CGAL/Kernel_d/Types/Hyperplane.h>
#include <CGAL/Kernel_d/Types/Aff_transformation.h> #include <CGAL/Kernel_d/Types/Aff_transformation.h>
#include <CGAL/Kernel_d/Types/Line.h>
#include <CGAL/Kernel_d/Types/Ray.h>
#include <CGAL/Kernel_d/Types/Iso_box.h>
#include <boost/mpl/if.hpp> #include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp> #include <boost/type_traits/is_same.hpp>
#include <boost/mpl/has_xxx.hpp> #include <boost/mpl/has_xxx.hpp>

View File

@ -21,11 +21,11 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
typedef typename Base::Segment Segment_d; typedef typename Base::Segment Segment_d;
typedef typename Base::Sphere Sphere_d; typedef typename Base::Sphere Sphere_d;
typedef typename Base::Hyperplane Hyperplane_d; typedef typename Base::Hyperplane Hyperplane_d;
//typedef typename Base::Direction Direction_d; typedef Vector_d Direction_d;
//typedef typename Base::Line Line_d; typedef typename Base::Line Line_d;
//typedef typename Base::Ray Ray_d; typedef typename Base::Ray Ray_d;
//typedef typename Base::Iso_box Iso_box_d; typedef typename Base::Iso_box Iso_box_d;
//typedef typename Base::Aff_transformation Aff_transformation_d; typedef typename Base::Aff_transformation Aff_transformation_d;
typedef typename Base::template Functor<Compute_point_cartesian_coordinate_tag>::type Compute_coordinate_d; typedef typename Base::template Functor<Compute_point_cartesian_coordinate_tag>::type Compute_coordinate_d;
typedef typename Base::template Functor<Compare_lexicographically_tag>::type Compare_lexicographically_d; typedef typename Base::template Functor<Compare_lexicographically_tag>::type Compare_lexicographically_d;
typedef typename Base::template Functor<Equal_points_tag>::type Equal_d; typedef typename Base::template Functor<Equal_points_tag>::type Equal_d;
@ -47,11 +47,11 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
typedef typename Base::template Functor<Construct_ttag<Segment_tag> >::type Construct_segment_d; typedef typename Base::template Functor<Construct_ttag<Segment_tag> >::type Construct_segment_d;
typedef typename Base::template Functor<Construct_ttag<Sphere_tag> >::type Construct_sphere_d; typedef typename Base::template Functor<Construct_ttag<Sphere_tag> >::type Construct_sphere_d;
typedef typename Base::template Functor<Construct_ttag<Hyperplane_tag> >::type Construct_hyperplane_d; typedef typename Base::template Functor<Construct_ttag<Hyperplane_tag> >::type Construct_hyperplane_d;
//typedef typename Base::template Functor<Construct_ttag<Direction_tag> >::type Construct_direction_d; typedef Construct_vector_d Construct_direction_d;
//typedef typename Base::template Functor<Construct_ttag<Line_tag> >::type Construct_line_d; typedef typename Base::template Functor<Construct_ttag<Line_tag> >::type Construct_line_d;
//typedef typename Base::template Functor<Construct_ttag<Ray_tag> >::type Construct_ray_d; typedef typename Base::template Functor<Construct_ttag<Ray_tag> >::type Construct_ray_d;
//typedef typename Base::template Functor<Construct_ttag<Iso_box_tag> >::type Construct_iso_box_d; typedef typename Base::template Functor<Construct_ttag<Iso_box_tag> >::type Construct_iso_box_d;
//typedef typename Base::template Functor<Construct_ttag<Aff_transformation_tag> >::type Construct_aff_transformation_d; typedef typename Base::template Functor<Construct_ttag<Aff_transformation_tag> >::type Construct_aff_transformation_d;
typedef typename Base::template Functor<Midpoint_tag>::type Midpoint_d; typedef typename Base::template Functor<Midpoint_tag>::type Midpoint_d;
struct Component_accessor_d : private Store_kernel<R_> { struct Component_accessor_d : private Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(Component_accessor_d) CGAL_FUNCTOR_INIT_STORE(Component_accessor_d)
@ -114,7 +114,7 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
//typedef typename Base::template Functor<Center_of_sphere_tag>::type Center_of_sphere_d; //typedef typename Base::template Functor<Center_of_sphere_tag>::type Center_of_sphere_d;
//typedef typename Base::template Functor<Value_at_tag>::type Value_at_d; //typedef typename Base::template Functor<Value_at_tag>::type Value_at_d;
//typedef typename Base::template Functor<Point_of_sphere_tag>::type Point_of_sphere_d; //typedef typename Base::template Functor<Point_of_sphere_tag>::type Point_of_sphere_d;
//typedef typename Base::template Functor<Orthogonal_vector_tag>::type Orthogonal_vector_d; typedef typename Base::template Functor<Orthogonal_vector_tag>::type Orthogonal_vector_d;
//typedef typename Base::template Functor<Linear_base_tag>::type Linear_base_d; //typedef typename Base::template Functor<Linear_base_tag>::type Linear_base_d;
//typedef ??? Intersect_d; //typedef ??? Intersect_d;
@ -137,6 +137,7 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
Vector_to_point_d vector_to_point_d_object()const{ return Vector_to_point_d(*this); } Vector_to_point_d vector_to_point_d_object()const{ return Vector_to_point_d(*this); }
Midpoint_d midpoint_d_object()const{ return Midpoint_d(*this); } Midpoint_d midpoint_d_object()const{ return Midpoint_d(*this); }
Component_accessor_d component_accessor_d_object()const{ return Component_accessor_d(*this); } Component_accessor_d component_accessor_d_object()const{ return Component_accessor_d(*this); }
Orthogonal_vector_d orthogonal_vector_d_object()const{ return Orthogonal_vector_d(*this); }
Construct_cartesian_const_iterator_d construct_cartesian_const_iterator_d_object()const{ return Construct_cartesian_const_iterator_d(*this); } Construct_cartesian_const_iterator_d construct_cartesian_const_iterator_d_object()const{ return Construct_cartesian_const_iterator_d(*this); }
Construct_point_d construct_point_d_object()const{ return Construct_point_d(*this); } Construct_point_d construct_point_d_object()const{ return Construct_point_d(*this); }
Construct_vector_d construct_vector_d_object()const{ return Construct_vector_d(*this); } Construct_vector_d construct_vector_d_object()const{ return Construct_vector_d(*this); }
@ -144,11 +145,11 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
Construct_sphere_d construct_sphere_d_object()const{ return Construct_sphere_d(*this); } Construct_sphere_d construct_sphere_d_object()const{ return Construct_sphere_d(*this); }
Construct_hyperplane_d construct_hyperplane_d_object()const{ return Construct_hyperplane_d(*this); } Construct_hyperplane_d construct_hyperplane_d_object()const{ return Construct_hyperplane_d(*this); }
Squared_distance_d squared_distance_d_object()const{ return Squared_distance_d(*this); } Squared_distance_d squared_distance_d_object()const{ return Squared_distance_d(*this); }
//Construct_direction_d construct_direction_d_object()const{ return Construct_direction_d(*this); } Construct_direction_d construct_direction_d_object()const{ return Construct_direction_d(*this); }
//Construct_line_d construct_line_d_object()const{ return Construct_line_d(*this); } Construct_line_d construct_line_d_object()const{ return Construct_line_d(*this); }
//Construct_ray_d construct_ray_d_object()const{ return Construct_ray_d(*this); } Construct_ray_d construct_ray_d_object()const{ return Construct_ray_d(*this); }
//Construct_iso_box_d construct_iso_box_d_object()const{ return Construct_iso_box_d(*this); } Construct_iso_box_d construct_iso_box_d_object()const{ return Construct_iso_box_d(*this); }
//Construct_aff_transformation_d construct_aff_transformation_d_object()const{ return Construct_aff_transformation_d(*this); } Construct_aff_transformation_d construct_aff_transformation_d_object()const{ return Construct_aff_transformation_d(*this); }
// Dummies for those required functors missing a concept. // Dummies for those required functors missing a concept.
typedef Null_functor Position_on_line_d; typedef Null_functor Position_on_line_d;

View File

@ -0,0 +1,48 @@
#ifndef CGAL_KERNELD_TYPES_ISO_BOX_H
#define CGAL_KERNELD_TYPES_ISO_BOX_H
#include <utility>
#include <CGAL/basic.h>
#include <CGAL/functor_tags.h>
#include <CGAL/Kernel/mpl.h>
#include <CGAL/transforming_pair_iterator.h>
namespace CGAL {
template <class R_> class Iso_box {
typedef typename R_::FT FT_;
typedef typename R_::Point Point_;
typedef std::pair<Point_,Point_> Data_;
Data_ data;
public:
Iso_box(){}
Iso_box(Point_ const&a, Point_ const&b): data(a,b) {}
Point_ min()const{
return data.first;
}
Point_ max()const{
return data.second;
}
};
namespace CartesianDKernelFunctors {
template <class R_> struct Construct_iso_box : Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(Construct_iso_box)
typedef typename R_::Iso_box result_type;
typedef typename R_::RT RT;
typedef typename R_::Point Point;
typedef typename R_::Vector Vector;
typedef typename R_::template Functor<Construct_ttag<Point_tag> >::type Cp_;
typedef typename R_::template Functor<Construct_ttag<Point_cartesian_const_iterator_tag> >::type Ci_;
result_type operator()(Point const&a, Point const&b)const{
Cp_ cp(this->kernel());
Ci_ ci(this->kernel());
return result_type(cp(
make_transforming_pair_iterator(ci(a,Begin_tag()), ci(b,Begin_tag()), Min<RT>()),
make_transforming_pair_iterator(ci(a,End_tag()), ci(b,End_tag()), Min<RT>())),
cp(
make_transforming_pair_iterator(ci(a,Begin_tag()), ci(b,Begin_tag()), Max<RT>()),
make_transforming_pair_iterator(ci(a,End_tag()), ci(b,End_tag()), Max<RT>())));
}
};
}
} // namespace CGAL
#endif // CGAL_KERNELD_TYPES_ISO_BOX_H

View File

@ -0,0 +1,45 @@
#ifndef CGAL_KERNELD_TYPES_LINE_H
#define CGAL_KERNELD_TYPES_LINE_H
#include <utility>
#include <CGAL/functor_tags.h>
#include <CGAL/Kernel/mpl.h>
namespace CGAL {
template <class R_> class Line {
typedef typename R_::FT FT_;
typedef typename R_::Point Point_;
typedef std::pair<Point_,Point_> Data_;
Data_ data;
public:
Line(){}
Line(Point_ const&a, Point_ const&b): data(a,b) {}
Point_ point(int i)const{
if(i==0) return data.first;
if(i==1) return data.second;
throw "not implemented";
}
Line opposite()const{
return Line(data.second,data.first);
}
};
namespace CartesianDKernelFunctors {
template <class R_> struct Construct_line : Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(Construct_line)
typedef typename R_::Line result_type;
typedef typename R_::Point Point;
typedef typename R_::Vector Vector;
typedef typename R_::template Functor<Translated_point_tag>::type Tp_;
//typedef typename R_::template Functor<Difference_of_points_tag>::type Dp_;
//typedef typename R_::template Functor<Scaled_vector_tag>::type Sv_;
result_type operator()(Point const&a, Point const&b)const{
return result_type(a,b);
}
result_type operator()(Point const&a, typename First_if_different<Vector,Point>::Type const&b)const{
Tp_ tp(this->kernel());
return result_type(a,tp(a,b));
}
};
}
} // namespace CGAL
#endif // CGAL_KERNELD_TYPES_LINE_H

View File

@ -0,0 +1,45 @@
#ifndef CGAL_KERNELD_TYPES_RAY_H
#define CGAL_KERNELD_TYPES_RAY_H
#include <utility>
#include <CGAL/functor_tags.h>
#include <CGAL/Kernel/mpl.h>
namespace CGAL {
template <class R_> class Ray {
typedef typename R_::FT FT_;
typedef typename R_::Point Point_;
typedef typename R_::Vector Vector_;
typedef std::pair<Point_,Vector_> Data_;
Data_ data;
public:
Ray(){}
Ray(Point_ const&a, Vector_ const&b): data(a,b) {}
Point_ source()const{
return data.first;
}
// FIXME: return a R_::Direction?
Vector_ direction()const{
return data.second;
}
};
namespace CartesianDKernelFunctors {
template <class R_> struct Construct_ray : Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(Construct_ray)
typedef typename R_::Ray result_type;
typedef typename R_::Point Point;
typedef typename R_::Vector Vector;
typedef typename R_::template Functor<Difference_of_points_tag>::type Dp_;
//typedef typename R_::template Functor<Translated_point_tag>::type Tp_;
//typedef typename R_::template Functor<Scaled_vector_tag>::type Sv_;
result_type operator()(Point const&a, Vector const&b)const{
return result_type(a,b);
}
result_type operator()(Point const&a, typename First_if_different<Point,Vector>::Type const&b)const{
Dp_ dp(this->kernel());
return result_type(a,dp(b,a));
}
};
}
} // namespace CGAL
#endif // CGAL_KERNELD_TYPES_RAY_H

View File

@ -349,6 +349,22 @@ template<class R_> struct Opposite_vector : private Store_kernel<R_> {
} }
}; };
template<class R_> struct Scaled_vector : private Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(Scaled_vector)
typedef R_ R;
typedef typename R_::FT FT;
typedef typename R::Vector Vector;
typedef typename R::template Functor<Construct_ttag<Vector_tag> >::type CV;
typedef typename R::template Functor<Construct_ttag<Vector_cartesian_const_iterator_tag> >::type CI;
typedef Vector result_type;
typedef Vector first_argument_type;
typedef FT second_argument_type;
result_type operator()(Vector const&v,FT const& s)const{
CI ci(this->kernel());
return CV(this->kernel())(make_transforming_iterator(ci(v,Begin_tag()),Scale<FT>(s)),make_transforming_iterator(ci(v,End_tag()),Scale<FT>(s)));
}
};
template<class R_> struct Sum_of_vectors : private Store_kernel<R_> { template<class R_> struct Sum_of_vectors : private Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(Sum_of_vectors) CGAL_FUNCTOR_INIT_STORE(Sum_of_vectors)
typedef R_ R; typedef R_ R;
@ -381,6 +397,25 @@ template<class R_> struct Difference_of_vectors : private Store_kernel<R_> {
} }
}; };
template<class R_> struct Translated_point : private Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(Translated_point)
typedef R_ R;
typedef typename R_::RT RT;
typedef typename R::Vector Vector;
typedef typename R::Point Point;
typedef typename R::template Functor<Construct_ttag<Point_tag> >::type CP;
typedef typename R::template Functor<Construct_ttag<Vector_cartesian_const_iterator_tag> >::type CVI;
typedef typename R::template Functor<Construct_ttag<Point_cartesian_const_iterator_tag> >::type CPI;
typedef Point result_type;
typedef Point first_argument_type;
typedef Vector second_argument_type;
result_type operator()(Point const&a, Vector const&b)const{
CVI cvi(this->kernel());
CPI cpi(this->kernel());
return CP(this->kernel())(make_transforming_pair_iterator(cpi(a,Begin_tag()),cvi(b,Begin_tag()),std::plus<RT>()),make_transforming_pair_iterator(cpi(a,End_tag()),cvi(b,End_tag()),std::plus<RT>()));
}
};
template<class R_> struct Difference_of_points : private Store_kernel<R_> { template<class R_> struct Difference_of_points : private Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(Difference_of_points) CGAL_FUNCTOR_INIT_STORE(Difference_of_points)
typedef R_ R; typedef R_ R;

View File

@ -39,8 +39,11 @@ CGAL_Kernel_obj1(Vector,vector)
CGAL_Kernel_obj1(Point,point) CGAL_Kernel_obj1(Point,point)
CGAL_Kernel_obj2(Segment,segment) CGAL_Kernel_obj2(Segment,segment)
CGAL_Kernel_obj2(Sphere,sphere) CGAL_Kernel_obj2(Sphere,sphere)
CGAL_Kernel_obj3(Line,line)
CGAL_Kernel_obj3(Ray,ray)
CGAL_Kernel_obj3(Hyperplane,hyperplane) CGAL_Kernel_obj3(Hyperplane,hyperplane)
CGAL_Kernel_obj3(Aff_transformation,aff_transformation) CGAL_Kernel_obj3(Aff_transformation,aff_transformation)
CGAL_Kernel_obj3(Iso_box,iso_box)
CGAL_Kernel_cons1(Construct_point_cartesian_const_iterator, CGAL_Kernel_cons1(Construct_point_cartesian_const_iterator,
construct_point_cartesian_const_iterator_object) construct_point_cartesian_const_iterator_object)
@ -50,8 +53,12 @@ CGAL_Kernel_cons2(Sum_of_vectors,
sum_of_vectors_object) sum_of_vectors_object)
CGAL_Kernel_cons2(Difference_of_vectors, CGAL_Kernel_cons2(Difference_of_vectors,
difference_of_vectors_object) difference_of_vectors_object)
CGAL_Kernel_cons2(Translated_point,
translated_point_object)
CGAL_Kernel_cons2(Opposite_vector, CGAL_Kernel_cons2(Opposite_vector,
opposite_vector_object) opposite_vector_object)
CGAL_Kernel_cons2(Scaled_vector,
scaled_vector_object)
CGAL_Kernel_cons2(Difference_of_points, CGAL_Kernel_cons2(Difference_of_points,
difference_of_points_object) difference_of_points_object)
CGAL_Kernel_cons2(Vector_to_point, CGAL_Kernel_cons2(Vector_to_point,
@ -60,6 +67,10 @@ CGAL_Kernel_cons2(Point_to_vector,
point_to_vector_object) point_to_vector_object)
CGAL_Kernel_cons2(Midpoint, CGAL_Kernel_cons2(Midpoint,
midpoint_object) midpoint_object)
CGAL_Kernel_cons2(Orthogonal_vector,
orthogonal_vector_object)
CGAL_Kernel_cons2(Hyperplane_translation,
hyperplane_translation_object)
//CGAL_Kernel_cons2(Construct_segment, //CGAL_Kernel_cons2(Construct_segment,
// construct_segment_object) // construct_segment_object)
CGAL_Kernel_cons2(Segment_extremity, CGAL_Kernel_cons2(Segment_extremity,

View File

@ -49,6 +49,7 @@ namespace CGAL {
DECL_OBJ(Direction); DECL_OBJ(Direction);
DECL_OBJ(Hyperplane); DECL_OBJ(Hyperplane);
DECL_OBJ(Ray); DECL_OBJ(Ray);
DECL_OBJ(Iso_box);
DECL_OBJ(Bbox); DECL_OBJ(Bbox);
DECL_OBJ(Aff_transformation); DECL_OBJ(Aff_transformation);
#undef DECL_OBJ #undef DECL_OBJ
@ -112,8 +113,10 @@ namespace CGAL {
DECL_CONSTRUCT(Sum_of_vectors,Vector); DECL_CONSTRUCT(Sum_of_vectors,Vector);
DECL_CONSTRUCT(Difference_of_vectors,Vector); DECL_CONSTRUCT(Difference_of_vectors,Vector);
DECL_CONSTRUCT(Opposite_vector,Vector); DECL_CONSTRUCT(Opposite_vector,Vector);
DECL_CONSTRUCT(Scaled_vector,Vector);
DECL_CONSTRUCT(Orthogonal_vector,Vector); DECL_CONSTRUCT(Orthogonal_vector,Vector);
DECL_CONSTRUCT(Difference_of_points,Vector); DECL_CONSTRUCT(Difference_of_points,Vector);
DECL_CONSTRUCT(Translated_point,Point);
DECL_CONSTRUCT(Point_to_vector,Vector); DECL_CONSTRUCT(Point_to_vector,Vector);
DECL_CONSTRUCT(Vector_to_point,Point); DECL_CONSTRUCT(Vector_to_point,Point);
#undef DECL_CONSTRUCT #undef DECL_CONSTRUCT