diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/Circular_arc_2.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/Circular_arc_2.h index c3b3d7fe7b1..0acf0d44641 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/Circular_arc_2.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/Circular_arc_2.h @@ -172,7 +172,7 @@ namespace internal { _begin = CGAL::circle_intersect(c, c1, b_1); _end = CGAL::circle_intersect(c, c2, b_2); } else { - typedef std::vector::result_type> solutions_container; diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/Line_arc_2.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/Line_arc_2.h index aa22c7caca9..d7d4d7a76f2 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/Line_arc_2.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/Line_arc_2.h @@ -74,7 +74,7 @@ public: intersect(const Line_2 & l, const Circle_2 & c, const bool b) { - typedef std::vector::result_type> + typedef std::vector::result_type> solutions_container; solutions_container solutions; @@ -129,7 +129,7 @@ public: CGAL_kernel_precondition(do_intersect(support, l1)); CGAL_kernel_precondition(do_intersect(support, l2)); //typedef typename Root_of_2::RT RT_2; - typename IT2::result_type + typename IT::result_type v = CGAL::internal::intersection(support, l1, CK()); CGAL_assertion(v); diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h index 91f4e7d89f6..58dfcc1be55 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h @@ -517,8 +517,6 @@ namespace CircularFunctors { public: - typedef typename CK::Linear_kernel::Intersect_2::result_type result_type; - using CK::Linear_kernel::Intersect_2::operator(); template < class OutputIterator > diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_circle_2.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_circle_2.h index ca7d624e0fa..d3df7a33d5e 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_circle_2.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_circle_2.h @@ -34,7 +34,7 @@ circle_intersect( const typename CK::Circle_2 & c1, const typename CK::Circle_2 & c2, bool b ) { - typedef std::vector::result_type> solutions_container; solutions_container solutions; @@ -123,7 +123,7 @@ namespace CircularFunctors { const typename CK::Circle_2 & c2, OutputIterator res ) { - typedef typename IT2 + typedef typename IT ::result_type result_type; typedef typename CK::Algebraic_kernel AK; typedef typename CK::Polynomial_for_circles_2_2 Equation; diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_circular_arc_2.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_circular_arc_2.h index d93a9880a31..8870162d4d5 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_circular_arc_2.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_circular_arc_2.h @@ -542,8 +542,8 @@ namespace CircularFunctors { const typename CK::Circular_arc_2 &a2, OutputIterator res ) { - typedef typename IT2::result_type result_type; + typedef typename IT::result_type result_type; typedef std::vector solutions_container; typedef typename CK::Circular_arc_2 Circular_arc_2; diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_line_arc_2.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_line_arc_2.h index 5ac4d2df242..06eca0c6e57 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_line_arc_2.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_line_arc_2.h @@ -381,7 +381,7 @@ namespace CircularFunctors { const typename CK::Circle_2 & c, OutputIterator res ) { - typedef typename IT2 + typedef typename IT ::result_type result_type; typedef typename CK::Algebraic_kernel AK; typedef typename CK::Polynomial_1_2 Equation_line; @@ -416,7 +416,7 @@ namespace CircularFunctors { const typename CK::Line_arc_2 &a2, OutputIterator res ) { - typedef typename IT2 + typedef typename IT ::result_type result_type; typedef typename CK::Circular_arc_point_2 Circular_arc_point_2; typedef typename CK::Line_arc_2 Line_arc_2; @@ -483,7 +483,7 @@ namespace CircularFunctors { } } - typename IT2::result_type + typename IT::result_type v = CGAL::internal::intersection(a1.supporting_line(), a2.supporting_line(), CK()); if(!v) return res; @@ -516,7 +516,7 @@ namespace CircularFunctors { const typename CK::Circle_2 &c, OutputIterator res ) { - typedef std::vector::result_type> + typedef std::vector::result_type> solutions_container; solutions_container solutions; @@ -547,7 +547,7 @@ namespace CircularFunctors { const typename CK::Circular_arc_2 &c, OutputIterator res ) { - typedef typename IT2 + typedef typename IT ::result_type result_type; typedef typename CK::Circular_arc_2 Circular_arc_2; typedef typename CK::Circular_arc_point_2 Circular_arc_point_2; @@ -628,7 +628,7 @@ namespace CircularFunctors { *res++ = result_type(std::make_pair(q,1u)); return res; } else { //Case 4b - typedef std::vector::result_type> + typedef std::vector::result_type> container; container solutions; CGAL::CircularFunctors::intersect_2( l.supporting_line(), c.supporting_circle(), @@ -754,13 +754,13 @@ namespace CircularFunctors { typedef typename CK::Line_2 Line_2; typedef typename CK::Root_of_2 Root_of_2; typedef typename CK::Root_for_circles_2_2 Root_for_circles_2_2; - typedef typename IT2::result_type result_type; + typedef typename IT::result_type result_type; if(LinearFunctors::non_oriented_equal(l, la.supporting_line())) { *res++ = result_type(la); } - typename IT2::result_type + typename IT::result_type v = intersection(l, la.supporting_line()); if(!v) return res; @@ -785,7 +785,7 @@ namespace CircularFunctors { typedef typename CK::Circular_arc_2 Circular_arc_2; typedef typename CK::Circular_arc_point_2 Circular_arc_point_2; typedef typename CK::Line_2 Line_2; - typedef std::vector< typename IT2::result_type> + typedef std::vector< typename IT::result_type> solutions_container; solutions_container solutions; diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_intersections.h b/Circular_kernel_2/include/CGAL/Circular_kernel_intersections.h index 2eba65051c2..46e28fe2628 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_intersections.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_intersections.h @@ -46,7 +46,7 @@ namespace internal { \ bool \ do_intersect(const typename K::A &c1, const typename K::B &c2, const K&) \ { \ - std::vector< typename IT2::result_type > res; \ + std::vector< typename IT::result_type > res; \ typename K::Intersect_2()(c1,c2,std::back_inserter(res)); \ return !res.empty(); \ } \ diff --git a/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2/bbox_filtered_predicates.h b/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2/bbox_filtered_predicates.h index 28e34c25a96..869cbd19a55 100644 --- a/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2/bbox_filtered_predicates.h +++ b/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2/bbox_filtered_predicates.h @@ -596,7 +596,6 @@ public: typedef typename BK::Circle_2 Circle; typedef typename BK::Line_2 Line_2; - typedef typename CK_Intersect_2::result_type result_type; using CK_Intersect_2::operator(); template < class OutputIterator > 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 c306a26d772..e1e3ddc21b2 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 @@ -163,7 +163,8 @@ namespace CGAL { const Sphere_3 &s1, bool less_xyz_s1, const Sphere_3 &s2, bool less_xyz_s2) { - std::vector sols1, sols2; + typedef typename IT::result_type result_type; + std::vector sols1, sols2; // The spheres must not include the circle CGAL_kernel_precondition(!SK().has_on_3_object()(s1,c)); CGAL_kernel_precondition(!SK().has_on_3_object()(s2,c)); @@ -173,11 +174,11 @@ namespace CGAL { CGAL_kernel_precondition(sols1.size() > 0); CGAL_kernel_precondition(sols2.size() > 0); const std::pair& pair1= - *object_cast >( + *boost::get >( &sols1[(sols1.size()==1)?(0):(less_xyz_s1?0:1)] ); const std::pair& pair2= - *object_cast >( + *boost::get >( &sols2[(sols2.size()==1)?(0):(less_xyz_s2?0:1)] ); // the source and target must be different @@ -189,7 +190,8 @@ namespace CGAL { const Plane_3 &p1, bool less_xyz_p1, const Plane_3 &p2, bool less_xyz_p2) { - std::vector sols1, sols2; + typedef typename IT::result_type result_type; + std::vector sols1, sols2; // The planes must not include the circle CGAL_kernel_precondition(!SK().has_on_3_object()(p1,c)); CGAL_kernel_precondition(!SK().has_on_3_object()(p2,c)); @@ -199,11 +201,11 @@ namespace CGAL { CGAL_kernel_precondition(sols1.size() > 0); CGAL_kernel_precondition(sols2.size() > 0); const std::pair& pair1= - *object_cast >( + *boost::get >( &sols1[(sols1.size()==1)?(0):(less_xyz_p1?0:1)] ); const std::pair& pair2= - *object_cast >( + *boost::get >( &sols2[(sols2.size()==1)?(0):(less_xyz_p2?0:1)] ); // the source and target must be different 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 cdc08edf794..97660462545 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 @@ -73,20 +73,20 @@ public: const Sphere_3 &s2, const Sphere_3 &s3, const bool less_xyz = true) { - std::vector sols; + std::vector::result_type> sols; SK().intersect_3_object()(s1, s2, s3, std::back_inserter(sols)); // s1,s2,s3 must intersect CGAL_kernel_precondition(sols.size() != 0); if(sols.size() == 1) { // the intersection must be a point const std::pair* pair= - object_cast >(&sols[0]); + boost::get >(&sols[0]); CGAL_kernel_precondition(pair!=NULL); *this = pair->first.rep(); } else { // the intersections must be a point const std::pair* pair= - object_cast >(&sols[less_xyz?0:1]); + boost::get >(&sols[less_xyz?0:1]); CGAL_kernel_precondition(pair!=NULL); *this = pair->first.rep(); } @@ -96,20 +96,20 @@ public: const Sphere_3 &s1, const Sphere_3 &s2, const bool less_xyz = true) { - std::vector sols; + std::vector::result_type> sols; SK().intersect_3_object()(p, s1, s2, std::back_inserter(sols)); // s1,s2,s3 must intersect CGAL_kernel_precondition(sols.size() != 0); if(sols.size() == 1) { // the intersection must be a point const std::pair* pair= - object_cast >(&sols[0]); + boost::get >(&sols[0]); CGAL_kernel_precondition(pair!=NULL); *this = pair->first.rep(); } else { // the intersections must be a point const std::pair* pair= - object_cast >(&sols[less_xyz?0:1]); + boost::get >(&sols[less_xyz?0:1]); CGAL_kernel_precondition(pair!=NULL); *this = pair->first.rep(); } @@ -119,20 +119,20 @@ public: const Plane_3 &p2, const Sphere_3 &s, const bool less_xyz = true) { - std::vector sols; + std::vector::result_type> sols; SK().intersect_3_object()(p1, p2, s, std::back_inserter(sols)); // s1,s2,s3 must intersect CGAL_kernel_precondition(sols.size() != 0); if(sols.size() == 1) { // the intersection must be a point const std::pair* pair= - object_cast >(&sols[0]); + boost::get >(&sols[0]); CGAL_kernel_precondition(pair!=NULL); *this = pair->first.rep(); } else { // the intersections must be a point const std::pair* pair= - object_cast >(&sols[less_xyz?0:1]); + boost::get >(&sols[less_xyz?0:1]); CGAL_kernel_precondition(pair!=NULL); *this = pair->first.rep(); } @@ -141,20 +141,20 @@ public: Circular_arc_point_3(const Line_3 &l, const Sphere_3 &s, const bool less_xyz = true) { - std::vector sols; + std::vector::result_type> sols; SK().intersect_3_object()(l, s, std::back_inserter(sols)); // s1,s2,s3 must intersect CGAL_kernel_precondition(sols.size() != 0); if(sols.size() == 1) { // the intersection must be a point const std::pair* pair= - object_cast >(&sols[0]); + boost::get >(&sols[0]); CGAL_kernel_precondition(pair!=NULL); *this = pair->first.rep(); } else { // the intersections must be a point const std::pair* pair= - object_cast >(&sols[less_xyz?0:1]); + boost::get >(&sols[less_xyz?0:1]); CGAL_kernel_precondition(pair!=NULL); *this = pair->first.rep(); } @@ -163,20 +163,20 @@ public: Circular_arc_point_3(const Circle_3 &c, const Plane_3 &p, const bool less_xyz = true) { - std::vector sols; + std::vector::result_type> sols; SK().intersect_3_object()(c, p, std::back_inserter(sols)); // s1,s2,s3 must intersect CGAL_kernel_precondition(sols.size() != 0); if(sols.size() == 1) { // the intersection must be a point const std::pair* pair= - object_cast >(&sols[0]); + boost::get >(&sols[0]); CGAL_kernel_precondition(pair!=NULL); *this = pair->first.rep(); } else { // the intersections must be a point const std::pair* pair= - object_cast >(&sols[less_xyz?0:1]); + boost::get >(&sols[less_xyz?0:1]); CGAL_kernel_precondition(pair!=NULL); *this = pair->first.rep(); } @@ -185,20 +185,20 @@ public: Circular_arc_point_3(const Circle_3 &c, const Sphere_3 &s, const bool less_xyz = true) { - std::vector sols; + std::vector::result_type> sols; SK().intersect_3_object()(c, s, std::back_inserter(sols)); // s1,s2,s3 must intersect CGAL_kernel_precondition(sols.size() != 0); if(sols.size() == 1) { // the intersection must be a point const std::pair* pair= - object_cast >(&sols[0]); + boost::get >(&sols[0]); CGAL_kernel_precondition(pair!=NULL); *this = pair->first.rep(); } else { // the intersections must be a point const std::pair* pair= - object_cast >(&sols[less_xyz?0:1]); + boost::get >(&sols[less_xyz?0:1]); CGAL_kernel_precondition(pair!=NULL); *this = pair->first.rep(); } 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 808cf0f8f23..c8d1845340d 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 @@ -92,14 +92,14 @@ namespace CGAL { const Sphere_3 &s, bool less_xyz_first = true) { - std::vector sols; + std::vector::result_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); const std::pair& pair1= - *object_cast >(&sols[0]); + *boost::get >(&sols[0]); const std::pair& pair2= - *object_cast >(&sols[1]); + *boost::get >(&sols[1]); if(less_xyz_first) { *this = Line_arc_3(l, pair1.first, pair2.first); } else { @@ -111,16 +111,16 @@ namespace CGAL { const Sphere_3 &s1, bool less_xyz_s1, const Sphere_3 &s2, bool less_xyz_s2) { - std::vector sols1, sols2; + std::vector::result_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 CGAL_kernel_precondition(sols1.size() > 0); CGAL_kernel_precondition(sols2.size() > 0); const std::pair& pair1= - *object_cast >(&sols1[(sols1.size()==1)?(0):(less_xyz_s1?0:1)]); + *boost::get >(&sols1[(sols1.size()==1)?(0):(less_xyz_s1?0:1)]); const std::pair& pair2= - *object_cast >(&sols2[(sols2.size()==1)?(0):(less_xyz_s2?0:1)]); + *boost::get >(&sols2[(sols2.size()==1)?(0):(less_xyz_s2?0:1)]); // the source and target must be different CGAL_kernel_precondition(pair1.first != pair2.first); *this = Line_arc_3(l, pair1.first, pair2.first); @@ -134,8 +134,11 @@ 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 - const typename SK::Point_3* point1=object_cast( & SK().intersect_3_object()(l, p1) ); - const typename SK::Point_3* point2=object_cast( & SK().intersect_3_object()(l, p2) ); + typedef typename IT::result_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 ); + const typename SK::Point_3* point2=boost::get( & *i2 ); CGAL_assertion(point1!=NULL); CGAL_assertion(point2!=NULL); // the source and target must be different 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 4fcc9f19945..8366a77c6aa 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 @@ -37,8 +37,6 @@ #include #include #include -#include - namespace CGAL { @@ -1096,26 +1094,27 @@ template < class SK > \ typedef typename SK::Circular_arc_3 Circular_arc_3; typedef typename SK::Plane_3 Plane_3; typedef typename SK::Circle_3 Circle_3; + typedef typename SK::Circle_3 Circular_arc_point_3; public: - typedef typename SK::Linear_kernel::Do_intersect_3::result_type result_type; + typedef typename SK::Linear_kernel::Do_intersect_3::result_type result_type; 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< Object > res; \ - typename SK::Intersect_3()(c1,c2,std::back_inserter(res)); \ - return res.size() != 0; } + { std::vector< typename IT::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_3(A,B,C) \ result_type \ operator()(const A & c1, const B & c2, const C & c3) const \ - { std::vector< Object > res; \ - typename SK::Intersect_3()(c1,c2,c3,std::back_inserter(res)); \ - return res.size() != 0; } + { std::vector< typename ITs::result_type > res; \ + typename SK::Intersect_3()(c1,c2,c3,std::back_inserter(res)); \ + return res.size() != 0; } CGAL_SPHERICAL_KERNEL_MACRO_DO_INTERSECTION_3_2(Sphere_3, Line_3) CGAL_SPHERICAL_KERNEL_MACRO_DO_INTERSECTION_3_2(Line_3, Sphere_3) @@ -1168,8 +1167,6 @@ template < class SK > \ public: - typedef typename SK::Linear_kernel::Intersect_3::result_type result_type; - typedef typename SK::Object_3 Object_3; using SK::Linear_kernel::Intersect_3::operator(); 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 8920b764d01..171d12f78b2 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 @@ -119,13 +119,13 @@ 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 inters; + std::vector::result_type > inters; intersect_3(circle,plane,std::back_inserter(inters)); CGAL_kernel_precondition(inters.size()==2); const std::pair* pt[2]={NULL,NULL}; - pt[0]=object_cast >(&inters[0]); - pt[1]=object_cast >(&inters[1]); + pt[0]=boost::get >(&inters[0]); + pt[1]=boost::get >(&inters[1]); CGAL_kernel_precondition(pt[0]!=NULL); CGAL_kernel_precondition(pt[1]!=NULL); 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 92e6b8a0d89..54570b746fc 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 @@ -87,7 +87,7 @@ namespace CGAL { OutputIterator res) { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; - typedef std::vector solutions_container; + typedef std::vector::result_type > solutions_container; typedef std::pair Solution; solutions_container solutions; @@ -96,12 +96,12 @@ namespace CGAL { std::back_inserter(solutions) ); if(solutions.size() == 0) return res; if(solutions.size() == 1) { - const Solution& sol=*object_cast(&solutions[0]); + const Solution& sol=*boost::get(&solutions[0]); if(SK().has_on_3_object()(ca,sol.first,true)) *res++ = solutions[0]; } else { - const Solution& sol1=*object_cast(&solutions[0]); - const Solution& sol2=*object_cast(&solutions[1]); + const Solution& sol1=*boost::get(&solutions[0]); + const Solution& sol2=*boost::get(&solutions[1]); if(SK().has_on_3_object()(ca,sol1.first,true)) *res++ = solutions[0]; if(SK().has_on_3_object()(ca,sol2.first,true)) @@ -117,11 +117,15 @@ namespace CGAL { OutputIterator res) { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; - typedef std::vector solutions_container; + typedef typename IT::result_type + result_type; + + typedef std::vector::result_type> + solutions_container; typedef std::pair Solution; if(non_oriented_equal(c, ca.supporting_circle())) { - *res++ = make_object(ca); + *res++ = result_type(ca); } solutions_container solutions; @@ -130,12 +134,12 @@ namespace CGAL { std::back_inserter(solutions) ); if(solutions.size() == 0) return res; if(solutions.size() == 1) { - const Solution& sol=*object_cast(&solutions[0]); + const Solution& sol=*boost::get(&solutions[0]); if(SK().has_on_3_object()(ca,sol.first,true)) *res++ = solutions[0]; } else { - const Solution& sol1=*object_cast(&solutions[0]); - const Solution& sol2=*object_cast(&solutions[1]); + const Solution& sol1=*boost::get(&solutions[0]); + const Solution& sol2=*boost::get(&solutions[1]); if(SK().has_on_3_object()(ca,sol1.first,true)) *res++ = solutions[0]; if(SK().has_on_3_object()(ca,sol2.first,true)) @@ -148,14 +152,19 @@ namespace CGAL { OutputIterator intersect_3(const typename SK::Sphere_3 & s, const typename SK::Circular_arc_3 & c, - OutputIterator res) + OutputIterator res) { + typedef typename IT::result_type + result_type; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; - typedef std::vector solutions_container; + typedef std::vector::result_type> + solutions_container; typedef std::pair Solution; if(SK().has_on_3_object()(s, c.supporting_circle())) { - *res++ = make_object(c); + *res++ = result_type(c); } solutions_container solutions; @@ -164,12 +173,12 @@ namespace CGAL { std::back_inserter(solutions) ); if(solutions.size() == 0) return res; if(solutions.size() == 1) { - const Solution& sol=*object_cast(&solutions[0]); + const Solution& sol=*boost::get(&solutions[0]); if(SK().has_on_3_object()(c,sol.first,true)) *res++ = solutions[0]; } else { - const Solution& sol1=*object_cast(&solutions[0]); - const Solution& sol2=*object_cast(&solutions[1]); + const Solution& sol1=*boost::get(&solutions[0]); + const Solution& sol2=*boost::get(&solutions[1]); if(SK().has_on_3_object()(c,sol1.first,true)) *res++ = solutions[0]; if(SK().has_on_3_object()(c,sol2.first,true)) @@ -184,12 +193,14 @@ namespace CGAL { const typename SK::Circular_arc_3 & ca, OutputIterator res) { + typedef typename IT::result_type result_type; typedef typename SK::Point_3 Point_3; typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; - typedef std::vector solutions_container; + typedef std::vector::result_type> solutions_container; typedef std::pair Solution; if(SK().has_on_3_object()(p,ca.supporting_circle())) { - *res++ = make_object(ca); + *res++ = result_type(ca); } solutions_container solutions; @@ -197,16 +208,16 @@ namespace CGAL { std::back_inserter(solutions) ); if(solutions.size() == 0) return res; if(solutions.size() == 1) { - const Solution& sol=*object_cast(&solutions[0]); + const Solution& sol=*boost::get(&solutions[0]); if(SK().has_on_3_object()(ca,sol.first,true)) - *res++ = solutions[0]; + *res++ = result_type(sol); } else { - const Solution& sol1=*object_cast(&solutions[0]); - const Solution& sol2=*object_cast(&solutions[1]); + const Solution& sol1=*boost::get(&solutions[0]); + const Solution& sol2=*boost::get(&solutions[1]); if(SK().has_on_3_object()(ca,sol1.first,true)) - *res++ = solutions[0]; + *res++ = result_type(sol1); if(SK().has_on_3_object()(ca,sol2.first,true)) - *res++ = solutions[1]; + *res++ = result_type(sol2); } return res; } @@ -218,7 +229,9 @@ namespace CGAL { OutputIterator res) { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; - typedef std::vector solutions_container; + typedef std::vector< + typename IT::result_type> + solutions_container; typedef std::pair Solution; solutions_container solutions; @@ -227,13 +240,13 @@ namespace CGAL { std::back_inserter(solutions) ); if(solutions.size() == 0) return res; if(solutions.size() == 1) { - const Solution& sol=*object_cast(&solutions[0]); + const Solution& sol=*boost::get(&solutions[0]); if(SK().has_on_3_object()(ca,sol.first,true) && SK().has_on_3_object()(la,sol.first,true)) *res++ = solutions[0]; } else { - const Solution& sol1=*object_cast(&solutions[0]); - const Solution& sol2=*object_cast(&solutions[1]); + const Solution& sol1=*boost::get(&solutions[0]); + const Solution& sol2=*boost::get(&solutions[1]); if(SK().has_on_3_object()(ca,sol1.first,true) && SK().has_on_3_object()(la,sol1.first,true)) *res++ = solutions[0]; @@ -250,18 +263,21 @@ namespace CGAL { const typename SK::Circular_arc_3 & a2, OutputIterator res) { + typedef typename IT::result_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 solutions_container; + typedef std::vector::result_type> solutions_container; typedef std::pair Solution; if(non_oriented_equal(a1.supporting_circle(), a2.supporting_circle())) { if(a1.rep().is_full()) { - *res++ = make_object(a2); + *res++ = result_type(a2); //return res; } else if(a2.rep().is_full()) { - *res++ = make_object(a1); + *res++ = result_type(a1); //return res; } else { bool t2_in_a1 = SK().has_on_3_object()(a1,a2.target(),true); @@ -274,58 +290,58 @@ namespace CGAL { SK().compare_xyz_3_object()(a1.source(), a2.source()); if(comp < 0) { if(a1.source() == a2.target()) { - *res++ = make_object(std::make_pair(a1.source(),1u)); + *res++ = result_type(std::make_pair(a1.source(),1u)); } else { const Circular_arc_3 & arc = Circular_arc_3(a1.supporting_circle(),a1.source(),a2.target()); - *res++ = make_object(arc); + *res++ = result_type(arc); } if(a2.source() == a1.target()) { - *res++ = make_object(std::make_pair(a2.source(),1u)); + *res++ = result_type(std::make_pair(a2.source(),1u)); } else { const Circular_arc_3 & arc = Circular_arc_3(a1.supporting_circle(),a2.source(),a1.target()); - *res++ = make_object(arc); + *res++ = result_type(arc); } } else if(comp > 0) { if(a2.source() == a1.target()) { - *res++ = make_object(std::make_pair(a2.source(),1u)); + *res++ = result_type(std::make_pair(a2.source(),1u)); } else { const Circular_arc_3 & arc = Circular_arc_3(a1.supporting_circle(),a2.source(),a1.target()); - *res++ = make_object(arc); + *res++ = result_type(arc); } if(a1.source() == a2.target()) { - *res++ = make_object(std::make_pair(a1.source(),1u)); + *res++ = result_type(std::make_pair(a1.source(),1u)); } else { const Circular_arc_3 & arc = Circular_arc_3(a1.supporting_circle(),a1.source(),a2.target()); - *res++ = make_object(arc); + *res++ = result_type(arc); } } else { - *res++ = make_object(a1); + *res++ = result_type(a1); } } else { - *res++ = make_object(a2); + *res++ = result_type(a2); } } else if(t2_in_a1) { if(a1.source() == a2.target()) - *res++ = make_object(std::make_pair(a1.source(),1u)); + *res++ = result_type(std::make_pair(a1.source(),1u)); else { const Circular_arc_3 & arc = Circular_arc_3(a1.supporting_circle(),a1.source(),a2.target()); - *res++ = make_object(arc); + *res++ = result_type(arc); } //return res; } else if(s2_in_a1) { if(a2.source() == a1.target()) { - *res++ = make_object(std::make_pair(a2.source(),1u)); + *res++ = result_type(std::make_pair(a2.source(),1u)); } else { const Circular_arc_3 & arc = Circular_arc_3(a1.supporting_circle(),a2.source(),a1.target()); - *res++ = make_object(arc); + *res++ = result_type(arc); } } else if(SK().has_on_3_object()(a2,a1.source(),true)) { - *res++ = make_object(a1); + *res++ = result_type(a1); } } } else { @@ -335,13 +351,13 @@ namespace CGAL { std::back_inserter(solutions) ); if(solutions.size() == 0) return res; if(solutions.size() == 1) { - const Solution& sol=*object_cast(&solutions[0]); + const Solution& sol=*boost::get(&solutions[0]); if(SK().has_on_3_object()(a1,sol.first,true) && SK().has_on_3_object()(a2,sol.first,true)) *res++ = solutions[0]; } else { - const Solution& sol1=*object_cast(&solutions[0]); - const Solution& sol2=*object_cast(&solutions[1]); + const Solution& sol1=*boost::get(&solutions[0]); + const Solution& sol2=*boost::get(&solutions[1]); if(SK().has_on_3_object()(a1,sol1.first,true) && SK().has_on_3_object()(a2,sol1.first,true)) *res++ = solutions[0]; @@ -381,7 +397,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 inters; + std::vector::result_type> + inters; intersect_3(plane,arc,std::back_inserter(inters)); @@ -433,7 +451,7 @@ 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 inters; + std::vector::result_type> inters; intersect_3(plane,arc,std::back_inserter(inters)); @@ -455,8 +473,8 @@ namespace CGAL { //one endpoint is extremal: just split the arc if (nb_extrem==1){ const std::pair* pt[2]={NULL,NULL}; - pt[0]=object_cast >(&inters[0]); - pt[1]=object_cast >(&inters[1]); + pt[0]=boost::get >(&inters[0]); + pt[1]=boost::get >(&inters[1]); CGAL_kernel_precondition(pt[0]!=NULL); CGAL_kernel_precondition(pt[1]!=NULL); const typename SK::Circular_arc_point_3& midpt=(arc.source()==pt[0]->first || arc.target()==pt[0]->first)?pt[1]->first:pt[0]->first; @@ -470,7 +488,7 @@ namespace CGAL { //only one intersection points if (inters.size()==1){ const std::pair* midpt=NULL; - midpt=object_cast >(&inters[0]); + midpt=boost::get >(&inters[0]); CGAL_kernel_precondition(midpt!=NULL); *out_it++=typename SK::Circular_arc_3(arc.supporting_circle(),arc.source(),midpt->first); *out_it++=typename SK::Circular_arc_3(arc.supporting_circle(),midpt->first,arc.target()); @@ -479,8 +497,8 @@ namespace CGAL { //three arcs are defined by two intersection points const std::pair* pt[2]={NULL,NULL}; - pt[0]=object_cast >(&inters[0]); - pt[1]=object_cast >(&inters[1]); + pt[0]=boost::get >(&inters[0]); + pt[1]=boost::get >(&inters[1]); CGAL_kernel_precondition(pt[0]!=NULL); CGAL_kernel_precondition(pt[1]!=NULL); @@ -557,19 +575,20 @@ namespace CGAL { const typename SK::Sphere_3& sphere) { typename SK::Plane_3 plane(sphere.center(),sphere.center()+m,sphere.center()+typename SK::Vector_3(0,0,1)); - std::vector inters; + + std::vector::result_type> inters; intersect_3(plane,arc,std::back_inserter(inters)); CGAL_kernel_precondition(!inters.empty()); if (inters.size()==1){ const typename SK::Circular_arc_point_3& pt= - object_cast >(&inters[0])->first; + boost::get >(&inters[0])->first; return pt; } CGAL_kernel_precondition(classify_circle_3(arc.supporting_circle(),sphere)!=NORMAL); - const typename SK::Circular_arc_point_3& pts1=object_cast >(&inters[0])->first; - const typename SK::Circular_arc_point_3& pts2=object_cast >(&inters[1])->first; + const typename SK::Circular_arc_point_3& pts1=boost::get >(&inters[0])->first; + const typename SK::Circular_arc_point_3& pts2=boost::get >(&inters[1])->first; //either a polar (1 pole + 1 pt) or a threaded circle (2 pts with theta-coord = +/- pi) 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 a7def11653c..8d3bb96ffe5 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 @@ -85,57 +85,58 @@ 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 IT::result_type result_type; - Point_3 inters_p; - Line_3 inters_l; + typename IT::result_type o = + SK().intersect_3_object()(l1.supporting_line(), + l2.supporting_line()); - Object o = SK().intersect_3_object()(l1.supporting_line(), - l2.supporting_line()); - - if(assign(inters_p, o)) { - Circular_arc_point_3 p = inters_p; - if(!SK().has_on_3_object()(l1,p,true)) return res; - if(!SK().has_on_3_object()(l2,p,true)) return res; - *res++ = make_object(std::make_pair(p,1u)); - } else if(assign(inters_l, o)) { + if(!o) + return res; + if(const Point_3* inters_p = boost::get(&(*o))) { + Circular_arc_point_3 p = *inters_p; + if(!SK().has_on_3_object()(l1,p,true)) return res; + if(!SK().has_on_3_object()(l2,p,true)) return res; + *res++ = result_type(std::make_pair(p,1u)); + } else if(const Line_3* inters_l = boost::get(&(*o))) { if(SK().compare_xyz_3_object()(l1.lower_xyz_extremity(), l2.lower_xyz_extremity()) < 0) { - int comparison = + int comparison = SK().compare_xyz_3_object()(l2.lower_xyz_extremity(), l1.higher_xyz_extremity()); - if(comparison < 0) { - if(SK().compare_xyz_3_object()(l1.higher_xyz_extremity(), + if(comparison < 0) { + if(SK().compare_xyz_3_object()(l1.higher_xyz_extremity(), l2.higher_xyz_extremity()) <= 0) { - *res++ = make_object - (Line_arc_3(l1.supporting_line(), + *res++ = result_type + (Line_arc_3(l1.supporting_line(), l2.lower_xyz_extremity(), l1.higher_xyz_extremity())); - } else { - *res++ = make_object(l2); - } - } else if (comparison == 0) { - *res++ = make_object(std::make_pair(l2.lower_xyz_extremity(),1u)); - } - } - else { - int comparison = - SK().compare_xyz_3_object()(l1.lower_xyz_extremity(), - l2.higher_xyz_extremity()); - if(comparison < 0){ - if(SK().compare_xyz_3_object()(l1.higher_xyz_extremity(), - l2.higher_xyz_extremity()) <= 0) { - *res++ = make_object(l1); - } else { - *res++ = make_object - (Line_arc_3(l1.supporting_line(), - l1.lower_xyz_extremity(), - l2.higher_xyz_extremity() )); - } - } - else if (comparison == 0){ - *res++ = make_object(std::make_pair(l1.lower_xyz_extremity(),1u)); - } + } else { + *res++ = result_type(l2); + } + } else if (comparison == 0) { + *res++ = result_type(std::make_pair(l2.lower_xyz_extremity(),1u)); + } + else { + int comparison = + SK().compare_xyz_3_object()(l1.lower_xyz_extremity(), + l2.higher_xyz_extremity()); + if(comparison < 0) { + if(SK().compare_xyz_3_object()(l1.higher_xyz_extremity(), + l2.higher_xyz_extremity()) <= 0) { + *res++ = result_type(l1); + } else { + *res++ = result_type + (Line_arc_3(l1.supporting_line(), + l1.lower_xyz_extremity(), + l2.higher_xyz_extremity() )); + } + } + else if (comparison == 0){ + *res++ = result_type(std::make_pair(l1.lower_xyz_extremity(),1u)); + } + } } } return res; @@ -151,19 +152,22 @@ 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 IT::result_type result_type; - Point_3 inters_p; - Line_3 inters_l; + typename IT::result_type o = + SK().intersect_3_object()(l, la.supporting_line()); - Object o = SK().intersect_3_object()(l, la.supporting_line()); + if(!o) + return res; - if(assign(inters_l, o)) { - *res++ = make_object(la); - } else if(assign(inters_p, o)) { - Circular_arc_point_3 p = inters_p; + if(const Line_3* inters_l = boost::get(&*o)) { + *res++ = result_type(la); + } else if(const Point_3* inters_p = boost::get(&*o)) { + Circular_arc_point_3 p = *inters_p; if(!SK().has_on_3_object()(la,p,true)) return res; - *res++ = make_object(std::make_pair(p,1u)); + *res++ = result_type(std::make_pair(p,1u)); } + return res; } @@ -174,24 +178,26 @@ namespace CGAL { OutputIterator res) { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; - typedef std::vector solutions_container; + typedef std::vector::result_type> + solutions_container; typedef std::pair Solution; + typedef typename IT::result_type result_type; + solutions_container solutions; SK().intersect_3_object()(l.supporting_line(), c, std::back_inserter(solutions) ); if(solutions.size() == 0) return res; if(solutions.size() == 1) { - Solution sol; - assign(sol, solutions[0]); - if(SK().has_on_3_object()(l,sol.first,true)) - *res++ = solutions[0]; + const Solution* sol = boost::get(&solutions[0]); + if(SK().has_on_3_object()(l,(*sol).first,true)) + *res++ = solutions[0]; } else { - Solution sol1, sol2; - assign(sol1, solutions[0]); - assign(sol2, solutions[1]); - if(SK().has_on_3_object()(l,sol1.first,true)) + const Solution* sol1 = boost::get(&solutions[0]); + const Solution* sol2 = boost::get(&solutions[1]); + + if(SK().has_on_3_object()(l,(*sol1).first,true)) *res++ = solutions[0]; - if(SK().has_on_3_object()(l,sol2.first,true)) + if(SK().has_on_3_object()(l,(*sol2).first,true)) *res++ = solutions[1]; } return res; @@ -204,24 +210,23 @@ namespace CGAL { OutputIterator res) { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; - typedef std::vector solutions_container; + typedef std::vector::result_type > solutions_container; typedef std::pair Solution; solutions_container solutions; SK().intersect_3_object()(l.supporting_line(), s, std::back_inserter(solutions) ); if(solutions.size() == 0) return res; if(solutions.size() == 1) { - Solution sol; - assign(sol, solutions[0]); - if(SK().has_on_3_object()(l,sol.first,true)) - *res++ = solutions[0]; + const Solution* sol = boost::get(&solutions[0]); + if(SK().has_on_3_object()(l,(*sol).first,true)) + *res++ = solutions[0]; } else { - Solution sol1, sol2; - assign(sol1, solutions[0]); - assign(sol2, solutions[1]); - if(SK().has_on_3_object()(l,sol1.first,true)) + const Solution* sol1 = boost::get(&solutions[0]); + const Solution* sol2 = boost::get(&solutions[1]); + if(SK().has_on_3_object()(l,(*sol1).first,true)) *res++ = solutions[0]; - if(SK().has_on_3_object()(l,sol2.first,true)) + if(SK().has_on_3_object()(l,(*sol2).first,true)) *res++ = solutions[1]; } return res; @@ -236,14 +241,19 @@ namespace CGAL { typedef typename SK::Point_3 Point_3; typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; if(SK().has_on_3_object()(p,l.supporting_line())) { - *res++ = make_object(l); + *res++ = result_type(l); } - Point_3 sol; - if(!assign(sol,SK().intersect_3_object()(p,l.supporting_line()))) + const Point_3* sol; + typename IT + ::result_type o = SK().intersect_3_object()(p,l.supporting_line()); + + if(!o) return res; - if(!SK().has_on_3_object()(l,sol)) return res; - Circular_arc_point_3 point = sol; - *res++ = make_object(std::make_pair(point,1u)); + if(sol = boost::get(&*o)) { + if(!SK().has_on_3_object()(l,*sol)) return res; + Circular_arc_point_3 point = sol; + *res++ = result_type(std::make_pair(point,1u)); + } return res; } diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_sphere_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_sphere_3.h index dfa44843d1c..c17d7f36cda 100644 --- a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_sphere_3.h +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_sphere_3.h @@ -199,12 +199,43 @@ namespace CGAL { (c1.target() == c2.target()); } + namespace internal { + // we need to pass the result_type, to hack around the fact that + // object doesn't support operator=(const T&) and so we keep backwards compatibility + template + RT pair_transform(const std::pair< typename SK::Root_for_spheres_2_3, unsigned >& p) { + return RT(std::make_pair(typename SK::Circular_arc_point_3(p.first), p.second)); + } + + // obscure trick: calculate the regular intersection between two + // objects, throw it away if empty, else check if the result was a + // point_3, if so turn in into a (circular_arc_point, unsigned) + // pair, otherwise just dump the value with conversion to RT + // (again: converting to RT before assigning to the Iterator is + // just to keep object working) + template + struct Point_conversion_visitor : public boost::static_visitor { + Point_conversion_visitor(const OutputIterator& it) : it(it) {} + template + OutputIterator operator()(const T& t) { *it++ = RT(t); return it; } + OutputIterator operator()(const typename SK::Point_3& p) { + // 2 multiplicities + *it++ = RT(std::make_pair(typename SK::Circular_arc_point_3(p), 2u)); + return it; + } + OutputIterator it; + }; + + } // namespace internal + template < class SK, class OutputIterator > OutputIterator intersect_3(const typename SK::Sphere_3 & s, const typename SK::Line_3 & l, OutputIterator res) { + typedef typename IT + ::result_type result_type; typedef typename SK::Algebraic_kernel Algebraic_kernel; typedef typename SK::Polynomial_for_spheres_2_3 Equation_sphere; typedef typename SK::Polynomials_for_line_3 Equation_line; @@ -218,71 +249,11 @@ namespace CGAL { solutions_container; solutions_container solutions; Algebraic_kernel().solve_object()(e1, e2, std::back_inserter(solutions)); - for ( typename solutions_container::iterator it = solutions.begin(); - it != solutions.end(); ++it ) { - *res++ = make_object(std::make_pair(Circular_arc_point_3(it->first), - it->second )); - } - return res; - } - - namespace internal { - - // It just converts when the solution is a Point_3 to Circular_arc_point_3 - - template < class SK, class OutputIterator > - OutputIterator - intersect_special(const typename SK::Sphere_3 & s1, - const typename SK::Sphere_3 & s2, - OutputIterator res) - { - Object obj = SK().intersect_3_object()(s1, s2); - if(obj.is_empty()) return res; - typename SK::Point_3 p; - if(assign(p, obj)) { - typename SK::Circular_arc_point_3 cp = p; - *res++ = make_object(std::make_pair(cp,2u)); - } else { - *res++ = obj; - } return res; - } - - template < class SK, class OutputIterator > - OutputIterator - intersect_special(const typename SK::Plane_3 & plane, - const typename SK::Sphere_3 & sphere, - OutputIterator res) - { - Object obj = SK().intersect_3_object()(plane, sphere); - if(obj.is_empty()) return res; - typename SK::Point_3 p; - if(assign(p, obj)) { - typename SK::Circular_arc_point_3 cp = p; - *res++ = make_object(std::make_pair(cp,2u)); - } else { - *res++ = obj; - } return res; - } - - template < class SK, class OutputIterator > - OutputIterator - intersect_special(const typename SK::Sphere_3 & sphere, - const typename SK::Plane_3 & plane, - OutputIterator res) - { - Object obj = SK().intersect_3_object()(plane, sphere); - if(obj.is_empty()) return res; - typename SK::Point_3 p; - if(assign(p, obj)) { - typename SK::Circular_arc_point_3 cp = p; - *res++ = make_object(std::make_pair(cp,2u)); - } else { - *res++ = obj; - } return res; - } - + + return std::transform(solutions.begin(), solutions.end(), res, internal::pair_transform); } + // The special 3 object functions template < class SK, class OutputIterator > OutputIterator intersect_3(const typename SK::Sphere_3 & s1, @@ -290,44 +261,58 @@ namespace CGAL { const typename SK::Sphere_3 & s3, OutputIterator res) { + // circle_3, sphere_3, (circular_arc_point_3, uint) typedef typename SK::Polynomial_for_spheres_2_3 Equation_sphere; typedef typename SK::Root_for_spheres_2_3 Root_for_spheres_2_3; typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; typedef typename SK::Circle_3 Circle_3; - typedef typename SK::Point_3 Point_3; + typedef typename SK::Point_3 Point_3; + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::Plane_3 Plane_3; typedef typename SK::Algebraic_kernel Algebraic_kernel; - typedef std::vector< Object > solutions_container; + typedef typename ITs::result_type result_type; + CGAL_kernel_precondition(!s1.is_degenerate()); CGAL_kernel_precondition(!s2.is_degenerate()); CGAL_kernel_precondition(!s3.is_degenerate()); if(non_oriented_equal(s1,s2) && non_oriented_equal(s2,s3)) { - *res++ = make_object(s1); + *res++ = result_type(s1); return res; } if(non_oriented_equal(s1,s2)) { - return internal::intersect_special(s1, s3, res); + if(typename IT::result_type v = + SK().intersect_3_object()(s1, s3)) { + internal::Point_conversion_visitor visitor(res); + return boost::apply_visitor(visitor, + *v); + } + return res; } - if((non_oriented_equal(s1,s3)) || - (non_oriented_equal(s2,s3))) { - return internal::intersect_special(s1, s2, res); + if(non_oriented_equal(s1,s3) || non_oriented_equal(s2,s3)) { + if(typename IT::result_type v = + SK().intersect_3_object()(s1, s2)) { + internal::Point_conversion_visitor visitor(res); + return boost::apply_visitor( + visitor, + *v); + } + return res; } if(SK().collinear_3_object()(s1.center(),s2.center(),s3.center())) { - Object obj = SK().intersect_3_object()(s1, s2); - if(obj.is_empty()) return res; - Point_3 p; - if(assign(p, obj)) { - if(SK().has_on_3_object()(s3, p)) { - Circular_arc_point_3 cp = p; - *res++ = make_object(std::make_pair(cp,2u)); - return res; - } else return res; + typename IT::result_type v = + SK().intersect_3_object()(s1, s2); + if(!v) return res; + if(const Point_3* p = boost::get(&*v)) { + if(SK().has_on_3_object()(s3, *p)) { + *res++ = result_type(std::make_pair(Circular_arc_point_3(*p),2u)); + } + return res; } - // must be a circle - Circle_3 c; - assign(c, obj); - if(SK().has_on_3_object()(s3,c)) { - *res++ = obj; - return res; + if(const Circle_3* c = boost::get(&*v)) { + if(SK().has_on_3_object()(s3, *c)) { + *res++ = result_type(*c); + } + return res; } return res; } @@ -338,12 +323,8 @@ namespace CGAL { algebraic_solutions_container; algebraic_solutions_container solutions; Algebraic_kernel().solve_object()(e1, e2, e3, std::back_inserter(solutions)); - for ( typename algebraic_solutions_container::iterator it = - solutions.begin(); it != solutions.end(); ++it ) { - *res++ = make_object(std::make_pair(Circular_arc_point_3(it->first), - it->second )); - } - return res; + + return std::transform(solutions.begin(), solutions.end(), res, internal::pair_transform); } template < class SK, class OutputIterator > @@ -353,21 +334,38 @@ namespace CGAL { const typename SK::Sphere_3 & s2, OutputIterator res) { + typedef typename boost::variant< std::pair< typename SK::Circular_arc_point_3, unsigned int>, + typename SK::Circle_3 > result_type; typedef typename SK::Root_for_spheres_2_3 Root_for_spheres_2_3; typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; typedef typename SK::Polynomial_for_spheres_2_3 Equation_sphere; typedef typename SK::Polynomial_1_3 Equation_plane; typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Sphere_3 Sphere_3; typedef typename SK::Algebraic_kernel Algebraic_kernel; CGAL_kernel_precondition(!p.is_degenerate()); CGAL_kernel_precondition(!s1.is_degenerate()); CGAL_kernel_precondition(!s2.is_degenerate()); if(non_oriented_equal(s1,s2)) { - return internal::intersect_special(p,s1,res); + if(typename IT::result_type v = + SK().intersect_3_object()(p, s1)) { + internal::Point_conversion_visitor visitor(res); + return boost::apply_visitor( + visitor, + *v); + } + return res; } Plane_3 radical_p = SK().construct_radical_plane_3_object()(s1,s2); if(non_oriented_equal(p,radical_p)) { - return internal::intersect_special(p,s1,res); + if(typename IT::result_type v = + SK().intersect_3_object()(p, s1)) { + internal::Point_conversion_visitor visitor(res); + return boost::apply_visitor( + visitor, + *v); + } + return res; } Equation_sphere e1 = get_equation(s1); Equation_sphere e2 = get_equation(s2); @@ -376,12 +374,7 @@ namespace CGAL { algebraic_solutions_container; algebraic_solutions_container solutions; Algebraic_kernel().solve_object()(e1, e2, e3, std::back_inserter(solutions)); - for ( typename algebraic_solutions_container::iterator it = - solutions.begin(); it != solutions.end(); ++it ) { - *res++ = make_object(std::make_pair(Circular_arc_point_3(it->first), - it->second )); - } - return res; + return std::transform(solutions.begin(), solutions.end(), res, internal::pair_transform); } template < class SK, class OutputIterator > @@ -391,16 +384,27 @@ namespace CGAL { const typename SK::Sphere_3 & s, OutputIterator res) { + typedef typename boost::variant< std::pair< typename SK::Circular_arc_point_3, unsigned int>, + typename SK::Circle_3 > result_type; typedef typename SK::Root_for_spheres_2_3 Root_for_spheres_2_3; typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; typedef typename SK::Polynomial_for_spheres_2_3 Equation_sphere; typedef typename SK::Polynomial_1_3 Equation_plane; typedef typename SK::Algebraic_kernel Algebraic_kernel; + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Sphere_3 Sphere_3; CGAL_kernel_precondition(!p1.is_degenerate()); CGAL_kernel_precondition(!p2.is_degenerate()); CGAL_kernel_precondition(!s.is_degenerate()); if(non_oriented_equal(p1,p2)) { - return internal::intersect_special(p1,s,res); + if(typename IT::result_type v = + SK().intersect_3_object()(p1, s)) { + internal::Point_conversion_visitor visitor(res); + return boost::apply_visitor( + visitor, + *v); + } + return res; } Equation_plane e1 = get_equation(p1); Equation_plane e2 = get_equation(p2); @@ -409,12 +413,7 @@ namespace CGAL { algebraic_solutions_container; algebraic_solutions_container solutions; Algebraic_kernel().solve_object()(e1, e2, e3, std::back_inserter(solutions)); - for ( typename algebraic_solutions_container::iterator it = - solutions.begin(); it != solutions.end(); ++it ) { - *res++ = make_object(std::make_pair(Circular_arc_point_3(it->first), - it->second )); - } - return res; + return std::transform(solutions.begin(), solutions.end(), res, internal::pair_transform); } template < class SK, class OutputIterator > @@ -446,8 +445,11 @@ namespace CGAL { typedef typename SK::Polynomials_for_circle_3 Equation_circle; typedef typename SK::Circle_3 Circle_3; typedef typename SK::Algebraic_kernel Algebraic_kernel; + typedef typename IT + ::result_type result_type; + if(non_oriented_equal(c1,c2)) { - *res++ = make_object(c1); + *res++ = result_type(c1); return res; } Equation_circle e1 = get_equation(c1); @@ -456,12 +458,7 @@ namespace CGAL { algebraic_solutions_container; algebraic_solutions_container solutions; Algebraic_kernel().solve_object()(e1, e2, std::back_inserter(solutions)); - for ( typename algebraic_solutions_container::iterator it = - solutions.begin(); it != solutions.end(); ++it ) { - *res++ = make_object(std::make_pair(Circular_arc_point_3(it->first), - it->second )); - } - return res; + return std::transform(solutions.begin(), solutions.end(), res, internal::pair_transform); } template < class SK, class OutputIterator > @@ -475,6 +472,7 @@ namespace CGAL { typedef typename SK::Polynomials_for_circle_3 Equation_circle; typedef typename SK::Polynomials_for_line_3 Equation_line; typedef typename SK::Circle_3 Circle_3; + typedef typename IT::result_type result_type; typedef typename SK::Algebraic_kernel Algebraic_kernel; CGAL_kernel_precondition(!l.is_degenerate()); Equation_circle e1 = get_equation(c); @@ -483,12 +481,7 @@ namespace CGAL { algebraic_solutions_container; algebraic_solutions_container solutions; Algebraic_kernel().solve_object()(e1, e2, std::back_inserter(solutions)); - for ( typename algebraic_solutions_container::iterator it = - solutions.begin(); it != solutions.end(); ++it ) { - *res++ = make_object(std::make_pair(Circular_arc_point_3(it->first), - it->second )); - } - return res; + return std::transform(solutions.begin(), solutions.end(), res, internal::pair_transform); } // At the moment we dont need those functions diff --git a/Circular_kernel_3/include/CGAL/Spherical_kernel_intersections.h b/Circular_kernel_3/include/CGAL/Spherical_kernel_intersections.h index 80d3f464811..427cf54648e 100644 --- a/Circular_kernel_3/include/CGAL/Spherical_kernel_intersections.h +++ b/Circular_kernel_3/include/CGAL/Spherical_kernel_intersections.h @@ -30,7 +30,6 @@ #include #include #include -#include namespace CGAL { @@ -78,6 +77,7 @@ CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Sphere_3, Circle_3) CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Circle_3, Circle_3) CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Circle_3, Line_3) CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Line_3, Circle_3) + CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Line_arc_3, Line_arc_3) CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Line_3, Line_arc_3) CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Line_arc_3, Line_3) @@ -101,4 +101,5 @@ CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Line_arc_3, Circular } //namespace CGAL +#undef CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_ #endif // CGAL_SPHERICAL_KERNEL_INTERNAL_FUNCTIONS_ON_INTERSECTION_3_H diff --git a/Intersections_2/include/CGAL/Intersection_traits.h b/Intersections_2/include/CGAL/Intersection_traits.h index 11173541f91..fd779db2eb9 100644 --- a/Intersections_2/include/CGAL/Intersection_traits.h +++ b/Intersections_2/include/CGAL/Intersection_traits.h @@ -51,6 +51,17 @@ struct Intersection_traits {}; template struct IT : public Intersection_traits {}; +// The version to cover ternary intersections of the Spherical_kernel +template +struct Intersection_traits_spherical { + typedef boost::variant< + typename K::Circle_3, typename K::Plane_3, typename K::Sphere_3, std::pair< typename K::Circular_arc_point_3, unsigned > > + result_type; +}; + +template +struct ITs : public Intersection_traits_spherical {}; + namespace internal { // tags for dispatch diff --git a/Intersections_3/include/CGAL/Intersection_traits_3.h b/Intersections_3/include/CGAL/Intersection_traits_3.h index 5f14f58fc20..79dc98c1691 100644 --- a/Intersections_3/include/CGAL/Intersection_traits_3.h +++ b/Intersections_3/include/CGAL/Intersection_traits_3.h @@ -191,6 +191,39 @@ template struct Intersection_traits : public Intersection_traits {}; +// Circular_arc_3 Circular_arc_3 +template +struct Intersection_traits { + typedef typename boost::variant< + typename K::Circle_3, + std::pair , + typename K::Circular_arc_3 > result_type; + typedef internal::Intersection_dim_three Dim_tag; +}; + +// Circular_arc_3 Plane_3 +template +struct Intersection_traits { + typedef typename boost::variant< + std::pair , + typename K::Circular_arc_3 > result_type; + typedef internal::Intersection_dim_three Dim_tag; +}; + +template +struct Intersection_traits + : public Intersection_traits {}; + + +template +struct Intersection_traits { + typedef typename boost::variant< + std::pair , + typename K::Line_arc_3 > result_type; + typedef internal::Intersection_dim_three Dim_tag; +}; + + } // namespace #endif /* CGAL_INTERSECTION_TRAITS_3_H */