From b7c906cf00a1bb9e751b84bc82ec30e9e32f559a Mon Sep 17 00:00:00 2001 From: Pedro Machado Manhaes de Castro Date: Fri, 25 Jul 2008 15:02:26 +0000 Subject: [PATCH] global functions and do_intersect for CK_2 --- .gitattributes | 2 + .../Circular_kernel_2/intersecting_arcs.cpp | 2 +- .../function_objects_polynomial_circular.h | 13 +++ .../CGAL/Circular_kernel_2/interface_macros.h | 3 +- .../internal_functions_on_intersection_2.h | 84 ++++++++++++++++++ .../CGAL/Filtered_bbox_circular_kernel_2.h | 5 ++ .../bbox_filtered_intersections.h | 73 ++++++++++++++++ .../bbox_filtered_predicates.h | 11 +++ .../CGAL/_test_circles_constructions.h | 87 ++++++++----------- 9 files changed, 227 insertions(+), 53 deletions(-) create mode 100644 Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_intersection_2.h create mode 100644 Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2/bbox_filtered_intersections.h diff --git a/.gitattributes b/.gitattributes index e2136127bf2..4d2cc618d43 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1585,6 +1585,8 @@ Circular_kernel_2/demo/Circular_kernel_2/help/trash.jpeg -text svneol=unset#imag Circular_kernel_2/doc_tex/Circular_kernel_2/fig/Boolean_operation.png -text Circular_kernel_2/doc_tex/Circular_kernel_2/fig/Boolean_operation_detail.png -text Circular_kernel_2/examples/Circular_kernel_2/CMakeLists.txt -text +Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_intersection_2.h -text +Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2/bbox_filtered_intersections.h -text Circular_kernel_3/demo/Circular_kernel_3/images/button_axis.gif -text svneol=unset#image/gif Circular_kernel_3/demo/Circular_kernel_3/images/button_light.gif -text svneol=unset#image/gif Circular_kernel_3/demo/Circular_kernel_3/images/button_line.gif -text svneol=unset#image/gif diff --git a/Circular_kernel_2/examples/Circular_kernel_2/intersecting_arcs.cpp b/Circular_kernel_2/examples/Circular_kernel_2/intersecting_arcs.cpp index 9f70a03b742..86ad4fffc67 100644 --- a/Circular_kernel_2/examples/Circular_kernel_2/intersecting_arcs.cpp +++ b/Circular_kernel_2/examples/Circular_kernel_2/intersecting_arcs.cpp @@ -23,7 +23,7 @@ double prob_2() { if(CGAL::orientation(p4, p5, p6) != CGAL::COUNTERCLOCKWISE) std::swap(p4, p6); T o2 = T(p4, p5, p6); std::vector< CGAL::Object > res; - Circular_k().intersect_2_object()(o1, o2, std::back_inserter(res)); + CGAL::intersection(o1, o2, std::back_inserter(res)); prob += (res.size() != 0) ? 1.0 : 0.0; } return prob/10000.0; 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 1b90d8de92e..7f133a1a8da 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 @@ -25,6 +25,7 @@ #ifndef CGAL_CIRCULAR_KERNEL_FUNCTION_OBJECTS_POLYNOMIAL_CIRCULAR_H #define CGAL_CIRCULAR_KERNEL_FUNCTION_OBJECTS_POLYNOMIAL_CIRCULAR_H +#include #include #include #include @@ -538,6 +539,18 @@ template < class CK > }; + template < class CK > + class Do_intersect_2 + : public CK::Linear_kernel::Do_intersect_2 + { + public: + typedef typename CK::Linear_kernel::Do_intersect_2::result_type result_type; + template + result_type + operator()(const T1& t1, const T2& t2) const + { return CGALi::do_intersect(t1, t2, CK()); } + using CK::Linear_kernel::Do_intersect_2::operator(); + }; template < class CK > class Intersect_2 diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/interface_macros.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/interface_macros.h index c1a41c8097b..4b7ddd00baf 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/interface_macros.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/interface_macros.h @@ -99,7 +99,8 @@ CGAL_Circular_Kernel_pred(Has_on_unbounded_side_2, has_on_unbounded_side_2_object) CGAL_Circular_Kernel_pred(Bounded_side_2, bounded_side_2_object) CGAL_Circular_Kernel_pred(Collinear_2, collinear_2_object) - + CGAL_Circular_Kernel_pred(Do_intersect_2, do_intersect_2_object) + CGAL_Circular_Kernel_cons(Construct_supporting_circle_2, construct_supporting_circle_2_object) CGAL_Circular_Kernel_cons(Construct_supporting_line_2, diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_intersection_2.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_intersection_2.h new file mode 100644 index 00000000000..b083e863b09 --- /dev/null +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/internal_functions_on_intersection_2.h @@ -0,0 +1,84 @@ +// Copyright (c) 2003-2008 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you may redistribute it under +// the terms of the Q Public License version 1.0. +// See the file LICENSE.QPL distributed with CGAL. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// Author(s) : Monique Teillaud, Sylvain Pion, Pedro Machado + +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_CIRCULAR_KERNEL_INTERNAL_FUNCTIONS_ON_INTERSECTION_2_H +#define CGAL_CIRCULAR_KERNEL_INTERNAL_FUNCTIONS_ON_INTERSECTION_2_H + +#include +#include +#include +#include +#include + +CGAL_BEGIN_NAMESPACE + +#define CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_(A,B) \ +template < class OutputIterator, class K > \ +OutputIterator \ +intersection(const A &c1, const B &c2, OutputIterator res) \ +{ \ + return typename K::Intersect_2()(c1, c2, res); \ +} \ +namespace CGALi { \ + template \ + inline \ + bool \ + do_intersect(const typename K::A &c1, const typename K::B &c2, const K&) \ + { \ + std::vector< Object > res; \ + typename K::Intersect_2()(c1,c2,std::back_inserter(res)); \ + return res.size() != 0; \ + } \ +} \ +template \ +inline \ +bool \ +do_intersect(const A &c1, const B &c2) \ +{ \ + return typename K::Do_intersect_2()(c1, c2); \ +} + +// Circle_2 Circle_2 already has its do_intersect +// so it needs only the global intersection +template < class OutputIterator, class K > +OutputIterator +intersection(const Circle_2 &c1, const Circle_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) +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_(Circle_2, Line_arc_2) +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_(Line_arc_2, Circular_arc_2) +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_(Circular_arc_2, Line_arc_2) +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_(Line_2, Circular_arc_2) +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_(Line_2, Line_arc_2) +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_(Circular_arc_2, Line_2) +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_(Line_arc_2, Line_2) + +CGAL_END_NAMESPACE + +#endif // CGAL_CIRCULAR_KERNEL_INTERNAL_FUNCTIONS_ON_INTERSECTION_2_H diff --git a/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2.h b/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2.h index 433fc2ab55c..ce4d7d8fd56 100644 --- a/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2.h +++ b/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2.h @@ -79,6 +79,7 @@ template typedef Bbox_functors::Equal_2 Equal_2; typedef Bbox_functors::In_x_range_2 In_x_range_2; typedef Bbox_functors::Make_x_monotone_2 Make_x_monotone_2; + typedef Bbox_functors::Do_intersect_2 Do_intersect_2; typedef Bbox_functors::Intersect_2 Intersect_2; typedef Bbox_functors::Split_2 Split_2; typedef Bbox_functors::Is_vertical_2 Is_vertical_2; @@ -161,6 +162,10 @@ template Is_vertical_2 is_vertical_2_object() const { return Is_vertical_2(); } + + Do_intersect_2 + do_intersect_2_object() const + { return Do_intersect_2(); } }; CGAL_END_NAMESPACE diff --git a/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2/bbox_filtered_intersections.h b/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2/bbox_filtered_intersections.h new file mode 100644 index 00000000000..21d6286c009 --- /dev/null +++ b/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2/bbox_filtered_intersections.h @@ -0,0 +1,73 @@ +// Copyright (c) 2003-2008 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you may redistribute it under +// the terms of the Q Public License version 1.0. +// See the file LICENSE.QPL distributed with CGAL. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// Author(s) : Monique Teillaud, Sylvain Pion, Pedro Machado + +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_CIRCULAR_KERNEL_BBOX_FILTERED_INTERSECTIONS_2_H +#define CGAL_CIRCULAR_KERNEL_BBOX_FILTERED_INTERSECTIONS_2_H + +#include +#include +#include +#include +#include + +CGAL_BEGIN_NAMESPACE + +#define CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_FBBOX(A,B) \ +template < class OutputIterator, class K > \ +OutputIterator \ +intersection(const A &c1, const B &c2, OutputIterator res) \ +{ \ + return typename K::Intersect_2()(c1, c2, res); \ +} \ +namespace CGALi { \ + template \ + inline \ + bool \ + do_intersect(const typename K::A &c1, const typename K::B &c2, const K&) \ + { \ + std::vector< Object > res; \ + typename K::Intersect_2()(c1,c2,std::back_inserter(res)); \ + return res.size() != 0; \ + } \ +} \ +template \ +inline \ +bool \ +do_intersect(const A &c1, const B &c2) \ +{ \ + return typename K::Do_intersect_2()(c1, c2); \ +} + +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_FBBOX(Circular_arc_with_bbox_2, Circular_arc_with_bbox_2) +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_FBBOX(Line_arc_with_bbox_2, Line_arc_with_bbox_2) +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_FBBOX(Line_arc_with_bbox_2, Circular_arc_with_bbox_2) +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_FBBOX(Circular_arc_with_bbox_2, Line_arc_with_bbox_2) +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_FBBOX(Line_2, Circular_arc_with_bbox_2) +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_FBBOX(Line_2, Line_arc_with_bbox_2) +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_FBBOX(Circular_arc_with_bbox_2, Line_2) +CGAL_CIRCULAR_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_FBBOX(Line_arc_with_bbox_2, Line_2) + +CGAL_END_NAMESPACE + +#endif // CGAL_CIRCULAR_KERNEL_BBOX_FILTERED_INTERSECTIONS_2_H 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 7cba1071b81..0bc6da7a2e5 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 @@ -26,6 +26,7 @@ #ifndef CGAL_BBOX_FILTERED_PREDICATES_H #define CGAL_BBOX_FILTERED_PREDICATES_H +#include #include #include #include @@ -681,6 +682,16 @@ class Do_overlap_2 } }; + template < class BK > + class Do_intersect_2 + { + public: + typedef typename BK::Bool_type result_type; + template + result_type + operator()(const T1& t1, const T2& t2) const + { return CGALi::do_intersect(t1, t2, BK()); } + }; template < class BK > class Intersect_2 diff --git a/Circular_kernel_2/test/Circular_kernel_2/include/CGAL/_test_circles_constructions.h b/Circular_kernel_2/test/Circular_kernel_2/include/CGAL/_test_circles_constructions.h index 296a713e683..38f91da7195 100644 --- a/Circular_kernel_2/test/Circular_kernel_2/include/CGAL/_test_circles_constructions.h +++ b/Circular_kernel_2/test/Circular_kernel_2/include/CGAL/_test_circles_constructions.h @@ -45,6 +45,7 @@ void _test_circle_construct(CK ck) typedef typename CK::Get_equation Get_equation; //typedef typename CK::Polynomial_for_circles_2_2 Polynomial_for_circles_2_2; typedef typename CK::Compare_xy_2 Compare_xy_2; + typedef typename CK::Do_intersect_2 Do_intersect_2; #else typedef CK::Circle_2 Circle_2; typedef CK::Circular_arc_2 Circular_arc_2; @@ -102,6 +103,7 @@ void _test_circle_construct(CK ck) //Constuct_intersections_2 with 2 intersection's points std::cout << std::endl << "construct_intersection_2" << std::endl; + Do_intersect_2 theDo_intersect_2 = ck.do_intersect_2_object(); Intersect_2 theConstruct_intersect_2 = ck.intersect_2_object(); int center_circ_intersection_2_1_x = theRandom.get_int(random_min, random_max); @@ -125,6 +127,7 @@ void _test_circle_construct(CK ck) circ_intersections_2_2, std::back_inserter(vector_for_intersection_1)); // there are 2 intersection's points + assert(theDo_intersect_2(circ_intersections_2_1, circ_intersections_2_1)); std::pair the_pair; assert(assign(the_pair, vector_for_intersection_1[0])); Circular_arc_point_2 first = the_pair.first; @@ -155,6 +158,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_intersections_2_1, circ_intersections_2_3, std::back_inserter(vector_for_intersection_2)); + assert(theDo_intersect_2(circ_intersections_2_1, circ_intersections_2_3)); assert(vector_for_intersection_2.size() == 1); assign(the_pair, vector_for_intersection_2[0]); assert(the_pair.first == the_intersection_point_1); @@ -171,6 +175,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_intersections_2_1, circ_intersections_2_3_bis, std::back_inserter(vector_for_intersection_2_bis)); + assert(theDo_intersect_2(circ_intersections_2_1, circ_intersections_2_3_bis)); assert(vector_for_intersection_2_bis.size() == 1); assign(the_pair, vector_for_intersection_2_bis[0]); assert(the_pair.second == 2u); @@ -209,6 +214,8 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_2_1_part_low, circ_arc_2_1_low_part_high, std::back_inserter(vector_for_intersection_3)); + assert(theDo_intersect_2(circ_arc_2_1_part_low, circ_arc_2_1_low_part_high)); + /////////////std::cout << "The size: " << vector_for_intersection_3.size() << std::endl; assert(vector_for_intersection_3.size() == 2); assign(the_pair, vector_for_intersection_3[0]); @@ -275,6 +282,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_overlap_1, circ_arc_overlap_1, std::back_inserter(vector_for_intersection_the_same_arc)); + assert(theDo_intersect_2(circ_arc_overlap_1, circ_arc_overlap_1)); assert(vector_for_intersection_the_same_arc.size() == 1); Circular_arc_2 res_same; assert(assign(res_same, vector_for_intersection_the_same_arc[0])); @@ -289,6 +297,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_overlap_2, circ_arc_overlap_1, std::back_inserter(vector_for_intersection_overlap_1_1)); + assert(theDo_intersect_2(circ_arc_overlap_2, circ_arc_overlap_1)); Circular_arc_2 circ_arc_overlap_result(circ_intersections_2_1, line_arc_overlap_low_left, true, line_arc_overlap_low_right, false); @@ -301,6 +310,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_overlap_2, circ_arc_overlap_1, std::back_inserter(vector_for_intersection_overlap_1_2)); + assert(theDo_intersect_2(circ_arc_overlap_2, circ_arc_overlap_1)); assert(vector_for_intersection_overlap_1_2.size() == 1); assign(circ_arc_in_overlap, vector_for_intersection_overlap_1_2[0]); assert(circ_arc_in_overlap.source() == circ_arc_overlap_result.source()); @@ -313,6 +323,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_overlap_1, circ_arc_overlap_3, std::back_inserter(vector_for_intersection_overlap_2_1)); + assert(theDo_intersect_2(circ_arc_overlap_1, circ_arc_overlap_3)); assert(vector_for_intersection_overlap_2_1.size() == 1); assign(the_pair, vector_for_intersection_overlap_2_1[0]); std::cout << "x = " << the_pair.first.x() << " the result must be = " << @@ -338,6 +349,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_overlap_3, circ_arc_overlap_1, std::back_inserter(vector_for_intersection_overlap_2_2)); + assert(theDo_intersect_2(circ_arc_overlap_3, circ_arc_overlap_1)); assert(vector_for_intersection_overlap_2_2.size() == 1); assign(the_pair, vector_for_intersection_overlap_2_2[0]); std::cout << "x = " << the_pair.first.x() << " the result must be = " << @@ -362,18 +374,9 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_overlap_upper_part, circ_arc_overlap_lower_part, std::back_inserter(vector_for_intersection_overlap_3_1)); - + assert(theDo_intersect_2(circ_arc_overlap_upper_part, circ_arc_overlap_lower_part)); assert(vector_for_intersection_overlap_3_1.size() == 2); - assign(the_pair, vector_for_intersection_overlap_3_1[0]); // apagar depois - std::cout << "res1 = (" << - to_double(the_pair.first.x()) << ", " << - to_double(the_pair.first.y()) << ")" << std::endl; - assign(the_pair, vector_for_intersection_overlap_3_1[1]); - std::cout << "res2 = (" << - to_double(the_pair.first.x()) << ", " << - to_double(the_pair.first.y()) << ")" << std::endl; - assign(the_pair, vector_for_intersection_overlap_3_1[0]); assert(the_pair.first == circ_arc_overlap_lower_part.source()); //assert(the_pair.first.is_left()); @@ -385,6 +388,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_overlap_lower_part, circ_arc_overlap_upper_part, std::back_inserter(vector_for_intersection_overlap_3_2)); + assert(theDo_intersect_2(circ_arc_overlap_lower_part, circ_arc_overlap_upper_part)); assert(vector_for_intersection_overlap_3_2.size() == 2); assign(the_pair, vector_for_intersection_overlap_3_2[0]); @@ -412,6 +416,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_no_x_monotone_1, circ_intersections_2_4, std::back_inserter(vector_for_intersection_no_x_monotone_1_1)); + assert(theDo_intersect_2(circ_arc_no_x_monotone_1, circ_intersections_2_4)); assert(vector_for_intersection_no_x_monotone_1_1.size() == 2); assert(assign(the_pair, vector_for_intersection_no_x_monotone_1_1[0])); assert(the_pair.first == CGAL::circle_intersect(circ_intersections_2_1, @@ -439,6 +444,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_no_x_monotone_1, circ_intersections_2_5, std::back_inserter(vector_for_intersection_no_x_monotone_1_2)); + assert(theDo_intersect_2(circ_arc_no_x_monotone_1, circ_intersections_2_5)); assert(vector_for_intersection_no_x_monotone_1_2.size() == 1); assert(assign(the_pair, vector_for_intersection_no_x_monotone_1_2[0])); assert(the_pair.first == CGAL::circle_intersect(circ_intersections_2_1, @@ -461,6 +467,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_no_x_monotone_1, circ_intersections_2_6, std::back_inserter(vector_for_intersection_no_x_monotone_1_3)); + assert(theDo_intersect_2(circ_arc_no_x_monotone_1, circ_intersections_2_6)); assert(vector_for_intersection_no_x_monotone_1_3.size() == 1); assert(assign(the_pair, vector_for_intersection_no_x_monotone_1_3[0])); assert(the_pair.first == CGAL::circle_intersect(circ_intersections_2_1, @@ -481,6 +488,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_no_x_monotone_1, circ_intersections_2_7, std::back_inserter(vector_for_intersection_no_x_monotone_1_4)); + assert(theDo_intersect_2(circ_arc_no_x_monotone_1, circ_intersections_2_7)); assert(vector_for_intersection_no_x_monotone_1_4.size() == 1); assert(assign(the_pair, vector_for_intersection_no_x_monotone_1_4[0])); assert(the_pair.first == CGAL::circle_intersect(circ_intersections_2_1, @@ -500,6 +508,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_no_x_monotone_1, circ_intersections_2_8, std::back_inserter(vector_for_intersection_no_x_monotone_1_5)); + assert(theDo_intersect_2(circ_arc_no_x_monotone_1, circ_intersections_2_8)); assert(vector_for_intersection_no_x_monotone_1_5.size() == 1); assert(assign(the_pair, vector_for_intersection_no_x_monotone_1_5[0])); assert(the_pair.first == CGAL::circle_intersect(circ_intersections_2_1, @@ -519,6 +528,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_no_x_monotone_1, circ_intersections_2_9, std::back_inserter(vector_for_intersection_no_x_monotone_1_6)); + assert(theDo_intersect_2(circ_arc_no_x_monotone_1, circ_intersections_2_9)); assert(vector_for_intersection_no_x_monotone_1_6.size() == 1); assert(assign(the_pair, vector_for_intersection_no_x_monotone_1_6[0])); assert(the_pair.first == CGAL::circle_intersect(circ_intersections_2_1, @@ -538,6 +548,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_no_x_monotone_1, circ_arc_no_x_monotone_2, std::back_inserter(vector_for_intersection_no_x_monotone_2_1)); + assert(theDo_intersect_2(circ_arc_no_x_monotone_1, circ_arc_no_x_monotone_2)); assert(vector_for_intersection_no_x_monotone_2_1.size() == 1); assert(assign(circ_arc_in_overlap, vector_for_intersection_no_x_monotone_2_1[0])); assert(circ_arc_in_overlap.is_x_monotone()); @@ -558,6 +569,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_no_x_monotone_1, circ_arc_no_x_monotone_3, std::back_inserter(vector_for_intersection_no_x_monotone_2_2)); + assert(theDo_intersect_2(circ_arc_no_x_monotone_1, circ_arc_no_x_monotone_3)); assert(vector_for_intersection_no_x_monotone_2_2.size() == 1); assert(assign(circ_arc_in_overlap, vector_for_intersection_no_x_monotone_2_2[0])); assert(circ_arc_in_overlap.source() == circ_arc_no_x_monotone_1.source()); @@ -576,6 +588,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_no_x_monotone_1, circ_arc_no_x_monotone_4, std::back_inserter(vector_for_intersection_no_x_monotone_2_3)); + assert(theDo_intersect_2(circ_arc_no_x_monotone_1, circ_arc_no_x_monotone_4)); std::cout << vector_for_intersection_no_x_monotone_2_3.size() << std::endl; std::cout << vector_for_intersection_no_x_monotone_2_3.size() << std::endl; @@ -605,6 +618,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_no_x_monotone_4, circ_arc_no_x_monotone_5, std::back_inserter(vector_for_intersection_no_x_monotone_2_4)); + assert(theDo_intersect_2(circ_arc_no_x_monotone_4, circ_arc_no_x_monotone_5)); std::cout << vector_for_intersection_no_x_monotone_2_4.size() << std::endl; assert(vector_for_intersection_no_x_monotone_2_4.size() == 2); assert(assign(the_pair, vector_for_intersection_no_x_monotone_2_4[0])); @@ -625,6 +639,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_no_x_monotone_6, circ_arc_no_x_monotone_5, std::back_inserter(vector_for_intersection_no_x_monotone_2_5)); + assert(theDo_intersect_2(circ_arc_no_x_monotone_6, circ_arc_no_x_monotone_5)); std::cout << vector_for_intersection_no_x_monotone_2_5.size() << std::endl; assert(vector_for_intersection_no_x_monotone_2_5.size() == 1); assert(assign(the_pair, vector_for_intersection_no_x_monotone_2_5[0])); @@ -642,6 +657,7 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(circ_arc_no_x_monotone_7, circ_arc_no_x_monotone_4, std::back_inserter(vector_for_intersection_no_x_monotone_2_6)); + assert(theDo_intersect_2(circ_arc_no_x_monotone_7, circ_arc_no_x_monotone_4)); std::cout << vector_for_intersection_no_x_monotone_2_6.size() << std::endl; assert(vector_for_intersection_no_x_monotone_2_6.size() == 2); assign(circ_arc_in_overlap,vector_for_intersection_no_x_monotone_2_6[0]); @@ -779,46 +795,6 @@ void _test_circle_construct(CK ck) assert(circular_arc_2_random.is_x_monotone()); } - - std::cout << "Split_2_object " << std::endl; - //we make the circle1 - int center1_x = theRandom.get_int(random_min, random_max); - int center1_y = theRandom.get_int(random_min, random_max); - Point_2 center1(center1_x,center1_y); - int circ1_r = theRandom.get_int(1, random_max); - Circle_2 circ1(center1, circ1_r * circ1_r); - Point_2 center1_low_right(center1_x + circ1_r, center1_y - circ1_r); - Circle_2 circ1_low_right(center1_low_right, circ1_r * circ1_r); - Point_2 center1_low_left(center1_x - circ1_r, center1_y - circ1_r); - Circle_2 circ1_low_left(center1_low_left, circ1_r * circ1_r); - Point_2 point_2_left(center1_x - circ1_r, center1_y); - Line_2 theLine_2_horizontal(center1, point_2_left); - //The circ1_arc_high and circ1_arc_low are x_monotone - Circular_arc_2 circ1_arc_low(circ1, - theLine_2_horizontal,true, - theLine_2_horizontal, false); - //p1 is lefter and lower than p2 - Circular_arc_point_2 circ1_arc_end_p1 = - CGAL::circle_intersect(circ1, circ1_low_right, true); - Split_2 theSplit_2 = ck.split_2_object(); - Circular_arc_2 circ_arc_split_1; - Circular_arc_2 circ_arc_split_2; - theSplit_2(circ1_arc_low, circ1_arc_end_p1, - circ_arc_split_1, circ_arc_split_2); - assert(circ_arc_split_1.target() == circ1_arc_end_p1); - assert(circ1_arc_low.source() == circ_arc_split_1.source()); - assert(circ_arc_split_1.target() == circ_arc_split_2.source()); - assert(circ1_arc_low.target() == circ_arc_split_2.target()); - - //We used a point created without the support circle - Circular_arc_point_2 circ1_arc_end_p2 = - CGAL::circle_intersect(circ1_low_left, circ1_low_right, true); - theSplit_2(circ1_arc_low, circ1_arc_end_p2, - circ_arc_split_1, circ_arc_split_2); - assert(circ_arc_split_1.target() == circ1_arc_end_p2); - assert(circ1_arc_low.source() == circ_arc_split_1.source()); - assert(circ_arc_split_1.target() == circ_arc_split_2.source()); - assert(circ1_arc_low.target() == circ_arc_split_2.target()); //The commented code in bottom must create an error ////We used a point which is not on the arc @@ -850,12 +826,21 @@ void _test_circle_construct(CK ck) theConstruct_intersect_2(lo1, cao7, std::back_inserter(v_ll7)); theConstruct_intersect_2(lo1, cao8, std::back_inserter(v_ll8)); assert(v_ll1.size() == 2); + assert(theDo_intersect_2(lo1, cao1)); assert(v_ll2.size() == 2); + assert(theDo_intersect_2(lo1, cao2)); assert(v_ll3.size() == 1); + assert(theDo_intersect_2(lo1, cao3)); assert(v_ll4.size() == 1); + assert(theDo_intersect_2(lo1, cao4)); assert(v_ll5.size() == 0); + assert(!theDo_intersect_2(lo1, cao5)); assert(v_ll6.size() == 2); + assert(theDo_intersect_2(lo1, cao6)); assert(v_ll7.size() == 1); + assert(theDo_intersect_2(lo1, cao7)); assert(v_ll8.size() == 0); - + assert(!theDo_intersect_2(lo1, cao8)); + CGAL::intersection(lo1, cao8, std::back_inserter(v_ll8)); + CGAL::do_intersect(lo1, cao8); }