From 9d4d5e6e7d8fb8d72a49e26f34726acc0a7adeb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Fri, 7 Dec 2012 18:00:30 +0100 Subject: [PATCH] Replace Intersection_traits with result_of --- .../CGAL/Circular_kernel_3/Circular_arc_3.h | 4 +- .../Circular_kernel_3/Circular_arc_point_3.h | 6 +- .../CGAL/Circular_kernel_3/Line_arc_3.h | 6 +- .../function_objects_polynomial_sphere.h | 38 ++++++------ .../internal_functions_on_circle_3.h | 3 +- .../internal_functions_on_circular_arc_3.h | 61 ++++++++++++------- .../internal_functions_on_line_arc_3.h | 25 ++++---- 7 files changed, 83 insertions(+), 60 deletions(-) diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circular_arc_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circular_arc_3.h index 415b5e116c8..bdb79d02906 100644 --- a/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circular_arc_3.h +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circular_arc_3.h @@ -164,7 +164,7 @@ namespace CGAL { const Sphere_3 &s1, bool less_xyz_s1, const Sphere_3 &s2, bool less_xyz_s2) { - typedef typename Intersection_traits::result_type result_type; + typedef typename boost::result_of::type result_type; std::vector sols1, sols2; // The spheres must not include the circle CGAL_kernel_precondition(!SK().has_on_3_object()(s1,c)); @@ -191,7 +191,7 @@ namespace CGAL { const Plane_3 &p1, bool less_xyz_p1, const Plane_3 &p2, bool less_xyz_p2) { - typedef typename Intersection_traits::result_type result_type; + typedef typename boost::result_of::type result_type; std::vector sols1, sols2; // The planes must not include the circle CGAL_kernel_precondition(!SK().has_on_3_object()(p1,c)); diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circular_arc_point_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circular_arc_point_3.h index 84dc163dac4..eb6c36e3252 100644 --- a/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circular_arc_point_3.h +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circular_arc_point_3.h @@ -142,7 +142,7 @@ public: Circular_arc_point_3(const Line_3 &l, const Sphere_3 &s, const bool less_xyz = true) { - std::vector::result_type> sols; + std::vector::type> sols; SK().intersect_3_object()(l, s, std::back_inserter(sols)); // s1,s2,s3 must intersect CGAL_kernel_precondition(sols.size() != 0); @@ -164,7 +164,7 @@ public: Circular_arc_point_3(const Circle_3 &c, const Plane_3 &p, const bool less_xyz = true) { - std::vector::result_type> sols; + std::vector::type> sols; SK().intersect_3_object()(c, p, std::back_inserter(sols)); // s1,s2,s3 must intersect CGAL_kernel_precondition(sols.size() != 0); @@ -186,7 +186,7 @@ public: Circular_arc_point_3(const Circle_3 &c, const Sphere_3 &s, const bool less_xyz = true) { - std::vector::result_type> sols; + std::vector::type> sols; SK().intersect_3_object()(c, s, std::back_inserter(sols)); // s1,s2,s3 must intersect CGAL_kernel_precondition(sols.size() != 0); diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/Line_arc_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/Line_arc_3.h index 62e975bd728..e5bd52e8222 100644 --- a/Circular_kernel_3/include/CGAL/Circular_kernel_3/Line_arc_3.h +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/Line_arc_3.h @@ -93,7 +93,7 @@ namespace CGAL { const Sphere_3 &s, bool less_xyz_first = true) { - std::vector::result_type> sols; + std::vector::type> sols; SK().intersect_3_object()(l, s, std::back_inserter(sols)); // l must intersect s in 2 points CGAL_kernel_precondition(sols.size() == 2); @@ -112,7 +112,7 @@ namespace CGAL { const Sphere_3 &s1, bool less_xyz_s1, const Sphere_3 &s2, bool less_xyz_s2) { - std::vector::result_type> sols1, sols2; + std::vector::type> sols1, sols2; SK().intersect_3_object()(l, s1, std::back_inserter(sols1)); SK().intersect_3_object()(l, s2, std::back_inserter(sols2)); // l must intersect s1 and s2 @@ -135,7 +135,7 @@ namespace CGAL { CGAL_kernel_precondition(!SK().has_on_3_object()(p1,l)); CGAL_kernel_precondition(!SK().has_on_3_object()(p2,l)); // l must intersect p1 and p2 - typedef typename Intersection_traits::result_type Intersection; + typedef typename boost::result_of::type Intersection; Intersection i1 = SK().intersect_3_object()(l, p1); Intersection i2 = SK().intersect_3_object()(l, p2); const typename SK::Point_3* point1=boost::get( & *i1 ); diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h index 2de2853257d..8c82fe58e49 100644 --- a/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h @@ -1105,19 +1105,19 @@ template < class SK > \ using SK::Linear_kernel::Do_intersect_3::operator(); -#define CGAL_SPHERICAL_KERNEL_MACRO_DO_INTERSECTION_3_2(A,B) \ - result_type \ - operator()(const A & c1, const B & c2) const \ - { std::vector< typename Intersection_traits::result_type > res; \ - typename SK::Intersect_3()(c1,c2,std::back_inserter(res)); \ - return res.size() != 0; } +#define CGAL_SPHERICAL_KERNEL_MACRO_DO_INTERSECTION_3_2(A,B) \ + result_type \ + operator()(const A & c1, const B & c2) const \ + { std::vector< typename boost::result_of::type > res; \ + typename SK::Intersect_3()(c1,c2,std::back_inserter(res)); \ + return !res.empty(); } -#define CGAL_SPHERICAL_KERNEL_MACRO_DO_INTERSECTION_3_3(A,B,C) \ - result_type \ - operator()(const A & c1, const B & c2, const C & c3) const \ - { std::vector< typename ITs::result_type > res; \ - typename SK::Intersect_3()(c1,c2,c3,std::back_inserter(res)); \ - return res.size() != 0; } +#define CGAL_SPHERICAL_KERNEL_MACRO_DO_INTERSECTION_3_3(A,B,C) \ + result_type \ + operator()(const A & c1, const B & c2, const C & c3) const \ + { std::vector< typename ITs::result_type > res; \ + typename SK::Intersect_3()(c1,c2,c3,std::back_inserter(res)); \ + return !res.empty(); } CGAL_SPHERICAL_KERNEL_MACRO_DO_INTERSECTION_3_2(Sphere_3, Line_3) CGAL_SPHERICAL_KERNEL_MACRO_DO_INTERSECTION_3_2(Line_3, Sphere_3) @@ -1159,7 +1159,6 @@ template < class SK > \ template < class SK > class Intersect_3 { - typedef typename SK::Sphere_3 Sphere_3; typedef typename SK::Line_3 Line_3; typedef typename SK::Line_arc_3 Line_arc_3; @@ -1176,7 +1175,7 @@ template < class SK > \ private: // helper to minimize result implementation template ::value> + typename C, bool is_iterator = CGAL::is_iterator::type>::value> struct result_impl { typedef typename boost::result_of::type type; }; @@ -1192,7 +1191,7 @@ template < class SK > \ // the binary overload always goes to Linear::Intersect_3 template struct result - { typedef typename boost::result_of::type type; }; + { typedef typename boost::result_of::type type; }; // we match the ternary case if the last argument is an iterator, // otherwise Linear::Intersect_3 wins @@ -1209,12 +1208,15 @@ template < class SK > \ template typename boost::result_of::type operator()(const A& a, const B& b) - { return SK().intersect_3_object()(a, b); } + { return typename SK::Linear_kernel().intersect_3_object()(a, b); } template typename boost::result_of::type - operator()(const A& a, const B& b, const C& c) - { return SK().intersect_3_object()(a, b, c); } + operator()(const A& a, const B& b, const C& c, + typename boost::enable_if_c::type>::value)>::type* = 0) + { + return typename SK::Linear_kernel().intersect_3_object()(a, b, c); + } template < class OutputIterator > OutputIterator diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circle_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circle_3.h index cb5edce8b33..e4259d6ea45 100644 --- a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circle_3.h +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circle_3.h @@ -120,7 +120,8 @@ namespace CGAL { typename SK::FT z_coord=extremal_points_z_coordinate(circle,sphere); typename SK::Plane_3 plane(0,0,1,-z_coord); - std::vector::result_type > inters; + std::vector::type > inters; intersect_3(circle,plane,std::back_inserter(inters)); CGAL_kernel_precondition(inters.size()==2); diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circular_arc_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circular_arc_3.h index 79ac82729cc..d635add73cc 100644 --- a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circular_arc_3.h +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circular_arc_3.h @@ -88,7 +88,9 @@ namespace CGAL { OutputIterator res) { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; - typedef std::vector::result_type > solutions_container; + typedef std::vector< + typename boost::result_of::type + > solutions_container; typedef std::pair Solution; solutions_container solutions; @@ -118,11 +120,13 @@ namespace CGAL { OutputIterator res) { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; - typedef typename Intersection_traits::result_type - result_type; + typedef typename boost::result_of< + typename SK::Intersect_3(typename SK::Circle_3, typename SK::Circular_arc_3) + >::type result_type; - typedef std::vector::result_type> - solutions_container; + typedef std::vector::type > solutions_container; typedef std::pair Solution; if(non_oriented_equal(c, ca.supporting_circle())) { @@ -155,13 +159,14 @@ namespace CGAL { const typename SK::Circular_arc_3 & c, OutputIterator res) { - typedef typename Intersection_traits::result_type - result_type; + typedef typename boost::result_of< + typename SK::Intersect_3(typename SK::Sphere_3, typename SK::Circular_arc_3) + >::type result_type; typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; - typedef std::vector::result_type> - solutions_container; + typedef std::vector::type + > solutions_container; typedef std::pair Solution; if(SK().has_on_3_object()(s, c.supporting_circle())) { @@ -194,11 +199,15 @@ namespace CGAL { const typename SK::Circular_arc_3 & ca, OutputIterator res) { - typedef typename Intersection_traits::result_type result_type; + typedef typename boost::result_of< + typename SK::Intersect_3(typename SK::Plane_3, typename SK::Circular_arc_3) + >::type result_type; typedef typename SK::Point_3 Point_3; typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; - typedef std::vector::result_type> solutions_container; + typedef std::vector< + typename boost::result_of::type + > solutions_container; + typedef std::pair Solution; if(SK().has_on_3_object()(p,ca.supporting_circle())) { *res++ = CGAL::internal::intersection_return(ca); @@ -231,7 +240,7 @@ namespace CGAL { { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; typedef std::vector< - typename Intersection_traits::result_type> + typename boost::result_of::type> solutions_container; typedef std::pair Solution; @@ -264,12 +273,15 @@ namespace CGAL { const typename SK::Circular_arc_3 & a2, OutputIterator res) { - typedef typename Intersection_traits::result_type result_type; + typedef typename boost::result_of< + typename SK::Intersect_3(typename SK::Circular_arc_3, typename SK::Circular_arc_3) + >::type result_type; typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; typedef typename SK::Circular_arc_3 Circular_arc_3; - typedef std::vector::result_type> solutions_container; + typedef std::vector< typename boost::result_of< + typename SK::Intersect_3(typename SK::Circle_3, typename SK::Circle_3 ) + >::type> solutions_container; + typedef std::pair Solution; if(non_oriented_equal(a1.supporting_circle(), a2.supporting_circle())) { @@ -415,8 +427,9 @@ namespace CGAL { typename SK::FT z_coord=extremal_points_z_coordinate(arc.supporting_circle(),sphere); typename SK::Plane_3 plane(0,0,1,-z_coord); - std::vector::result_type> + std::vector::type> inters; intersect_3(plane,arc,std::back_inserter(inters)); @@ -469,7 +482,9 @@ namespace CGAL { case NORMAL:{ typename SK::FT z_coord=extremal_points_z_coordinate(arc.supporting_circle(),sphere); typename SK::Plane_3 plane(0,0,1,-z_coord); - std::vector::result_type> inters; + std::vector::type + > inters; intersect_3(plane,arc,std::back_inserter(inters)); @@ -594,7 +609,9 @@ namespace CGAL { { typename SK::Plane_3 plane(sphere.center(),sphere.center()+m,sphere.center()+typename SK::Vector_3(0,0,1)); - std::vector::result_type> inters; + std::vector::type> inters; intersect_3(plane,arc,std::back_inserter(inters)); CGAL_kernel_precondition(!inters.empty()); if (inters.size()==1){ diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_line_arc_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_line_arc_3.h index f8cf9bbc9d9..ba5b77f0498 100644 --- a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_line_arc_3.h +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_line_arc_3.h @@ -86,9 +86,9 @@ namespace CGAL { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; typedef typename SK::Line_3 Line_3; typedef typename SK::Line_arc_3 Line_arc_3; - typedef typename Intersection_traits::result_type result_type; + typedef typename boost::result_of::type result_type; - typename Intersection_traits::result_type o = + typename boost::result_of::type o = SK().intersect_3_object()(l1.supporting_line(), l2.supporting_line()); @@ -153,9 +153,9 @@ namespace CGAL { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; typedef typename SK::Line_3 Line_3; typedef typename SK::Line_arc_3 Line_arc_3; - typedef typename Intersection_traits::result_type result_type; + typedef typename boost::result_of::type result_type; - typename Intersection_traits::result_type o = + typename boost::result_of::type o = SK().intersect_3_object()(l, la.supporting_line()); if(!o) @@ -179,10 +179,12 @@ namespace CGAL { OutputIterator res) { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; - typedef std::vector::result_type> - solutions_container; + typedef std::vector< + typename boost::result_of::type> solutions_container; typedef std::pair Solution; - typedef typename Intersection_traits::result_type result_type; + typedef typename boost::result_of< + typename SK::Intersect_3(typename SK::Circle_3, typename SK::Line_arc_3)>::type result_type; solutions_container solutions; SK().intersect_3_object()(l.supporting_line(), c, @@ -211,8 +213,9 @@ namespace CGAL { OutputIterator res) { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; - typedef std::vector::result_type > solutions_container; + typedef std::vector::type > solutions_container; typedef std::pair Solution; solutions_container solutions; SK().intersect_3_object()(l.supporting_line(), s, @@ -245,8 +248,8 @@ namespace CGAL { *res++ = result_type(l); } const Point_3* sol; - typename Intersection_traits - ::result_type o = SK().intersect_3_object()(p,l.supporting_line()); + typename boost::result_of + ::type o = SK().intersect_3_object()(p,l.supporting_line()); if(!o) return res;