From 119da894fec4a62ac68249d5b46a3ae71e1f4dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 17 Jan 2017 10:19:00 +0100 Subject: [PATCH 1/2] add missing CK::Intersect_2(Line_2,Line_2,OutputIterator) --- .../include/CGAL/Circular_kernel_2/Intersection_traits.h | 6 ++++++ .../function_objects_polynomial_circular.h | 9 +++++++++ .../include/CGAL/Circular_kernel_intersections.h | 7 +++++++ 3 files changed, 22 insertions(+) diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/Intersection_traits.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/Intersection_traits.h index e78f530b2a9..90c08f3d626 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/Intersection_traits.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/Intersection_traits.h @@ -153,6 +153,12 @@ struct CK2_Intersection_traits : public CK2_Intersection_traits {}; +template +struct CK2_Intersection_traits +{ + typedef typename Intersection_traits::result_type type; +}; + } //end of namespace CGAL #else 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 b6ede80bfbb..c7119904ea7 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 @@ -632,6 +632,15 @@ namespace CircularFunctors { OutputIterator res) const { return CircularFunctors::intersect_2 (l,la,res); } + template < class OutputIterator > + OutputIterator + operator()(const Line & l1, const Line & l2, + OutputIterator res) const + { + *res++=typename CK::Linear_kernel::Intersect_2()(l1, l2); + return res; + } + }; template < class CK > diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_intersections.h b/Circular_kernel_2/include/CGAL/Circular_kernel_intersections.h index 6548aa5cb9c..d30fc7c413a 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_intersections.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_intersections.h @@ -86,6 +86,13 @@ intersection(const Line_2 &c1, const Circle_2 &c2, OutputIterator res) return typename K::Intersect_2()(c1, c2, res); } +template < class OutputIterator, class K > +OutputIterator +intersection(const Line_2 &c1, const Line_2 &c2, OutputIterator res) +{ + return typename K::Intersect_2()(c1, c2, res); +} + CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_(Circular_arc_2, Circular_arc_2) CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_(Line_arc_2, Line_arc_2) CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_(Line_arc_2, Circle_2) From 3ce00989fc5f5097e9ebbcdea7aa02d0fbefdc4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 17 Jan 2017 10:19:32 +0100 Subject: [PATCH 2/2] update old code using Object with code using variants --- .../internal_functions_on_line_arc_2.h | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) 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 d398dd10c8b..baaeb3d5135 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 @@ -557,9 +557,6 @@ namespace CircularFunctors { const typename CK::Circular_arc_2 &c, OutputIterator res ) { - typedef std::vector solutions_container; - typedef typename CK::Circular_arc_point_2 Circular_arc_point_2; - #if defined(CGAL_CK_EXPLOIT_IDENTITY) || \ defined(CGAL_INTERSECTION_MAP_FOR_SUPPORTING_CIRCLES) typedef typename CK::Line_arc_2 Line_arc_2; @@ -667,7 +664,8 @@ namespace CircularFunctors { } #endif // CGAL_CK_EXPLOIT_IDENTITY - typedef std::vector solutions_container; + typedef std::vector::type> + solutions_container; solutions_container solutions; #ifdef CGAL_INTERSECTION_MAP_FOR_SUPPORTING_CIRCLES @@ -687,25 +685,30 @@ namespace CircularFunctors { } #endif + for (typename solutions_container::iterator it = solutions.begin(); - it != solutions.end(); ++it) { - const std::pair - *result = CGAL::object_cast - > (&(*it)); -#ifdef CGAL_CK_TEST_BBOX_BEFORE_HAS_ON - Bbox_2 rb = result->first.bbox(); - if(do_overlap(l.bbox(), rb) && do_overlap(c.bbox(),rb)){ - if (has_on(l,result->first,true) && - has_on(c,result->first,true)) { - *res++ = *it; - } - } -#else - if (has_on(l,result->first,true) && - has_on(c,result->first,true)) { + it != solutions.end(); ++it) + { + #if CGAL_INTERSECTION_VERSION < 2 + if(const std::pair* p = + object_cast< std::pair< typename CK::Circular_arc_point_2, unsigned> >(& (*it))) + { + #ifdef CGAL_CK_TEST_BBOX_BEFORE_HAS_ON + Bbox_2 rb = p->first.bbox(); + if(!do_overlap(l.bbox(), rb) || !do_overlap(c.bbox(),rb)) continue; + #endif + Has_on_visitor vis1(&l); + Has_on_visitor vis2(&c); + if(vis1(*p) && vis2(*p)) + *res++ = *it; + } + #else + if(boost::apply_visitor(Has_on_visitor(&l), *it) && + boost::apply_visitor(Has_on_visitor(&c), *it) ) + { *res++ = *it; } -#endif + #endif } return res; }