From 7daca6fb9bd7d2e9f45d2f72a7a17975f9578c1a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 19 Sep 2012 14:37:44 +0000 Subject: [PATCH] More types and functors from the Kernel_d concept. --- .../CGAL/Kernel_d/Cartesian_complete.h | 3 ++ .../CGAL/Kernel_d/Kernel_d_interface.h | 33 ++++++------- .../include/CGAL/Kernel_d/Types/Iso_box.h | 48 +++++++++++++++++++ .../include/CGAL/Kernel_d/Types/Line.h | 45 +++++++++++++++++ NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h | 45 +++++++++++++++++ .../Kernel_d/function_objects_cartesian.h | 35 ++++++++++++++ .../include/CGAL/Kernel_d/interface_macros.h | 11 +++++ NewKernel_d/include/CGAL/functor_tags.h | 3 ++ 8 files changed, 207 insertions(+), 16 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Types/Line.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index a81f7ed3bca..c507f947aa9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -7,6 +7,9 @@ #include #include #include +#include +#include +#include #include #include #include diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 79d37647d65..8ba2c3bad8b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -21,11 +21,11 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::Segment Segment_d; typedef typename Base::Sphere Sphere_d; typedef typename Base::Hyperplane Hyperplane_d; - //typedef typename Base::Direction Direction_d; - //typedef typename Base::Line Line_d; - //typedef typename Base::Ray Ray_d; - //typedef typename Base::Iso_box Iso_box_d; - //typedef typename Base::Aff_transformation Aff_transformation_d; + typedef Vector_d Direction_d; + typedef typename Base::Line Line_d; + typedef typename Base::Ray Ray_d; + typedef typename Base::Iso_box Iso_box_d; + typedef typename Base::Aff_transformation Aff_transformation_d; typedef typename Base::template Functor::type Compute_coordinate_d; typedef typename Base::template Functor::type Compare_lexicographically_d; typedef typename Base::template Functor::type Equal_d; @@ -47,11 +47,11 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::template Functor >::type Construct_segment_d; typedef typename Base::template Functor >::type Construct_sphere_d; typedef typename Base::template Functor >::type Construct_hyperplane_d; - //typedef typename Base::template Functor >::type Construct_direction_d; - //typedef typename Base::template Functor >::type Construct_line_d; - //typedef typename Base::template Functor >::type Construct_ray_d; - //typedef typename Base::template Functor >::type Construct_iso_box_d; - //typedef typename Base::template Functor >::type Construct_aff_transformation_d; + typedef Construct_vector_d Construct_direction_d; + typedef typename Base::template Functor >::type Construct_line_d; + typedef typename Base::template Functor >::type Construct_ray_d; + typedef typename Base::template Functor >::type Construct_iso_box_d; + typedef typename Base::template Functor >::type Construct_aff_transformation_d; typedef typename Base::template Functor::type Midpoint_d; struct Component_accessor_d : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Component_accessor_d) @@ -114,7 +114,7 @@ template struct Kernel_d_interface : public Base_ { //typedef typename Base::template Functor::type Center_of_sphere_d; //typedef typename Base::template Functor::type Value_at_d; //typedef typename Base::template Functor::type Point_of_sphere_d; - //typedef typename Base::template Functor::type Orthogonal_vector_d; + typedef typename Base::template Functor::type Orthogonal_vector_d; //typedef typename Base::template Functor::type Linear_base_d; //typedef ??? Intersect_d; @@ -137,6 +137,7 @@ template struct Kernel_d_interface : public Base_ { 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); } 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_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); } @@ -144,11 +145,11 @@ template struct Kernel_d_interface : public Base_ { 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); } 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_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_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_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_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_aff_transformation_d construct_aff_transformation_d_object()const{ return Construct_aff_transformation_d(*this); } // Dummies for those required functors missing a concept. typedef Null_functor Position_on_line_d; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h new file mode 100644 index 00000000000..088b484ae8c --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h @@ -0,0 +1,48 @@ +#ifndef CGAL_KERNELD_TYPES_ISO_BOX_H +#define CGAL_KERNELD_TYPES_ISO_BOX_H +#include +#include +#include +#include +#include +namespace CGAL { +template class Iso_box { + typedef typename R_::FT FT_; + typedef typename R_::Point Point_; + typedef std::pair 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 struct Construct_iso_box : Store_kernel { + 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 >::type Cp_; + typedef typename R_::template Functor >::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()), + make_transforming_pair_iterator(ci(a,End_tag()), ci(b,End_tag()), Min())), + cp( + make_transforming_pair_iterator(ci(a,Begin_tag()), ci(b,Begin_tag()), Max()), + make_transforming_pair_iterator(ci(a,End_tag()), ci(b,End_tag()), Max()))); + } + }; +} + +} // namespace CGAL + +#endif // CGAL_KERNELD_TYPES_ISO_BOX_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h new file mode 100644 index 00000000000..bc1db94f166 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h @@ -0,0 +1,45 @@ +#ifndef CGAL_KERNELD_TYPES_LINE_H +#define CGAL_KERNELD_TYPES_LINE_H +#include +#include +#include +namespace CGAL { +template class Line { + typedef typename R_::FT FT_; + typedef typename R_::Point Point_; + typedef std::pair 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 struct Construct_line : Store_kernel { + 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::type Tp_; + //typedef typename R_::template Functor::type Dp_; + //typedef typename R_::template Functor::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::Type const&b)const{ + Tp_ tp(this->kernel()); + return result_type(a,tp(a,b)); + } + }; +} + +} // namespace CGAL + +#endif // CGAL_KERNELD_TYPES_LINE_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h new file mode 100644 index 00000000000..5987bcacf62 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h @@ -0,0 +1,45 @@ +#ifndef CGAL_KERNELD_TYPES_RAY_H +#define CGAL_KERNELD_TYPES_RAY_H +#include +#include +#include +namespace CGAL { +template class Ray { + typedef typename R_::FT FT_; + typedef typename R_::Point Point_; + typedef typename R_::Vector Vector_; + typedef std::pair 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 struct Construct_ray : Store_kernel { + 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::type Dp_; + //typedef typename R_::template Functor::type Tp_; + //typedef typename R_::template Functor::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::Type const&b)const{ + Dp_ dp(this->kernel()); + return result_type(a,dp(b,a)); + } + }; +} + +} // namespace CGAL + +#endif // CGAL_KERNELD_TYPES_RAY_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h index 73ca7d88fec..9f74ef63bd4 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -349,6 +349,22 @@ template struct Opposite_vector : private Store_kernel { } }; +template struct Scaled_vector : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Scaled_vector) + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Vector Vector; + typedef typename R::template Functor >::type CV; + typedef typename R::template Functor >::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(s)),make_transforming_iterator(ci(v,End_tag()),Scale(s))); + } +}; + template struct Sum_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Sum_of_vectors) typedef R_ R; @@ -381,6 +397,25 @@ template struct Difference_of_vectors : private Store_kernel { } }; +template struct Translated_point : private Store_kernel { + 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 >::type CP; + typedef typename R::template Functor >::type CVI; + typedef typename R::template Functor >::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()),make_transforming_pair_iterator(cpi(a,End_tag()),cvi(b,End_tag()),std::plus())); + } +}; + template struct Difference_of_points : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Difference_of_points) typedef R_ R; diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index b18e7c881d9..9c1b1668003 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -39,8 +39,11 @@ CGAL_Kernel_obj1(Vector,vector) CGAL_Kernel_obj1(Point,point) CGAL_Kernel_obj2(Segment,segment) CGAL_Kernel_obj2(Sphere,sphere) +CGAL_Kernel_obj3(Line,line) +CGAL_Kernel_obj3(Ray,ray) CGAL_Kernel_obj3(Hyperplane,hyperplane) CGAL_Kernel_obj3(Aff_transformation,aff_transformation) +CGAL_Kernel_obj3(Iso_box,iso_box) CGAL_Kernel_cons1(Construct_point_cartesian_const_iterator, construct_point_cartesian_const_iterator_object) @@ -50,8 +53,12 @@ CGAL_Kernel_cons2(Sum_of_vectors, sum_of_vectors_object) CGAL_Kernel_cons2(Difference_of_vectors, difference_of_vectors_object) +CGAL_Kernel_cons2(Translated_point, + translated_point_object) CGAL_Kernel_cons2(Opposite_vector, opposite_vector_object) +CGAL_Kernel_cons2(Scaled_vector, + scaled_vector_object) CGAL_Kernel_cons2(Difference_of_points, difference_of_points_object) CGAL_Kernel_cons2(Vector_to_point, @@ -60,6 +67,10 @@ CGAL_Kernel_cons2(Point_to_vector, point_to_vector_object) CGAL_Kernel_cons2(Midpoint, midpoint_object) +CGAL_Kernel_cons2(Orthogonal_vector, + orthogonal_vector_object) +CGAL_Kernel_cons2(Hyperplane_translation, + hyperplane_translation_object) //CGAL_Kernel_cons2(Construct_segment, // construct_segment_object) CGAL_Kernel_cons2(Segment_extremity, diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index b4525ea9b77..f5fc7fcbcbf 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -49,6 +49,7 @@ namespace CGAL { DECL_OBJ(Direction); DECL_OBJ(Hyperplane); DECL_OBJ(Ray); + DECL_OBJ(Iso_box); DECL_OBJ(Bbox); DECL_OBJ(Aff_transformation); #undef DECL_OBJ @@ -112,8 +113,10 @@ namespace CGAL { DECL_CONSTRUCT(Sum_of_vectors,Vector); DECL_CONSTRUCT(Difference_of_vectors,Vector); DECL_CONSTRUCT(Opposite_vector,Vector); + DECL_CONSTRUCT(Scaled_vector,Vector); DECL_CONSTRUCT(Orthogonal_vector,Vector); DECL_CONSTRUCT(Difference_of_points,Vector); + DECL_CONSTRUCT(Translated_point,Point); DECL_CONSTRUCT(Point_to_vector,Vector); DECL_CONSTRUCT(Vector_to_point,Point); #undef DECL_CONSTRUCT