From f01e24c75ba41c83473be003e257f89d6e7ffa88 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 10 Mar 2022 10:55:44 +0000 Subject: [PATCH 1/9] Add Orientation_3::operator()(Origin,Point_3,Point_3,Point_3) --- .../include/CGAL/Cartesian/function_objects.h | 9 +++ Filtered_kernel/include/CGAL/Epic_converter.h | 5 +- .../include/CGAL/Static_filtered_predicate.h | 17 ++++-- Kernel_23/include/CGAL/Origin.h | 13 ++++- Kernel_23/test/Kernel_23/origin_3.cpp | 57 +++++++++++++++++++ 5 files changed, 93 insertions(+), 8 deletions(-) create mode 100644 Kernel_23/test/Kernel_23/origin_3.cpp diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 05cdeb2ac54..9fcab1e977c 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -4307,6 +4307,15 @@ namespace CartesianKernelFunctors { w.x(), w.y(), w.z()); } + result_type + operator()( Origin o, const Point_3& u, + const Point_3& v, const Point_3& w) const + { + return orientationC3(u.x(), u.y(), u.z(), + v.x(), v.y(), v.z(), + w.x(), w.y(), w.z()); + } + result_type operator()( const Tetrahedron_3& t) const { diff --git a/Filtered_kernel/include/CGAL/Epic_converter.h b/Filtered_kernel/include/CGAL/Epic_converter.h index 2db2ffa0ec2..0a6c0fb963f 100644 --- a/Filtered_kernel/include/CGAL/Epic_converter.h +++ b/Filtered_kernel/include/CGAL/Epic_converter.h @@ -49,7 +49,10 @@ class Epic_converter { typedef typename IK::FT IK_FT; public: - + std::pair operator()(Origin o) const + { + return std::make_pair(o, true); + } std::pair operator()(const typename IK::FT n) const { diff --git a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h index 03f9da943bd..cc6935f4dce 100644 --- a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h +++ b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h @@ -7,7 +7,6 @@ // $Id$ // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial // -// // Author(s) : Andreas Fabri, Laurent Rineau #ifndef CGAL_STATIC_FILTERED_PREDICATE_H @@ -127,23 +126,29 @@ public: result_type operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) const { CGAL::Epic_converter convert; - typedef typename Kernel_traits::type EK; - typedef typename Type_mapper::type T1; + typedef typename Kernel_traits::type EK1; + typedef typename Type_mapper::type T1; std::pair aa1 = convert(a1.approx()); if(! aa1.second){ return fp(a1, a2, a3, a4); } - typedef typename Type_mapper::type T2; + + typedef typename Kernel_traits::type EK2; + typedef typename Type_mapper::type T2; std::pair aa2 = convert(a2.approx()); if(! aa2.second){ return fp(a1, a2, a3, a4); } - typedef typename Type_mapper::type T3; + + typedef typename Kernel_traits::type EK3; + typedef typename Type_mapper::type T3; std::pair aa3 = convert(a3.approx()); if(! aa3.second){ return fp(a1, a2, a3, a4); } - typedef typename Type_mapper::type T4; + + typedef typename Kernel_traits::type EK4; + typedef typename Type_mapper::type T4; std::pair aa4 = convert(a4.approx()); if(! aa4.second){ return fp(a1, a2, a3, a4); diff --git a/Kernel_23/include/CGAL/Origin.h b/Kernel_23/include/CGAL/Origin.h index a84ed4d5a03..061401763e5 100644 --- a/Kernel_23/include/CGAL/Origin.h +++ b/Kernel_23/include/CGAL/Origin.h @@ -23,7 +23,18 @@ namespace CGAL { class Origin -{}; +{ +public: + const Origin& approx() const + { + return *this; + } + + const Origin& exact() const + { + return *this; + } +}; class Null_vector {}; diff --git a/Kernel_23/test/Kernel_23/origin_3.cpp b/Kernel_23/test/Kernel_23/origin_3.cpp new file mode 100644 index 00000000000..99d136d9dae --- /dev/null +++ b/Kernel_23/test/Kernel_23/origin_3.cpp @@ -0,0 +1,57 @@ +//#define CGAL_PROFILE +#include +#include +#include +#include +typedef CGAL::Exact_predicates_exact_constructions_kernel K; +typedef K::Point_3 Point_3; +typedef CGAL::Timer Timer; + +int main(int argc, char* argv[] ) +{ + std::ifstream ifs((argc>1)? argv[1]:CGAL::data_file_path("points/cube.xyz")); + + std::vector points; + Point_3 p; + + while(ifs >> p){ + points.push_back(p); + } + + const int N = points.size()-3; + + const K::Orientation_3 orientation = K().orientation_3_object(); + + int positive = 0; + Timer t; + t.start(); + { + + for(int k = 0; k < 100; ++k) + for(int i = 0; i < N; ++i){ + Point_3 o(CGAL::ORIGIN); + if(orientation(o, points[i], points[i+1], points[i+2]) == CGAL::POSITIVE){ + ++positive; + } + } + } + t.stop(); + + std::cout << t.time() << " sec." << std::endl; + + t.reset(); + t.start(); + { + for (int k = 0; k < 100; ++k) + for(int i = 0; i < N; ++i){ + if(orientation(CGAL::ORIGIN, points[i], points[i+1], points[i+2]) == CGAL::POSITIVE){ + --positive; + } + } + } + t.stop(); + + assert(positive == 0); + std::cout << t.time() << " sec." << std::endl; + return 0; +} From 6e4483a7d02497d87a53916aa92630ae194c3313 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 10 Mar 2022 14:18:48 +0000 Subject: [PATCH 2/9] The same for Construct_orthogonal_vector_3 --- .../include/CGAL/Cartesian/function_objects.h | 18 ++++++ Kernel_23/test/Kernel_23/origin_3.cpp | 59 +++++++++++++++++-- 2 files changed, 73 insertions(+), 4 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 9fcab1e977c..a6813639693 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3031,6 +3031,24 @@ namespace CartesianKernelFunctors { return construct_vector(vx, vy, vz); } + + Vector_3 + operator()( Origin o , const Point_3& q, const Point_3& r ) const + { + FT orx = r.x(); + FT ory = r.y(); + FT orz = r.z(); + FT oqx = q.x(); + FT oqy = q.y(); + FT oqz = q.z(); + // Cross product oq * or + FT vx = oqy*orz - oqz*ory; + FT vy = oqz*orx - oqx*orz; + FT vz = oqx*ory - oqy*orx; + typename K::Construct_vector_3 construct_vector; + + return construct_vector(vx, vy, vz); + } }; template diff --git a/Kernel_23/test/Kernel_23/origin_3.cpp b/Kernel_23/test/Kernel_23/origin_3.cpp index 99d136d9dae..d2f3a7224b5 100644 --- a/Kernel_23/test/Kernel_23/origin_3.cpp +++ b/Kernel_23/test/Kernel_23/origin_3.cpp @@ -5,6 +5,7 @@ #include typedef CGAL::Exact_predicates_exact_constructions_kernel K; typedef K::Point_3 Point_3; +typedef K::Vector_3 Vector_3; typedef CGAL::Timer Timer; int main(int argc, char* argv[] ) @@ -18,15 +19,18 @@ int main(int argc, char* argv[] ) points.push_back(p); } + std::cout << "Orientation_3" << std::endl; + Timer t; + const int N = points.size()-3; const K::Orientation_3 orientation = K().orientation_3_object(); int positive = 0; - Timer t; + t.start(); { - + std::cout << "overload with 4 points" << std::endl; for(int k = 0; k < 100; ++k) for(int i = 0; i < N; ++i){ Point_3 o(CGAL::ORIGIN); @@ -42,7 +46,8 @@ int main(int argc, char* argv[] ) t.reset(); t.start(); { - for (int k = 0; k < 100; ++k) + std::cout << "overload with origin and 3 points" << std::endl; + for (int k = 0; k < 100; ++k) for(int i = 0; i < N; ++i){ if(orientation(CGAL::ORIGIN, points[i], points[i+1], points[i+2]) == CGAL::POSITIVE){ --positive; @@ -51,7 +56,53 @@ int main(int argc, char* argv[] ) } t.stop(); - assert(positive == 0); + + if(positive =! 0){ + std::cout << "Not the same results for Orientation_3"<< std::endl; + assert(false); + } std::cout << t.time() << " sec." << std::endl; + + + std::cout << "Construct_orthogonal_vector_3" << std::endl; + + const K::Construct_orthogonal_vector_3 construct_orthogonal_vector = K().construct_orthogonal_vector_3_object(); + + double sumx1 = 0, sumx2 = 0; + + t.start(); + { + std::cout << "overload with 3 points" << std::endl; + for(int k = 0; k < 100; ++k) + for(int i = 0; i < N; ++i){ + Point_3 o(CGAL::ORIGIN); + Vector_3 v = construct_orthogonal_vector(o, points[i], points[i+1]); + sumx1 += CGAL::to_double(v.approx().x()); + } + } + t.stop(); + + std::cout << t.time() << " sec." << std::endl; + + t.reset(); + t.start(); + { + std::cout << "overload with origin and 2 points" << std::endl; + for (int k = 0; k < 100; ++k) + for(int i = 0; i < N; ++i){ + Vector_3 v = construct_orthogonal_vector(CGAL::ORIGIN, points[i], points[i+1]); + sumx2 += CGAL::to_double(v.approx().x()); + } + } + + t.stop(); + + if(sumx1 == sumx2){ + std::cout << "Not the same results for Construct_orthogonal_vector" << std::endl; + assert(false); + } + std::cout << t.time() << " sec." << std::endl; + + return 0; } From 04fa75eb848da258b08252acd4268922d36292e4 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 11 Mar 2022 09:12:17 +0000 Subject: [PATCH 3/9] Use auto --- Filtered_kernel/include/CGAL/Lazy.h | 4 +- .../include/CGAL/Static_filtered_predicate.h | 131 ++++++------------ Kernel_23/include/CGAL/Origin.h | 13 +- 3 files changed, 42 insertions(+), 106 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 07ad822d7f5..c94b77e4274 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -799,7 +799,7 @@ struct Approx_converter template < typename T > decltype(auto) operator()(const T&t) const - { return t.approx(); } + { return approx(t); } const Null_vector& operator()(const Null_vector& n) const @@ -824,7 +824,7 @@ struct Exact_converter template < typename T > decltype(auto) operator()(const T&t) const - { return t.exact(); } + { return exact(t); } const Null_vector& operator()(const Null_vector& n) const diff --git a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h index cc6935f4dce..1b7b61bed0f 100644 --- a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h +++ b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h @@ -28,9 +28,7 @@ public: result_type operator()(const A1& a1) const { CGAL::Epic_converter convert; - typedef typename Kernel_traits::type EK; - typedef typename Type_mapper::type T1; - std::pair aa1 = convert(a1.approx()); + auto aa1 = convert(approx(a1)); if(! aa1.second){ return fp(a1); } @@ -42,9 +40,7 @@ public: result_type operator()(const A1& a1, const Null_vector& v) const { CGAL::Epic_converter convert; - typedef typename Kernel_traits::type EK; - typedef typename Type_mapper::type T1; - std::pair aa1 = convert(a1.approx()); + auto aa1 = convert(approx(a1)); if(! aa1.second){ return fp(a1, v); } @@ -56,14 +52,11 @@ public: result_type operator()(const A1& a1, const A2& a2) const { CGAL::Epic_converter convert; - typedef typename Kernel_traits::type EK; - typedef typename Type_mapper::type T1; - std::pair aa1 = convert(approx(a1)); + auto aa1 = convert(approx(a1)); if(! aa1.second){ return fp(a1, a2); } - typedef typename Type_mapper::type T2; - std::pair aa2 = convert(approx(a2)); + auto aa2 = convert(approx(a2)); if(! aa2.second){ return fp(a1, a2); } @@ -76,9 +69,7 @@ public: result_type operator()(const Bbox_2& bb, const A2& a2) const { CGAL::Epic_converter convert; - typedef typename Kernel_traits::type EK; - typedef typename Type_mapper::type T2; - std::pair aa2 = convert(approx(a2)); + auto aa2 = convert(approx(a2)); if(! aa2.second){ return fp(bb, a2); } @@ -89,9 +80,7 @@ public: result_type operator()(const Bbox_3& bb, const A2& a2) const { CGAL::Epic_converter convert; - typedef typename Kernel_traits::type EK; - typedef typename Type_mapper::type T2; - std::pair aa2 = convert(approx(a2)); + auto aa2 = convert(approx(a2)); if(! aa2.second){ return fp(bb, a2); } @@ -102,19 +91,15 @@ public: result_type operator()(const A1& a1, const A2& a2, const A3& a3) const { CGAL::Epic_converter convert; - typedef typename Kernel_traits::type EK; - typedef typename Type_mapper::type T1; - std::pair aa1 = convert(a1.approx()); + auto aa1 = convert(approx(a1)); if(! aa1.second){ return fp(a1, a2, a3); } - typedef typename Type_mapper::type T2; - std::pair aa2 = convert(a2.approx()); + auto aa2 = convert(approx(a2)); if(! aa2.second){ return fp(a1, a2, a3); } - typedef typename Type_mapper::type T3; - std::pair aa3 = convert(a3.approx()); + auto aa3 = convert(approx(a3)); if(! aa3.second){ return fp(a1, a2, a3); } @@ -126,30 +111,22 @@ public: result_type operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) const { CGAL::Epic_converter convert; - typedef typename Kernel_traits::type EK1; - typedef typename Type_mapper::type T1; - std::pair aa1 = convert(a1.approx()); + auto aa1 = convert(approx(a1)); if(! aa1.second){ return fp(a1, a2, a3, a4); } - typedef typename Kernel_traits::type EK2; - typedef typename Type_mapper::type T2; - std::pair aa2 = convert(a2.approx()); + auto aa2 = convert(approx(a2)); if(! aa2.second){ return fp(a1, a2, a3, a4); } - typedef typename Kernel_traits::type EK3; - typedef typename Type_mapper::type T3; - std::pair aa3 = convert(a3.approx()); + auto aa3 = convert(approx(a3)); if(! aa3.second){ return fp(a1, a2, a3, a4); } - typedef typename Kernel_traits::type EK4; - typedef typename Type_mapper::type T4; - std::pair aa4 = convert(a4.approx()); + auto aa4 = convert(approx(a4)); if(! aa4.second){ return fp(a1, a2, a3, a4); } @@ -160,29 +137,23 @@ public: result_type operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) const { CGAL::Epic_converter convert; - typedef typename Kernel_traits::type EK; - typedef typename Type_mapper::type T1; - std::pair aa1 = convert(a1.approx()); + auto aa1 = convert(approx(a1)); if(! aa1.second){ return fp(a1, a2, a3, a4, a5); } - typedef typename Type_mapper::type T2; - std::pair aa2 = convert(a2.approx()); + auto aa2 = convert(approx(a2)); if(! aa2.second){ return fp(a1, a2, a3, a4, a5); } - typedef typename Type_mapper::type T3; - std::pair aa3 = convert(a3.approx()); + auto aa3 = convert(approx(a3)); if(! aa3.second){ return fp(a1, a2, a3, a4, a5); } - typedef typename Type_mapper::type T4; - std::pair aa4 = convert(a4.approx()); + auto aa4 = convert(approx(a4)); if(! aa4.second){ return fp(a1, a2, a3, a4, a5); } - typedef typename Type_mapper::type T5; - std::pair aa5 = convert(a5.approx()); + auto aa5 = convert(approx(a5)); if(! aa5.second){ return fp(a1, a2, a3, a4, a5); } @@ -193,34 +164,27 @@ public: result_type operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6) const { CGAL::Epic_converter convert; - typedef typename Kernel_traits::type EK; - typedef typename Type_mapper::type T1; - std::pair aa1 = convert(a1.approx()); + auto aa1 = convert(approx(a1)); if(! aa1.second){ return fp(a1, a2, a3, a4, a5, a6); } - typedef typename Type_mapper::type T2; - std::pair aa2 = convert(a2.approx()); + auto aa2 = convert(approx(a2)); if(! aa2.second){ return fp(a1, a2, a3, a4, a5, a6); } - typedef typename Type_mapper::type T3; - std::pair aa3 = convert(a3.approx()); + auto aa3 = convert(approx(a3)); if(! aa3.second){ return fp(a1, a2, a3, a4, a5, a6); } - typedef typename Type_mapper::type T4; - std::pair aa4 = convert(a4.approx()); + auto aa4 = convert(approx(a4)); if(! aa4.second){ return fp(a1, a2, a3, a4, a5, a6); } - typedef typename Type_mapper::type T5; - std::pair aa5 = convert(a5.approx()); + auto aa5 = convert(approx(a5)); if(! aa5.second){ return fp(a1, a2, a3, a4, a5, a6); } - typedef typename Type_mapper::type T6; - std::pair aa6 = convert(a6.approx()); + auto aa6 = convert(approx(a6)); if(! aa6.second){ return fp(a1, a2, a3, a4, a5, a6); } @@ -231,39 +195,31 @@ public: result_type operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A6& a7) const { CGAL::Epic_converter convert; - typedef typename Kernel_traits::type EK; - typedef typename Type_mapper::type T1; - std::pair aa1 = convert(a1.approx()); + auto aa1 = convert(approx(a1)); if(! aa1.second){ return fp(a1, a2, a3, a4, a5, a6, a7); } - typedef typename Type_mapper::type T2; - std::pair aa2 = convert(a2.approx()); + auto aa2 = convert(approx(a2)); if(! aa2.second){ return fp(a1, a2, a3, a4, a5, a6, a7); } - typedef typename Type_mapper::type T3; - std::pair aa3 = convert(a3.approx()); + auto aa3 = convert(approx(a3)); if(! aa3.second){ return fp(a1, a2, a3, a4, a5, a6, a7); } - typedef typename Type_mapper::type T4; - std::pair aa4 = convert(a4.approx()); + auto aa4 = convert(approx(a4)); if(! aa4.second){ return fp(a1, a2, a3, a4, a5, a6, a7); } - typedef typename Type_mapper::type T5; - std::pair aa5 = convert(a5.approx()); + auto aa5 = convert(approx(a5)); if(! aa5.second){ return fp(a1, a2, a3, a4, a5, a6, a7); } - typedef typename Type_mapper::type T6; - std::pair aa6 = convert(a6.approx()); + auto aa6 = convert(approx(a6)); if(! aa6.second){ return fp(a1, a2, a3, a4, a5, a6, a7); } - typedef typename Type_mapper::type T7; - std::pair aa7 = convert(a7.approx()); + auto aa7 = convert(approx(a7)); if(! aa7.second){ return fp(a1, a2, a3, a4, a5, a6, a7); } @@ -275,44 +231,35 @@ public: result_type operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8) const { CGAL::Epic_converter convert; - typedef typename Kernel_traits::type EK; - typedef typename Type_mapper::type T1; - std::pair aa1 = convert(a1.approx()); + auto aa1 = convert(approx(a1)); if(! aa1.second){ return fp(a1, a2, a3, a4, a5, a6, a7, a8); } - typedef typename Type_mapper::type T2; - std::pair aa2 = convert(a2.approx()); + auto aa2 = convert(approx(a2)); if(! aa2.second){ return fp(a1, a2, a3, a4, a5, a6, a7, a8); } - typedef typename Type_mapper::type T3; - std::pair aa3 = convert(a3.approx()); + auto aa3 = convert(approx(a3)); if(! aa3.second){ return fp(a1, a2, a3, a4, a5, a6, a7, a8); } - typedef typename Type_mapper::type T4; - std::pair aa4 = convert(a4.approx()); + auto aa4 = convert(approx(a4)); if(! aa4.second){ return fp(a1, a2, a3, a4, a5, a6, a7, a8); } - typedef typename Type_mapper::type T5; - std::pair aa5 = convert(a5.approx()); + auto aa5 = convert(approx(a5)); if(! aa5.second){ return fp(a1, a2, a3, a4, a5, a6, a7, a8); } - typedef typename Type_mapper::type T6; - std::pair aa6 = convert(a6.approx()); + auto aa6 = convert(approx(a6)); if(! aa6.second){ return fp(a1, a2, a3, a5, a5, a6, a7, a8); } - typedef typename Type_mapper::type T7; - std::pair aa7 = convert(a7.approx()); + auto aa7 = convert(approx(a7)); if(! aa7.second){ return fp(a1, a2, a3, a5, a5, a6, a7, a8); } - typedef typename Type_mapper::type T8; - std::pair aa8 = convert(a8.approx()); + auto aa8 = convert(approx(a8)); if(! aa8.second){ return fp(a1, a2, a3, a4, a5, a6, a7, a8); } diff --git a/Kernel_23/include/CGAL/Origin.h b/Kernel_23/include/CGAL/Origin.h index 061401763e5..a84ed4d5a03 100644 --- a/Kernel_23/include/CGAL/Origin.h +++ b/Kernel_23/include/CGAL/Origin.h @@ -23,18 +23,7 @@ namespace CGAL { class Origin -{ -public: - const Origin& approx() const - { - return *this; - } - - const Origin& exact() const - { - return *this; - } -}; +{}; class Null_vector {}; From 53a6308edbf951d23c84742b30db4684aea1842f Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 11 Mar 2022 09:17:45 +0000 Subject: [PATCH 4/9] No longer a need for a partial specaialization for Bbox (thank you Mael) --- .../include/CGAL/Static_filtered_predicate.h | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h index 1b7b61bed0f..c16329c3ce2 100644 --- a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h +++ b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h @@ -63,29 +63,6 @@ public: return epicp(aa1.first, aa2.first); } - // We need these two specializations as in general we determine - // the kernel for the template argument A1, and this does not work for Bbox_2 and Bbox_3 - template - result_type operator()(const Bbox_2& bb, const A2& a2) const - { - CGAL::Epic_converter convert; - auto aa2 = convert(approx(a2)); - if(! aa2.second){ - return fp(bb, a2); - } - return epicp(bb, aa2.first); - } - - template - result_type operator()(const Bbox_3& bb, const A2& a2) const - { - CGAL::Epic_converter convert; - auto aa2 = convert(approx(a2)); - if(! aa2.second){ - return fp(bb, a2); - } - return epicp(bb, aa2.first); - } template result_type operator()(const A1& a1, const A2& a2, const A3& a3) const From 7a7e1d2724bba8ddd2b3d6f6074abe31434db541 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 11 Mar 2022 11:13:42 +0100 Subject: [PATCH 5/9] Update Cartesian_kernel/include/CGAL/Cartesian/function_objects.h Co-authored-by: Mael --- .../include/CGAL/Cartesian/function_objects.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index a6813639693..20086abfaf0 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3035,16 +3035,10 @@ namespace CartesianKernelFunctors { Vector_3 operator()( Origin o , const Point_3& q, const Point_3& r ) const { - FT orx = r.x(); - FT ory = r.y(); - FT orz = r.z(); - FT oqx = q.x(); - FT oqy = q.y(); - FT oqz = q.z(); // Cross product oq * or - FT vx = oqy*orz - oqz*ory; - FT vy = oqz*orx - oqx*orz; - FT vz = oqx*ory - oqy*orx; + FT vx = q.y()*r.z() - r.y()*q.z(); + FT vy = q.z()*r.x() - r.z()*q.x(); + FT vz = q.x()*r.y() - r.x()*q.y(); typename K::Construct_vector_3 construct_vector; return construct_vector(vx, vy, vz); From c4b8c370cbc6d1ffd7a68922938b507cedc45f39 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 11 Mar 2022 10:21:51 +0000 Subject: [PATCH 6/9] Deal with Null_vector similar to Origin --- Filtered_kernel/include/CGAL/Epic_converter.h | 5 +++++ .../include/CGAL/Static_filtered_predicate.h | 11 ----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Epic_converter.h b/Filtered_kernel/include/CGAL/Epic_converter.h index 0a6c0fb963f..b8dd072176d 100644 --- a/Filtered_kernel/include/CGAL/Epic_converter.h +++ b/Filtered_kernel/include/CGAL/Epic_converter.h @@ -54,6 +54,11 @@ public: return std::make_pair(o, true); } + std::pair operator()(Null_vector n) const + { + return std::make_pair(n, true); + } + std::pair operator()(const typename IK::FT n) const { double d; diff --git a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h index c16329c3ce2..9ff3aea5d1c 100644 --- a/Filtered_kernel/include/CGAL/Static_filtered_predicate.h +++ b/Filtered_kernel/include/CGAL/Static_filtered_predicate.h @@ -36,17 +36,6 @@ public: return epicp(aa1.first); } - template - result_type operator()(const A1& a1, const Null_vector& v) const - { - CGAL::Epic_converter convert; - auto aa1 = convert(approx(a1)); - if(! aa1.second){ - return fp(a1, v); - } - - return epicp(aa1.first, v); - } template result_type operator()(const A1& a1, const A2& a2) const From c3ba0ab4a2e2eb85b35c8146cb67a06a99a8be36 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 14 Mar 2022 10:27:33 +0100 Subject: [PATCH 7/9] Fix the test code --- Kernel_23/test/Kernel_23/origin_3.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Kernel_23/test/Kernel_23/origin_3.cpp b/Kernel_23/test/Kernel_23/origin_3.cpp index d2f3a7224b5..c1a74c68f30 100644 --- a/Kernel_23/test/Kernel_23/origin_3.cpp +++ b/Kernel_23/test/Kernel_23/origin_3.cpp @@ -10,7 +10,7 @@ typedef CGAL::Timer Timer; int main(int argc, char* argv[] ) { - std::ifstream ifs((argc>1)? argv[1]:CGAL::data_file_path("points/cube.xyz")); + std::ifstream ifs((argc>1)? argv[1]:CGAL::data_file_path("points_3/cube.xyz")); std::vector points; Point_3 p; @@ -57,7 +57,7 @@ int main(int argc, char* argv[] ) t.stop(); - if(positive =! 0){ + if(positive != 0){ std::cout << "Not the same results for Orientation_3"<< std::endl; assert(false); } @@ -97,7 +97,7 @@ int main(int argc, char* argv[] ) t.stop(); - if(sumx1 == sumx2){ + if(sumx1 != sumx2){ std::cout << "Not the same results for Construct_orthogonal_vector" << std::endl; assert(false); } From 9a2d78234577f6c4857c166fe6c780ed6a1beff6 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 15 Mar 2022 12:42:56 +0100 Subject: [PATCH 8/9] No need for parameter --- Cartesian_kernel/include/CGAL/Cartesian/function_objects.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 20086abfaf0..ab8a8122bd7 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3033,7 +3033,7 @@ namespace CartesianKernelFunctors { } Vector_3 - operator()( Origin o , const Point_3& q, const Point_3& r ) const + operator()( Origin, const Point_3& q, const Point_3& r ) const { // Cross product oq * or FT vx = q.y()*r.z() - r.y()*q.z(); @@ -4320,7 +4320,7 @@ namespace CartesianKernelFunctors { } result_type - operator()( Origin o, const Point_3& u, + operator()( Origin, const Point_3& u, const Point_3& v, const Point_3& w) const { return orientationC3(u.x(), u.y(), u.z(), From 6c66626cbaa5eacd90f42085abc9efb7b8acf848 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 16 Mar 2022 08:01:56 +0100 Subject: [PATCH 9/9] int -> std::size_t --- Kernel_23/test/Kernel_23/origin_3.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Kernel_23/test/Kernel_23/origin_3.cpp b/Kernel_23/test/Kernel_23/origin_3.cpp index c1a74c68f30..7367abe052e 100644 --- a/Kernel_23/test/Kernel_23/origin_3.cpp +++ b/Kernel_23/test/Kernel_23/origin_3.cpp @@ -22,7 +22,7 @@ int main(int argc, char* argv[] ) std::cout << "Orientation_3" << std::endl; Timer t; - const int N = points.size()-3; + const std::size_t N = points.size()-3; const K::Orientation_3 orientation = K().orientation_3_object(); @@ -31,8 +31,8 @@ int main(int argc, char* argv[] ) t.start(); { std::cout << "overload with 4 points" << std::endl; - for(int k = 0; k < 100; ++k) - for(int i = 0; i < N; ++i){ + for(std::size_t k = 0; k < 100; ++k) + for(std::size_t i = 0; i < N; ++i){ Point_3 o(CGAL::ORIGIN); if(orientation(o, points[i], points[i+1], points[i+2]) == CGAL::POSITIVE){ ++positive; @@ -47,8 +47,8 @@ int main(int argc, char* argv[] ) t.start(); { std::cout << "overload with origin and 3 points" << std::endl; - for (int k = 0; k < 100; ++k) - for(int i = 0; i < N; ++i){ + for (std::size_t k = 0; k < 100; ++k) + for(std::size_t i = 0; i < N; ++i){ if(orientation(CGAL::ORIGIN, points[i], points[i+1], points[i+2]) == CGAL::POSITIVE){ --positive; } @@ -73,8 +73,8 @@ int main(int argc, char* argv[] ) t.start(); { std::cout << "overload with 3 points" << std::endl; - for(int k = 0; k < 100; ++k) - for(int i = 0; i < N; ++i){ + for(std::size_t k = 0; k < 100; ++k) + for(std::size_t i = 0; i < N; ++i){ Point_3 o(CGAL::ORIGIN); Vector_3 v = construct_orthogonal_vector(o, points[i], points[i+1]); sumx1 += CGAL::to_double(v.approx().x()); @@ -88,8 +88,8 @@ int main(int argc, char* argv[] ) t.start(); { std::cout << "overload with origin and 2 points" << std::endl; - for (int k = 0; k < 100; ++k) - for(int i = 0; i < N; ++i){ + for (std::size_t k = 0; k < 100; ++k) + for(std::size_t i = 0; i < N; ++i){ Vector_3 v = construct_orthogonal_vector(CGAL::ORIGIN, points[i], points[i+1]); sumx2 += CGAL::to_double(v.approx().x()); }