From 6e31445f6207e98557905f11cde0859a3d3dd6ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 30 Apr 2019 15:09:36 +0200 Subject: [PATCH 01/16] fix the prev/next pointers after polyline removal --- .../internal/Corefinement/face_graph_utils.h | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h index be442040d31..54019ea09c6 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h @@ -1612,6 +1612,7 @@ void remove_unused_polylines( } } + std::vector vertices_kept; BOOST_FOREACH(vertex_descriptor v, vertices_to_remove) { bool to_remove=true; @@ -1626,7 +1627,31 @@ void remove_unused_polylines( } if (to_remove) remove_vertex(v,tm); + else + vertices_kept.push_back(v); } + + // update next/prev pointers around vertices in vertices_kept + BOOST_FOREACH(vertex_descriptor v, vertices_kept) + { + halfedge_descriptor h = halfedge(v, tm), start=GT::null_halfedge(); + + do{ + while ( !is_border(h, tm) || is_border(opposite(h, tm), tm) ) + h = opposite(next(h, tm), tm); + halfedge_descriptor in = h; + if (start==GT::null_halfedge()) + start=in; + else + if (start==in) + break; + while ( is_border(h, tm) ) + h = opposite(next(h, tm), tm); + set_next(in, opposite(h, tm), tm); + } + while(true);//this loop handles non-manifold vertices + } + BOOST_FOREACH(edge_descriptor e, edges_to_remove) remove_edge(e,tm); } From 621542afbd2532190e0ecacc71bc8de36e685bba Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 16 May 2019 15:10:40 +0200 Subject: [PATCH 02/16] Add Epick_without_intervals That `Epick` without the dynamic filters: only the static filters are applied before the exact computation. --- Convex_hull_3/test/Convex_hull_3/test_extreme_points.cpp | 2 +- .../test/Convex_hull_3/test_halfspace_intersections.cpp | 2 ++ .../CGAL/Exact_predicates_inexact_constructions_kernel.h | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Convex_hull_3/test/Convex_hull_3/test_extreme_points.cpp b/Convex_hull_3/test/Convex_hull_3/test_extreme_points.cpp index 0e9f60afdbd..d217ee357d2 100644 --- a/Convex_hull_3/test/Convex_hull_3/test_extreme_points.cpp +++ b/Convex_hull_3/test/Convex_hull_3/test_extreme_points.cpp @@ -14,7 +14,7 @@ #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Epick_without_intervals K; typedef CGAL::Polyhedron_3 Polyhedron_3; typedef K::Point_3 Point_3; diff --git a/Convex_hull_3/test/Convex_hull_3/test_halfspace_intersections.cpp b/Convex_hull_3/test/Convex_hull_3/test_halfspace_intersections.cpp index 385236066d9..623dec0cc25 100644 --- a/Convex_hull_3/test/Convex_hull_3/test_halfspace_intersections.cpp +++ b/Convex_hull_3/test/Convex_hull_3/test_halfspace_intersections.cpp @@ -81,4 +81,6 @@ int main() test >(); test >(); test >(); + test >(); } diff --git a/Kernel_23/include/CGAL/Exact_predicates_inexact_constructions_kernel.h b/Kernel_23/include/CGAL/Exact_predicates_inexact_constructions_kernel.h index d30bcd7adca..0677d285d24 100644 --- a/Kernel_23/include/CGAL/Exact_predicates_inexact_constructions_kernel.h +++ b/Kernel_23/include/CGAL/Exact_predicates_inexact_constructions_kernel.h @@ -45,6 +45,12 @@ class Epick #endif {}; +class Epick_without_intervals + : public Static_filters_base< + Type_equality_wrapper< Simple_cartesian::Base::Type, + Epick_without_intervals > > +{}; + typedef Epick Exact_predicates_inexact_constructions_kernel; template <> From 162544dade187954dce6b1e0c352cb6b38d9a25b Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 16 May 2019 15:27:46 +0200 Subject: [PATCH 03/16] Add a test of Epick_without_intervals in Kernel_23 --- Kernel_23/test/Kernel_23/Simple_cartesian.cpp | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/Kernel_23/test/Kernel_23/Simple_cartesian.cpp b/Kernel_23/test/Kernel_23/Simple_cartesian.cpp index 10d2e4a2fd6..71900f364a5 100644 --- a/Kernel_23/test/Kernel_23/Simple_cartesian.cpp +++ b/Kernel_23/test/Kernel_23/Simple_cartesian.cpp @@ -22,6 +22,7 @@ #include +#include #include #include @@ -46,30 +47,26 @@ #include "CGAL/_test_mf_plane_3_to_2d.h" -int -main() -{ - typedef CGAL::Simple_cartesian Clsd; - std::cout << "Testing IO with Simple_cartesian :" << std::endl; - _test_io( Clsd() ); +#include - typedef CGAL::Simple_cartesian > Cls; - std::cout << "Testing 2d with Simple_cartesian> :"; +template +void test_kernel(std::string kernel_name, Cls) { + std::cout << "Testing 2d with "+kernel_name+" :"; std::cout << std::endl; _test_2( Cls() ); - std::cout << "Testing 3d with Simple_cartesian> :"; + std::cout << "Testing 3d with "+kernel_name+" :"; std::cout << std::endl; _test_3( Cls() ); - std::cout << "Testing new 2d with Simple_cartesian>:"; + std::cout << "Testing new 2d with "+kernel_name+" :"; std::cout << std::endl; test_new_2( Cls() ); - std::cout << "Testing new 3d with Simple_cartesian>:"; + std::cout << "Testing new 3d with "+kernel_name+" :"; std::cout << std::endl; test_new_3( Cls() ); - std::cout << "Testing new parts with Simple_cartesian> :"; + std::cout << "Testing new parts with "+kernel_name+" :"; std::cout << std::endl; _test_orientation_and_bounded_side( Cls() ); _test_fct_points_implicit_sphere( Cls() ); @@ -80,9 +77,21 @@ main() _test_cls_iso_cuboid_3( Cls() ); _test_angle( Cls() ); - std::cout << "Testing 3d-2d with Simple_cartesian>:"; + std::cout << "Testing 3d-2d with "+kernel_name+" :"; std::cout << std::endl; _test_mf_plane_3_to_2d( Cls() ); +} +int +main() +{ + typedef CGAL::Simple_cartesian Clsd; + std::cout << "Testing IO with Simple_cartesian :" << std::endl; + _test_io( Clsd() ); + + typedef CGAL::Simple_cartesian > Cls; + test_kernel("Simple_cartesian>", Cls()); + typedef CGAL::Simple_cartesian > Cls; + test_kernel("Epick_without_intervals", CGAL::Epick_without_intervals()); return 0; } From 7105406ee11a08742b19d1f98518d2ba5ed9605c Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 16 May 2019 15:27:35 +0200 Subject: [PATCH 04/16] Fix warnings with CGAL_USE --- .../include/CGAL/_test_cls_aff_transformation_2.h | 4 +++- .../include/CGAL/_test_cls_aff_transformation_3.h | 4 +++- .../Kernel_23/include/CGAL/_test_cls_direction_2.h | 4 +++- .../Kernel_23/include/CGAL/_test_cls_direction_3.h | 4 +++- .../test/Kernel_23/include/CGAL/_test_cls_line_3.h | 6 ++++-- .../test/Kernel_23/include/CGAL/_test_cls_plane_3.h | 10 ++++++---- .../test/Kernel_23/include/CGAL/_test_cls_point_2.h | 3 ++- .../test/Kernel_23/include/CGAL/_test_cls_point_3.h | 3 ++- .../test/Kernel_23/include/CGAL/_test_cls_vector_2.h | 4 +++- .../test/Kernel_23/include/CGAL/_test_cls_vector_3.h | 4 +++- 10 files changed, 32 insertions(+), 14 deletions(-) diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h index 23aff3a4c96..86c8c4d8d6d 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_AFF_TRANSFORMATION_2_H #define CGAL__TEST_CLS_AFF_TRANSFORMATION_2_H +#include + template bool _test_cls_aff_transformation_2(const R& ) @@ -56,7 +58,7 @@ _test_cls_aff_transformation_2(const R& ) CGAL::Vector_2 tvec; CGAL::Point_2 pnt( n8, n1, n10 ); // ( 6,-5) CGAL::Point_2 tpnt; - CGAL::Point_2 pvec = CGAL::ORIGIN + vec; + CGAL::Point_2 pvec = CGAL::ORIGIN + vec; CGAL_USE(pvec); CGAL::Vector_2 vpnt = pnt - CGAL::ORIGIN; CGAL::Point_2 p1(-n3, n7, n3 ); // (-1, 2) diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h index a186c20d14a..6a30e82c11d 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_AFF_TRANSFORMATION_3_H #define CGAL__TEST_CLS_AFF_TRANSFORMATION_3_H +#include + template bool _test_cls_aff_transformation_3(const R& ) @@ -56,7 +58,7 @@ _test_cls_aff_transformation_3(const R& ) CGAL::Vector_3 tvec; CGAL::Point_3 pnt( n8, n1, n9, n10 ); // ( 6,-5, 3) CGAL::Point_3 tpnt; - CGAL::Point_3 pvec = CGAL::ORIGIN + vec; + CGAL::Point_3 pvec = CGAL::ORIGIN + vec; CGAL_USE(pvec); CGAL::Vector_3 vpnt = pnt - CGAL::ORIGIN; CGAL::Point_3 p1(-n3, n7, n11, n3 ); // (-1, 2,-3) diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_2.h index 07106cadb25..93800057c5c 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_2.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_DIRECTION_2_H #define CGAL__TEST_CLS_DIRECTION_2_H +#include + template bool _test_cls_direction_2(const R& ) @@ -34,7 +36,7 @@ _test_cls_direction_2(const R& ) typename R::Direction_2 id; CGAL::Direction_2 d0; - CGAL::Direction_2 d1(id); + CGAL::Direction_2 d1(id); CGAL_USE(d1); std::cout << '.'; RT n0 = 10; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_3.h index d25d0ad830d..afdb4cff38a 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_3.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_DIRECTION_3_H #define CGAL__TEST_CLS_DIRECTION_3_H +#include + template bool _test_cls_direction_3(const R& ) @@ -35,7 +37,7 @@ _test_cls_direction_3(const R& ) typename R::Direction_3 id; CGAL::Direction_3 d0; - CGAL::Direction_3 d1(id); + CGAL::Direction_3 d1(id); CGAL_USE(d1); std::cout << '.'; RT n0 = 10; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h index af722474195..35190bc4742 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_LINE_3_H #define CGAL__TEST_CLS_LINE_3_H +#include + template bool _test_cls_line_3(const R& ) @@ -33,8 +35,8 @@ _test_cls_line_3(const R& ) typedef typename R::RT RT; typename R::Line_3 il; - CGAL::Line_3 l0( il ); - CGAL::Line_3 l1; + CGAL::Line_3 l0( il ); CGAL_USE(l0); + CGAL::Line_3 l1; CGAL_USE(l1); RT n1 = 3; RT n2 = 53; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_plane_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_plane_3.h index a62e3a2a22d..bf423e8bf09 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_plane_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_plane_3.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_PLANE_3_H #define CGAL__TEST_CLS_PLANE_3_H +#include + template bool _test_cls_plane_3(const R& ) @@ -34,7 +36,7 @@ _test_cls_plane_3(const R& ) typedef typename R::FT FT; typename R::Plane_3 ip; - CGAL::Plane_3 pl0(ip); + CGAL::Plane_3 pl0(ip); CGAL_USE(pl0); RT x1 = -1; RT x2 = 4; @@ -45,7 +47,7 @@ _test_cls_plane_3(const R& ) py(RT(0),RT(1),RT(0)), pz(RT(0),RT(0),RT(1)); - CGAL::Point_3 p3(p1); + CGAL::Point_3 p3(p1); CGAL_USE(p3); CGAL::Direction_3 d1( RT(5), RT(-5), RT(10) ); CGAL::Vector_3 v1 = d1.vector(); @@ -121,8 +123,8 @@ _test_cls_plane_3(const R& ) assert( xy_pl.has_on( gnup ) ); CGAL::Vector_3 nov = pl1.orthogonal_vector(); - CGAL::Vector_3 vb1 = pl1.base1(); - CGAL::Vector_3 vb2 = pl1.base2(); + CGAL::Vector_3 vb1 = pl1.base1(); CGAL_USE(vb1); + CGAL::Vector_3 vb2 = pl1.base2(); CGAL_USE(vb2); assert( (nov*pl1.base1()) == FT(0)&&(nov*pl1.base2()) == FT(0) ); assert( (pl1.base2()*pl1.base1()) == FT(0) ); assert( pl1.has_on(pl1.point() + pl1.base1()) ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_2.h index 802b5482037..6a5a6d4d967 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_2.h @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -49,7 +50,7 @@ _test_cls_point_2(const R& ) typedef typename R::Point_2::Cartesian_const_iterator CCI; CGAL::Point_2 p1; - CGAL::Point_2 p2(ip); + CGAL::Point_2 p2(ip); CGAL_USE(p2); CGAL::Point_2 p0(CGAL::ORIGIN); RT n1(-35 ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_3.h index a54a062e8db..45b61412639 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_3.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -46,7 +47,7 @@ _test_cls_point_3(const R& ) typedef typename R::Point_3::Cartesian_const_iterator CCI; CGAL::Point_3 p1; - CGAL::Point_3 p2(ip); + CGAL::Point_3 p2(ip); CGAL_USE(p2); CGAL::Point_3 p0(CGAL::ORIGIN); RT n1(-35 ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_2.h index 0ea7a3f621f..8b4b1b5d6af 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_2.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_VECTOR_2_H #define CGAL__TEST_CLS_VECTOR_2_H +#include + template bool _test_cls_vector_2(const R& ) @@ -37,7 +39,7 @@ _test_cls_vector_2(const R& ) typedef typename R::Vector_2::Cartesian_const_iterator CCI; CGAL::Vector_2 v1; - CGAL::Vector_2 v2(iv); + CGAL::Vector_2 v2(iv); CGAL_USE(v2); CGAL::Vector_2 v0(CGAL::NULL_VECTOR); RT n1( 12 ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_3.h index e2b35fab772..7477b855d28 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_3.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_VECTOR_3_H #define CGAL__TEST_CLS_VECTOR_3_H +#include + template bool _test_cls_vector_3(const R& ) @@ -37,7 +39,7 @@ _test_cls_vector_3(const R& ) typedef typename R::Vector_3::Cartesian_const_iterator CCI; CGAL::Vector_3 v1; - CGAL::Vector_3 v2(iv); + CGAL::Vector_3 v2(iv); CGAL_USE(v2); CGAL::Vector_3 v0(CGAL::NULL_VECTOR); RT n1( 12 ); From 086136716932fba420474e7608c7ced5e101a75c Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 22 May 2019 12:06:40 +0200 Subject: [PATCH 05/16] Replace the planes by a vector+point The idea with those planes is a sort of pre-computation of minors of the determinant of the orientation of `(p,q,r,s)`, with `(p,q,r)` fixed. But the three minors are only the coordinates `(a,b,c)` of the plane defined by `(p,q,r)`, and the coordinate `d` is the determinant of the orientation of `(p,q,r,O)` where `O` is the origin of the Euclidean plane. We do not want to compute that `d`! So, instead of computing planes, one computes only the normal `(a,b,c)` of the plan `(p,q,r)`, and a stores it with `p`. That allows to compute the determinant of `orientation(p,q,r,s)` once `s` is known. --- Convex_hull_3/include/CGAL/convex_hull_3.h | 52 +++++++++++++++------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/Convex_hull_3/include/CGAL/convex_hull_3.h b/Convex_hull_3/include/CGAL/convex_hull_3.h index 531bfd3d943..ba0200f7164 100644 --- a/Convex_hull_3/include/CGAL/convex_hull_3.h +++ b/Convex_hull_3/include/CGAL/convex_hull_3.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -236,17 +237,23 @@ public: //and in case of failure, exact arithmetic is used. template class Is_on_positive_side_of_plane_3, boost::true_type >{ - typedef Simple_cartesian::Type> PK; - typedef Simple_cartesian CK; + typedef Simple_cartesian::Type> Exact_K; + typedef Simple_cartesian Approx_K; typedef Convex_hull_traits_3 Traits; typedef typename Traits::Point_3 Point_3; - Cartesian_converter to_CK; - Cartesian_converter to_PK; + Cartesian_converter to_AK; + Cartesian_converter to_EK; + + template + struct Vector_plus_point { + typename K::Vector_3 vector; + typename K::Point_3 point; + }; const Point_3& p,q,r; - mutable typename CK::Plane_3* ck_plane; - mutable typename PK::Plane_3* pk_plane; + mutable Vector_plus_point ak_plane; + mutable Vector_plus_point* ek_plane_ptr; double m10,m20,m21,Maxx,Maxy,Maxz; @@ -292,8 +299,13 @@ public: typedef typename Interval_nt_advanced::Protector Protector; Is_on_positive_side_of_plane_3(const Traits&,const Point_3& p_,const Point_3& q_,const Point_3& r_) - :p(p_),q(q_),r(r_),ck_plane(NULL),pk_plane(NULL) + : p(p_),q(q_),r(r_) + , ak_plane() + , ek_plane_ptr(0) { + ak_plane.vector = + typename Approx_K::Vector_3(Interval_nt_advanced(0., std::numeric_limits::infinity()), + 0., 0.); double pqx = q.x() - p.x(); double pqy = q.y() - p.y(); double pqz = q.z() - p.z(); @@ -319,8 +331,7 @@ public: } ~Is_on_positive_side_of_plane_3(){ - if (ck_plane!=NULL) delete ck_plane; - if (pk_plane!=NULL) delete pk_plane; + if (ek_plane_ptr!=NULL) delete ek_plane_ptr; } bool operator() (const Point_3& s) const @@ -334,14 +345,25 @@ public: return static_res == 1; try{ - if (ck_plane==NULL) - ck_plane=new typename CK::Plane_3(to_CK(p),to_CK(q),to_CK(r)); - return ck_plane->has_on_positive_side(to_CK(s)); + // infinity() is the sentinel for uninitialized `ak_plane` + if (ak_plane.vector.x().sup() == std::numeric_limits::infinity()) + { + const typename Approx_K::Point_3 ap = to_AK(p); + ak_plane.vector = cross_product(to_AK(q)-ap, to_AK(r)-ap); + ak_plane.point = ap; + } + return sign(scalar_product(to_AK(s) - ak_plane.point, + ak_plane.vector)) == POSITIVE; } catch (Uncertain_conversion_exception&){ - if (pk_plane==NULL) - pk_plane=new typename PK::Plane_3(to_PK(p),to_PK(q),to_PK(r)); - return pk_plane->has_on_positive_side(to_PK(s)); + if (ek_plane_ptr==NULL) { + const typename Exact_K::Point_3 ep = to_EK(p); + ek_plane_ptr = new Vector_plus_point; + ek_plane_ptr->vector = cross_product(to_EK(q)-ep, to_EK(r)-ep); + ek_plane_ptr->point = ep; + } + return sign(scalar_product(to_EK(s) - ek_plane_ptr->point, + ek_plane_ptr->vector)) == POSITIVE; } } }; From a126f2173e195ef8748110b28f4236b33a4e6217 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 22 May 2019 15:21:50 +0200 Subject: [PATCH 06/16] Use is_certain to avoid throwing exceptions --- Convex_hull_3/include/CGAL/convex_hull_3.h | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Convex_hull_3/include/CGAL/convex_hull_3.h b/Convex_hull_3/include/CGAL/convex_hull_3.h index ba0200f7164..18f5464f93a 100644 --- a/Convex_hull_3/include/CGAL/convex_hull_3.h +++ b/Convex_hull_3/include/CGAL/convex_hull_3.h @@ -352,19 +352,22 @@ public: ak_plane.vector = cross_product(to_AK(q)-ap, to_AK(r)-ap); ak_plane.point = ap; } - return sign(scalar_product(to_AK(s) - ak_plane.point, - ak_plane.vector)) == POSITIVE; - } - catch (Uncertain_conversion_exception&){ - if (ek_plane_ptr==NULL) { - const typename Exact_K::Point_3 ep = to_EK(p); - ek_plane_ptr = new Vector_plus_point; - ek_plane_ptr->vector = cross_product(to_EK(q)-ep, to_EK(r)-ep); - ek_plane_ptr->point = ep; + Uncertain res = + sign(scalar_product(to_AK(s) - ak_plane.point, + ak_plane.vector)); + if(is_certain(res)) { + return (get_certain(res) == POSITIVE); } - return sign(scalar_product(to_EK(s) - ek_plane_ptr->point, - ek_plane_ptr->vector)) == POSITIVE; } + catch (Uncertain_conversion_exception&){} + if (ek_plane_ptr==NULL) { + const typename Exact_K::Point_3 ep = to_EK(p); + ek_plane_ptr = new Vector_plus_point; + ek_plane_ptr->vector = cross_product(to_EK(q)-ep, to_EK(r)-ep); + ek_plane_ptr->point = ep; + } + return sign(scalar_product(to_EK(s) - ek_plane_ptr->point, + ek_plane_ptr->vector)) == POSITIVE; } }; From 4ac7d2004d94dc2106bbc1c1dc5adad103d39d03 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 24 May 2019 17:32:14 +0200 Subject: [PATCH 07/16] Improve doc --- .../doc/Convex_hull_3/CGAL/convex_hull_3.h | 8 ++++---- Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt | 14 +++++++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3.h b/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3.h index 6227b56d944..bc83e1d13a0 100644 --- a/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3.h +++ b/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3.h @@ -4,7 +4,7 @@ namespace CGAL { \ingroup PkgConvexHull3Functions \brief computes the convex hull of the set of points in the range -[`first`, `last`). The polyhedron `pm` is cleared, then +[`first`, `last`). The polygon mesh `pm` is cleared, then the convex hull is stored in `pm`. Note that the convex hull will be triangulated, that is `pm` will contain only triangular facets. if the convex hull is a point or a segment, endpoints will be added in `pm` as isolated vertices. @@ -39,9 +39,9 @@ void convex_hull_3(InputIterator first, InputIterator last, PolygonMesh& pm, con \brief computes the convex hull of the set of points in the range [`first`, `last`). The result, which may be a point, a segment, -a triangle, or a polyhedron, is stored in `ch_object`. -In the case the result is a polyhedron, the convex hull will be triangulated, -that is the polyhedron will contain only triangular facets. +a triangle, or a polygon mesh, is stored in `ch_object`. +In the case the result is a polygon mesh, the convex hull will be triangulated, +that is the polygon mesh will contain only triangular facets. \tparam InputIterator must be an input iterator with a value type equivalent to `Traits::Point_3`. \tparam Traits must be model of the concept `ConvexHullTraits_3`. diff --git a/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt b/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt index 74ef744c7b3..a14a9f07703 100644 --- a/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt +++ b/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt @@ -49,11 +49,19 @@ computing the hull. The function `convex_hull_3()` is parameterized by a traits class, which specifies the types and geometric primitives to be used in the -computation. If input points from a kernel with exact predicates +computation. As the function constructs 3D planes from three input +points, we cannot simply pass a kernel with inexact constructions as +optional argument for the traits class. + +If input points from a kernel with exact predicates and non-exact constructions are used, and a certified result is expected, the traits `Convex_hull_traits_3` should be used -(`R` being the input kernel). Note that the default traits class takes this into -account. +(`R` being the input kernel). +If the constructions from a kernel are exact this kernel can be used +directly as a traits class. + +Note that the default traits class takes this into account, that is the +above considerations are only important for custom traits classes. \subsubsection Convex_hull_3Example Example From 44e606571078c72168f74bdfcc93714a6e424357 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 24 May 2019 17:47:25 +0200 Subject: [PATCH 08/16] Improve documentation --- .../doc/Convex_hull_3/CGAL/Convex_hull_traits_3.h | 7 +++++++ Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_traits_3.h b/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_traits_3.h index 1c8b0619343..ee7e28c9b7e 100644 --- a/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_traits_3.h +++ b/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_traits_3.h @@ -13,6 +13,13 @@ function when `R` is a kernel with exact predicates but inexact constructions \cgalModels `IsStronglyConvexTraits_3` \attention The user must include the header file of the polygon mesh type, even for the default type. + +\cgalAdvancedBegin +This class has a fourth undocumented template argument. Passing `CGAL::Tag_false` +switches off a caching of a plane with coordinates with interval arithmetic. +Instead an orientation test of four points is performed. +\cgalAdvancedEnd + */ template< typename R, typename PolygonMesh = Polyhedron_3 > class Convex_hull_traits_3 { diff --git a/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt b/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt index a14a9f07703..b7d25b6b505 100644 --- a/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt +++ b/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt @@ -55,7 +55,7 @@ optional argument for the traits class. If input points from a kernel with exact predicates and non-exact constructions are used, and a certified result is expected, -the traits `Convex_hull_traits_3` should be used +the class `Convex_hull_traits_3` should be used (`R` being the input kernel). If the constructions from a kernel are exact this kernel can be used directly as a traits class. From f94122b31b0b96d69ed7ed6c44bcadf17822aed0 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 13 Jun 2019 09:11:02 +0200 Subject: [PATCH 09/16] Add a testsuite for Epick --- .../test/Kernel_23/Filtered_cartesian.cpp | 13 +++++- .../Kernel_23/include/CGAL/_approx_equal.h | 44 +++++++++++++++++++ .../include/CGAL/_test_fct_weighted_point_2.h | 7 ++- .../include/CGAL/_test_further_fct_point_2.h | 6 ++- 4 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 Kernel_23/test/Kernel_23/include/CGAL/_approx_equal.h diff --git a/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp b/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp index 841aeb1fcd3..19d96c02f2b 100644 --- a/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp +++ b/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp @@ -27,6 +27,7 @@ #include #include +#include #include @@ -52,9 +53,12 @@ #include "CGAL/_test_mf_plane_3_to_2d.h" +template +void test(); int main() { + CGAL::force_ieee_double_precision(); typedef CGAL::Cartesian Clsdb; typedef CGAL::Filtered_kernel Clsd; @@ -71,6 +75,13 @@ main() std::cout << "Testing IO with F_k>:" << std::endl; _test_io( Clsd() ); + std::cout << "Testing with Epick:\n"; + test(); + return 0; +} + +template +void test() { std::cout << "Testing 2d :"; std::cout << std::endl; _test_2( Cls() ); @@ -101,6 +112,4 @@ main() std::cout << "Testing 3d-2d :"; std::cout << std::endl; _test_mf_plane_3_to_2d( Cls() ); - - return 0; } diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_approx_equal.h b/Kernel_23/test/Kernel_23/include/CGAL/_approx_equal.h new file mode 100644 index 00000000000..361d0800554 --- /dev/null +++ b/Kernel_23/test/Kernel_23/include/CGAL/_approx_equal.h @@ -0,0 +1,44 @@ +#ifndef CGAL_TESTSUITE_APPROX_EQUAL_H +#define CGAL_TESTSUITE_APPROX_EQUAL_H +#include + +namespace CGAL { +namespace testsuite { + +template +bool approx_equal(FT a, FT b) { return a == b; } + +bool approx_equal(double a, double b) { + return std::abs(boost::math::float_distance(a, b)) <= 1; +} + +struct Xyz_tag {}; +struct Xy_tag {}; + +template +bool approx_equal(Object a, Object b, CGAL::testsuite::Xyz_tag) +{ + return approx_equal(a.x(), b.x()) && + approx_equal(a.y(), b.y()) && + approx_equal(a.z(), b.z()); +} + +template +bool approx_equal(Object a, Object b, CGAL::testsuite::Xy_tag) +{ + return approx_equal(a.x(), b.x()) && approx_equal(a.y(), b.y()); +} + +struct Direction_2_tag {}; +template +bool approx_equal(Object a, Object b, CGAL::testsuite::Direction_2_tag) +{ + return CGAL_NTS sign(a.dx()) == CGAL_NTS sign(a.dx()) + && CGAL_NTS sign(a.dy()) == CGAL_NTS sign(b.dy()) + && approx_equal(a.dx() * b.dy(), a.dy() * b.dx()); +} + +} // end namespace testsuite +} // end namespace CGAL + +#endif // CGAL_TESTSUITE_APPROX_EQUAL_H diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_2.h index dbe58ed1121..a0ffb40e8be 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_2.h @@ -31,6 +31,8 @@ #include #include +#include "_approx_equal.h" + template bool _test_fct_weighted_point_2(const R& ) @@ -158,8 +160,9 @@ _test_fct_weighted_point_2(const R& ) std::cout << CGAL::weighted_circumcenter(wp_00, wp_10, wp_01) << std::endl; - assert( CGAL::squared_radius_smallest_orthogonal_circle(wp1, wp3, wp5) - == CGAL::squared_radius(p1, p3, p5)); + using CGAL::testsuite::approx_equal; + assert( approx_equal(CGAL::squared_radius_smallest_orthogonal_circle(wp1, wp3, wp5), + CGAL::squared_radius(p1, p3, p5)) ); assert( CGAL::squared_radius_smallest_orthogonal_circle(wp_00, wp_10, wp_01) == RT(0)); std::cout << "done" << std::endl; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h index f17c9028deb..cf498947577 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_FURTHER_FCT_POINT_2_H #define CGAL__TEST_FURTHER_FCT_POINT_2_H +#include "_approx_equal.h" + template bool _test_further_fct_point_2(const R& ) @@ -95,8 +97,10 @@ _test_further_fct_point_2(const R& ) p4 = p0.transform(rotate4); p5 = p0.transform(rotate5); + using CGAL::testsuite::approx_equal; + using CGAL::testsuite::Direction_2_tag; - assert( (p5 - CGAL::ORIGIN).direction() == dir5 ); + assert( approx_equal((p5 - CGAL::ORIGIN).direction(), dir5, Direction_2_tag()) ); assert( CGAL::side_of_bounded_circle(p1, p2, p3, CGAL::Point_2(CGAL::ORIGIN))\ == CGAL::ON_BOUNDED_SIDE ); From 3b2b6bb468e05ec91dda4e0b909e39e02257e034 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 13 Jun 2019 09:11:12 +0200 Subject: [PATCH 10/16] Fix that incorrect testsuite of Epick_without_intervals --- Kernel_23/test/Kernel_23/Simple_cartesian.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Kernel_23/test/Kernel_23/Simple_cartesian.cpp b/Kernel_23/test/Kernel_23/Simple_cartesian.cpp index 71900f364a5..4058ddaa5b3 100644 --- a/Kernel_23/test/Kernel_23/Simple_cartesian.cpp +++ b/Kernel_23/test/Kernel_23/Simple_cartesian.cpp @@ -22,7 +22,6 @@ #include -#include #include #include @@ -91,7 +90,5 @@ main() typedef CGAL::Simple_cartesian > Cls; test_kernel("Simple_cartesian>", Cls()); - typedef CGAL::Simple_cartesian > Cls; - test_kernel("Epick_without_intervals", CGAL::Epick_without_intervals()); return 0; } From 7d543d5bf80ae5fe3d0075d52b9750e3a0115fbc Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 13 Jun 2019 15:06:19 +0200 Subject: [PATCH 11/16] Add a testsuite for Epick and Epick_without_intervals --- .../test/Kernel_23/Filtered_cartesian.cpp | 6 ++- .../CGAL/_test_cls_aff_transformation_2.h | 19 ++++---- .../CGAL/_test_cls_aff_transformation_3.h | 34 +++++++------- .../include/CGAL/_test_cls_circle_2.h | 14 ++++-- .../Kernel_23/include/CGAL/_test_cls_line_3.h | 12 +++-- .../include/CGAL/_test_cls_sphere_3.h | 26 ++++++----- .../CGAL/_test_fct_points_implicit_sphere.h | 28 ++++++----- .../include/CGAL/_test_fct_weighted_point_3.h | 8 ++-- .../include/CGAL/_test_further_fct_point_2.h | 19 ++++---- .../include/CGAL/_test_mf_plane_3_to_2d.h | 46 ++++++++++--------- 10 files changed, 121 insertions(+), 91 deletions(-) diff --git a/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp b/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp index 19d96c02f2b..25a57e1965e 100644 --- a/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp +++ b/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp @@ -75,8 +75,12 @@ main() std::cout << "Testing IO with F_k>:" << std::endl; _test_io( Clsd() ); - std::cout << "Testing with Epick:\n"; + std::cout << "Testing with Epeck:\n"; test(); + std::cout << "Testing with Epick:\n"; + test(); + std::cout << "Testing with Epick_without_intervals:\n"; + test(); return 0; } diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h index 86c8c4d8d6d..fe63c96b789 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h @@ -25,6 +25,7 @@ #define CGAL__TEST_CLS_AFF_TRANSFORMATION_2_H #include +#include template bool @@ -35,6 +36,8 @@ _test_cls_aff_transformation_2(const R& ) typedef typename R::RT RT; typedef typename R::FT FT; + const bool nonexact = boost::is_same::value; + typename R::Aff_transformation_2 ia; CGAL::Aff_transformation_2 a1(ia); @@ -170,7 +173,7 @@ _test_cls_aff_transformation_2(const R& ) tisor= isor.transform( a[i]); assert( tseg == CGAL::Segment_2(tp1, tp2) ); assert( tray == CGAL::Ray_2(tp3, tp2) ); - assert( tlin == CGAL::Line_2(tp2, tp4) ); + assert( tlin == CGAL::Line_2(tp2, tp4) || nonexact); assert( ttri == CGAL::Triangle_2(tp2, tp3, tp4) ); assert( tisor== CGAL::Iso_rectangle_2( tp3, tp4 ) ); @@ -180,11 +183,11 @@ _test_cls_aff_transformation_2(const R& ) tray = tray.transform( inv ); tlin = tlin.transform( inv ); ttri = ttri.transform( inv ); - assert( tp4 == p4 ); - assert( tseg == seg ); - assert( tray == ray ); - assert( tlin == lin ); - assert( ttri == tri ); + assert( tp4 == p4 || nonexact ); + assert( tseg == seg || nonexact ); + assert( tray == ray || nonexact ); + assert( tlin == lin || nonexact ); + assert( ttri == tri || nonexact ); }; std::cout << '.'; @@ -293,7 +296,7 @@ _test_cls_aff_transformation_2(const R& ) // rotation assert( d0.transform( rot90 ) == d1 ); assert( d1.transform( rot90.inverse() ) == d0 ); - assert( d0.transform( rot3 ) == CGAL::Direction_2( RT(4), RT(3)) ); + assert( d0.transform( rot3 ) == CGAL::Direction_2( RT(4), RT(3)) || nonexact); co1 = rot3 * rot90; assert( d1.transform( rot3) == d0.transform( co1 ) ); co1 = rot2 * rot90; @@ -326,7 +329,7 @@ _test_cls_aff_transformation_2(const R& ) tp3 = p3.transform( rot3 ); tp4 = p4.transform( rot3 ); tcirc = circ.orthogonal_transform( rot3 ); - assert( tcirc == CGAL::Circle_2( tp2, tp3, tp4 ) ); + assert( tcirc == CGAL::Circle_2( tp2, tp3, tp4 ) || nonexact ); // copy diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h index 6a30e82c11d..2d52d61a01b 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h @@ -25,6 +25,7 @@ #define CGAL__TEST_CLS_AFF_TRANSFORMATION_3_H #include +#include template bool @@ -34,6 +35,7 @@ _test_cls_aff_transformation_3(const R& ) typedef typename R::RT RT; typedef typename R::FT FT; + const bool nonexact = boost::is_same::value; typename R::Aff_transformation_3 ia; CGAL::Aff_transformation_3 a1(ia); @@ -184,7 +186,7 @@ _test_cls_aff_transformation_3(const R& ) tlin = lin.transform( a[i] ); ttri = tri.transform( a[i] ); ttet = tet.transform( a[i] ); - assert( tpla == CGAL::Plane_3( tp1, tp2, tp3) ); + assert( tpla == CGAL::Plane_3( tp1, tp2, tp3) || nonexact ); assert( tseg == CGAL::Segment_3(tp1, tp2) ); assert( tray == CGAL::Ray_3(tp3, tp2) ); assert( tlin == CGAL::Line_3(tp2, tp4) ); @@ -198,13 +200,13 @@ _test_cls_aff_transformation_3(const R& ) tlin = tlin.transform( inv ); ttri = ttri.transform( inv ); ttet = ttet.transform( inv ); - assert( tp4 == p4 ); - assert( tpla == pla ); - assert( tseg == seg ); - assert( tray == ray ); - assert( tlin == lin ); - assert( ttri == tri ); - assert( ttet == tet ); + assert( tp4 == p4 || nonexact ); + assert( tpla == pla || nonexact ); + assert( tseg == seg || nonexact ); + assert( tray == ray || nonexact ); + assert( tlin == lin || nonexact ); + assert( ttri == tri || nonexact ); + assert( ttet == tet || nonexact ); }; std::cout << '.'; @@ -213,7 +215,7 @@ _test_cls_aff_transformation_3(const R& ) assert( vec.transform(ident) == vec ); assert( dir.transform(ident) == dir ); assert( pnt.transform(ident) == pnt ); - assert( pla.transform(ident) == pla ); + assert( pla.transform(ident) == pla || nonexact ); // scale11 and gscale tpnt = pnt.transform(scale11); @@ -236,7 +238,7 @@ _test_cls_aff_transformation_3(const R& ) assert( vec.transform(scale11) == vec.transform(gscale) ); assert( dir.transform(scale11) == dir.transform(gscale) ); assert( pnt.transform(scale11) == pnt.transform(gscale) ); - assert( pla.transform(scale11) == pla.transform(gscale) ); + assert( pla.transform(scale11) == pla.transform(gscale) || nonexact ); // translate and gtrans tvec = vec.transform(translate); @@ -274,7 +276,7 @@ _test_cls_aff_transformation_3(const R& ) assert( pnt.transform(xrefl).transform(xrefl) == pnt ); assert( dir.transform(xrefl).transform(xrefl) == dir ); assert( vec.transform(xrefl).transform(xrefl) == vec ); - assert( pla.transform(xrefl).transform(xrefl) == pla ); + assert( pla.transform(xrefl).transform(xrefl) == pla || nonexact ); CGAL::Aff_transformation_3 co1 = xrefl * xrefl; assert( pnt.transform(xrefl).transform(xrefl) == pnt.transform(co1) ); assert( dir.transform(xrefl).transform(xrefl) == dir.transform(co1) ); @@ -284,7 +286,7 @@ _test_cls_aff_transformation_3(const R& ) assert( pnt.transform(gat3).transform(gat2) == pnt.transform(co1) ); assert( dir.transform(gat3).transform(gat2) == dir.transform(co1) ); assert( vec.transform(gat3).transform(gat2) == vec.transform(co1) ); - assert( pla.transform(gat3).transform(gat2) == pla.transform(co1) ); + assert( pla.transform(gat3).transform(gat2) == pla.transform(co1) || nonexact ); co1 = ident * gat1; assert( vec.transform(gat1) == vec.transform(co1) ); assert( dir.transform(gat1) == dir.transform(co1) ); @@ -296,10 +298,10 @@ _test_cls_aff_transformation_3(const R& ) assert( pnt.transform(gat1) == pnt.transform(co1) ); assert( pla.transform(gat1) == pla.transform(co1) ); co1 = gat1 * gat1.inverse() ; - assert( vec == vec.transform(co1) ); - assert( dir == dir.transform(co1) ); - assert( pnt == pnt.transform(co1) ); - assert( pla == pla.transform(co1) ); + assert( vec == vec.transform(co1) || nonexact ); + assert( dir == dir.transform(co1) || nonexact ); + assert( pnt == pnt.transform(co1) || nonexact ); + assert( pla == pla.transform(co1) || nonexact ); assert( vec.transform( gat5 ) == vec.transform( gat2 ) ); assert( dir.transform( gat5 ) == dir.transform( gat2 ) ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_circle_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_circle_2.h index c93726b81ed..6933bec5a4d 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_circle_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_circle_2.h @@ -27,6 +27,8 @@ #include #include +#include + template void _test_construct_radical_line(const K &k) { typedef typename K::FT FT; @@ -83,6 +85,8 @@ _test_cls_circle_2(const R& ) typename R::Circle_2 ic; CGAL::Circle_2 c0; + const bool nonexact = boost::is_same::value; + RT n0 = 0; RT n1 = 16; RT n2 = -4; @@ -194,9 +198,9 @@ _test_cls_circle_2(const R& ) == CGAL::ON_POSITIVE_SIDE ); assert( c10.oriented_side(CGAL::ORIGIN + v1 + vx*n2 ) \ == CGAL::ON_NEGATIVE_SIDE ); - assert( c10.oriented_side(p9 ) == CGAL::ON_ORIENTED_BOUNDARY ); - assert( c10.has_on_boundary(p9) ); - assert( c10.has_on_boundary(p4 + v1) ); + assert( c10.oriented_side(p9 ) == CGAL::ON_ORIENTED_BOUNDARY || nonexact); + assert( c10.has_on_boundary(p9) || nonexact); + assert( c10.has_on_boundary(p4 + v1) || nonexact ); CGAL::Point_2 p11( n4, n4, n3) ; // (2.5, 2.5) CGAL::Point_2 p12( n5, n5, n3) ; // ( 5 , 5 ) assert( c10.has_on_bounded_side( p11 ) ); @@ -206,8 +210,8 @@ _test_cls_circle_2(const R& ) assert( c10.has_on_negative_side( p12 ) ); assert( c10.opposite().has_on_negative_side( p11 ) ); assert( c10.opposite().has_on_positive_side( p12 ) ); - assert( c10.has_on_boundary( p6 ) ); - assert( c10.has_on_boundary( p8 ) ); + assert( c10.has_on_boundary( p6 ) || nonexact); + assert( c10.has_on_boundary( p8 ) || nonexact); std::cout << '.'; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h index 35190bc4742..9c0509b17ab 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h @@ -25,6 +25,7 @@ #define CGAL__TEST_CLS_LINE_3_H #include +#include template bool @@ -33,6 +34,7 @@ _test_cls_line_3(const R& ) std::cout << "Testing class Line_3" ; typedef typename R::RT RT; + const bool nonexact = boost::is_same::value; typename R::Line_3 il; CGAL::Line_3 l0( il ); CGAL_USE(l0); @@ -101,20 +103,20 @@ _test_cls_line_3(const R& ) assert( l4.point(2) - l4.point(1) == l4.point(1) - l4.point(0) ); CGAL::Point_3 p1l4proj = l4.projection(p1); - assert( l4.has_on( p1l4proj ) ); - assert( l4.perpendicular_plane( p1l4proj ).has_on( p1l4proj ) ); - assert( l4.perpendicular_plane( p1l4proj ).has_on( p1 ) ); + assert( l4.has_on( p1l4proj ) || nonexact ); + assert( l4.perpendicular_plane( p1l4proj ).has_on( p1l4proj ) || nonexact ); + assert( l4.perpendicular_plane( p1l4proj ).has_on( p1 ) || nonexact ); CGAL::Point_3 p4 = l4.projection(p2); CGAL::Point_3 p5 = l4.projection(p3); assert( ( l4.direction() == ( p5 - p4 ).direction() )\ - ||( l4.direction() == ( p4 - p5 ).direction() ) ); + ||( l4.direction() == ( p4 - p5 ).direction() ) || nonexact ); assert( l5.direction() == - l6.direction() ); std::cout <<'.'; assert( l2.has_on(p1) ); assert( l2.has_on(p2) ); - assert( l4.has_on(p4) ); + assert( l4.has_on(p4) || nonexact ); assert( l4.has_on(p5) ); assert( CGAL::Line_3(p1,p1).is_degenerate() ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_sphere_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_sphere_3.h index 69bac242dae..f3428f32226 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_sphere_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_sphere_3.h @@ -26,6 +26,7 @@ #include #include +#include template bool @@ -38,6 +39,7 @@ _test_cls_sphere_3(const R& ) typename R::Sphere_3 ic; CGAL::Sphere_3 c0; + const bool nonexact = boost::is_same::value; RT n0 = 0; RT n1 = 16; RT n2 = -4; @@ -104,8 +106,8 @@ _test_cls_sphere_3(const R& ) assert( cn3 == cp3.opposite() ); assert( c7.opposite() == c8 ); assert( c8.opposite() == c7 ); - assert( c1.opposite() == c3 ); - assert( c3.opposite() == c1 ); + assert( c1.opposite() == c3 || nonexact ); + assert( c3.opposite() == c1 || nonexact ); assert( c7.orientation() == CGAL::POSITIVE ); assert( c8.orientation() == CGAL::NEGATIVE ); assert( c5.orientation() == CGAL::POSITIVE ); @@ -181,22 +183,22 @@ _test_cls_sphere_3(const R& ) CGAL::Point_3 ori = CGAL::Point_3( RT(0), RT(0), RT(0)); CGAL::Point_3 p6 = p2.transform( rotate1 ); - assert( CGAL::compare_distance_to_point( ori, p2, p6) == CGAL::EQUAL ); + assert( CGAL::compare_distance_to_point( ori, p2, p6) == CGAL::EQUAL || nonexact ); CGAL::Point_3 p7 = p2.transform( rotate2 ); - assert( CGAL::compare_distance_to_point( ori, p2, p7) == CGAL::EQUAL ); + assert( CGAL::compare_distance_to_point( ori, p2, p7) == CGAL::EQUAL || nonexact ); CGAL::Point_3 p8 = p2.transform( rotate3 ); - assert( CGAL::compare_distance_to_point( ori, p2, p8) == CGAL::EQUAL ); + assert( CGAL::compare_distance_to_point( ori, p2, p8) == CGAL::EQUAL || nonexact ); CGAL::Point_3 p9 = p2.transform( rotate4 ); assert( CGAL::compare_distance_to_point( ori, p2, p9) == CGAL::EQUAL ); CGAL::Point_3 p10 = p2.transform( rotate5 ); - assert( CGAL::compare_distance_to_point( ori, p2, p10) == CGAL::EQUAL ); + assert( CGAL::compare_distance_to_point( ori, p2, p10) == CGAL::EQUAL || nonexact ); p6 = p6 + v1; p7 = p7 + v1; p8 = p8 + v1; p9 = p9 + v1; p10 = p10 + v1; CGAL::Sphere_3 c10 (p6, p8, p7, p9); - assert( c10.center() == ori + v1 ); + assert( c10.center() == ori + v1 || nonexact ); assert( c10.orientation() == CGAL::POSITIVE ); assert( c10.opposite().orientation() == CGAL::NEGATIVE ); @@ -205,9 +207,9 @@ _test_cls_sphere_3(const R& ) == CGAL::ON_POSITIVE_SIDE ); assert( c10.oriented_side(CGAL::ORIGIN + v1 + vx*n2 ) \ == CGAL::ON_NEGATIVE_SIDE ); - assert( c10.oriented_side(p9 ) == CGAL::ON_ORIENTED_BOUNDARY ); - assert( c10.has_on_boundary(p9) ); - assert( c10.has_on_boundary(p4 + v1) ); + assert( c10.oriented_side(p9 ) == CGAL::ON_ORIENTED_BOUNDARY || nonexact ); + assert( c10.has_on_boundary(p9) || nonexact ); + assert( c10.has_on_boundary(p4 + v1) || nonexact ); CGAL::Point_3 p11( n4, n4, n4, n3) ; // (2.5, 2.5, 2.5) CGAL::Point_3 p12( n5, n5, n5, n3) ; // ( 5 , 5, 5 ) assert( c10.has_on_bounded_side( p11 ) ); @@ -217,8 +219,8 @@ _test_cls_sphere_3(const R& ) assert( c10.has_on_negative_side( p12 ) ); assert( c10.opposite().has_on_negative_side( p11 ) ); assert( c10.opposite().has_on_positive_side( p12 ) ); - assert( c10.has_on_boundary( p6 ) ); - assert( c10.has_on_boundary( p8 ) ); + assert( c10.has_on_boundary( p6 ) || nonexact ); + assert( c10.has_on_boundary( p8 ) || nonexact ); std::cout << '.'; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_points_implicit_sphere.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_points_implicit_sphere.h index abf69f2fe5b..97cf0c43e41 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_points_implicit_sphere.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_points_implicit_sphere.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_FCT_POINTS_IMPLICIT_SPHERE_H #define CGAL__TEST_FCT_POINTS_IMPLICIT_SPHERE_H +#include + template bool _test_fct_points_implicit_sphere(const R&) @@ -32,6 +34,8 @@ _test_fct_points_implicit_sphere(const R&) typedef typename R::FT FT; typedef CGAL::Tetrahedron_3 Tetrahedron; + const bool nonexact = boost::is_same::value; + const RT RT0(0); const RT RT4(4); const FT FT1(1); @@ -70,7 +74,7 @@ _test_fct_points_implicit_sphere(const R&) CGAL::Point_3 tpt = p.transform(rot_z); assert( CGAL::squared_distance( tpt, org ) == FT1 ); p = tpt.transform(rot_z); - assert( CGAL::squared_distance( p, org ) == FT1 ); + assert( CGAL::squared_distance( p, org ) == FT1 || nonexact ); CGAL::rational_rotation_approximation( RT(35), RT(-8), sin, cos, den, @@ -82,9 +86,9 @@ _test_fct_points_implicit_sphere(const R&) assert( CGAL::squared_distance( q, org ) == FT1 ); tpt = q.transform(rot_x); - assert( CGAL::squared_distance( tpt, org ) == FT1 ); + assert( CGAL::squared_distance( tpt, org ) == FT1 || nonexact ); q = tpt.transform(rot_y); - assert( CGAL::squared_distance( q, org ) == FT1 ); + assert( CGAL::squared_distance( q, org ) == FT1 || nonexact ); CGAL::rational_rotation_approximation( RT(9), RT(-8), sin, cos, den, @@ -98,7 +102,7 @@ _test_fct_points_implicit_sphere(const R&) tpt = r.transform(rot_z); assert( CGAL::squared_distance( tpt, org ) == FT1 ); r = tpt.transform(rot_y); - assert( CGAL::squared_distance( r, org ) == FT1 ); + assert( CGAL::squared_distance( r, org ) == FT1 || nonexact ); CGAL::rational_rotation_approximation( RT(-19), RT(-1), sin, cos, den, @@ -137,11 +141,11 @@ _test_fct_points_implicit_sphere(const R&) CGAL::Point_3 ez( RT0, RT0, RT1); CGAL::Point_3 oz( RT0, RT0, -RT1); assert( CGAL::circumcenter(ex, ey, ez, oz) == org ); - assert( CGAL::circumcenter(p,q,r,s) == org ); - assert( CGAL::circumcenter(p,r,q,s) == org ); + assert( CGAL::circumcenter(p,q,r,s) == org || nonexact ); + assert( CGAL::circumcenter(p,r,q,s) == org || nonexact ); assert( CGAL::circumcenter(Tetrahedron(ex, ey, ez, oz)) == org ); - assert( CGAL::circumcenter(Tetrahedron(p,q,r,s)) == org ); - assert( CGAL::circumcenter(Tetrahedron(p,r,q,s)) == org ); + assert( CGAL::circumcenter(Tetrahedron(p,q,r,s)) == org || nonexact ); + assert( CGAL::circumcenter(Tetrahedron(p,r,q,s)) == org || nonexact ); CGAL::Vector_3 v( RT(12), RT(4), RT(-4), RT(2) ); CGAL::Point_3 pt = p + v; @@ -169,10 +173,10 @@ _test_fct_points_implicit_sphere(const R&) assert( CGAL::side_of_bounded_sphere(pt,rt,qt,st,ot) \ == CGAL::ON_UNBOUNDED_SIDE); - assert( CGAL::circumcenter(pt,qt,rt,st) == c ); - assert( CGAL::circumcenter(pt,rt,qt,st) == c ); - assert( CGAL::circumcenter(Tetrahedron(pt,qt,rt,st)) == c ); - assert( CGAL::circumcenter(Tetrahedron(pt,rt,qt,st)) == c ); + assert( CGAL::circumcenter(pt,qt,rt,st) == c || nonexact ); + assert( CGAL::circumcenter(pt,rt,qt,st) == c || nonexact ); + assert( CGAL::circumcenter(Tetrahedron(pt,qt,rt,st)) == c || nonexact ); + assert( CGAL::circumcenter(Tetrahedron(pt,rt,qt,st)) == c || nonexact ); // Now test side_of_bounded_sphere(p, q, t). diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_3.h index 11d455778db..b860bc86c3d 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_3.h @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -37,6 +38,7 @@ _test_fct_weighted_point_3(const R& ) std::cout << "Testing functions Weighted_point_3" ; typedef typename R::RT RT; + const bool nonexact = boost::is_same::value; CGAL::Point_3 p1(RT(18), RT(15), RT(-21), RT(3) ); // 6, 5, -7 CGAL::Point_3 p2(RT(18), RT(15), RT( 12), RT(3) ); // 6, 5, 4 @@ -138,7 +140,7 @@ _test_fct_weighted_point_3(const R& ) assert( CGAL::power_side_of_bounded_power_sphere(wp3_b, wp1_b, wp6b_b) == CGAL::ON_BOUNDED_SIDE ); assert( CGAL::power_side_of_bounded_power_sphere(wp1_b, wp3_b, wp6b_b) == CGAL::ON_BOUNDED_SIDE ); - assert( CGAL::coplanar(p4, p5, p6, p7) ); + assert( CGAL::coplanar(p4, p5, p6, p7) || nonexact ); assert( CGAL::power_side_of_bounded_power_sphere(wp4, wp5, wp6, wp7) == CGAL::side_of_bounded_sphere(p4, p5, p6, p7) ); assert( CGAL::power_side_of_bounded_power_sphere(wp4, wp5, wp6, wp5) @@ -171,11 +173,11 @@ _test_fct_weighted_point_3(const R& ) assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp1_b, wp3_b) == RT(164)); assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp1, wp3, wp5) - == CGAL::squared_radius(p1, p3, p5)); + == CGAL::squared_radius(p1, p3, p5) || nonexact); assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp000, wp100, wp010) == RT(0)); assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp1, wp3, wp4, wp5) - == CGAL::squared_radius(p1, p3, p4, p5)); + == CGAL::squared_radius(p1, p3, p4, p5) || nonexact); assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp000, wp100, wp010, wp001) == RT(0)); std::cout << "."; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h index cf498947577..828b0493d0e 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h @@ -25,6 +25,7 @@ #define CGAL__TEST_FURTHER_FCT_POINT_2_H #include "_approx_equal.h" +#include template bool @@ -100,6 +101,8 @@ _test_further_fct_point_2(const R& ) using CGAL::testsuite::approx_equal; using CGAL::testsuite::Direction_2_tag; + const bool nonexact = boost::is_same::value; + assert( approx_equal((p5 - CGAL::ORIGIN).direction(), dir5, Direction_2_tag()) ); assert( CGAL::side_of_bounded_circle(p1, p2, p3, CGAL::Point_2(CGAL::ORIGIN))\ @@ -107,15 +110,15 @@ _test_further_fct_point_2(const R& ) assert( CGAL::side_of_bounded_circle(p1+v, p2+v, p3+v, CGAL::ORIGIN + v) \ == CGAL::ON_BOUNDED_SIDE ); assert( CGAL::side_of_bounded_circle(p1+v, p2+v, p3+v, CGAL::ORIGIN - v) \ - == CGAL::ON_UNBOUNDED_SIDE ); + == CGAL::ON_UNBOUNDED_SIDE || nonexact); assert( CGAL::side_of_bounded_circle(p1, p2, p3, p4) \ - == CGAL::ON_BOUNDARY ); + == CGAL::ON_BOUNDARY || nonexact); assert( CGAL::side_of_bounded_circle(p1+v, p2+v, p3+v, p4+v) \ - == CGAL::ON_BOUNDARY ); + == CGAL::ON_BOUNDARY || nonexact); assert( CGAL::side_of_bounded_circle(p1+v, p3+v, p4+v, p2+v) \ - == CGAL::ON_BOUNDARY ); + == CGAL::ON_BOUNDARY || nonexact); assert( CGAL::side_of_bounded_circle(p2+v, p4+v, p1+v, p3+v) \ - == CGAL::ON_BOUNDARY ); + == CGAL::ON_BOUNDARY || nonexact); assert( CGAL::orientation( p1, p2, p3 ) == CGAL::POSITIVE ); @@ -130,11 +133,11 @@ _test_further_fct_point_2(const R& ) assert( CGAL::side_of_oriented_circle(p2+v, p1+v, p3+v, CGAL::ORIGIN - v) \ == CGAL::ON_POSITIVE_SIDE ); assert( CGAL::side_of_oriented_circle(p1, p2, p3, p4) \ - == CGAL::ON_ORIENTED_BOUNDARY ); + == CGAL::ON_ORIENTED_BOUNDARY || nonexact); assert( CGAL::side_of_oriented_circle(p1+v, p2+v, p3+v, p4+v) \ - == CGAL::ON_ORIENTED_BOUNDARY ); + == CGAL::ON_ORIENTED_BOUNDARY || nonexact); assert( CGAL::side_of_oriented_circle(p1+v, p3+v, p4+v, p2+v) \ - == CGAL::ON_ORIENTED_BOUNDARY ); + == CGAL::ON_ORIENTED_BOUNDARY || nonexact); CGAL::Point_2 p10( RT(100), RT(100), RT(10) ); CGAL::Point_2 p11( RT(-100), RT(-100), RT(10) ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_mf_plane_3_to_2d.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_mf_plane_3_to_2d.h index 48348c0e2c6..d86c33d2e2f 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_mf_plane_3_to_2d.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_mf_plane_3_to_2d.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_MF_PLANE_3_TO_2D_H #define CGAL__TEST_MF_PLANE_3_TO_2D_H +#include + template bool _test_mf_plane_3_to_2d(const R& ) @@ -35,6 +37,8 @@ _test_mf_plane_3_to_2d(const R& ) typedef CGAL::Point_3< R> Point_3; typedef CGAL::Point_2< R> Point_2; + const bool nonexact = boost::is_same::value; + RT n0 = 0; RT n1 = 7; RT n2 = 21; @@ -51,33 +55,33 @@ _test_mf_plane_3_to_2d(const R& ) Point_3 p4 = p3 + (p2 - p1); Plane_3 pl1( p1, p2, p3); - assert( pl1.has_on( pl1.to_3d( pl1.to_2d( pl1.point() ))) ); - assert( pl1.has_on( pl1.to_3d( pl1.to_2d( p4 ))) ); - assert( p1 == pl1.to_3d( pl1.to_2d( p1)) ); - assert( p2 == pl1.to_3d( pl1.to_2d( p2)) ); - assert( p3 == pl1.to_3d( pl1.to_2d( p3)) ); - assert( p4 == pl1.to_3d( pl1.to_2d( p4)) ); + assert( pl1.has_on( pl1.to_3d( pl1.to_2d( pl1.point() ))) || nonexact ); + assert( pl1.has_on( pl1.to_3d( pl1.to_2d( p4 ))) || nonexact ); + assert( p1 == pl1.to_3d( pl1.to_2d( p1)) || nonexact ); + assert( p2 == pl1.to_3d( pl1.to_2d( p2)) || nonexact ); + assert( p3 == pl1.to_3d( pl1.to_2d( p3)) || nonexact ); + assert( p4 == pl1.to_3d( pl1.to_2d( p4)) || nonexact ); std::cout << '.'; Plane_3 pl2( p2, p1, p3); - assert( pl2.has_on( pl2.to_3d( pl2.to_2d( pl2.point() ))) ); - assert( pl2.has_on( pl2.to_3d( pl2.to_2d( p4 ))) ); - assert( p1 == pl2.to_3d( pl2.to_2d( p1)) ); - assert( p2 == pl2.to_3d( pl2.to_2d( p2)) ); - assert( p3 == pl2.to_3d( pl2.to_2d( p3)) ); - assert( p4 == pl2.to_3d( pl2.to_2d( p4)) ); + assert( pl2.has_on( pl2.to_3d( pl2.to_2d( pl2.point() ))) || nonexact ); + assert( pl2.has_on( pl2.to_3d( pl2.to_2d( p4 ))) || nonexact ); + assert( p1 == pl2.to_3d( pl2.to_2d( p1)) || nonexact ); + assert( p2 == pl2.to_3d( pl2.to_2d( p2)) || nonexact ); + assert( p3 == pl2.to_3d( pl2.to_2d( p3)) || nonexact ); + assert( p4 == pl2.to_3d( pl2.to_2d( p4)) || nonexact ); Point_3 p5( n2, n8, n0, n7); Point_3 p6( n4, n5, n0, n8); Plane_3 pl3( p4, p5, p6); - assert( p4 == pl3.to_3d( pl3.to_2d( p4)) ); + assert( p4 == pl3.to_3d( pl3.to_2d( p4)) || nonexact ); assert( p5 == pl3.to_3d( pl3.to_2d( p5)) ); - assert( p6 == pl3.to_3d( pl3.to_2d( p6)) ); + assert( p6 == pl3.to_3d( pl3.to_2d( p6)) || nonexact ); Plane_3 pl4( p4, p6, p5); - assert( p4 == pl4.to_3d( pl4.to_2d( p4)) ); + assert( p4 == pl4.to_3d( pl4.to_2d( p4)) || nonexact ); assert( p5 == pl4.to_3d( pl4.to_2d( p5)) ); - assert( p6 == pl4.to_3d( pl4.to_2d( p6)) ); + assert( p6 == pl4.to_3d( pl4.to_2d( p6)) || nonexact ); Point_3 p7 = CGAL::midpoint( p1, p2); Point_3 p8 = CGAL::midpoint( p3, p3 + (p2-p1) ); @@ -98,14 +102,14 @@ _test_mf_plane_3_to_2d(const R& ) CGAL::Segment_2 sp2( pp9, pp10); Point_2 pp; assert( CGAL::assign( pp, CGAL::intersection( sp1, sp2)) ); - assert( sp1.has_on( pp) ); - assert( sp2.has_on( pp) ); + assert( sp1.has_on( pp) || nonexact ); + assert( sp2.has_on( pp) || nonexact ); Point_3 p = pl1.to_3d( pp); - assert( pl1.has_on( p )); + assert( pl1.has_on( p ) || nonexact ); CGAL::Segment_3 s1( p7, p8); CGAL::Segment_3 s2( p9, p10); - assert( s1.has_on( p) ); - assert( s2.has_on( p) ); + assert( s1.has_on( p) || nonexact ); + assert( s2.has_on( p) || nonexact ); std::cout << '.' << std::endl; return true; From 30b25a4d58684681e04d21fffa3143dc383d9763 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 14 Jun 2019 11:09:40 +0200 Subject: [PATCH 12/16] Fix warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There was a unused assigned variable: ``` test/Kernel_23/include/CGAL/_test_new_2.h:375:6: warning: variable ‘tmp22d’ set but not used [-Wunused-but-set-variable] 375 | FT tmp22d = Compute_squared_distance(p1, p2); | ^~~~~~ ``` and also use of uninitialized variable. That pattern was used a lot: ``` typename R::Iso_cuboid_3 ir; CGAL::Iso_cuboid_3 r0(ir); ``` that is: - create a default-initialized object, - then copy it. Default-initialized object cannot be copied without a warning. --- .../test/Kernel_23/include/CGAL/_test_cls_iso_cuboid_3.h | 8 +++++--- .../Kernel_23/include/CGAL/_test_cls_iso_rectangle_2.h | 8 +++++--- Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_2.h | 5 ++++- .../test/Kernel_23/include/CGAL/_test_cls_triangle_2.h | 8 +++++--- Kernel_23/test/Kernel_23/include/CGAL/_test_new_2.h | 9 +++++---- Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h | 6 +++--- 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_cuboid_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_cuboid_3.h index 0307fe1f38f..b4fa97c2f29 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_cuboid_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_cuboid_3.h @@ -26,6 +26,7 @@ #include #include +#include template bool @@ -36,9 +37,6 @@ _test_cls_iso_cuboid_3(const R& ) typedef typename R::RT RT; typedef typename R::FT FT; - typename R::Iso_cuboid_3 ir; - CGAL::Iso_cuboid_3 r0(ir); - RT n1 = 1; RT n2 = 2; RT n3 = 3; @@ -65,6 +63,10 @@ _test_cls_iso_cuboid_3(const R& ) CGAL::Point_3 p12(n1, n1, n3 ); // ( 1, 1, 3) CGAL::Point_3 p13(n4, n1, n3 ); // ( 4, 1, 3) + typename R::Iso_cuboid_3 ir0; CGAL_USE(ir0); // test default-construction + typename R::Iso_cuboid_3 ir( p1, p3); + CGAL::Iso_cuboid_3 r0(ir); + const CGAL::Iso_cuboid_3 r1( p1, p3); CGAL::Iso_cuboid_3 r1_( p1, p3, 0); CGAL::Iso_cuboid_3 r2( p3, p1); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_rectangle_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_rectangle_2.h index c2411734ff9..1f488e830af 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_rectangle_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_rectangle_2.h @@ -26,6 +26,7 @@ #include #include +#include template bool @@ -36,9 +37,6 @@ _test_cls_iso_rectangle_2(const R& ) typedef typename R::RT RT; typedef typename R::FT FT; - typename R::Iso_rectangle_2 ir; - CGAL::Iso_rectangle_2 r0(ir); - RT n1 = 1; RT n2 = 2; RT n3 = 3; @@ -59,6 +57,10 @@ _test_cls_iso_rectangle_2(const R& ) CGAL::Point_2 p8( n4, n6, n2); // ( 2, 3) CGAL::Point_2 p9(-n3, n7); // (-3, 7) + typename R::Iso_rectangle_2 ir0; CGAL_USE(ir0); // test default-construction + typename R::Iso_rectangle_2 ir(p1, p3); + CGAL::Iso_rectangle_2 r0(ir); + const CGAL::Iso_rectangle_2 r1( p1, p3); CGAL::Iso_rectangle_2 r1_( p1, p3, 0); CGAL::Iso_rectangle_2 r2( p3, p1); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_2.h index 7c16868a588..f9895fb0270 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_2.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_LINE_2_H #define CGAL__TEST_CLS_LINE_2_H +#include + template bool _test_cls_line_2(const R& ) @@ -47,7 +49,8 @@ _test_cls_line_2(const R& ) CGAL::Point_2 p3(-n6, n6, n3 ); // (-2, 2 ) CGAL::Point_2 p4( n8, n4, n2 ); // ( 4, 2 ) - typename R::Line_2 il; + typename R::Line_2 il0; CGAL_USE(il0); // test default-construction + typename R::Line_2 il(p1, p2); CGAL::Line_2 l0(il); CGAL::Line_2 l12( p1, p2 ); CGAL::Line_2 l21( p2, p1 ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_triangle_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_triangle_2.h index 4c1a4c28655..06f9afd582a 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_triangle_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_triangle_2.h @@ -26,6 +26,7 @@ #include #include +#include template bool @@ -36,9 +37,6 @@ _test_cls_triangle_2(const R& ) typedef typename R::RT RT; typedef typename R::FT FT; - typename R::Triangle_2 it; - CGAL::Triangle_2 t0(it); - RT n0 = 0; RT n1 = 1; RT n2 = 2; @@ -62,6 +60,10 @@ _test_cls_triangle_2(const R& ) CGAL::Point_2 p8(-n12,-n8,-n2); // ( 6, 4) CGAL::Point_2 p9( n9, n9, n3); // ( 3, 3) + typename R::Triangle_2 it0; CGAL_USE(it0); // test default-construction + typename R::Triangle_2 it(p1, p2, p3); + CGAL::Triangle_2 t0(it); + CGAL::Triangle_2 t1( p1, p3, p5); CGAL::Triangle_2 t2( p3, p1, p5); CGAL::Triangle_2 t3( p7, p8, p9); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_new_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_new_2.h index ae3ae7fbbe8..59f0a94a19a 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_new_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_new_2.h @@ -35,7 +35,7 @@ #include "_test_cls_iso_rectangle_new_2.h" #include "_test_cls_circle_new_2.h" -#include +#include using CGAL::internal::use; @@ -175,8 +175,8 @@ test_new_2(const R& rep) typename R::Construct_triangle_2 construct_triangle = rep.construct_triangle_2_object(); - Triangle_2 t1; - Triangle_2 t2 = construct_triangle(p2,p3,p4); + Triangle_2 t0; CGAL_USE(t0); // test default-construction + Triangle_2 t2 = construct_triangle(p2,p3,p4), t1 = t2; typename R::Construct_iso_rectangle_2 construct_iso_rectangle = rep.construct_iso_rectangle_2_object(); @@ -379,6 +379,7 @@ test_new_2(const R& rep) typename R::Compute_power_product_2 compute_power_product = rep.compute_power_product_2_object(); tmp22d = compute_power_product(wp6, wp7); + CGAL_USE(tmp22d); typename R::Compute_squared_length_2 Compute_squared_length = rep.compute_squared_length_2_object(); @@ -672,7 +673,7 @@ test_new_2(const R& rep) use(tmp9); use(tmp10); use(tmp11); use(tmp12); use(tmp12a); use(tmp14); use(tmp14a); use(tmp15); use(tmp16); use(tmp16); use(tmp17); use(tmp19); use(tmp19a); use(tmp22a); - use(tmp22b); use(tmp22c); use(tmp23); + use(tmp22b); use(tmp22c); use(tmp22d); use(tmp23); use(tmp58); use(tmp57); use(tmp56); use(tmp55); use(tmp54); use(tmp53b); use(tmp53a); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h index c9493e57108..f78c879628f 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h @@ -29,7 +29,7 @@ #include #include -#include +#include using CGAL::internal::use; @@ -157,8 +157,8 @@ test_new_3(const R& rep) typename R::Construct_segment_3 construct_segment = rep.construct_segment_3_object(); - Segment_3 s1; - Segment_3 s2 = construct_segment(p2,p3); + Segment_3 s0; CGAL_USE(s0); // test default-construction + Segment_3 s2 = construct_segment(p2,p3), s1 = s2; typename R::Construct_ray_3 construct_ray = rep.construct_ray_3_object(); From 34a9b24698934acb382fa54b228764878a8937ce Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 17 Jun 2019 10:03:56 +0200 Subject: [PATCH 13/16] Fix a remaining warning about t1 not being initialized There are a lot of uninitialized variables, in that testsuite, that are used anyway (like copied). Strangely the compilers do not seem to catch them all at the same time. That probably depends on inlinings. --- Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h index f78c879628f..6b5939a9afa 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h @@ -214,11 +214,10 @@ test_new_3(const R& rep) Sphere_3 sp8 = construct_sphere(p3); Sphere_3 sp9 = construct_sphere(p3,CLOCKWISE); - + Triangle_3 t0; CGAL_USE(t0); // test the default-construction typename R::Construct_triangle_3 construct_triangle = rep.construct_triangle_3_object(); - Triangle_3 t1; - Triangle_3 t2 = construct_triangle(p2,p3,p4); + Triangle_3 t1 = construct_triangle(p2,p3,p4), t2 = t1; typename R::Construct_tetrahedron_3 construct_tetrahedron = rep.construct_tetrahedron_3_object(); From 4e15225e982bcb288ef831990d7bcba290d71417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 18 Jun 2019 11:04:09 +0200 Subject: [PATCH 14/16] Derecursify 'expand_conflict_region' --- .../include/CGAL/Segment_Delaunay_graph_2.h | 25 +- .../Segment_Delaunay_graph_2_impl.h | 296 ++++++++++-------- .../Segment_Delaunay_graph_hierarchy_2_impl.h | 3 +- ...ent_Delaunay_graph_Linf_hierarchy_2_impl.h | 3 +- 4 files changed, 185 insertions(+), 142 deletions(-) diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h index 24aa1ed5478..1d78f845f6a 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -1448,16 +1449,22 @@ protected: std::pair find_faces_to_split(const Vertex_handle& v, const Site_2& t) const; - void expand_conflict_region(const Face_handle& f, const Site_2& t, - const Storage_site_2& ss, -#ifdef CGAL_SDG_NO_FACE_MAP - List& l, -#else - List& l, Face_map& fm, - std::map& sign_map, + bool check_unregistered_face(const Face_handle& n, + const Site_2& t, + List& l, +#ifndef CGAL_SDG_NO_FACE_MAP + Face_map& fm, #endif - Triple& vcross); + Triple& vcross); + + void expand_conflict_region(const Face_handle& in_f, + const Site_2& t, + List& l, +#ifndef CGAL_SDG_NO_FACE_MAP + Face_map& fm, + std::map& sign_map, +#endif + Triple& vcross); Vertex_handle add_bogus_vertex(Edge e, List& l); Vertex_list add_bogus_vertices(List& l); diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h index bdd4d43e1a7..83c47c96006 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h @@ -465,9 +465,9 @@ insert_point2(const Storage_site_2& ss, const Site_2& t, // REGION AND EXPANDS THE CONFLICT REGION. initialize_conflict_region(start_f, l); #ifdef CGAL_SDG_NO_FACE_MAP - expand_conflict_region(start_f, t, ss, l, vcross); + expand_conflict_region(start_f, t, l, vcross); #else - expand_conflict_region(start_f, t, ss, l, fm, sign_map, vcross); + expand_conflict_region(start_f, t, l, fm, sign_map, vcross); #endif CGAL_assertion( !vcross.first ); @@ -846,9 +846,9 @@ insert_segment_interior(const Site_2& t, const Storage_site_2& ss, // REGION AND EXPANDS THE CONFLICT REGION. initialize_conflict_region(start_f, l); #ifdef CGAL_SDG_NO_FACE_MAP - expand_conflict_region(start_f, t, ss, l, vcross); + expand_conflict_region(start_f, t, l, vcross); #else - expand_conflict_region(start_f, t, ss, l, fm, sign_map, vcross); + expand_conflict_region(start_f, t, l, fm, sign_map, vcross); #endif CGAL_assertion( vcross.third == AT2::DISJOINT || @@ -958,152 +958,190 @@ initialize_conflict_region(const Face_handle& f, List& l) template -void +bool Segment_Delaunay_graph_2:: -expand_conflict_region(const Face_handle& f, const Site_2& t, - const Storage_site_2& ss, -#ifdef CGAL_SDG_NO_FACE_MAP - List& l, -#else - List& l, Face_map& fm, - std::map& sign_map, +check_unregistered_face(const Face_handle& n, + const Site_2& t, + List& l, +#ifndef CGAL_SDG_NO_FACE_MAP + Face_map& fm, #endif - Triple& vcross) + Triple& vcross) { + for (int j = 0; j < 3; ++j) + { + Vertex_handle vf = n->vertex(j); + + if ( is_infinite(vf) ) + continue; + + Arrangement_type at_res = arrangement_type(t, vf); + + CGAL_assertion( vcross.third == AT2::DISJOINT || + vcross.third == AT2::CROSSING || + vcross.third == AT2::INTERIOR ); + + if ( vf->is_segment() ) + { + CGAL_assertion( at_res != AT2::IDENTICAL ); + CGAL_assertion( at_res != AT2::TOUCH_11_INTERIOR_1 ); + CGAL_assertion( at_res != AT2::TOUCH_12_INTERIOR_1 ); + + if ( at_res == AT2::CROSSING ) + { + vcross.first = true; + vcross.second = vf; + vcross.third = AT2::CROSSING; + l.clear(); #ifdef CGAL_SDG_NO_FACE_MAP - if ( f->tds_data().is_in_conflict() ) { return; } + fhc_.clear(); #else - if ( fm.find(f) != fm.end() ) { return; } + fm.clear(); #endif - - // this is done to stop the recursion when intersecting segments - // are found - if ( vcross.first ) { return; } - - // setting fm[f] to true means that the face has been reached and - // that the face is available for recycling. If we do not want the - // face to be available for recycling we must set this flag to - // false. -#ifdef CGAL_SDG_NO_FACE_MAP - f->tds_data().mark_in_conflict(); - fhc_.push_back(f); -#else - fm[f] = true; -#endif - - // CGAL_assertion( fm.find(f) != fm.end() ); - - for (int i = 0; i < 3; i++) { - Face_handle n = f->neighbor(i); - -#ifdef CGAL_SDG_NO_FACE_MAP - bool face_registered = n->tds_data().is_in_conflict(); -#else - bool face_registered = (fm.find(n) != fm.end()); -#endif - - if ( !face_registered ) { - for (int j = 0; j < 3; j++) { - Vertex_handle vf = n->vertex(j); - - if ( is_infinite(vf) ) { continue; } - - Arrangement_type at_res = arrangement_type(t, vf); - - CGAL_assertion( vcross.third == AT2::DISJOINT || - vcross.third == AT2::CROSSING || - vcross.third == AT2::INTERIOR ); - - if ( vf->is_segment() ) { - CGAL_assertion( at_res != AT2::IDENTICAL ); - CGAL_assertion( at_res != AT2::TOUCH_11_INTERIOR_1 ); - CGAL_assertion( at_res != AT2::TOUCH_12_INTERIOR_1 ); - - if ( at_res == AT2::CROSSING ) { - vcross.first = true; - vcross.second = vf; - vcross.third = AT2::CROSSING; - l.clear(); -#ifdef CGAL_SDG_NO_FACE_MAP - fhc_.clear(); -#else - fm.clear(); -#endif - return; - } else { - CGAL_assertion ( at_res == AT2::DISJOINT || - at_res == AT2::TOUCH_1 || - at_res == AT2::TOUCH_2 || - at_res == AT2::TOUCH_11 || - at_res == AT2::TOUCH_12 || - at_res == AT2::TOUCH_21 || - at_res == AT2::TOUCH_22 ); - // we do nothing in these cases - } - } else { - CGAL_assertion( vf->is_point() ); - if ( at_res == AT2::INTERIOR ) { - vcross.first = true; - vcross.second = vf; - vcross.third = AT2::INTERIOR; - l.clear(); -#ifdef CGAL_SDG_NO_FACE_MAP - fhc_.clear(); -#else - fm.clear(); -#endif - return; - } - } + return true; + } + else // at_res != AT2::CROSSING + { + CGAL_assertion ( at_res == AT2::DISJOINT || + at_res == AT2::TOUCH_1 || + at_res == AT2::TOUCH_2 || + at_res == AT2::TOUCH_11 || + at_res == AT2::TOUCH_12 || + at_res == AT2::TOUCH_21 || + at_res == AT2::TOUCH_22 ); + // we do nothing in these cases } } + else // ! vf->is_segment() + { + CGAL_assertion( vf->is_point() ); + if ( at_res == AT2::INTERIOR ) + { + vcross.first = true; + vcross.second = vf; + vcross.third = AT2::INTERIOR; + l.clear(); +#ifdef CGAL_SDG_NO_FACE_MAP + fhc_.clear(); +#else + fm.clear(); +#endif + return true; + } + } + } - Sign s = incircle(n, t); + return false; +} + +template +void +Segment_Delaunay_graph_2:: +expand_conflict_region(const Face_handle& in_f, + const Site_2& t, + List& l, +#ifndef CGAL_SDG_NO_FACE_MAP + Face_map& fm, + std::map& sign_map, +#endif + Triple& vcross) +{ + std::stack face_stack; + face_stack.push(in_f); + + while(!face_stack.empty()) + { + // Stop as soon as intersecting segments are found + if ( vcross.first ) + break; + + const Face_handle curr_f = face_stack.top(); + face_stack.pop(); #ifdef CGAL_SDG_NO_FACE_MAP - n->tds_data().set_incircle_sign(s); - - Sign s_f = f->tds_data().incircle_sign(); + if ( curr_f->tds_data().is_in_conflict() ) + continue; #else - sign_map[n] = s; - - Sign s_f = sign_map[f]; + if ( fm.find(curr_f) != fm.end() ) + continue; #endif - if ( s == POSITIVE ) { continue; } - if ( s != s_f ) { continue; } + // setting fm[f] to true means that the face has been reached and + // that the face is available for recycling. If we do not want the + // face to be available for recycling we must set this flag to false. +#ifdef CGAL_SDG_NO_FACE_MAP + curr_f->tds_data().mark_in_conflict(); + fhc_.push_back(curr_f); +#else + fm[curr_f] = true; +#endif - bool interior_in_conflict = edge_interior(f, i, t, s); +// CGAL_assertion( fm.find(curr_f) != fm.end() ); - if ( !interior_in_conflict ) { continue; } - - if ( face_registered ) { continue; } - - Edge e = sym_edge(f, i); - - CGAL_assertion( l.is_in_list(e) ); - int j = this->_tds.mirror_index(f, i); - Edge e_before = sym_edge(n, ccw(j)); - Edge e_after = sym_edge(n, cw(j)); - if ( !l.is_in_list(e_before) ) { - l.insert_before(e, e_before); - } - if ( !l.is_in_list(e_after) ) { - l.insert_after(e, e_after); - } - l.remove(e); + for (int i = 0; i < 3; ++i) + { + Face_handle n = curr_f->neighbor(i); #ifdef CGAL_SDG_NO_FACE_MAP - expand_conflict_region(n, t, ss, l, vcross); + bool face_registered = n->tds_data().is_in_conflict(); #else - expand_conflict_region(n, t, ss, l, fm, sign_map, vcross); + bool face_registered = (fm.find(n) != fm.end()); #endif - // this is done to stop the recursion when intersecting segments - // are found - // if ( fm.size() == 0 && l.size() == 0 ) { return; } - if ( vcross.first ) { return; } - } // for-loop + if ( !face_registered ) + { +#ifdef CGAL_SDG_NO_FACE_MAP + if(check_unregistered_face(n, t, l, vcross)) +#else + if(check_unregistered_face(n, t, l, fm, vcross)) +#endif + { + CGAL_assertion(vcross.first); + break; // intersecting segments were found + } + } + + Sign s = incircle(n, t); + +#ifdef CGAL_SDG_NO_FACE_MAP + n->tds_data().set_incircle_sign(s); + + Sign s_f = curr_f->tds_data().incircle_sign(); +#else + sign_map[n] = s; + + Sign s_f = sign_map[curr_f]; +#endif + + if ( s == POSITIVE ) + continue; + if ( s != s_f ) + continue; + if ( face_registered ) + continue; + + bool interior_in_conflict = edge_interior(curr_f, i, t, s); + if ( !interior_in_conflict ) + continue; + + Edge e = sym_edge(curr_f, i); + CGAL_assertion( l.is_in_list(e) ); + + int j = this->_tds.mirror_index(curr_f, i); + Edge e_before = sym_edge(n, ccw(j)); + Edge e_after = sym_edge(n, cw(j)); + + if ( !l.is_in_list(e_before) ) + l.insert_before(e, e_before); + + if ( !l.is_in_list(e_after) ) + l.insert_after(e, e_after); + + l.remove(e); + + face_stack.push(n); + } // neighbor for-loop + } } diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h index a5f635f1a37..1ddcca8dd44 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h @@ -478,8 +478,7 @@ insert_segment_interior(const Site_2& t, const Storage_site_2& ss, vcross(false, Vertex_handle(), AT2::DISJOINT); hierarchy[0]->initialize_conflict_region(start_f, l); - hierarchy[0]->expand_conflict_region(start_f, t, ss, l, fm, - sign_map, vcross); + hierarchy[0]->expand_conflict_region(start_f, t, l, fm, sign_map, vcross); CGAL_assertion( vcross.third == AT2::DISJOINT || vcross.third == AT2::CROSSING || diff --git a/Segment_Delaunay_graph_Linf_2/include/CGAL/Segment_Delaunay_graph_Linf_2/Segment_Delaunay_graph_Linf_hierarchy_2_impl.h b/Segment_Delaunay_graph_Linf_2/include/CGAL/Segment_Delaunay_graph_Linf_2/Segment_Delaunay_graph_Linf_hierarchy_2_impl.h index 218909e0213..b27bfb83685 100644 --- a/Segment_Delaunay_graph_Linf_2/include/CGAL/Segment_Delaunay_graph_Linf_2/Segment_Delaunay_graph_Linf_hierarchy_2_impl.h +++ b/Segment_Delaunay_graph_Linf_2/include/CGAL/Segment_Delaunay_graph_Linf_2/Segment_Delaunay_graph_Linf_hierarchy_2_impl.h @@ -520,8 +520,7 @@ insert_segment_interior(const Site_2& t, const Storage_site_2& ss, vcross(false, Vertex_handle(), AT2::DISJOINT); hierarchy[0]->initialize_conflict_region(start_f, l); - hierarchy[0]->expand_conflict_region(start_f, t, ss, l, fm, - sign_map, vcross); + hierarchy[0]->expand_conflict_region(start_f, t, l, fm, sign_map, vcross); CGAL_assertion( vcross.third == AT2::DISJOINT || vcross.third == AT2::CROSSING || From a6c528cd8f2873d0e90622eddbc46fd64c46c242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 18 Jun 2019 13:18:25 +0200 Subject: [PATCH 15/16] Derecursify Apollonius_graph_2::expand_conflict_region() --- .../include/CGAL/Apollonius_graph_2.h | 3 +- .../Apollonius_graph_2_impl.h | 112 ++++++++++-------- 2 files changed, 66 insertions(+), 49 deletions(-) diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2.h index ae3fc8f8ef3..20c27711e82 100644 --- a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2.h +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2.h @@ -32,8 +32,9 @@ #include -#include #include +#include +#include #include diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Apollonius_graph_2_impl.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Apollonius_graph_2_impl.h index a1be16f6372..c22ff29c1e3 100644 --- a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Apollonius_graph_2_impl.h +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Apollonius_graph_2_impl.h @@ -817,69 +817,85 @@ check_edge_for_hidden_sites(const Face_handle& f, int i, template void Apollonius_graph_2:: -expand_conflict_region(const Face_handle& f, const Site_2& p, - List& l, Face_map& fm, Vertex_map& vm, - std::vector* fe) +expand_conflict_region(const Face_handle& in_f, + const Site_2& p, + List& l, + Face_map& fm, + Vertex_map& vm, + std::vector* fe) { - // setting fm[f] to true means that the face has been reached and - // that the face is available for recycling. If we do not want the - // face to be available for recycling we must set this flag to - // false. - fm[f] = true; + std::stack face_stack; + face_stack.push(in_f); - // CGAL_assertion( fm.find(f) != fm.end() ); - for (int i = 0; i < 3; i++) { - bool hidden_found = - check_edge_for_hidden_sites(f, i, p, vm); + while(!face_stack.empty()) + { + const Face_handle curr_f = face_stack.top(); + face_stack.pop(); - Face_handle n = f->neighbor(i); + // setting fm[curr_f] to true means that the face has been reached and + // that the face is available for recycling. If we do not want the + // face to be available for recycling we must set this flag to false. + fm[curr_f] = true; - if ( !hidden_found ) { - Sign s = incircle(n, p); - if ( s != NEGATIVE ) { continue; } + // CGAL_assertion( fm.find(curr_f) != fm.end() ); + for (int i = 0; i < 3; ++i) + { + bool hidden_found = check_edge_for_hidden_sites(curr_f, i, p, vm); - bool interior_in_conflict = edge_interior(f, i, p, true); + Face_handle n = curr_f->neighbor(i); - if ( !interior_in_conflict ) { continue; } - } + if ( !hidden_found ) + { + Sign s = incircle(n, p); + if ( s != NEGATIVE ) + continue; - if ( fm.find(n) != fm.end() ) { - Edge e = sym_edge(f, i); - if ( l.is_in_list(e) || - l.is_in_list(sym_edge(e)) ) { - l.remove(e); - l.remove(sym_edge(e)); + bool interior_in_conflict = edge_interior(curr_f, i, p, true); + if ( !interior_in_conflict ) + continue; } - continue; - } - Edge e = sym_edge(f, i); + if ( fm.find(n) != fm.end() ) + { + Edge e = sym_edge(curr_f, i); + if ( l.is_in_list(e) ) + l.remove(e); - CGAL_assertion( l.is_in_list(e) ); - int j = tds().mirror_index(f, i); - Edge e_before = sym_edge(n, ccw(j)); - Edge e_after = sym_edge(n, cw(j)); - if ( !l.is_in_list(e_before) ) { - l.insert_before(e, e_before); - } - if ( !l.is_in_list(e_after) ) { - l.insert_after(e, e_after); - } - l.remove(e); + if( l.is_in_list(sym_edge(e)) ) + l.remove(sym_edge(e)); - if ( fe != NULL ) { - Vh_triple* vhq = new Vh_triple[1]; + continue; + } - (*vhq)[0] = Vertex_handle(); - (*vhq)[1] = n->vertex( j ); - (*vhq)[2] = n->vertex( ccw(j) ); + Edge e = sym_edge(curr_f, i); + CGAL_assertion( l.is_in_list(e) ); - fe->push_back(vhq); - } + int j = tds().mirror_index(curr_f, i); + Edge e_before = sym_edge(n, ccw(j)); + Edge e_after = sym_edge(n, cw(j)); + if ( !l.is_in_list(e_before) ) + l.insert_before(e, e_before); - expand_conflict_region(n, p, l, fm, vm, fe); - } // for-loop + if ( !l.is_in_list(e_after) ) + l.insert_after(e, e_after); + + l.remove(e); + + if ( fe != NULL ) + { + Vh_triple* vhq = new Vh_triple[1]; + + (*vhq)[0] = Vertex_handle(); + (*vhq)[1] = n->vertex( j ); + (*vhq)[2] = n->vertex( ccw(j) ); + + fe->push_back(vhq); + } + + face_stack.push(n); + } // neighbor for-loop + } } From 51333214c0748f20ba0c26311e8224d3c0d20769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 18 Jun 2019 13:18:51 +0200 Subject: [PATCH 16/16] Derecursify SDG_2::expand_conflict_region_remove() --- .../include/CGAL/Segment_Delaunay_graph_2.h | 10 +-- .../Segment_Delaunay_graph_2_impl.h | 88 +++++++++++-------- 2 files changed, 57 insertions(+), 41 deletions(-) diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h index 1d78f845f6a..501ec5e4c7f 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h @@ -969,11 +969,11 @@ protected: std::map& vmap, List& l) const; - void expand_conflict_region_remove(const Face_handle& f, - const Site_2& t, - const Storage_site_2& ss, - List& l, Face_map& fm, - Sign_map& sign_map); + void expand_conflict_region_remove(const Face_handle& in_f, + const Site_2& t, + List& l, + Face_map& fm, + Sign_map& sign_map); void find_conflict_region_remove(const Vertex_handle& v, const Vertex_handle& vnearest, diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h index 83c47c96006..145c1a4b464 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h @@ -1601,56 +1601,72 @@ equalize_degrees(const Vertex_handle& v, Self& small_d, template void Segment_Delaunay_graph_2:: -expand_conflict_region_remove(const Face_handle& f, const Site_2& t, - const Storage_site_2& ss, - List& l, Face_map& fm, Sign_map& sign_map) +expand_conflict_region_remove(const Face_handle& in_f, + const Site_2& t, + List& l, + Face_map& fm, + Sign_map& sign_map) { - if ( fm.find(f) != fm.end() ) { return; } + std::stack face_stack; + face_stack.push(in_f); - // setting fm[f] to true means that the face has been reached and - // that the face is available for recycling. If we do not want the - // face to be available for recycling we must set this flag to - // false. - fm[f] = true; + while(!face_stack.empty()) + { + const Face_handle curr_f = face_stack.top(); + face_stack.pop(); - // CGAL_assertion( fm.find(f) != fm.end() ); + if ( fm.find(curr_f) != fm.end() ) + continue; - for (int i = 0; i < 3; i++) { - Face_handle n = f->neighbor(i); + // setting fm[curr_f] to true means that the face has been reached and + // that the face is available for recycling. If we do not want the + // face to be available for recycling we must set this flag to + // false. + fm[curr_f] = true; - bool face_registered = (fm.find(n) != fm.end()); + // CGAL_assertion( fm.find(f) != fm.end() ); - Sign s = incircle(n, t); + for (int i = 0; i < 3; ++i) + { + Face_handle n = curr_f->neighbor(i); - sign_map[n] = s; + bool face_registered = (fm.find(n) != fm.end()); - Sign s_f = sign_map[f]; + Sign s = incircle(n, t); - if ( s == POSITIVE ) { continue; } - if ( s != s_f ) { continue; } + sign_map[n] = s; - bool interior_in_conflict = edge_interior(f, i, t, s); + Sign s_f = sign_map[curr_f]; - if ( !interior_in_conflict ) { continue; } + if ( s == POSITIVE ) + continue; + if ( s != s_f ) + continue; + if ( face_registered ) + continue; - if ( face_registered ) { continue; } + bool interior_in_conflict = edge_interior(curr_f, i, t, s); + if ( !interior_in_conflict ) + continue; - Edge e = sym_edge(f, i); + Edge e = sym_edge(curr_f, i); + CGAL_assertion( l.is_in_list(e) ); - CGAL_assertion( l.is_in_list(e) ); - int j = this->_tds.mirror_index(f, i); - Edge e_before = sym_edge(n, ccw(j)); - Edge e_after = sym_edge(n, cw(j)); - if ( !l.is_in_list(e_before) ) { - l.insert_before(e, e_before); - } - if ( !l.is_in_list(e_after) ) { - l.insert_after(e, e_after); - } - l.remove(e); + int j = this->_tds.mirror_index(curr_f, i); + Edge e_before = sym_edge(n, ccw(j)); + Edge e_after = sym_edge(n, cw(j)); - expand_conflict_region_remove(n, t, ss, l, fm, sign_map); - } // for-loop + if ( !l.is_in_list(e_before) ) + l.insert_before(e, e_before); + + if ( !l.is_in_list(e_after) ) + l.insert_after(e, e_after); + + l.remove(e); + + face_stack.push(n); + } // neighbor for-loop + } } @@ -1728,7 +1744,7 @@ find_conflict_region_remove(const Vertex_handle& v, } initialize_conflict_region(start_f, l); - expand_conflict_region_remove(start_f, t, ss, l, fm, sign_map); + expand_conflict_region_remove(start_f, t, l, fm, sign_map); }