From 434384ac6421ddf4e69a7312cbfbe908ea4c1db5 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 30 Jan 2025 15:43:19 +0000 Subject: [PATCH] Kernel_23 Add a functor for offsetting (WIP) --- .../include/CGAL/Cartesian/function_objects.h | 26 ++++++++++++++++ .../include/CGAL/constructions/kernel_ftC3.h | 11 +++++++ Filtered_kernel/include/CGAL/Lazy_kernel.h | 3 +- .../CGAL/Homogeneous/function_objects.h | 30 +++++++++++++++++++ .../include/CGAL/Kernel/function_objects.h | 2 -- .../include/CGAL/Kernel/global_functions_3.h | 16 ++++++++++ .../CGAL/Kernel/global_functions_internal_3.h | 18 +++++++++++ .../include/CGAL/Kernel/interface_macros.h | 2 ++ .../include/CGAL/_test_fct_plane_3.h | 6 ++++ 9 files changed, 111 insertions(+), 3 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index ffb1056f1478..34ebf2dc0a85 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -4525,6 +4525,32 @@ namespace CartesianKernelFunctors { }; +template + class Intersect_offset_planes_3 + { + typedef typename K::FT FT; + typedef typename K::Point_3 Point_3; + typedef typename K::Plane_3 Plane_3; + public: + // typedef std::pair result_type; + typedef FT result_type; + + result_type operator()(const Plane_3& p0, const FT& t0, + const Plane_3& p1, const FT& t1, + const Plane_3& p2, const FT& t2, + const Plane_3& p3, const FT& t3) const + { + FT x, y, z, t; + intersect_offset_planesC3(p0.a(), p0.b(), p0.c(), p0.d(), t0, + p1.a(), p1.b(), p1.c(), p1.d(), t1, + p2.a(), p2.b(), p2.c(), p2.d(), t2, + p3.a(), p3.b(), p3.c(), p3.d(), t3, + x, y, z, t); + // return std::make_pair(Point_3(x, y, z),t); + return t; + } + }; + } // namespace CartesianKernelFunctors } //namespace CGAL diff --git a/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h b/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h index dbc6c1c2fa1f..b3f52acc3766 100644 --- a/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h +++ b/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h @@ -951,6 +951,17 @@ power_distance_to_power_sphereC3(const FT &px, const FT &py, const FT &pz, const return -ff0/(ff1 - ff0); } + +template < class FT > +void +intersect_offset_planesC3(const FT &p1a, const FT &p1b, const FT &p1c, const FT &p1d, const FT &t1, + const FT &p2a, const FT &p2b, const FT &p2c, const FT &p2d, const FT &t2, + const FT &p3a, const FT &p3b, const FT &p3c, const FT &p3d, const FT &t3, + const FT &p4a, const FT &p4b, const FT &p4c, const FT &p4d, const FT &t4 , + FT&px, FT &py, FT &pz, FT& t) +{ +} + // I will use this to test if the radial axis of three spheres // intersect the triangle formed by the centers. // // resolution of the system (where we note c the center) diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index a6b2ac165bae..57ada313c30f 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -79,7 +79,7 @@ struct Lazy_result_type class Enum_holder { protected: - enum { NONE, NT, VARIANT, OBJECT, BBOX, OPTIONAL_ }; + enum { NONE, NT, VARIANT, OBJECT, BBOX, OPTIONAL_ , PAIR}; }; } // internal @@ -213,6 +213,7 @@ class Lazy_kernel_generic_base : protected internal::Enum_holder CGAL_WRAPPER_TRAIT(Intersect_2, VARIANT) CGAL_WRAPPER_TRAIT(Intersect_3, VARIANT) CGAL_WRAPPER_TRAIT(Intersect_point_3_for_polyhedral_envelope, OPTIONAL_) + CGAL_WRAPPER_TRAIT(Intersect_offset_planes_3, NT) CGAL_WRAPPER_TRAIT(Compute_squared_radius_2, NT) CGAL_WRAPPER_TRAIT(Compute_x_3, NT) CGAL_WRAPPER_TRAIT(Compute_y_3, NT) diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h index b88aab964dcc..92c9720b4d11 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h @@ -46,6 +46,36 @@ namespace HomogeneousKernelFunctors { using CartesianKernelFunctors::Compute_area_divided_by_pi_3; using CartesianKernelFunctors::Compute_squared_length_divided_by_pi_square_3; + + +template + class Intersect_offset_planes_3 + { + typedef typename K::FT FT; + typedef typename K::Point_3 Point_3; + typedef typename K::Plane_3 Plane_3; + public: + // typedef std::pair result_type; + typedef FT result_type; + + result_type operator()(const Plane_3& p0, const FT& t0, + const Plane_3& p1, const FT& t1, + const Plane_3& p2, const FT& t2, + const Plane_3& p3, const FT& t3) const + { + FT x, y, z, t; + /* + intersect_offset_planesC3(p0.a(), p0.b(), p0.c(), p0.d(), t0, + p1.a(), p1.b(), p1.c(), p1.d(), t1, + p2.a(), p2.b(), p2.c(), p2.d(), t2, + p3.a(), p3.b(), p3.c(), p3.d(), t3, + x, y, z, t); + */ + // return std::make_pair(Point_3(x, y, z),t); + assert(false); + return t; + } + }; template class Angle_2 { diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index 5a7b0774e6df..0eae6be5c293 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -37,8 +37,6 @@ namespace CGAL { namespace CommonKernelFunctors { - - template class Non_zero_coordinate_index_3 { diff --git a/Kernel_23/include/CGAL/Kernel/global_functions_3.h b/Kernel_23/include/CGAL/Kernel/global_functions_3.h index 6fb9b975647a..a71c13f41ba5 100644 --- a/Kernel_23/include/CGAL/Kernel/global_functions_3.h +++ b/Kernel_23/include/CGAL/Kernel/global_functions_3.h @@ -709,6 +709,22 @@ has_smaller_signed_distance_to_plane(const Plane_3 &h, return internal::has_smaller_signed_distance_to_plane(h, p, q, K()); } +template < class K > +inline +// std::pair +typename K::FT +intersect_offset_planes(const Plane_3 &p0, + const Plane_3 &p1, + const Plane_3 &p2, + const Plane_3 &p3, + const typename K::FT& t0, + const typename K::FT& t1, + const typename K::FT& t2, + const typename K::FT& t3) +{ + return internal::intersect_offset_planes(p0, p1, p2, p3, t0, t1, t2, t3, K()); +} + template < class K > inline typename K::Boolean diff --git a/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h b/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h index 9aa8e4a339ed..d55c3a190ffd 100644 --- a/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h +++ b/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h @@ -805,6 +805,24 @@ has_smaller_signed_distance_to_plane(const typename K::Point_3 &hp, return k.less_signed_distance_to_plane_3_object()(hp, hq, hr, p, q); } +template < class K > +inline +// std::pair +typename K::FT +intersect_offset_planes(const typename K::Plane_3 &p0, + const typename K::Plane_3 &p1, + const typename K::Plane_3 &p2, + const typename K::Plane_3 &p3, + const typename K::FT &t0, + const typename K::FT &t1, + const typename K::FT &t2, + const typename K::FT &t3, + const K &k) +{ + return k.intersect_offset_planes_3_object()(p0, t0, p1, t1, p2, t2, p3, t3); +} + + template < class K > inline typename K::Boolean diff --git a/Kernel_23/include/CGAL/Kernel/interface_macros.h b/Kernel_23/include/CGAL/Kernel/interface_macros.h index a2314aef1b79..50d470195ec4 100644 --- a/Kernel_23/include/CGAL/Kernel/interface_macros.h +++ b/Kernel_23/include/CGAL/Kernel/interface_macros.h @@ -544,6 +544,8 @@ CGAL_Kernel_cons(Intersect_2, intersect_2_object) CGAL_Kernel_cons(Intersect_3, intersect_3_object) +CGAL_Kernel_cons(Intersect_offset_planes_3, + intersect_offset_planes_3_object) CGAL_Kernel_cons(Intersect_point_3_for_polyhedral_envelope, intersect_point_3_for_polyhedral_envelope_object) CGAL_Kernel_pred(Is_degenerate_2, diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_plane_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_plane_3.h index 17578d544ce4..565f65012176 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_plane_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_plane_3.h @@ -23,6 +23,7 @@ _test_fct_plane_sqrt_3(const R&) { typedef typename R::Point_3 Point_3; typedef typename R::Plane_3 Plane_3; + typedef typename R::FT FT; // bisector of 2 planes Point_3 q0(0, 0, 0, 1); @@ -43,6 +44,11 @@ _test_fct_plane_sqrt_3(const R&) assert( CGAL::bisector(ql4, ql2) == ql3 ); assert( CGAL::bisector(ql1, ql5) == ql1 ); +FT one(1); + +// std::pair res = +FT res = CGAL::intersect_offset_planes(ql1, ql2, ql3, ql4, one, one, one, one); + return true; }