From f01e24c75ba41c83473be003e257f89d6e7ffa88 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 10 Mar 2022 10:55:44 +0000 Subject: [PATCH] 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; +}