diff --git a/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h b/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h index 601dcf5c9a0..7e49bb62376 100644 --- a/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h +++ b/Cartesian_kernel/include/CGAL/predicates/kernel_ftC2.h @@ -55,10 +55,10 @@ equal_lineC2(const FT &l1a, const FT &l1b, const FT &l1c, return false; // Not parallel. typename Sgn::result_type s1a = CGAL_NTS sign(l1a); if (s1a != ZERO) - return s1a == CGAL_NTS sign(l2a) - && sign_of_determinant(l1a, l1c, l2a, l2c) == ZERO; - return CGAL_NTS sign(l1b) == CGAL_NTS sign(l2b) - && sign_of_determinant(l1b, l1c, l2b, l2c) == ZERO; + return CGAL_AND(s1a == CGAL_NTS sign(l2a), + sign_of_determinant(l1a, l1c, l2a, l2c) == ZERO); + return CGAL_AND(CGAL_NTS sign(l1b) == CGAL_NTS sign(l2b), + sign_of_determinant(l1b, l1c, l2b, l2c) == ZERO); } template < class FT > @@ -230,7 +230,7 @@ compare_y_at_x_segment_C2(const FT &px, CGAL_kernel_precondition(are_ordered(s1sx, px, s1tx)); CGAL_kernel_precondition(are_ordered(s2sx, px, s2tx)); - if (s1sx != s1tx && s2sx != s2tx) { + if (CGAL_AND(s1sx != s1tx, s2sx != s2tx)) { FT s1stx = s1sx-s1tx; FT s2stx = s2sx-s2tx; @@ -265,9 +265,9 @@ typename Equal_to::result_type equal_directionC2(const FT &dx1, const FT &dy1, const FT &dx2, const FT &dy2) { - return CGAL_NTS sign(dx1) == CGAL_NTS sign(dx2) - && CGAL_NTS sign(dy1) == CGAL_NTS sign(dy2) - && sign_of_determinant(dx1, dy1, dx2, dy2) == ZERO; + return CGAL_AND_3( CGAL_NTS sign(dx1) == CGAL_NTS sign(dx2), + CGAL_NTS sign(dy1) == CGAL_NTS sign(dy2), + sign_of_determinant(dx1, dy1, dx2, dy2) == ZERO ); } template < class FT > @@ -391,7 +391,9 @@ typename Compare::result_type compare_lexicographically_xyC2(const FT &px, const FT &py, const FT &qx, const FT &qy) { - typename Compare::result_type c = CGAL_NTS compare(px,qx); + typedef typename Compare::result_type Cmp; + Cmp c = CGAL_NTS compare(px,qx); + if (is_indeterminate(c)) return indeterminate(); return (c != EQUAL) ? c : CGAL_NTS compare(py,qy); } diff --git a/Cartesian_kernel/include/CGAL/predicates/kernel_ftC3.h b/Cartesian_kernel/include/CGAL/predicates/kernel_ftC3.h index ba15fd30790..8765d0cb587 100644 --- a/Cartesian_kernel/include/CGAL/predicates/kernel_ftC3.h +++ b/Cartesian_kernel/include/CGAL/predicates/kernel_ftC3.h @@ -61,8 +61,10 @@ compare_lexicographically_xyzC3(const FT &px, const FT &py, const FT &pz, { typedef typename Compare::result_type Cmp; Cmp c = CGAL_NTS compare(px, qx); + if (is_indeterminate(c)) return indeterminate(); if (c != EQUAL) return c; c = CGAL_NTS compare(py, qy); + if (is_indeterminate(c)) return indeterminate(); if (c != EQUAL) return c; return CGAL_NTS compare(pz, qz); } @@ -288,12 +290,12 @@ typename Equal_to::result_type equal_directionC3(const FT &dx1, const FT &dy1, const FT &dz1, const FT &dx2, const FT &dy2, const FT &dz2) { - return sign_of_determinant(dx1, dy1, dx2, dy2) == ZERO - && sign_of_determinant(dx1, dz1, dx2, dz2) == ZERO - && sign_of_determinant(dy1, dz1, dy2, dz2) == ZERO - && CGAL_NTS sign(dx1) == CGAL_NTS sign(dx2) - && CGAL_NTS sign(dy1) == CGAL_NTS sign(dy2) - && CGAL_NTS sign(dz1) == CGAL_NTS sign(dz2); + return CGAL_AND_6(sign_of_determinant(dx1, dy1, dx2, dy2) == ZERO, + sign_of_determinant(dx1, dz1, dx2, dz2) == ZERO, + sign_of_determinant(dy1, dz1, dy2, dz2) == ZERO, + CGAL_NTS sign(dx1) == CGAL_NTS sign(dx2), + CGAL_NTS sign(dy1) == CGAL_NTS sign(dy2), + CGAL_NTS sign(dz1) == CGAL_NTS sign(dz2) ); } template < class FT > @@ -313,10 +315,10 @@ equal_planeC3(const FT &ha, const FT &hb, const FT &hc, const FT &hd, sign_of_determinant(pa, pd, ha, hd) == ZERO ); Sg s1b = CGAL_NTS sign(hb); if (s1b != ZERO) - return s1b == CGAL_NTS sign(pb) - && sign_of_determinant(pb, pd, hb, hd) == ZERO; - return CGAL_NTS sign(pc) == CGAL_NTS sign(hc) - && sign_of_determinant(pc, pd, hc, hd) == ZERO; + return CGAL_AND(s1b == CGAL_NTS sign(pb), + sign_of_determinant(pb, pd, hb, hd) == ZERO ); + return CGAL_AND( CGAL_NTS sign(pc) == CGAL_NTS sign(hc), + sign_of_determinant(pc, pd, hc, hd) == ZERO ); } template diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index 89a84b5f150..0e9bb380f6a 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -480,6 +480,16 @@ public: }; + struct Less_xyz_3 : public BaseClass::Less_xyz_3 + { + typedef typename Kernel_::Point_3 Point_3; + + bool operator()(const Point_3& p, const Point_3& q) const + { + if (p.rep().identical(q.rep())) { return false; } + return BaseClass::Less_xyz_3::operator()(p,q); + } + }; Construct_point_2 construct_point_2_object() const { @@ -502,7 +512,6 @@ public: return Compute_weight_3(); } - Assign_2 assign_2_object() const { return Assign_2(); } @@ -534,6 +543,10 @@ public: Compute_approximate_area_3 compute_approximate_area_3_object() const { return Compute_approximate_area_3(); } + + Less_xyz_3 + less_xyz_3_object() const + { return Less_xyz_3(); } }; // end class Lazy_kernel_base diff --git a/Kernel_23/benchmark/Kernel_23/CMakeLists.txt b/Kernel_23/benchmark/Kernel_23/CMakeLists.txt new file mode 100644 index 00000000000..d061469c729 --- /dev/null +++ b/Kernel_23/benchmark/Kernel_23/CMakeLists.txt @@ -0,0 +1,12 @@ +# Created by the script cgal_create_cmake_script +# This is the CMake script for compiling a CGAL application. + +cmake_minimum_required(VERSION 3.1...3.14) +project( benchmark ) + +find_package(CGAL REQUIRED QUIET OPTIONAL_COMPONENTS Core ) + + include_directories (BEFORE "../include") + +create_single_source_cgal_program( "cmp_epeck_points.cpp" ) + diff --git a/Kernel_23/benchmark/Kernel_23/cmp_epeck_points.cpp b/Kernel_23/benchmark/Kernel_23/cmp_epeck_points.cpp new file mode 100644 index 00000000000..86e8fec5f9c --- /dev/null +++ b/Kernel_23/benchmark/Kernel_23/cmp_epeck_points.cpp @@ -0,0 +1,36 @@ +#define TEST_IDENTICAL + +#include +#include + +#include +#include + +typedef CGAL::Exact_predicates_exact_constructions_kernel K; +typedef K::Point_3 Point_3; +typedef K::Vector_3 Vector_3; + + +int main(){ + + int N = 10000000; + + std::vector points(N); + + int count = 0; + for(int i = 0; i < N; i+=10){ + points[i] = Point_3((N-i) * CGAL_PI , 0, 0) + Vector_3(i * (CGAL_PI/2.0), 0, 0); + if(points[i].approx().x().inf() != points[i].approx().x().sup()){ + ++count; + } + for(int j = 1; j < 10; j++){ + points[i+j] = points[i]; + } + } + std::cout << count << " points approx().x().inf() != approx().x().sup()" << std::endl; + CGAL::Timer t; + t.start(); + std::sort(points.begin(), points.end()); + std::cout << t.time() << " sec." << std::endl; + return 0; +} diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index 1a803d094ae..40d05f8094d 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -3111,7 +3111,7 @@ namespace CommonKernelFunctors { result_type operator()(const Iso_rectangle_2& i1, const Iso_rectangle_2& i2) const { - return ((i1.min)() == (i2.min)()) && ((i1.max)() == (i2.max)()); + return CGAL_AND((i1.min)() == (i2.min)(), (i1.max)() == (i2.max)()); } }; @@ -3138,7 +3138,7 @@ namespace CommonKernelFunctors { result_type operator()(const Point_3 &p, const Point_3 &q) const { - return p.x() == q.x() && p.y() == q.y() && p.z() == q.z(); + return CGAL_AND_3(p.x() == q.x(), p.y() == q.y(), p.z() == q.z()); } result_type diff --git a/STL_Extension/include/CGAL/Uncertain.h b/STL_Extension/include/CGAL/Uncertain.h index 21f46a9196a..1a7539b2b24 100644 --- a/STL_Extension/include/CGAL/Uncertain.h +++ b/STL_Extension/include/CGAL/Uncertain.h @@ -348,6 +348,7 @@ Uncertain operator&(Uncertain a, bool b) #endif #define CGAL_AND_3(X, Y, Z) CGAL_AND(X, CGAL_AND(Y, Z)) +#define CGAL_AND_6(A, B, C, D, E, F) CGAL_AND(CGAL_AND_3(A, B, C), CGAL_AND_3(D, E,F)) #define CGAL_OR_3(X, Y, Z) CGAL_OR(X, CGAL_OR(Y, Z))