From da0635e4b1e62cfc8b58d2faf1a9006b36ee0494 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Mon, 20 Jul 2020 17:03:28 +0200 Subject: [PATCH 001/130] result_of changed to decltype --- Filtered_kernel/include/CGAL/Lazy.h | 1 + Kernel_23/examples/Kernel_23/MyKernel.cpp | 3 +- .../Kernel_23/cartesian_converter.cpp | 3 +- .../examples/Kernel_23/intersection_get.cpp | 3 +- .../Kernel_23/intersection_visitor.cpp | 6 +--- .../examples/Kernel_23/intersections.cpp | 3 +- Kernel_23/include/CGAL/Bbox_3.h | 1 - Kernel_23/include/CGAL/Circle_2.h | 5 ++-- Kernel_23/include/CGAL/Circle_3.h | 6 ++-- Kernel_23/include/CGAL/Direction_2.h | 7 ++--- Kernel_23/include/CGAL/Direction_3.h | 9 +++--- Kernel_23/include/CGAL/Iso_cuboid_3.h | 26 ++++++++--------- Kernel_23/include/CGAL/Iso_rectangle_2.h | 21 +++++++------- .../include/CGAL/Kernel/function_objects.h | 14 ++++----- Kernel_23/include/CGAL/Kernel_checker.h | 12 +++----- Kernel_23/include/CGAL/Plane_3.h | 9 +++--- Kernel_23/include/CGAL/Point_2.h | 17 +++++------ Kernel_23/include/CGAL/Point_3.h | 18 ++++++------ Kernel_23/include/CGAL/Ray_2.h | 7 ++--- Kernel_23/include/CGAL/Ray_3.h | 9 +++--- Kernel_23/include/CGAL/Segment_2.h | 29 +++++++++---------- Kernel_23/include/CGAL/Segment_3.h | 24 +++++++-------- Kernel_23/include/CGAL/Sphere_3.h | 2 +- Kernel_23/include/CGAL/Tetrahedron_3.h | 6 ++-- Kernel_23/include/CGAL/Triangle_2.h | 5 ++-- Kernel_23/include/CGAL/Triangle_3.h | 4 +-- Kernel_23/include/CGAL/Vector_2.h | 17 +++++------ Kernel_23/include/CGAL/Vector_3.h | 23 +++++++-------- Kernel_23/include/CGAL/Weighted_point_2.h | 19 ++++++------ Kernel_23/include/CGAL/Weighted_point_3.h | 22 +++++++------- Kernel_23/include/CGAL/basic.h | 5 ---- .../CGAL/_test_all_linear_intersections.h | 9 ++---- 32 files changed, 153 insertions(+), 192 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 067fbe57463..559e9daea55 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include diff --git a/Kernel_23/examples/Kernel_23/MyKernel.cpp b/Kernel_23/examples/Kernel_23/MyKernel.cpp index 7f0b862067a..13eec454b3d 100644 --- a/Kernel_23/examples/Kernel_23/MyKernel.cpp +++ b/Kernel_23/examples/Kernel_23/MyKernel.cpp @@ -56,8 +56,7 @@ int main() K::Intersect_2 intersection; - CGAL::cpp11::result_of::type - intersect = intersection(s1, s2); + const auto intersect = intersection(s1, s2); K::Construct_cartesian_const_iterator_2 construct_it; K::Cartesian_const_iterator_2 cit = construct_it(a); diff --git a/Kernel_23/examples/Kernel_23/cartesian_converter.cpp b/Kernel_23/examples/Kernel_23/cartesian_converter.cpp index 63c49c37585..ebd4343d304 100644 --- a/Kernel_23/examples/Kernel_23/cartesian_converter.cpp +++ b/Kernel_23/examples/Kernel_23/cartesian_converter.cpp @@ -25,8 +25,7 @@ int main(){ EK::Triangle_3 t2=to_exact(t1); EK::Line_3 l2=to_exact(l1); - CGAL::cpp11::result_of::type - inter = CGAL::intersection(t2,l2); + const auto inter = CGAL::intersection(t2,l2); // As we are sure that there IS an intersection // and that the intersection IS a point diff --git a/Kernel_23/examples/Kernel_23/intersection_get.cpp b/Kernel_23/examples/Kernel_23/intersection_get.cpp index 2e6c66cec4f..ff2332a153c 100644 --- a/Kernel_23/examples/Kernel_23/intersection_get.cpp +++ b/Kernel_23/examples/Kernel_23/intersection_get.cpp @@ -12,8 +12,7 @@ int main() Segment_2 seg(Point_2(0,0), Point_2(2,2)); Line_2 lin(1,-1,0); - CGAL::cpp11::result_of::type - result = intersection(seg, lin); + const auto result = intersection(seg, lin); if (result) { if (const Segment_2* s = boost::get(&*result)) { std::cout << *s << std::endl; diff --git a/Kernel_23/examples/Kernel_23/intersection_visitor.cpp b/Kernel_23/examples/Kernel_23/intersection_visitor.cpp index 1c511387b65..ffe5c09c7d8 100644 --- a/Kernel_23/examples/Kernel_23/intersection_visitor.cpp +++ b/Kernel_23/examples/Kernel_23/intersection_visitor.cpp @@ -26,11 +26,7 @@ int main() Segment_2 seg(Point_2(0,0), Point_2(1,1)); Line_2 lin(1,-1,0); - // with C++11 support - // auto result = intersection(seg, lin); - // without C++11 - CGAL::cpp11::result_of::type - result = intersection(seg, lin); + const auto result = intersection(seg, lin); if (result) { boost::apply_visitor(Intersection_visitor(), *result); } else { diff --git a/Kernel_23/examples/Kernel_23/intersections.cpp b/Kernel_23/examples/Kernel_23/intersections.cpp index 283fd5b9aad..193e77c292d 100644 --- a/Kernel_23/examples/Kernel_23/intersections.cpp +++ b/Kernel_23/examples/Kernel_23/intersections.cpp @@ -15,13 +15,12 @@ typedef CGAL::Creator_uniform_2< Point, Segment> Seg_creator; typedef CGAL::Join_input_iterator_2< P1, P2, Seg_creator> Seg_iterator; struct Intersector{ - typedef CGAL::cpp11::result_of::type result_type; const Segment& s; K::Intersect_2 intersect; Intersector(const Segment& seg): s(seg) {} - result_type + decltype(auto) operator() ( const Segment& other) const { return intersect(s, other); diff --git a/Kernel_23/include/CGAL/Bbox_3.h b/Kernel_23/include/CGAL/Bbox_3.h index 1e5bb0d8eb9..2f5b6e49425 100644 --- a/Kernel_23/include/CGAL/Bbox_3.h +++ b/Kernel_23/include/CGAL/Bbox_3.h @@ -18,7 +18,6 @@ #include #include -#include #include #include #include diff --git a/Kernel_23/include/CGAL/Circle_2.h b/Kernel_23/include/CGAL/Circle_2.h index c9522d24c02..a1cc8092654 100644 --- a/Kernel_23/include/CGAL/Circle_2.h +++ b/Kernel_23/include/CGAL/Circle_2.h @@ -24,7 +24,6 @@ #include #include #include -#include namespace CGAL { @@ -89,13 +88,13 @@ public: Circle_2(const Point_2 & center) : RCircle_2(typename R::Construct_circle_2()(Return_base_tag(), center, FT(0), COUNTERCLOCKWISE)) {} - typename cpp11::result_of::type + decltype(auto) center() const { return R().construct_center_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) squared_radius() const { return R().compute_squared_radius_2_object()(*this); diff --git a/Kernel_23/include/CGAL/Circle_3.h b/Kernel_23/include/CGAL/Circle_3.h index e2c5c6c9adc..0b42941a064 100644 --- a/Kernel_23/include/CGAL/Circle_3.h +++ b/Kernel_23/include/CGAL/Circle_3.h @@ -93,8 +93,7 @@ public: Circle_3(const Rep& r) : Rep(r) {} - typename cpp11::result_of - ::type + decltype(auto) diametral_sphere() const { return typename R::Construct_sphere_3()(*this); @@ -110,8 +109,7 @@ public: return typename R::Construct_sphere_3()(*this).squared_radius(); } - typename cpp11::result_of - ::type + decltype(auto) supporting_plane() const { return typename R::Construct_plane_3()(*this); diff --git a/Kernel_23/include/CGAL/Direction_2.h b/Kernel_23/include/CGAL/Direction_2.h index 6517028cfa0..37f1196d794 100644 --- a/Kernel_23/include/CGAL/Direction_2.h +++ b/Kernel_23/include/CGAL/Direction_2.h @@ -23,7 +23,6 @@ #include #include #include -#include #include namespace CGAL { @@ -93,19 +92,19 @@ public: return R().construct_perpendicular_direction_2_object()(*this,o); } - typename cpp11::result_of::type + decltype(auto) dx() const { return R().compute_dx_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) dy() const { return R().compute_dy_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) delta(int i) const { CGAL_kernel_precondition( ( i == 0 ) || ( i == 1 ) ); diff --git a/Kernel_23/include/CGAL/Direction_3.h b/Kernel_23/include/CGAL/Direction_3.h index 3c491375d03..77be97c63be 100644 --- a/Kernel_23/include/CGAL/Direction_3.h +++ b/Kernel_23/include/CGAL/Direction_3.h @@ -23,7 +23,6 @@ #include #include #include -#include #include namespace CGAL { @@ -99,25 +98,25 @@ public: Vector_3 vector() const { return to_vector(); } - typename cpp11::result_of::type + decltype(auto) dx() const { return R().compute_dx_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) dy() const { return R().compute_dy_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) dz() const { return R().compute_dz_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) delta(int i) const { CGAL_kernel_precondition( i >= 0 && i <= 2 ); diff --git a/Kernel_23/include/CGAL/Iso_cuboid_3.h b/Kernel_23/include/CGAL/Iso_cuboid_3.h index 0dd33eb0b9f..9c241a184ec 100644 --- a/Kernel_23/include/CGAL/Iso_cuboid_3.h +++ b/Kernel_23/include/CGAL/Iso_cuboid_3.h @@ -86,67 +86,67 @@ public: : Rep(typename R::Construct_iso_cuboid_3()(Return_base_tag(), bbox.xmin(), bbox.ymin(), bbox.zmin(), bbox.xmax(), bbox.ymax(), bbox.zmax())) {} - typename cpp11::result_of::type + decltype(auto) min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return R().construct_min_vertex_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return R().construct_max_vertex_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) vertex(int i) const { return R().construct_vertex_3_object()(*this,i); } - typename cpp11::result_of::type + decltype(auto) operator[](int i) const { return R().construct_vertex_3_object()(*this,i); } - typename cpp11::result_of::type + decltype(auto) xmin() const { return R().compute_xmin_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) xmax() const { return R().compute_xmax_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) ymin() const { return R().compute_ymin_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) ymax() const { return R().compute_ymax_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) zmin() const { return R().compute_zmin_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) zmax() const { return R().compute_zmax_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) min_coord(int i) const { CGAL_kernel_precondition( i == 0 || i == 1 || i == 2 ); @@ -158,7 +158,7 @@ public: return zmin(); } - typename cpp11::result_of::type + decltype(auto) max_coord(int i) const { CGAL_kernel_precondition( i == 0 || i == 1 || i == 2 ); @@ -206,7 +206,7 @@ public: return R().is_degenerate_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) volume() const { return R().compute_volume_3_object()(*this); diff --git a/Kernel_23/include/CGAL/Iso_rectangle_2.h b/Kernel_23/include/CGAL/Iso_rectangle_2.h index 187b9df2b86..10041882ce5 100644 --- a/Kernel_23/include/CGAL/Iso_rectangle_2.h +++ b/Kernel_23/include/CGAL/Iso_rectangle_2.h @@ -22,7 +22,6 @@ #include #include #include -#include namespace CGAL { @@ -82,13 +81,13 @@ public: Iso_rectangle_2(const Bbox_2& bbox) : Rep(typename R::Construct_iso_rectangle_2()(Return_base_tag(), bbox.xmin(), bbox.ymin(), bbox.xmax(), bbox.ymax())) {} - typename cpp11::result_of::type + decltype(auto) min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return R().construct_min_vertex_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return R().construct_max_vertex_2_object()(*this); @@ -107,43 +106,43 @@ public: } - typename cpp11::result_of::type + decltype(auto) vertex(int i) const { return R().construct_vertex_2_object()(*this,i); } - typename cpp11::result_of::type + decltype(auto) operator[](int i) const { return R().construct_vertex_2_object()(*this,i); } - typename cpp11::result_of::type + decltype(auto) xmin() const { return R().compute_xmin_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) xmax() const { return R().compute_xmax_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) ymin() const { return R().compute_ymin_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) ymax() const { return R().compute_ymax_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) min_coord(int i) const { CGAL_kernel_precondition( i == 0 || i == 1 ); @@ -153,7 +152,7 @@ public: return ymin(); } - typename cpp11::result_of::type + decltype(auto) max_coord(int i) const { CGAL_kernel_precondition( i == 0 || i == 1 ); diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index cd335df94fc..c3c3537838e 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -1682,8 +1682,7 @@ namespace CommonKernelFunctors { Line l1 = construct_line(l11, l12); Line l2 = construct_line(l21, l22); - typename cpp11::result_of::type - res = typename K::Intersect_3()(l1,l2); + const auto res = typename K::Intersect_3()(l1,l2); CGAL_assertion(res!=boost::none); const Point* e_pt = boost::get(&(*res)); CGAL_assertion(e_pt!=nullptr); @@ -2082,8 +2081,7 @@ namespace CommonKernelFunctors { Plane plane = construct_plane(p1, p2, p3); Line line = construct_line( l1, l2 ); - typename cpp11::result_of::type - res = typename K::Intersect_3()(plane,line); + const auto res = typename K::Intersect_3()(plane,line); CGAL_assertion(res!=boost::none); const Point* e_pt = boost::get(&(*res)); CGAL_assertion(e_pt!=nullptr); @@ -2096,8 +2094,7 @@ namespace CommonKernelFunctors { { Line line = construct_line( l1, l2 ); - typename cpp11::result_of::type - res = typename K::Intersect_3()(plane,line); + const auto res = typename K::Intersect_3()(plane,line); CGAL_assertion(res!=boost::none); const Point* e_pt = boost::get(&(*res)); CGAL_assertion(e_pt!=nullptr); @@ -3328,8 +3325,7 @@ namespace CommonKernelFunctors { if(!K().do_intersect_3_object()(s1, s2)) return false; const Circle_3 circ(s1, s2); const Plane_3& plane = circ.supporting_plane(); - typename CGAL::cpp11::result_of::type - optional = K().intersect_3_object()(plane, Segment_3(a, b)); + const auto optional = K().intersect_3_object()(plane, Segment_3(a, b)); CGAL_kernel_assertion_msg(bool(optional) == true, "the segment does not intersect the supporting" " plane"); @@ -3558,7 +3554,7 @@ namespace CommonKernelFunctors { // n possibilities, so I keep the template. template - typename cpp11::result_of< Intersect_3(T1, T2) >::type + decltype(auto) operator()(const T1& t1, const T2& t2) const { return Intersections::internal::intersection(t1, t2, K() ); } diff --git a/Kernel_23/include/CGAL/Kernel_checker.h b/Kernel_23/include/CGAL/Kernel_checker.h index b16a3d4806c..a4753265266 100644 --- a/Kernel_23/include/CGAL/Kernel_checker.h +++ b/Kernel_23/include/CGAL/Kernel_checker.h @@ -21,7 +21,6 @@ // This file contains the definition of a kernel traits checker. #include -#include #include #include @@ -80,19 +79,16 @@ public: { } template - typename Pairify::type, - typename CGAL::cpp11::result_of::type>::result_type + decltype(auto) operator()(const A&... a) const { - typedef typename CGAL::cpp11::result_of::type result_type_1; - typedef typename CGAL::cpp11::result_of::type result_type_2; - result_type_1 res1 = p1(a.first...); - result_type_2 res2 = p2(a.second...); + auto res1 = p1(a.first...); + auto res2 = p2(a.second...); if (! cmp(res1, res2)) { CGAL_kernel_assertion(false); } - return Pairify()(res1, res2); + return Pairify()(res1, res2); } }; diff --git a/Kernel_23/include/CGAL/Plane_3.h b/Kernel_23/include/CGAL/Plane_3.h index 1cb4aaff9bb..659cde8d50b 100644 --- a/Kernel_23/include/CGAL/Plane_3.h +++ b/Kernel_23/include/CGAL/Plane_3.h @@ -21,7 +21,6 @@ #include #include #include -#include #include namespace CGAL { @@ -107,25 +106,25 @@ public: return Direction_3(a(), b(), c()); } - typename cpp11::result_of::type + decltype(auto) a() const { return R().compute_a_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) b() const { return R().compute_b_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) c() const { return R().compute_c_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) d() const { return R().compute_d_3_object()(*this); diff --git a/Kernel_23/include/CGAL/Point_2.h b/Kernel_23/include/CGAL/Point_2.h index 7358d0dc46b..1d4403354b7 100644 --- a/Kernel_23/include/CGAL/Point_2.h +++ b/Kernel_23/include/CGAL/Point_2.h @@ -24,7 +24,6 @@ #include #include #include -#include namespace CGAL { @@ -93,26 +92,26 @@ public: swap(a.rep(), b.rep()); } - typename cpp11::result_of::type + decltype(auto) x() const { return typename R::Compute_x_2()(*this); } - typename cpp11::result_of::type + decltype(auto) y() const { return typename R::Compute_y_2()(*this); } - typename cpp11::result_of::type + decltype(auto) cartesian(int i) const { CGAL_kernel_precondition( (i == 0) || (i == 1) ); return (i==0) ? x() : y(); } - typename cpp11::result_of::type + decltype(auto) operator[](int i) const { return cartesian(i); @@ -129,19 +128,19 @@ public: } - typename cpp11::result_of::type + decltype(auto) hx() const { return typename R::Compute_hx_2()(*this); } - typename cpp11::result_of::type + decltype(auto) hy() const { return typename R::Compute_hy_2()(*this); } - typename cpp11::result_of::type + decltype(auto) hw() const { return typename R::Compute_hw_2()(*this); @@ -152,7 +151,7 @@ public: return 2; } - typename cpp11::result_of::type + decltype(auto) homogeneous(int i) const { CGAL_kernel_precondition( (i >= 0) || (i <= 2) ); diff --git a/Kernel_23/include/CGAL/Point_3.h b/Kernel_23/include/CGAL/Point_3.h index 01b07bd3e0e..a8487afeb38 100644 --- a/Kernel_23/include/CGAL/Point_3.h +++ b/Kernel_23/include/CGAL/Point_3.h @@ -90,49 +90,49 @@ public: swap(a.rep(), b.rep()); } - typename cpp11::result_of::type + decltype(auto) x() const { return typename R::Compute_x_3()(*this); } - typename cpp11::result_of::type + decltype(auto) y() const { return typename R::Compute_y_3()(*this); } - typename cpp11::result_of::type + decltype(auto) z() const { return typename R::Compute_z_3()(*this); } - typename cpp11::result_of::type + decltype(auto) hx() const { return R().compute_hx_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) hy() const { return R().compute_hy_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) hz() const { return R().compute_hz_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) hw() const { return R().compute_hw_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) cartesian(int i) const { CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) ); @@ -151,7 +151,7 @@ public: return hw(); } - typename cpp11::result_of::type + decltype(auto) operator[](int i) const { return cartesian(i); diff --git a/Kernel_23/include/CGAL/Ray_2.h b/Kernel_23/include/CGAL/Ray_2.h index b0568ee2cd3..732ea145918 100644 --- a/Kernel_23/include/CGAL/Ray_2.h +++ b/Kernel_23/include/CGAL/Ray_2.h @@ -23,7 +23,6 @@ #include #include #include -#include #include namespace CGAL { @@ -81,13 +80,13 @@ public: : RRay_2(typename R::Construct_ray_2()(Return_base_tag(), sp, l)) {} - typename cpp11::result_of::type + decltype(auto) source() const { return R().construct_source_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) second_point() const { return R().construct_second_point_2_object()(*this); @@ -108,7 +107,7 @@ public: construct_scaled_vector(construct_vector(source(), second_point()), i)); } - typename cpp11::result_of::type + decltype(auto) start() const { return source(); diff --git a/Kernel_23/include/CGAL/Ray_3.h b/Kernel_23/include/CGAL/Ray_3.h index 242edee56c5..6854f30a46f 100644 --- a/Kernel_23/include/CGAL/Ray_3.h +++ b/Kernel_23/include/CGAL/Ray_3.h @@ -22,7 +22,6 @@ #include #include #include -#include #include namespace CGAL { @@ -99,25 +98,25 @@ public: bool collinear_has_on(const Point_3 &p) const; */ - typename cpp11::result_of::type + decltype(auto) point(const FT i) const { return R().construct_point_on_3_object()(*this, i); } - typename cpp11::result_of::type + decltype(auto) source() const { return R().construct_source_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) second_point() const { return R().construct_second_point_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) start() const { return source(); diff --git a/Kernel_23/include/CGAL/Segment_2.h b/Kernel_23/include/CGAL/Segment_2.h index a318f285648..acb75fd5374 100644 --- a/Kernel_23/include/CGAL/Segment_2.h +++ b/Kernel_23/include/CGAL/Segment_2.h @@ -23,7 +23,6 @@ #include #include #include -#include namespace CGAL { @@ -70,44 +69,44 @@ public: Segment_2(const Point_2 &sp, const Point_2 &ep) : RSegment_2(typename R::Construct_segment_2()(Return_base_tag(), sp,ep)) {} - typename cpp11::result_of::type + decltype(auto) source() const { return R_().construct_source_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) target() const { return R_().construct_target_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) start() const { return source(); } - typename cpp11::result_of::type + decltype(auto) end() const { return target(); } - typename cpp11::result_of::type + decltype(auto) min BOOST_PREVENT_MACRO_SUBSTITUTION() const; - typename cpp11::result_of::type + decltype(auto) max BOOST_PREVENT_MACRO_SUBSTITUTION () const; - typename cpp11::result_of::type + decltype(auto) vertex(int i) const; - typename cpp11::result_of::type + decltype(auto) point(int i) const; - typename cpp11::result_of::type + decltype(auto) operator[](int i) const; bool is_horizontal() const; @@ -172,7 +171,7 @@ public: template < class R_ > CGAL_KERNEL_INLINE -typename cpp11::result_of )>::type +decltype(auto) Segment_2::min BOOST_PREVENT_MACRO_SUBSTITUTION () const { typename R_::Less_xy_2 less_xy; @@ -181,7 +180,7 @@ Segment_2::min BOOST_PREVENT_MACRO_SUBSTITUTION () const template < class R_ > CGAL_KERNEL_INLINE -typename cpp11::result_of )>::type +decltype(auto) Segment_2::max BOOST_PREVENT_MACRO_SUBSTITUTION () const { typename R_::Less_xy_2 less_xy; @@ -190,7 +189,7 @@ Segment_2::max BOOST_PREVENT_MACRO_SUBSTITUTION () const template < class R_ > CGAL_KERNEL_INLINE -typename cpp11::result_of, int )>::type +decltype(auto) Segment_2::vertex(int i) const { return (i%2 == 0) ? source() : target(); @@ -198,7 +197,7 @@ Segment_2::vertex(int i) const template < class R_ > inline -typename cpp11::result_of, int )>::type +decltype(auto) Segment_2::point(int i) const { return vertex(i); @@ -206,7 +205,7 @@ Segment_2::point(int i) const template < class R_ > inline -typename cpp11::result_of, int )>::type +decltype(auto) Segment_2::operator[](int i) const { return vertex(i); diff --git a/Kernel_23/include/CGAL/Segment_3.h b/Kernel_23/include/CGAL/Segment_3.h index da8783d67fb..9bece158b35 100644 --- a/Kernel_23/include/CGAL/Segment_3.h +++ b/Kernel_23/include/CGAL/Segment_3.h @@ -68,44 +68,44 @@ public: Segment_3(const Point_3& sp, const Point_3& ep) : Rep(typename R::Construct_segment_3()(Return_base_tag(), sp, ep)) {} - typename cpp11::result_of::type + decltype(auto) source() const { return R_().construct_source_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) target() const { return R_().construct_target_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) start() const { return source(); } - typename cpp11::result_of::type + decltype(auto) end() const { return target(); } - typename cpp11::result_of::type + decltype(auto) min BOOST_PREVENT_MACRO_SUBSTITUTION () const; - typename cpp11::result_of::type + decltype(auto) max BOOST_PREVENT_MACRO_SUBSTITUTION () const; - typename cpp11::result_of::type + decltype(auto) vertex(int i) const; - typename cpp11::result_of::type + decltype(auto) point(int i) const { return vertex(i); } - typename cpp11::result_of::type + decltype(auto) operator[](int i) const { return vertex(i); } @@ -163,7 +163,7 @@ public: template < class R_ > CGAL_KERNEL_INLINE -typename cpp11::result_of ) >::type +decltype(auto) Segment_3::min BOOST_PREVENT_MACRO_SUBSTITUTION () const { typename R_::Less_xyz_3 less_xyz; @@ -172,7 +172,7 @@ Segment_3::min BOOST_PREVENT_MACRO_SUBSTITUTION () const template < class R_ > CGAL_KERNEL_INLINE -typename cpp11::result_of ) >::type +decltype(auto) Segment_3::max BOOST_PREVENT_MACRO_SUBSTITUTION () const { typename R_::Less_xyz_3 less_xyz; @@ -181,7 +181,7 @@ Segment_3::max BOOST_PREVENT_MACRO_SUBSTITUTION () const template < class R_ > CGAL_KERNEL_INLINE -typename cpp11::result_of, int ) >::type +decltype(auto) Segment_3::vertex(int i) const { return (i%2 == 0) ? source() : target(); diff --git a/Kernel_23/include/CGAL/Sphere_3.h b/Kernel_23/include/CGAL/Sphere_3.h index 8e9076b6c3c..246801a068e 100644 --- a/Kernel_23/include/CGAL/Sphere_3.h +++ b/Kernel_23/include/CGAL/Sphere_3.h @@ -86,7 +86,7 @@ public: Sphere_3 orthogonal_transform(const Aff_transformation_3 &t) const; - typename cpp11::result_of::type + decltype(auto) center() const { return R().construct_center_3_object()(*this); diff --git a/Kernel_23/include/CGAL/Tetrahedron_3.h b/Kernel_23/include/CGAL/Tetrahedron_3.h index 5916902e060..634e73434da 100644 --- a/Kernel_23/include/CGAL/Tetrahedron_3.h +++ b/Kernel_23/include/CGAL/Tetrahedron_3.h @@ -70,13 +70,13 @@ public: t.transform(this->vertex(3))); } - typename cpp11::result_of::type + decltype(auto) vertex(int i) const { return R().construct_vertex_3_object()(*this,i); } - typename cpp11::result_of::type + decltype(auto) operator[](int i) const { return vertex(i); @@ -128,7 +128,7 @@ public: return R().has_on_unbounded_side_3_object()(*this, p); } - typename cpp11::result_of::type + decltype(auto) volume() const { return R().compute_volume_3_object()(*this); diff --git a/Kernel_23/include/CGAL/Triangle_2.h b/Kernel_23/include/CGAL/Triangle_2.h index 7bd394e10f3..5cc5aa97cad 100644 --- a/Kernel_23/include/CGAL/Triangle_2.h +++ b/Kernel_23/include/CGAL/Triangle_2.h @@ -22,7 +22,6 @@ #include #include #include -#include #include namespace CGAL { @@ -101,13 +100,13 @@ public: return !(*this == t); } - typename cpp11::result_of::type + decltype(auto) vertex(int i) const { return R().construct_vertex_2_object()(*this,i); } - typename cpp11::result_of::type + decltype(auto) operator[](int i) const { return vertex(i); diff --git a/Kernel_23/include/CGAL/Triangle_3.h b/Kernel_23/include/CGAL/Triangle_3.h index 61a310fb5fe..7999ca64f82 100644 --- a/Kernel_23/include/CGAL/Triangle_3.h +++ b/Kernel_23/include/CGAL/Triangle_3.h @@ -82,13 +82,13 @@ public: } - typename cpp11::result_of::type + decltype(auto) vertex(int i) const { return R().construct_vertex_3_object()(*this, i); } - typename cpp11::result_of::type + decltype(auto) operator[](int i) const { return vertex(i); diff --git a/Kernel_23/include/CGAL/Vector_2.h b/Kernel_23/include/CGAL/Vector_2.h index fed404db54b..8c08dfd29d5 100644 --- a/Kernel_23/include/CGAL/Vector_2.h +++ b/Kernel_23/include/CGAL/Vector_2.h @@ -25,7 +25,6 @@ #include #include #include -#include #include namespace CGAL { @@ -103,26 +102,26 @@ public: } - typename cpp11::result_of::type + decltype(auto) x() const { return R().compute_x_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) y() const { return R().compute_y_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) cartesian(int i) const { CGAL_kernel_precondition( (i == 0) || (i == 1) ); return (i==0) ? x() : y(); } - typename cpp11::result_of::type + decltype(auto) operator[](int i) const { return cartesian(i); @@ -138,26 +137,26 @@ public: return typename R::Construct_cartesian_const_iterator_2()(*this,2); } - typename cpp11::result_of::type + decltype(auto) hx() const { return R().compute_hx_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) hy() const { return R().compute_hy_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) hw() const { return R().compute_hw_2_object()(*this); } - typename cpp11::result_of::type + decltype(auto) homogeneous(int i) const { CGAL_kernel_precondition( (i >= 0) || (i <= 2) ); diff --git a/Kernel_23/include/CGAL/Vector_3.h b/Kernel_23/include/CGAL/Vector_3.h index 9304ca4701b..681e3ec7ceb 100644 --- a/Kernel_23/include/CGAL/Vector_3.h +++ b/Kernel_23/include/CGAL/Vector_3.h @@ -25,7 +25,6 @@ #include #include #include -#include #include namespace CGAL { @@ -173,49 +172,49 @@ public: return *this; } - typename cpp11::result_of::type + decltype(auto) x() const { return R().compute_x_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) y() const { return R().compute_y_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) z() const { return R().compute_z_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) hx() const { return R().compute_hx_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) hy() const { return R().compute_hy_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) hz() const { return R().compute_hz_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) hw() const { return R().compute_hw_3_object()(*this); } - typename cpp11::result_of::type + decltype(auto) cartesian(int i) const { CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) ); @@ -224,7 +223,7 @@ public: return z(); } - typename cpp11::result_of::type + decltype(auto) homogeneous(int i) const { CGAL_kernel_precondition( (i >= 0) || (i <= 3) ); @@ -239,7 +238,7 @@ public: return 3; } - typename cpp11::result_of::type + decltype(auto) operator[](int i) const { return cartesian(i); @@ -255,7 +254,7 @@ public: return typename R::Construct_cartesian_const_iterator_3()(*this,3); } - typename cpp11::result_of::type + decltype(auto) squared_length() const { return R().compute_squared_length_3_object()(*this); diff --git a/Kernel_23/include/CGAL/Weighted_point_2.h b/Kernel_23/include/CGAL/Weighted_point_2.h index 0b9919d784b..fc6dd9ff44b 100644 --- a/Kernel_23/include/CGAL/Weighted_point_2.h +++ b/Kernel_23/include/CGAL/Weighted_point_2.h @@ -24,7 +24,6 @@ #include #include #include -#include #include namespace CGAL { @@ -83,50 +82,50 @@ public: : Rep(typename R::Construct_weighted_point_2()(Return_base_tag(), x, y)) {} - typename cpp11::result_of::type + decltype(auto) point() const { return typename R::Construct_point_2()(*this); } - typename cpp11::result_of::type + decltype(auto) weight() const { return typename R::Compute_weight_2()(*this); } - typename cpp11::result_of::type + decltype(auto) x() const { return typename R::Compute_x_2()(point()); } - typename cpp11::result_of::type + decltype(auto) y() const { return typename R::Compute_y_2()(point()); } - typename cpp11::result_of::type + decltype(auto) hx() const { return R().compute_hx_2_object()(point()); } - typename cpp11::result_of::type + decltype(auto) hy() const { return R().compute_hy_2_object()(point()); } - typename cpp11::result_of::type + decltype(auto) hw() const { return R().compute_hw_2_object()(point()); } - typename cpp11::result_of::type + decltype(auto) cartesian(int i) const { CGAL_kernel_precondition( (i == 0) || (i == 1) ); @@ -143,7 +142,7 @@ public: return hw(); } - typename cpp11::result_of::type + decltype(auto) operator[](int i) const { return cartesian(i); diff --git a/Kernel_23/include/CGAL/Weighted_point_3.h b/Kernel_23/include/CGAL/Weighted_point_3.h index e03a8b651b3..548614a9e79 100644 --- a/Kernel_23/include/CGAL/Weighted_point_3.h +++ b/Kernel_23/include/CGAL/Weighted_point_3.h @@ -84,62 +84,62 @@ public: : Rep(typename R::Construct_weighted_point_3()(Return_base_tag(), x, y, z)) {} - typename cpp11::result_of::type + decltype(auto) point() const { return typename R::Construct_point_3()(*this); } - typename cpp11::result_of::type + decltype(auto) weight() const { return typename R::Compute_weight_3()(*this); } - typename cpp11::result_of::type + decltype(auto) x() const { return typename R::Compute_x_3()(point()); } - typename cpp11::result_of::type + decltype(auto) y() const { return typename R::Compute_y_3()(point()); } - typename cpp11::result_of::type + decltype(auto) z() const { return typename R::Compute_z_3()(point()); } - typename cpp11::result_of::type + decltype(auto) hx() const { return R().compute_hx_3_object()(point()); } - typename cpp11::result_of::type + decltype(auto) hy() const { return R().compute_hy_3_object()(point()); } - typename cpp11::result_of::type + decltype(auto) hz() const { return R().compute_hz_3_object()(point()); } - typename cpp11::result_of::type + decltype(auto) hw() const { return R().compute_hw_3_object()(point()); } - typename cpp11::result_of::type + decltype(auto) cartesian(int i) const { CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) ); @@ -158,7 +158,7 @@ public: return hw(); } - typename cpp11::result_of::type + decltype(auto) operator[](int i) const { return cartesian(i); diff --git a/Kernel_23/include/CGAL/basic.h b/Kernel_23/include/CGAL/basic.h index 7a9f0a31771..7c6e2768bae 100644 --- a/Kernel_23/include/CGAL/basic.h +++ b/Kernel_23/include/CGAL/basic.h @@ -23,11 +23,6 @@ #include #include -// This cannot be disabled for now until we have a clear idea which -// compilers implement N3276. - -#include - #include #include #include diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_all_linear_intersections.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_all_linear_intersections.h index 92278176ca6..4d2b09ac3b2 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_all_linear_intersections.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_all_linear_intersections.h @@ -17,8 +17,7 @@ template void test_2d(const T1& t1, const T2& t2) { CGAL::Cartesian_converter convert; - typename CGAL::cpp11::result_of::type res1 = - CGAL::intersection(t1, t2); + const auto res1 = CGAL::intersection(t1, t2); assert( is_intersection_empty( convert(res1) ) == is_intersection_empty(res1) ); } @@ -26,8 +25,7 @@ template void test_3d(const T1& t1, const T2& t2) { CGAL::Cartesian_converter convert; - typename CGAL::cpp11::result_of::type res1 = - CGAL::intersection(t1, t2); + const auto res1 = CGAL::intersection(t1, t2); assert( is_intersection_empty( convert(res1) ) == is_intersection_empty(res1) ); } @@ -112,7 +110,6 @@ void test_linear_intersections() test_3d(triangle_3, triangle_3); CGAL::Cartesian_converter convert; - typename CGAL::cpp11::result_of::type res1 = - CGAL::intersection(plane_3, plane_3, plane_3); + const auto res1 = CGAL::intersection(plane_3, plane_3, plane_3); assert( is_intersection_empty( convert(res1) ) == is_intersection_empty(res1) ); } From eb2f7e5b90f8a047f2acd35c9d1b5f4170ceb488 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Wed, 22 Jul 2020 14:24:56 +0200 Subject: [PATCH 002/130] kernel_23 doc typo fixes --- Kernel_23/doc/Kernel_23/CGAL/intersections.h | 6 +++--- Kernel_23/doc/Kernel_23/Kernel_23.txt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Kernel_23/doc/Kernel_23/CGAL/intersections.h b/Kernel_23/doc/Kernel_23/CGAL/intersections.h index 47155df7898..7421c3e57f6 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/intersections.h +++ b/Kernel_23/doc/Kernel_23/CGAL/intersections.h @@ -95,7 +95,7 @@ The following tables give the possible values for `Type1` and `Type2`. \cgalHeading{2D Intersections} -The return type can be obtained through `CGAL::cpp11::result_of::%type`. +The return type can be obtained through `cpp11::result_of::%type`. It is equivalent to `boost::optional< boost::variant< T... > >`, the last column in the table providing the template parameter pack.
@@ -191,7 +191,7 @@ intersections existing with the type `Iso_rectangle_2`. Note that the return typ \cgalHeading{3D Intersections} -The return type can be obtained through `CGAL::cpp11::result_of::%type`. +The return type can be obtained through `cpp11::result_of::%type`. It is equivalent to `boost::optional< boost::variant< T... > >`, the last column in the table providing the template parameter pack.
@@ -350,7 +350,7 @@ The following examples demonstrate the most common use of `intersection()` functions with the 2D and 3D Linear %Kernel. In the first two examples we intersect a segment and a line. -The result type can be obtained with `CGAL::cpp11::result_of`. It looks simpler +The result type can be obtained with `cpp11::result_of`. It looks simpler if you use a C++ compiler which supports `auto`, but you must anyways know that the result type is a `boost::optional >`, in order to unpack the point or segment. diff --git a/Kernel_23/doc/Kernel_23/Kernel_23.txt b/Kernel_23/doc/Kernel_23/Kernel_23.txt index 0947dbecd5e..c624cc64db8 100644 --- a/Kernel_23/doc/Kernel_23/Kernel_23.txt +++ b/Kernel_23/doc/Kernel_23/Kernel_23.txt @@ -498,8 +498,8 @@ in a type-safe way \cgal uses return values of type `boost::optional< boost::variant< T... > >` were `T...` is a list of all possible resulting geometric objects. The exact result type of an intersection can be determined through the metafunction -`cpp11::result_of` or -`cpp11::result_of`, where +`CGAL::cpp11::result_of` or +`CGAL::cpp11::result_of`, where `Type1` and `Type2` are the types of the objects used in the intersection computation. @@ -525,7 +525,7 @@ std::cin >> segment_1 >> segment_2; // auto v = intersection(segment_1, segment_2); /* C++03 */ -cpp11::result_of::type +CGAL::cpp11::result_of::type v = intersection(segment_1, segment_2); if(v) { /* not empty */ From 059bc6062d6a91c3aa3bd7dce0664b6746b2611b Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Wed, 22 Jul 2020 15:13:09 +0200 Subject: [PATCH 003/130] circular kernel 2 result_of to decltype --- Circular_kernel_2/include/CGAL/Circular_arc_2.h | 15 +++++++-------- .../include/CGAL/Circular_arc_point_2.h | 7 ++----- .../CGAL/Circular_kernel_2/Circular_arc_2.h | 4 ++-- .../function_objects_polynomial_circular.h | 4 ++-- Circular_kernel_2/include/CGAL/Line_arc_2.h | 9 ++++----- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/Circular_kernel_2/include/CGAL/Circular_arc_2.h b/Circular_kernel_2/include/CGAL/Circular_arc_2.h index 54be46b256a..37f94cf45fe 100644 --- a/Circular_kernel_2/include/CGAL/Circular_arc_2.h +++ b/Circular_kernel_2/include/CGAL/Circular_arc_2.h @@ -22,7 +22,6 @@ #include -#include #include #include namespace CGAL { @@ -107,25 +106,25 @@ public: {} - typename cpp11::result_of::type + decltype(auto) source() const { return typename R::Construct_circular_source_vertex_2()(*this); } - typename cpp11::result_of::type + decltype(auto) target() const { return typename R::Construct_circular_target_vertex_2()(*this); } - typename cpp11::result_of::type + decltype(auto) left() const { return typename R::Construct_circular_min_vertex_2()(*this); } - typename cpp11::result_of::type + decltype(auto) right() const { return typename R::Construct_circular_max_vertex_2()(*this); @@ -141,19 +140,19 @@ public: return typename R::Is_y_monotone_2()(*this); } - typename cpp11::result_of::type + decltype(auto) supporting_circle() const { return typename R::Construct_circle_2()(*this); } - typename cpp11::result_of::type + decltype(auto) center() const { return typename R::Construct_center_2()(*this); } - typename cpp11::result_of::type + decltype(auto) squared_radius() const { return typename R::Compute_squared_radius_2()(*this); diff --git a/Circular_kernel_2/include/CGAL/Circular_arc_point_2.h b/Circular_kernel_2/include/CGAL/Circular_arc_point_2.h index 99cfbbfeced..8dbadf1ebcf 100644 --- a/Circular_kernel_2/include/CGAL/Circular_arc_point_2.h +++ b/Circular_kernel_2/include/CGAL/Circular_arc_point_2.h @@ -21,7 +21,6 @@ #include -#include #include #include @@ -72,15 +71,13 @@ public: : RCircular_arc_point_2(typename R::Construct_circular_arc_point_2()(p)) {} - typename - cpp11::result_of::type + decltype(auto) x() const { return typename R::Compute_circular_x_2()(*this); } - typename - cpp11::result_of::type + decltype(auto) y() const { return typename R::Compute_circular_y_2()(*this); diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/Circular_arc_2.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/Circular_arc_2.h index f6ef588c083..4288ef1657b 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/Circular_arc_2.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/Circular_arc_2.h @@ -639,13 +639,13 @@ public: return _support; } - typename cpp11::result_of::type + decltype(auto) center() const { return supporting_circle().center(); } - typename cpp11::result_of::type + decltype(auto) squared_radius() const { return supporting_circle().squared_radius(); diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h index fe78f2e6e5c..75b4350bf30 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h @@ -1307,7 +1307,7 @@ namespace CircularFunctors { typedef typename cpp11::result_of::type type; }; - typename cpp11::result_of::type + decltype(auto) operator()( const Circle_2& c) const { return LK_Compute_squared_radius_2()(c); } @@ -1320,7 +1320,7 @@ namespace CircularFunctors { FT operator()( const Point_2& p, const Point_2& q, const Point_2& r) const { return LK_Compute_squared_radius_2()(p, q, r); } - typename cpp11::result_of::type + decltype(auto) operator()(const Circular_arc_2& c) const { return c.rep().squared_radius(); } diff --git a/Circular_kernel_2/include/CGAL/Line_arc_2.h b/Circular_kernel_2/include/CGAL/Line_arc_2.h index 3bd75815e8c..deb4cecc458 100644 --- a/Circular_kernel_2/include/CGAL/Line_arc_2.h +++ b/Circular_kernel_2/include/CGAL/Line_arc_2.h @@ -21,7 +21,6 @@ #include -#include #include namespace CGAL { @@ -91,25 +90,25 @@ public: : RLine_arc_2(a) {} - typename cpp11::result_of< typename R::Construct_circular_source_vertex_2(Line_arc_2)>::type + decltype(auto) source() const { return typename R::Construct_circular_source_vertex_2()(*this); } - typename cpp11::result_of< typename R::Construct_circular_target_vertex_2(Line_arc_2)>::type + decltype(auto) target() const { return typename R::Construct_circular_target_vertex_2()(*this); } - typename cpp11::result_of< typename R::Construct_circular_min_vertex_2(Line_arc_2)>::type + decltype(auto) left() const { return typename R::Construct_circular_min_vertex_2()(*this); } - typename cpp11::result_of< typename R::Construct_circular_max_vertex_2(Line_arc_2)>::type + decltype(auto) right() const { return typename R::Construct_circular_max_vertex_2()(*this); From acdf4c6beed88832b4d84642ac3e5e600be66bf3 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Wed, 22 Jul 2020 15:23:09 +0200 Subject: [PATCH 004/130] circular kernel 3 result_of to decltype --- Circular_kernel_3/include/CGAL/Circular_arc_3.h | 7 +++---- Circular_kernel_3/include/CGAL/Circular_arc_point_3.h | 7 +++---- Circular_kernel_3/include/CGAL/Line_arc_3.h | 11 +++++------ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Circular_kernel_3/include/CGAL/Circular_arc_3.h b/Circular_kernel_3/include/CGAL/Circular_arc_3.h index 86c0756bda4..6843fac6003 100644 --- a/Circular_kernel_3/include/CGAL/Circular_arc_3.h +++ b/Circular_kernel_3/include/CGAL/Circular_arc_3.h @@ -20,7 +20,6 @@ #include -#include #include namespace CGAL { @@ -117,19 +116,19 @@ namespace CGAL { : RCircular_arc_3(a) {} - typename cpp11::result_of::type + decltype(auto) source() const { return typename R::Construct_circular_source_vertex_3()(*this); } - typename cpp11::result_of::type + decltype(auto) target() const { return typename R::Construct_circular_target_vertex_3()(*this); } - typename cpp11::result_of::type + decltype(auto) supporting_circle() const { return typename R::Construct_circle_3()(*this); diff --git a/Circular_kernel_3/include/CGAL/Circular_arc_point_3.h b/Circular_kernel_3/include/CGAL/Circular_arc_point_3.h index 36c0ed41c18..f9f941d2d8b 100644 --- a/Circular_kernel_3/include/CGAL/Circular_arc_point_3.h +++ b/Circular_kernel_3/include/CGAL/Circular_arc_point_3.h @@ -20,7 +20,6 @@ #include -#include #include #include @@ -196,15 +195,15 @@ public: - typename cpp11::result_of::type + decltype(auto) x() const { return typename R::Compute_circular_x_3()(*this);} - typename cpp11::result_of::type + decltype(auto) y() const { return typename R::Compute_circular_y_3()(*this);} - typename cpp11::result_of::type + decltype(auto) z() const { return typename R::Compute_circular_z_3()(*this);} diff --git a/Circular_kernel_3/include/CGAL/Line_arc_3.h b/Circular_kernel_3/include/CGAL/Line_arc_3.h index e2413b1317c..f9955774c9b 100644 --- a/Circular_kernel_3/include/CGAL/Line_arc_3.h +++ b/Circular_kernel_3/include/CGAL/Line_arc_3.h @@ -20,7 +20,6 @@ #include -#include #include @@ -122,31 +121,31 @@ namespace CGAL { : RLine_arc_3(a) {} - typename cpp11::result_of::type + decltype(auto) source() const { return typename R::Construct_circular_source_vertex_3()(*this); } - typename cpp11::result_of::type + decltype(auto) target() const { return typename R::Construct_circular_target_vertex_3()(*this); } - typename cpp11::result_of::type + decltype(auto) lower_xyz_extremity() const { return typename R::Construct_circular_min_vertex_3()(*this); } - typename cpp11::result_of::type + decltype(auto) higher_xyz_extremity() const { return typename R::Construct_circular_max_vertex_3()(*this); } - typename cpp11::result_of::type + decltype(auto) supporting_line() const { return typename R::Construct_line_3()(*this); From 4b187338210ce32c8bb04ea56f8f4f508636019e Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Wed, 22 Jul 2020 16:19:15 +0200 Subject: [PATCH 005/130] filtered kernel result_of to decltype --- Filtered_kernel/include/CGAL/Lazy.h | 2 +- .../test/Filtered_kernel/test_lazy_vector_objects.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 559e9daea55..c4df37b5a03 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -1705,7 +1705,7 @@ struct result { \ BOOST_PP_REPEAT_FROM_TO(1, 9, CGAL_CONSTRUCTION_OPERATOR, _) // nullary - typename Type_mapper< typename cpp11::result_of::type ,AK, LK>::type + decltype(auto) operator()() const { typedef typename cpp11::result_of::type AT; diff --git a/Filtered_kernel/test/Filtered_kernel/test_lazy_vector_objects.cpp b/Filtered_kernel/test/Filtered_kernel/test_lazy_vector_objects.cpp index 6d6b9737c34..a0793b58c8b 100644 --- a/Filtered_kernel/test/Filtered_kernel/test_lazy_vector_objects.cpp +++ b/Filtered_kernel/test/Filtered_kernel/test_lazy_vector_objects.cpp @@ -35,7 +35,7 @@ int main() obj = CGAL::intersection(s1,s2); // check the variant return type - CGAL::cpp11::result_of::type o_variant = CGAL::intersection(t1,t2); + const auto o_variant = CGAL::intersection(t1,t2); if(!o_variant) { std::cerr << "ERROR, empty" << std::endl; return EXIT_FAILURE; @@ -75,7 +75,7 @@ int main() } // check the variant return type - CGAL::cpp11::result_of::type o_variant = CGAL::intersection(t1,t2); + const auto o_variant = CGAL::intersection(t1,t2); if(!o_variant) { std::cerr << "ERROR, empty" << std::endl; return EXIT_FAILURE; From e4f5d0b5bdb4fcea7a0ac5e413a9553486e76b1a Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Wed, 22 Jul 2020 16:28:40 +0200 Subject: [PATCH 006/130] kernel_d result_of to decltype --- Kernel_d/doc/Kernel_d/CGAL/intersections_d.h | 2 +- .../Kernel_d/Concepts/Kernel--Intersect_d.h | 2 +- Kernel_d/doc/Kernel_d/Kernel_d.txt | 4 +-- Kernel_d/include/CGAL/intersections_d.h | 30 +++++++++---------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/intersections_d.h b/Kernel_d/doc/Kernel_d/CGAL/intersections_d.h index f425e157a84..5949422420c 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/intersections_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/intersections_d.h @@ -147,7 +147,7 @@ void foo(Segment_d seg, Line_d lin) // auto result = intersection(seg, lin); // without C++11 support - typename cpp11::result_of, Line_d)>::type + typename CGAL::cpp11::result_of, Line_d)>::type result = intersection(seg, lin); if(result) { boost::apply_visitor(Intersection_visitor(), *result); } diff --git a/Kernel_d/doc/Kernel_d/Concepts/Kernel--Intersect_d.h b/Kernel_d/doc/Kernel_d/Concepts/Kernel--Intersect_d.h index 7d01b176b0c..79d9ec8d323 100644 --- a/Kernel_d/doc/Kernel_d/Concepts/Kernel--Intersect_d.h +++ b/Kernel_d/doc/Kernel_d/Concepts/Kernel--Intersect_d.h @@ -23,7 +23,7 @@ For a list of the possible return types, see `CGAL::intersection()`. \pre `p` and `q` have the same dimension. */ template -cpp11::result_of::type +CGAL::cpp11::result_of::type operator()(const Type1& p, const Type2& q); /// @} diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index fb1ca9a5b92..f61d9de2636 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -481,7 +481,7 @@ returns a `boost::optional< boost::variant< T... > >` where `T...` is a list of all possible resulting geometric objects. The exact result type of an intersection can be determined by using -`cpp11::result_of::%type` +`CGAL::cpp11::result_of::%type` where `Type1` and `Type2` are the types of the objects used in the intersection computation. @@ -500,7 +500,7 @@ typedef Segment_d Segment; Segment s1, s2; std::cin >> s1 >> s2; -cpp11::result_of::type +CGAL::cpp11::result_of::type v = intersection(s1, s2); if(v) { // not empty diff --git a/Kernel_d/include/CGAL/intersections_d.h b/Kernel_d/include/CGAL/intersections_d.h index 84697944f78..75607475d94 100644 --- a/Kernel_d/include/CGAL/intersections_d.h +++ b/Kernel_d/include/CGAL/intersections_d.h @@ -25,7 +25,7 @@ namespace Intersections { namespace internal { template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Line_d& l1, const typename R::Line_d& l2, const R&) { typedef typename R::Line_d_Line_d_pair ll_pair; @@ -46,7 +46,7 @@ intersection(const typename R::Line_d& l1, const typename R::Line_d& l2, const R } template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Ray_d& l1, const typename R::Ray_d& l2, const R&) { typedef typename R::Ray_d_Ray_d_pair ll_pair; @@ -75,7 +75,7 @@ intersection(const typename R::Ray_d& l1, const typename R::Ray_d& l2, const R&) } template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Segment_d& l1, const typename R::Segment_d& l2, const R&) { typedef typename R::Segment_d_Segment_d_pair ll_pair; @@ -99,7 +99,7 @@ intersection(const typename R::Segment_d& l1, const typename R::Segment_d& l2, c } template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Line_d& l, const typename R::Ray_d& r, const R&) { typedef typename R::Line_d_Ray_d_pair lr_pair; @@ -121,12 +121,12 @@ intersection(const typename R::Line_d& l, const typename R::Ray_d& r, const R&) } template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Ray_d& r, const typename R::Line_d& l, const R& k) { return intersection(l,r,k); } template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Ray_d& r, const typename R::Segment_d& s, const R&) { typedef typename R::Ray_d_Segment_d_pair rs_pair; @@ -150,12 +150,12 @@ intersection(const typename R::Ray_d& r, const typename R::Segment_d& s, const R } template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Segment_d& s, const typename R::Ray_d& r, const R& k) { return intersection(r,s, k); } template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Line_d& l, const typename R::Segment_d& s, const R&) { typedef typename R::Line_d_Segment_d_pair rs_pair; @@ -179,12 +179,12 @@ intersection(const typename R::Line_d& l, const typename R::Segment_d& s, const } template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Segment_d& s, const typename R::Line_d& l, const R& r) { return intersection(l,s,r); } template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Line_d& l, const typename R::Hyperplane_d& h, const R&) { typedef typename R::Line_d_Hyperplane_d_pair lh_pair; @@ -205,12 +205,12 @@ intersection(const typename R::Line_d& l, const typename R::Hyperplane_d& h, con } template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Hyperplane_d& h, const typename R::Line_d& l, const R& r) { return intersection(l,h,r); } template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Ray_d& r, const typename R::Hyperplane_d& h, const R&) { typedef typename R::Ray_d_Hyperplane_d_pair rh_pair; @@ -231,12 +231,12 @@ intersection(const typename R::Ray_d& r, const typename R::Hyperplane_d& h, cons } template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Hyperplane_d& h, const typename R::Ray_d& r, const R& k) { return intersection(r,h,k); } template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Segment_d& s, const typename R::Hyperplane_d& h, const R&) { typedef typename R::Segment_d_Hyperplane_d_pair sh_pair; @@ -258,7 +258,7 @@ intersection(const typename R::Segment_d& s, const typename R::Hyperplane_d& h, } template -typename cpp11::result_of::type +decltype(auto) intersection(const typename R::Hyperplane_d& h, const typename R::Segment_d& s, const R& r) { return intersection(s,h,r); } From 4248a8a9f79887ebc4ccaba95f035e6313e9160f Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Thu, 23 Jul 2020 16:00:06 +0200 Subject: [PATCH 007/130] lazy and type mapper result_of fix --- Filtered_kernel/include/CGAL/Lazy.h | 39 ++++++++++----------- Kernel_23/include/CGAL/Kernel/Type_mapper.h | 3 ++ STL_Extension/include/CGAL/result_of.h | 15 ++------ 3 files changed, 24 insertions(+), 33 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index c4df37b5a03..39f335151fc 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -786,7 +786,8 @@ struct Lazy_construction_bbox CGAL_NO_UNIQUE_ADDRESS EC ec; template - result_type operator()(const L1& l1) const + decltype(auto) + operator()(const L1& l1) const { CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); // Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG @@ -994,14 +995,14 @@ struct Lazy_cartesian_const_iterator_2 public: template < typename L1> - result_type + decltype(auto) operator()(const L1& l1) const { return result_type(&l1); } template < typename L1> - result_type + decltype(auto) operator()(const L1& l1, int) const { return result_type(&l1,2); @@ -1023,14 +1024,14 @@ struct Lazy_cartesian_const_iterator_3 public: template < typename L1> - result_type + decltype(auto) operator()(const L1& l1) const { return result_type(&l1); } template < typename L1> - result_type + decltype(auto) operator()(const L1& l1, int) const { return result_type(&l1,3); @@ -1243,7 +1244,7 @@ struct Lazy_construction_object public: template - result_type + decltype(auto) operator()(const L1& l1) const { CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); @@ -1276,7 +1277,7 @@ public: } template - result_type + decltype(auto) operator()(const L1& l1, const L2& l2) const { CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); @@ -1330,7 +1331,7 @@ CGAL_Kernel_obj(Point_3) } template - result_type + decltype(auto) operator()(const L1& l1, const L2& l2, const L3& l3) const { CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); @@ -1497,9 +1498,9 @@ struct Lazy_construction_variant { BOOST_PP_REPEAT_FROM_TO(1, 9, CGAL_RESULT, _) template - typename result::type + decltype(auto) operator()(const L1& l1, const L2& l2) const { - typedef typename cpp11::result_of::type result_type; + typedef typename result::type result_type; typedef typename cpp11::result_of::type, typename Type_mapper::type)>::type AT; @@ -1545,7 +1546,7 @@ struct Lazy_construction_variant { } template - typename result::type + decltype(auto) operator()(const L1& l1, const L2& l2, const L3& l3) const { typedef typename result::type result_type; @@ -1620,7 +1621,7 @@ struct Lazy_construction { #define CGAL_CONSTRUCTION_OPERATOR(z, n, d ) \ template \ - result_type \ + decltype(auto) \ operator()( BOOST_PP_ENUM(n, CGAL_LARGS, _) ) const { \ typedef Lazy< AT, ET, E2A> Handle; \ CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ @@ -1638,7 +1639,7 @@ struct Lazy_construction { BOOST_PP_REPEAT_FROM_TO(1, 9, CGAL_CONSTRUCTION_OPERATOR, _) // nullary - result_type + decltype(auto) operator()() const { typedef Lazy Handle; @@ -1680,16 +1681,14 @@ struct result { \ #define CGAL_CONSTRUCTION_OPERATOR(z, n, d) \ template \ - typename cpp11::result_of::type \ + decltype(auto) \ operator()( BOOST_PP_ENUM(n, CGAL_LARGS, _) ) const { \ BOOST_PP_REPEAT(n, CGAL_TYPEMAP_EC, L) \ BOOST_PP_REPEAT(n, CGAL_TYPEMAP_AC, L) \ - typedef typename boost::remove_cv< typename boost::remove_reference < \ - typename cpp11::result_of< EC(BOOST_PP_ENUM_PARAMS(n, E)) >::type >::type >::type ET; \ - typedef typename boost::remove_cv< typename boost::remove_reference < \ - typename cpp11::result_of< AC(BOOST_PP_ENUM_PARAMS(n, A)) >::type >::type >::type AT; \ + typedef typename Type_mapper::type,EK,EK>::type ET; \ + typedef typename Type_mapper::type,AK,AK>::type AT; \ typedef Lazy< AT, ET, E2A> Handle; \ - typedef typename cpp11::result_of::type result_type; \ + typedef typename result::type result_type; \ CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ Protect_FPU_rounding P; \ try { \ @@ -1711,7 +1710,7 @@ struct result { \ typedef typename cpp11::result_of::type AT; typedef typename cpp11::result_of::type ET; typedef Lazy Handle; - typedef typename Type_mapper< typename cpp11::result_of::type ,AK, LK>::type result_type; + typedef typename Type_mapper::type result_type; return result_type( Handle(new Lazy_rep_0()) ); } diff --git a/Kernel_23/include/CGAL/Kernel/Type_mapper.h b/Kernel_23/include/CGAL/Kernel/Type_mapper.h index fe54b5fe96b..3dda35168d6 100644 --- a/Kernel_23/include/CGAL/Kernel/Type_mapper.h +++ b/Kernel_23/include/CGAL/Kernel/Type_mapper.h @@ -90,6 +90,9 @@ BOOST_PP_REPEAT_FROM_TO(1, 10, CGAL_VARIANT_TYPEMAP, _) #define CGAL_Kernel_obj(X) \ template < typename K1, typename K2 > \ struct Type_mapper_impl < typename K1::X, K1, K2 > \ + { typedef typename K2::X type; }; \ + template < typename K1, typename K2 > \ + struct Type_mapper_impl < typename K1::X::Rep, K1, K2 > \ { typedef typename K2::X type; }; #include diff --git a/STL_Extension/include/CGAL/result_of.h b/STL_Extension/include/CGAL/result_of.h index 337344bc328..f75ebc6c859 100644 --- a/STL_Extension/include/CGAL/result_of.h +++ b/STL_Extension/include/CGAL/result_of.h @@ -20,6 +20,7 @@ #include #include +#include // Address the warning C4003: not enough actual parameters for macro 'BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY' // result_of.hpp includes files from boost/preprocessor @@ -37,21 +38,9 @@ namespace CGAL{ -// Even if for now we use the tr1 result_of implementation, we use the cpp11 -// namespace since in the future, that's the decltype version that will be used namespace cpp11{ -template -struct result_of -{ - // from boost 1.44 release note https://www.boost.org/users/history/version_1_44_0.html : - // New template boost::tr1_result_of that implements the TR1 ResultOf protocol even if boost::result_of uses the C++0x decltype-based implementation. - #if BOOST_VERSION < 104400 - typedef typename boost::result_of::type type; - #else - typedef typename boost::tr1_result_of::type type; - #endif -}; +using std::result_of; } From 847e2277d60f242f7748360b38901762fb0df3f6 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Thu, 23 Jul 2020 18:46:46 +0200 Subject: [PATCH 008/130] result_of types to decltype(declval), both issues #3035 and #3846 are addressed --- .../function_objects_polynomial_circular.h | 4 +- Filtered_kernel/include/CGAL/Lazy.h | 43 ++++++++----------- STL_Extension/include/CGAL/iterator.h | 7 ++- STL_Extension/include/CGAL/result_of.h | 11 ++++- 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h index 75b4350bf30..b2326adedd4 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h @@ -1299,12 +1299,12 @@ namespace CircularFunctors { template struct result { - typedef typename cpp11::result_of::type type; + typedef decltype(std::declval()(Circle_2())) type; }; template struct result { - typedef typename cpp11::result_of::type type; + typedef decltype(std::declval()(Circle_2())) type; }; decltype(auto) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 39f335151fc..7ae3bcb36fe 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -399,6 +398,7 @@ public: }; // Macro helpers to build the kernel objects +#define CGAL_PARAM(z, n, t) t##n() #define CGAL_TYPEMAP_AC(z, n, t) typedef typename Type_mapper< t##n, LK, AK >::type A##n; #define CGAL_TYPEMAP_EC(z, n, t) typedef typename Type_mapper< t##n, LK, EK >::type E##n; #define CGAL_LEXACT(z,n,t) CGAL::exact( l##n ) @@ -826,7 +826,7 @@ struct Lazy_construction_nt { BOOST_PP_REPEAT(n, CGAL_TYPEMAP_EC, T) \ typedef Lazy_exact_nt< \ typename boost::remove_cv< typename boost::remove_reference < \ - typename cpp11::result_of::type >::type >::type > type; \ + decltype(std::declval()(BOOST_PP_ENUM(n, CGAL_PARAM, E))) >::type >::type > type; \ }; BOOST_PP_REPEAT_FROM_TO(1, 6, CGAL_RESULT_NT, _) @@ -1370,7 +1370,7 @@ CGAL_Kernel_obj(Point_3) //____________________________________________________________ // The magic functor that has Lazy as result type. // Two versions are distinguished: one that needs to fiddle -// with result_of and another that can forward the result types. +// with decltype and another that can forward the result types. namespace internal { BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type) @@ -1492,7 +1492,7 @@ struct Lazy_construction_variant { struct result { \ BOOST_PP_REPEAT(n, CGAL_TYPEMAP_AC, T) \ typedef typename Type_mapper< \ - typename cpp11::result_of::type, AK, LK>::type type; \ + decltype(std::declval()(BOOST_PP_ENUM(n, CGAL_PARAM, A))), AK, LK>::type type; \ }; BOOST_PP_REPEAT_FROM_TO(1, 9, CGAL_RESULT, _) @@ -1502,10 +1502,10 @@ struct Lazy_construction_variant { operator()(const L1& l1, const L2& l2) const { typedef typename result::type result_type; - typedef typename cpp11::result_of::type, - typename Type_mapper::type)>::type AT; - typedef typename cpp11::result_of::type, - typename Type_mapper::type)>::type ET; + typedef decltype(std::declval()(typename Type_mapper::type(), + typename Type_mapper::type())) AT; + typedef decltype(std::declval()(typename Type_mapper::type(), + typename Type_mapper::type())) ET; CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; @@ -1550,12 +1550,12 @@ struct Lazy_construction_variant { operator()(const L1& l1, const L2& l2, const L3& l3) const { typedef typename result::type result_type; - typedef typename cpp11::result_of::type, - typename Type_mapper::type, - typename Type_mapper::type)>::type AT; - typedef typename cpp11::result_of::type, - typename Type_mapper::type, - typename Type_mapper::type)>::type ET; + typedef decltype(std::declval()(typename Type_mapper::type(), + typename Type_mapper::type(), + typename Type_mapper::type())) AT; + typedef decltype(std::declval()(typename Type_mapper::type(), + typename Type_mapper::type(), + typename Type_mapper::type())) ET; CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; @@ -1670,13 +1670,6 @@ struct Lazy_construction CGAL_NO_UNIQUE_ADDRESS EC ec; // acquire the result_type of the approximate kernel, map it back to the lazy kernel object -#define CGAL_RESULT(z, n, d) \ -template< typename F, BOOST_PP_ENUM_PARAMS(n, class T) > \ -struct result { \ - BOOST_PP_REPEAT(n, CGAL_TYPEMAP_AC, T) \ - typedef typename Type_mapper< typename cpp11::result_of::type, AK, LK>::type type; \ -}; - BOOST_PP_REPEAT_FROM_TO(1, 9, CGAL_RESULT, _) #define CGAL_CONSTRUCTION_OPERATOR(z, n, d) \ @@ -1685,8 +1678,8 @@ struct result { \ operator()( BOOST_PP_ENUM(n, CGAL_LARGS, _) ) const { \ BOOST_PP_REPEAT(n, CGAL_TYPEMAP_EC, L) \ BOOST_PP_REPEAT(n, CGAL_TYPEMAP_AC, L) \ - typedef typename Type_mapper::type,EK,EK>::type ET; \ - typedef typename Type_mapper::type,AK,AK>::type AT; \ + typedef typename Type_mapper()(BOOST_PP_ENUM(n, CGAL_PARAM, E))),EK,EK>::type ET; \ + typedef typename Type_mapper()(BOOST_PP_ENUM(n, CGAL_PARAM, A))),AK,AK>::type AT; \ typedef Lazy< AT, ET, E2A> Handle; \ typedef typename result::type result_type; \ CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ @@ -1707,8 +1700,8 @@ struct result { \ decltype(auto) operator()() const { - typedef typename cpp11::result_of::type AT; - typedef typename cpp11::result_of::type ET; + typedef decltype(std::declval()()) AT; + typedef decltype(std::declval()()) ET; typedef Lazy Handle; typedef typename Type_mapper::type result_type; diff --git a/STL_Extension/include/CGAL/iterator.h b/STL_Extension/include/CGAL/iterator.h index ea2b445b6f5..dec026e4a43 100644 --- a/STL_Extension/include/CGAL/iterator.h +++ b/STL_Extension/include/CGAL/iterator.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -660,7 +659,7 @@ class Join_input_iterator_1 public: typedef typename std::iterator_traits::iterator_category iterator_category; - typedef std::decay_t::type> value_type; + typedef std::decay_t()(arg_type()))> value_type; typedef typename std::iterator_traits::difference_type difference_type; typedef value_type const* pointer; typedef value_type const& reference; @@ -746,7 +745,7 @@ class Join_input_iterator_2 public: typedef typename std::iterator_traits::iterator_category iterator_category; - typedef typename cpp11::result_of::type value_type; + typedef decltype(std::declval()(arg_type_1(), arg_type_2())) value_type; typedef typename std::iterator_traits::difference_type difference_type; typedef value_type* pointer; typedef value_type& reference; @@ -840,7 +839,7 @@ class Join_input_iterator_3 public: typedef typename std::iterator_traits::iterator_category iterator_category; - typedef typename cpp11::result_of::type + typedef decltype(std::declval()(arg_type_1(), arg_type_2(), arg_type_3())) value_type; typedef typename std::iterator_traits::difference_type difference_type; typedef value_type* pointer; diff --git a/STL_Extension/include/CGAL/result_of.h b/STL_Extension/include/CGAL/result_of.h index f75ebc6c859..bd25c2a45fe 100644 --- a/STL_Extension/include/CGAL/result_of.h +++ b/STL_Extension/include/CGAL/result_of.h @@ -40,7 +40,16 @@ namespace CGAL{ namespace cpp11{ -using std::result_of; +// When we switch to C++17, we should use the std::invoke_result instead. +// #if __cplusplus >= 201703L +// template +// struct result_of : public std::invoke_result +// { + +// }; +// #else + using std::result_of; +// #endif } From 2f7f37983b59802d2aee1cabee2ad9d5827f347a Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Fri, 24 Jul 2020 11:26:28 +0200 Subject: [PATCH 009/130] periodic 3 and generator fixes + the issue #3083 is addressed --- .../internal/Generic_random_point_generator.h | 1 + .../CGAL/Periodic_3_regular_triangulation_3.h | 3 +- .../include/CGAL/Periodic_3_triangulation_3.h | 3 +- STL_Extension/include/CGAL/result_of.h | 61 +++++++++++-------- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/Generator/include/CGAL/internal/Generic_random_point_generator.h b/Generator/include/CGAL/internal/Generic_random_point_generator.h index a161df1da76..76c52dd55cb 100644 --- a/Generator/include/CGAL/internal/Generic_random_point_generator.h +++ b/Generator/include/CGAL/internal/Generic_random_point_generator.h @@ -18,6 +18,7 @@ #include #include #include +#include #include diff --git a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_3.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_3.h index 27583fe8a15..030d0f9d409 100644 --- a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_3.h +++ b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_3.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -497,7 +498,7 @@ public: // Spatial sorting can only be applied to bare points, so we need an adaptor typedef typename Geom_traits::Construct_point_3 Construct_point_3; - typedef typename boost::result_of::type Ret; + typedef typename cpp11::result_of::type Ret; typedef boost::function_property_map fpmap; typedef CGAL::Spatial_sort_traits_adapter_3 Search_traits_3; diff --git a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h index c96cb05bc11..93854244f30 100644 --- a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h +++ b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h @@ -47,7 +47,6 @@ #include #include #include -#include #include #include @@ -650,7 +649,7 @@ public: // but point() -like functions have return type Point template // can be Point or Point_3 - typename boost::result_of::type + decltype(auto) construct_point(const P& p) const { return geom_traits().construct_point_3_object()(p); } diff --git a/STL_Extension/include/CGAL/result_of.h b/STL_Extension/include/CGAL/result_of.h index bd25c2a45fe..1ed20008f20 100644 --- a/STL_Extension/include/CGAL/result_of.h +++ b/STL_Extension/include/CGAL/result_of.h @@ -20,41 +20,50 @@ #include #include -#include -// Address the warning C4003: not enough actual parameters for macro 'BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY' -// result_of.hpp includes files from boost/preprocessor -// This concerns boost 1_65_1 -#if defined(BOOST_MSVC) -# pragma warning(push) -# pragma warning(disable: 4003) -#endif -#include -#if defined(BOOST_MSVC) -# pragma warning(pop) -#endif +#if CGAL_CXX11 -#include + #include -namespace CGAL{ +#else // C++<11 -namespace cpp11{ + // Address the warning C4003: not enough actual parameters for macro 'BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY' + // result_of.hpp includes files from boost/preprocessor + // This concerns boost 1_65_1 + #if defined(BOOST_MSVC) + #pragma warning(push) + #pragma warning(disable: 4003) + #endif + #include + #if defined(BOOST_MSVC) + #pragma warning(pop) + #endif + #include -// When we switch to C++17, we should use the std::invoke_result instead. -// #if __cplusplus >= 201703L -// template -// struct result_of : public std::invoke_result -// { +#endif // end C++<11 + +namespace CGAL { +namespace cpp11 { + +#if CGAL_CXX20 + + template class result_of; + template + class result_of : public std::invoke_result { }; + +#elif CGAL_CXX11 -// }; -// #else using std::result_of; -// #endif -} +#else // C++<11 -} + using boost::result_of; + +#endif + +} // end cpp11 +} // end CGAL #include -#endif //CGAL_RESULT_OF_H +#endif // CGAL_RESULT_OF_H From ad813b4cb0c276bb77755c1d5bfeee770a0d5477 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Thu, 30 Jul 2020 16:19:02 +0200 Subject: [PATCH 010/130] further removed result_of and result --- AABB_tree/include/CGAL/AABB_traits.h | 1 + .../function_objects_polynomial_circular.h | 45 +------------------ .../function_objects_polynomial_sphere.h | 40 +---------------- .../get_equation_object_on_curved_kernel_3.h | 27 ----------- Filtered_kernel/include/CGAL/Lazy.h | 16 ------- .../include/CGAL/Intersection_traits.h | 19 ++++---- .../internal/intersection_3_1_impl.h | 2 +- .../include/CGAL/Kernel/function_objects.h | 35 +-------------- 8 files changed, 16 insertions(+), 169 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_traits.h b/AABB_tree/include/CGAL/AABB_traits.h index 8ff12dfe862..07bdad7d520 100644 --- a/AABB_tree/include/CGAL/AABB_traits.h +++ b/AABB_tree/include/CGAL/AABB_traits.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h index b2326adedd4..beecb4c1dba 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h @@ -518,22 +518,8 @@ namespace CircularFunctors { //using CK::Linear_kernel::Intersect_2::operator(); - template - struct result; - - template - struct result { - typedef typename Intersection_traits::result_type type; - }; - - //need a specialization for the case of 3 object in CK - template - struct result { - typedef OutputIterator type; - }; - template - typename Intersection_traits::result_type + decltype(auto) operator()(const A& a, const B& b) const{ return typename CK::Linear_kernel::Intersect_2()(a,b); } @@ -643,21 +629,6 @@ namespace CircularFunctors { { public: - template - struct result; - - template - struct result - { - typedef typename CK::Polynomial_1_2 type; - }; - - template - struct result - { - typedef typename CK::Polynomial_for_circles_2_2 type; - }; - typename CK::Polynomial_1_2 operator() ( const typename CK::Line_2 & l ) { @@ -1292,20 +1263,6 @@ namespace CircularFunctors { typedef typename CK::Point_2 Point_2; typedef typename CK::Circle_2 Circle_2; public: - template - struct result{ - typedef FT type; - }; - - template - struct result { - typedef decltype(std::declval()(Circle_2())) type; - }; - - template - struct result { - typedef decltype(std::declval()(Circle_2())) type; - }; decltype(auto) operator()( const Circle_2& c) const diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h index 694705639c3..7ab1bd49b97 100644 --- a/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h @@ -667,15 +667,6 @@ template < class SK > \ typedef typename SK::Kernel_base::Circle_3 RCircle_3; typedef typename Circle_3::Rep Rep; public: - template - struct result { - typedef forwarded_result_type type; - }; - - template - struct result { - typedef const forwarded_result_type& type; - }; forwarded_result_type operator()(const Point_3& p, const FT& sr, @@ -1168,44 +1159,17 @@ template < class SK > \ public: - template - struct result; - - // the binary overload always goes to Linear::Intersect_3 - template - struct result - { typedef typename Intersection_traits::result_type type; }; - - // This one is only for the spherical kernel, O is an output iterator - template - struct result - { typedef OutputIterator type;}; - - // there is no quaternary form in the linear Kernel - template - struct result - { typedef OutputIterator type; }; - - //only ternary from the linear kernel - template - struct result { - typedef boost::optional< - boost::variant< Point_3, - Line_3, - Plane_3 > > type; - }; - //using SK::Linear_kernel::Intersect_3::operator(); typedef typename SK::Linear_kernel::Intersect_3 Intersect_linear_3; template - typename Intersection_traits::result_type + decltype(auto) operator()(const A& a, const B& b) const{ return Intersect_linear_3()(a,b); } - typename result::type + decltype(auto) operator()(const Plane_3& p, const Plane_3& q, const Plane_3& r) const { return Intersect_linear_3()(p, q, r); diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/get_equation_object_on_curved_kernel_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/get_equation_object_on_curved_kernel_3.h index 7bd216c466b..ef7bd172f99 100644 --- a/Circular_kernel_3/include/CGAL/Circular_kernel_3/get_equation_object_on_curved_kernel_3.h +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/get_equation_object_on_curved_kernel_3.h @@ -41,33 +41,6 @@ namespace CGAL { typedef typename SK::Polynomials_for_circle_3 result_type_for_circle; //using LinearFunctors::Get_equation::operator(); - template - struct result; - - template - struct result - { - typedef result_type_for_sphere type; - }; - - template - struct result - { - typedef result_type_for_plane type; - }; - - template - struct result - { - typedef result_type_for_line type; - }; - - template - struct result - { - typedef result_type_for_circle type; - }; - result_type_for_sphere operator() ( const typename SK::Sphere_3 & s ) { diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 7ae3bcb36fe..f348718c544 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -817,20 +817,6 @@ struct Lazy_construction_nt { CGAL_NO_UNIQUE_ADDRESS AC ac; CGAL_NO_UNIQUE_ADDRESS EC ec; - template - struct result { }; - -#define CGAL_RESULT_NT(z, n, d) \ - template< typename F, BOOST_PP_ENUM_PARAMS(n, class T) > \ - struct result { \ - BOOST_PP_REPEAT(n, CGAL_TYPEMAP_EC, T) \ - typedef Lazy_exact_nt< \ - typename boost::remove_cv< typename boost::remove_reference < \ - decltype(std::declval()(BOOST_PP_ENUM(n, CGAL_PARAM, E))) >::type >::type > type; \ - }; - - BOOST_PP_REPEAT_FROM_TO(1, 6, CGAL_RESULT_NT, _) - template auto operator()(L const&...l) const -> Lazy_exact_nt>> @@ -847,8 +833,6 @@ struct Lazy_construction_nt { return new Lazy_rep_0 >(ec( CGAL::exact(l)... )); } } - -#undef CGAL_RESULT_NT }; diff --git a/Intersections_2/include/CGAL/Intersection_traits.h b/Intersections_2/include/CGAL/Intersection_traits.h index 740fe435f9e..5892d511db3 100644 --- a/Intersections_2/include/CGAL/Intersection_traits.h +++ b/Intersections_2/include/CGAL/Intersection_traits.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -41,13 +40,13 @@ #define CGAL_INTERSECTION_FUNCTION(A, B, DIM) \ template \ inline \ - typename cpp11::result_of::type \ + decltype(auto) \ intersection(const A& a, const B& b) { \ return BOOST_PP_CAT(K().intersect_, BOOST_PP_CAT(DIM, _object()(a, b))); \ } \ template \ inline \ - typename cpp11::result_of::type \ + decltype(auto) \ intersection(const B& a, const A& b) { \ return BOOST_PP_CAT(K().intersect_, BOOST_PP_CAT(DIM, _object()(a, b))); \ } @@ -55,7 +54,7 @@ #define CGAL_INTERSECTION_FUNCTION_SELF(A, DIM) \ template \ inline \ - typename cpp11::result_of::type \ + decltype(auto) \ intersection(const A & a, const A & b) { \ return BOOST_PP_CAT(K().intersect_, BOOST_PP_CAT(DIM, _object()(a, b))); \ } @@ -123,11 +122,11 @@ namespace internal { // the real type. // Overloads for empty returns are also provided. template - inline typename cpp11::result_of::type - intersection_return(T&& t) { return typename cpp11::result_of::type(std::forward(t)); } + decltype(auto) + intersection_return(T&& t) { return decltype(std::declval()(A(), B()))(std::forward(t)); } template - inline typename cpp11::result_of::type - intersection_return() { return typename cpp11::result_of::type(); } + decltype(auto) + intersection_return() { return decltype(std::declval()(A(), B()))(); } // Something similar to wrap around boost::get and object_cast to // prevent ifdefing too much. Another way could be to introduce an @@ -153,14 +152,14 @@ const T* intersect_get(const boost::variant & v) { } template -typename cpp11::result_of::Kernel::Intersect_2(A, B)>::type +decltype(auto) intersection_impl(const A& a, const B& b, CGAL::Dimension_tag<2>) { typedef typename CGAL::Kernel_traits::Kernel Kernel; return Kernel().intersect_2_object()(a, b); } template -typename cpp11::result_of::Kernel::Intersect_3(A, B)>::type +decltype(auto) intersection_impl(const A& a, const B& b, Dimension_tag<3>) { typedef typename CGAL::Kernel_traits::Kernel Kernel; return Kernel().intersect_3_object()(a, b); diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/intersection_3_1_impl.h b/Intersections_3/include/CGAL/Intersections_3/internal/intersection_3_1_impl.h index f836dbd6aea..b8c1b77dad8 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/intersection_3_1_impl.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/intersection_3_1_impl.h @@ -57,7 +57,7 @@ namespace CGAL { // the special plane_3 function template inline -typename cpp11::result_of::type +decltype(auto) intersection(const Plane_3 &plane1, const Plane_3 &plane2, const Plane_3 &plane3) { diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index c3c3537838e..41e978b703b 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -2557,15 +2557,6 @@ namespace CommonKernelFunctors { typedef typename K::Triangle_3 Triangle_3; typedef typename K::Tetrahedron_3 Tetrahedron_3; public: - template - struct result { - typedef const Point_3& type; - }; - - template - struct result { - typedef Point_3 type; - }; const Point_3& operator()( const Segment_3& s, int i) const @@ -3516,17 +3507,10 @@ namespace CommonKernelFunctors { class Intersect_2 { public: - template - struct result; - - template - struct result { - typedef typename Intersection_traits::result_type type; - }; // 25 possibilities, so I keep the template. template - typename Intersection_traits::result_type + decltype(auto) operator()(const T1& t1, const T2& t2) const { return Intersections::internal::intersection(t1, t2, K()); } }; @@ -3536,21 +3520,6 @@ namespace CommonKernelFunctors { { typedef typename K::Plane_3 Plane_3; public: - template - struct result; - - template - struct result { - typedef typename Intersection_traits::result_type type; - }; - - template - struct result { - typedef boost::optional< - boost::variant< typename K::Point_3, - typename K::Line_3, - typename K::Plane_3 > > type; - }; // n possibilities, so I keep the template. template @@ -3558,7 +3527,7 @@ namespace CommonKernelFunctors { operator()(const T1& t1, const T2& t2) const { return Intersections::internal::intersection(t1, t2, K() ); } - typename boost::optional< boost::variant< typename K::Point_3, typename K::Line_3, typename K::Plane_3 > > + decltype(auto) operator()(const Plane_3& pl1, const Plane_3& pl2, const Plane_3& pl3)const { return Intersections::internal::intersection(pl1, pl2, pl3, K() ); } }; From 758ae808c0f527bfccd90cec8643dda5fbb60b94 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Thu, 30 Jul 2020 17:33:00 +0200 Subject: [PATCH 011/130] better use of declval --- Filtered_kernel/include/CGAL/Lazy.h | 22 +++++++++++----------- STL_Extension/include/CGAL/iterator.h | 8 +++++--- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index f348718c544..33228d1a0fd 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -398,7 +398,7 @@ public: }; // Macro helpers to build the kernel objects -#define CGAL_PARAM(z, n, t) t##n() +#define CGAL_PARAM(z, n, t) std::declval() #define CGAL_TYPEMAP_AC(z, n, t) typedef typename Type_mapper< t##n, LK, AK >::type A##n; #define CGAL_TYPEMAP_EC(z, n, t) typedef typename Type_mapper< t##n, LK, EK >::type E##n; #define CGAL_LEXACT(z,n,t) CGAL::exact( l##n ) @@ -1486,10 +1486,10 @@ struct Lazy_construction_variant { operator()(const L1& l1, const L2& l2) const { typedef typename result::type result_type; - typedef decltype(std::declval()(typename Type_mapper::type(), - typename Type_mapper::type())) AT; - typedef decltype(std::declval()(typename Type_mapper::type(), - typename Type_mapper::type())) ET; + typedef decltype(std::declval()(std::declval::type>(), + std::declval::type>())) AT; + typedef decltype(std::declval()(std::declval::type>(), + std::declval::type>())) ET; CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; @@ -1534,12 +1534,12 @@ struct Lazy_construction_variant { operator()(const L1& l1, const L2& l2, const L3& l3) const { typedef typename result::type result_type; - typedef decltype(std::declval()(typename Type_mapper::type(), - typename Type_mapper::type(), - typename Type_mapper::type())) AT; - typedef decltype(std::declval()(typename Type_mapper::type(), - typename Type_mapper::type(), - typename Type_mapper::type())) ET; + typedef decltype(std::declval()(std::declval::type>(), + std::declval::type>(), + std::declval::type>())) AT; + typedef decltype(std::declval()(std::declval::type>(), + std::declval::type>(), + std::declval::type>())) ET; CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; diff --git a/STL_Extension/include/CGAL/iterator.h b/STL_Extension/include/CGAL/iterator.h index dec026e4a43..8395606f4b5 100644 --- a/STL_Extension/include/CGAL/iterator.h +++ b/STL_Extension/include/CGAL/iterator.h @@ -659,7 +659,8 @@ class Join_input_iterator_1 public: typedef typename std::iterator_traits::iterator_category iterator_category; - typedef std::decay_t()(arg_type()))> value_type; + typedef std::decay_t()(std::declval()))> + value_type; typedef typename std::iterator_traits::difference_type difference_type; typedef value_type const* pointer; typedef value_type const& reference; @@ -745,7 +746,8 @@ class Join_input_iterator_2 public: typedef typename std::iterator_traits::iterator_category iterator_category; - typedef decltype(std::declval()(arg_type_1(), arg_type_2())) value_type; + typedef decltype(std::declval()(std::declval(), std::declval())) + value_type; typedef typename std::iterator_traits::difference_type difference_type; typedef value_type* pointer; typedef value_type& reference; @@ -839,7 +841,7 @@ class Join_input_iterator_3 public: typedef typename std::iterator_traits::iterator_category iterator_category; - typedef decltype(std::declval()(arg_type_1(), arg_type_2(), arg_type_3())) + typedef decltype(std::declval()(std::declval(), std::declval(), std::declval())) value_type; typedef typename std::iterator_traits::difference_type difference_type; typedef value_type* pointer; From 69ed0152cc19b31191f2b6df4a4a2154162388ec Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Thu, 30 Jul 2020 18:30:56 +0200 Subject: [PATCH 012/130] some cleanup --- Filtered_kernel/include/CGAL/Lazy.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 33228d1a0fd..1fa84f44ceb 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -979,14 +979,14 @@ struct Lazy_cartesian_const_iterator_2 public: template < typename L1> - decltype(auto) + result_type operator()(const L1& l1) const { return result_type(&l1); } template < typename L1> - decltype(auto) + result_type operator()(const L1& l1, int) const { return result_type(&l1,2); @@ -1008,14 +1008,14 @@ struct Lazy_cartesian_const_iterator_3 public: template < typename L1> - decltype(auto) + result_type operator()(const L1& l1) const { return result_type(&l1); } template < typename L1> - decltype(auto) + result_type operator()(const L1& l1, int) const { return result_type(&l1,3); From 209513dc5612a8a3be2b19fc8f5e4460e4ea7535 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Fri, 31 Jul 2020 15:58:38 +0200 Subject: [PATCH 013/130] fixed docs + a few code improvements --- .../doc/AABB_tree/Concepts/AABBGeomTraits.h | 4 +-- .../include/CGAL/AABB_segment_primitive.h | 8 ++---- AABB_tree/include/CGAL/AABB_traits.h | 14 ++++------ .../include/CGAL/AABB_triangle_primitive.h | 9 +++--- .../AABB_triangulation_3_cell_primitive.h | 8 +++--- .../include/CGAL/Intersection_traits.h | 4 +-- .../CGAL/Circular_kernel_intersections.h | 2 +- .../CGAL/Spherical_kernel_intersections.h | 13 ++++----- Kernel_23/doc/Kernel_23/CGAL/intersections.h | 28 +++++++++++-------- .../Concepts/FunctionObjectConcepts.h | 10 ++----- Kernel_23/doc/Kernel_23/Kernel_23.txt | 28 +++++++------------ Kernel_d/doc/Kernel_d/CGAL/intersections_d.h | 23 +++++++-------- .../Kernel_d/Concepts/Kernel--Intersect_d.h | 2 +- Kernel_d/doc/Kernel_d/Kernel_d.txt | 17 +++++------ .../NewKernel_d/Cartesian_static_filters.h | 1 - .../CGAL/NewKernel_d/Filtered_predicate2.h | 1 - .../CGAL/NewKernel_d/KernelD_converter.h | 2 +- .../CGAL/NewKernel_d/Kernel_d_interface.h | 10 +++---- .../CGAL/NewKernel_d/Wrapper/Point_d.h | 2 +- .../CGAL/NewKernel_d/Wrapper/Vector_d.h | 1 - .../CGAL/Periodic_3_regular_triangulation_3.h | 3 +- .../doc/STL_Extension/CGAL/result_of.h | 16 ++++++----- .../include/CGAL/transforming_iterator.h | 1 - 23 files changed, 91 insertions(+), 116 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits.h index 6f732e50340..e9a664c2ff8 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits.h @@ -45,11 +45,9 @@ typedef unspecified_type Do_intersect_3; /*! A functor object to construct the intersection between two geometric objects. -This functor must support the result_of protocol, that is the return -type of the `operator()(A, B)` is `CGAL::cpp11::result`. Provides the operators: -`CGAL::cpp11::result operator()(const A& a, const B& b);` +`decltype(auto) operator()(const A& a, const B& b);` where `A` and `B` are any relevant types among `Ray_3`, `Segment_3`, `Line_3`, `Triangle_3`, `Plane_3` and `Bbox_3`. Relevant herein means that a line primitive (ray, segment, line) is tested diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive.h b/AABB_tree/include/CGAL/AABB_segment_primitive.h index 34851f55a63..d28c681c4c3 100644 --- a/AABB_tree/include/CGAL/AABB_segment_primitive.h +++ b/AABB_tree/include/CGAL/AABB_segment_primitive.h @@ -20,7 +20,6 @@ #include #include -#include #include namespace CGAL { @@ -31,9 +30,9 @@ namespace internal { //classical typedefs typedef Iterator key_type; typedef typename GeomTraits::Point_3 value_type; - typedef typename cpp11::result_of< - typename GeomTraits::Construct_source_3(typename GeomTraits::Segment_3) - >::type reference; + typedef decltype( + std::declval()( + std::declval())) reference; typedef boost::readable_property_map_tag category; inline friend @@ -57,7 +56,6 @@ namespace internal { * \tparam GeomTraits is a traits class providing the nested type `Point_3` and `Segment_3`. * It also provides the functor `Construct_source_3` that has an operator taking a `Segment_3` * and returning its source as a type convertible to `Point_3`. - * In addition `Construct_source_3` must support the result_of protocol. * \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Segment_3` * \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case, * the datum is stored in the primitive, while in the latter it is diff --git a/AABB_tree/include/CGAL/AABB_traits.h b/AABB_tree/include/CGAL/AABB_traits.h index 07bdad7d520..0018d9476e7 100644 --- a/AABB_tree/include/CGAL/AABB_traits.h +++ b/AABB_tree/include/CGAL/AABB_traits.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -190,14 +189,14 @@ public: typedef typename std::pair Point_and_primitive_id; /// `Intersection_and_primitive_id::%Type::first_type` is found according to - /// the result type of `GeomTraits::Intersect_3::operator()`, - /// (that is cpp11::result_of::type). If it is + /// the result type of `GeomTraits::Intersect_3::operator()`. If it is /// `boost::optional` then it is `T`, and the result type otherwise. template struct Intersection_and_primitive_id { - typedef typename cpp11::result_of< - typename GeomTraits::Intersect_3(Query, typename Primitive::Datum) - >::type Intersection_type; + typedef decltype( + std::declval()( + std::declval(), + std::declval())) Intersection_type; typedef std::pair< typename internal::AABB_tree::Remove_optional::type, @@ -364,8 +363,7 @@ public: template boost::optional< typename Intersection_and_primitive_id::Type > operator()(const Query& query, const typename AT::Primitive& primitive) const { - typename cpp11::result_of::type - inter_res = GeomTraits().intersect_3_object()(internal::Primitive_helper::get_datum(primitive,m_traits),query); + auto inter_res = GeomTraits().intersect_3_object()(internal::Primitive_helper::get_datum(primitive,m_traits),query); if (!inter_res) return boost::none; return boost::make_optional( std::make_pair(*inter_res, primitive.id()) ); diff --git a/AABB_tree/include/CGAL/AABB_triangle_primitive.h b/AABB_tree/include/CGAL/AABB_triangle_primitive.h index 5c1502d60af..89b45f940be 100644 --- a/AABB_tree/include/CGAL/AABB_triangle_primitive.h +++ b/AABB_tree/include/CGAL/AABB_triangle_primitive.h @@ -20,7 +20,6 @@ #include #include -#include #include namespace CGAL { @@ -31,9 +30,10 @@ namespace internal { //classical typedefs typedef Iterator key_type; typedef typename GeomTraits::Point_3 value_type; - typedef typename cpp11::result_of< - typename GeomTraits::Construct_vertex_3(typename GeomTraits::Triangle_3,int) - >::type reference; + typedef decltype( + std::declval()( + std::declval(), + std::declval())) reference; typedef boost::readable_property_map_tag category; inline friend @@ -57,7 +57,6 @@ namespace internal { * \tparam GeomTraits is a traits class providing the nested type `Point_3` and `Triangle_3`. * It also provides the functor `Construct_vertex_3` that has an operator taking a `Triangle_3` * and an integer as parameters and returning a triangle point as a type convertible to `Point_3`. - * In addition `Construct_vertex_3` must support the result_of protocol. * \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Triangle_3` * \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case, * the datum is stored in the primitive, while in the latter it is diff --git a/AABB_tree/include/CGAL/AABB_triangulation_3_cell_primitive.h b/AABB_tree/include/CGAL/AABB_triangulation_3_cell_primitive.h index 66783dcff9b..90d520061a4 100644 --- a/AABB_tree/include/CGAL/AABB_triangulation_3_cell_primitive.h +++ b/AABB_tree/include/CGAL/AABB_triangulation_3_cell_primitive.h @@ -18,7 +18,6 @@ #include -#include #include namespace CGAL @@ -31,9 +30,10 @@ namespace CGAL //classical typedefs typedef Iterator key_type; typedef typename GeomTraits::Point_3 value_type; - typedef typename cpp11::result_of< - typename GeomTraits::Construct_vertex_3(typename GeomTraits::Tetrahedron_3, int) - >::type reference; + typedef decltype( + std::declval()( + std::declval(), + std::declval())) reference; typedef boost::readable_property_map_tag category; inline friend diff --git a/Intersections_2/include/CGAL/Intersection_traits.h b/Intersections_2/include/CGAL/Intersection_traits.h index 5892d511db3..cafd0428ef8 100644 --- a/Intersections_2/include/CGAL/Intersection_traits.h +++ b/Intersections_2/include/CGAL/Intersection_traits.h @@ -123,10 +123,10 @@ namespace internal { // Overloads for empty returns are also provided. template decltype(auto) - intersection_return(T&& t) { return decltype(std::declval()(A(), B()))(std::forward(t)); } + intersection_return(T&& t) { return decltype(std::declval()(std::declval(), std::declval()))(std::forward(t)); } template decltype(auto) - intersection_return() { return decltype(std::declval()(A(), B()))(); } + intersection_return() { return decltype(std::declval()(std::declval(), std::declval()))(); } // Something similar to wrap around boost::get and object_cast to // prevent ifdefing too much. Another way could be to introduce an diff --git a/Kernel_23/doc/Kernel_23/CGAL/Circular_kernel_intersections.h b/Kernel_23/doc/Kernel_23/CGAL/Circular_kernel_intersections.h index 5cc62d8227c..52b6131ddbc 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Circular_kernel_intersections.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Circular_kernel_intersections.h @@ -48,7 +48,7 @@ with `Dispatch_output_iterator`. Since both the number of intersections, if any, and their types, depend on the arguments, the function expects an output iterator on -`cpp11::result_of::%type`, as +`decltype(std::declval()(std::declval(), std::declval()))`, as presented below. */ diff --git a/Kernel_23/doc/Kernel_23/CGAL/Spherical_kernel_intersections.h b/Kernel_23/doc/Kernel_23/CGAL/Spherical_kernel_intersections.h index 3dbd6b566ae..63b75823a33 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Spherical_kernel_intersections.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Spherical_kernel_intersections.h @@ -59,18 +59,15 @@ with `Dispatch_output_iterator`. Since both the number of intersections, if any, and their types, depend on the arguments, the function expects an output iterator on -`cpp11::result_of::%type`, +`decltype(std::declval()(std::declval(), std::declval()))`, as presented below. */ /// @{ /*! -Copies in the output iterator the intersection elements between the -two objects. `intersections` iterates on -elements of type `result_of< Intersect_3(SphericalType1, SphericalType2) >`, in lexicographic order, -when this ordering is defined on the computed objects, - -where `SphericalType1` and `SphericalType2` can both be one of: +Constructs the intersection elements between the two input +objects and stores them in the OutputIterator in lexicographic order, +where both, `SphericalType1` and `SphericalType2`, can be either - `Sphere_3`, - `Plane_3`, @@ -90,7 +87,7 @@ type can be and if the two objets `obj1` and `obj2` are equal, - `Line_3` or `Circle_3` when `SphericalType1` and `SphericalType2` - are two-dimensional objets intersecting along a curve (2 planes, or 2 + are two-dimensional objects intersecting along a curve (2 planes, or 2 spheres, or one plane and one sphere), - `Circular_arc_3` in case of an overlap of two circular arcs or diff --git a/Kernel_23/doc/Kernel_23/CGAL/intersections.h b/Kernel_23/doc/Kernel_23/CGAL/intersections.h index 7421c3e57f6..b39269c53a6 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/intersections.h +++ b/Kernel_23/doc/Kernel_23/CGAL/intersections.h @@ -95,12 +95,15 @@ The following tables give the possible values for `Type1` and `Type2`. \cgalHeading{2D Intersections} -The return type can be obtained through `cpp11::result_of::%type`. -It is equivalent to `boost::optional< boost::variant< T... > >`, the last column in the table providing the template parameter pack. +The return type of intersecting two objects of the types `Type1` and `Type2` can be +specified through the placeholder type specifier `auto`. It is equivalent to +`boost::optional< boost::variant< T... > >`, the last column in the table providing +the template parameter pack.
- + + @@ -191,12 +194,15 @@ intersections existing with the type `Iso_rectangle_2`. Note that the return typ \cgalHeading{3D Intersections} -The return type can be obtained through `cpp11::result_of::%type`. -It is equivalent to `boost::optional< boost::variant< T... > >`, the last column in the table providing the template parameter pack. +The return type of intersecting two objects of the types `Type1` and `Type2` can be +specified through the placeholder type specifier `auto`. It is equivalent to +`boost::optional< boost::variant< T... > >`, the last column in the table providing +the template parameter pack.
Type1
Type1 Type2 Return Type: `T...`
- + + @@ -350,9 +356,9 @@ The following examples demonstrate the most common use of `intersection()` functions with the 2D and 3D Linear %Kernel. In the first two examples we intersect a segment and a line. -The result type can be obtained with `cpp11::result_of`. It looks simpler -if you use a C++ compiler which supports `auto`, -but you must anyways know that the result type is a `boost::optional >`, in order to unpack the point or segment. +The result type can be specified through the placeholder type specifier `auto`, +but you must anyway know that the result type is a `boost::optional >`, +in order to unpack the point or segment. `boost::optional` comes in as there might be no intersection. `boost::variant` comes in @@ -374,7 +380,7 @@ a standard library algorithm. */ template -cpp11::result_of::type +decltype(auto) intersection(Type1 obj1, Type2 obj2); /*! @@ -382,7 +388,7 @@ returns the intersection of 3 planes, which can be a point, a line, a plane, or empty. */ template -boost::optional< boost::variant< Point_3, Line_3, Plane_3 > > +decltype(auto) intersection(const Plane_3& pl1, const Plane_3& pl2, const Plane_3& pl3); diff --git a/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h b/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h index 44e13cfbbe4..b77db9d9a89 100644 --- a/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h +++ b/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h @@ -8413,8 +8413,6 @@ public: \cgalRefines `AdaptableFunctor` (with two arguments) \sa \link intersection_grp `CGAL::intersection()` \endlink - \sa `CGAL::cpp11::result_of` - */ class Intersect_2 { public: @@ -8428,7 +8426,7 @@ public: `Type1` and `Type2`, for all pairs `Type1` and `Type2`. For details see the reference manual page for \link intersection_grp `CGAL::intersection()` \endlink. */ - CGAL::cpp11::result_of::type + decltype(auto) operator()(Type1 obj1, Type2 obj2); /// @} @@ -8442,8 +8440,6 @@ public: \cgalRefines `AdaptableFunctor` (with two or three arguments) \sa intersection_linear_grp - \sa `CGAL::cpp11::result_of` - */ class Intersect_3 { public: @@ -8457,8 +8453,8 @@ public: objects of type `Type1` and `Type2`. For details see the reference manual page for \ref intersection_linear_grp. */ - CGAL::cpp11::result_of::type - operator()(Type1 obj1, Type2 obj2); + decltype(auto) + operator()(Type1 obj1, Type2 obj2); diff --git a/Kernel_23/doc/Kernel_23/Kernel_23.txt b/Kernel_23/doc/Kernel_23/Kernel_23.txt index c624cc64db8..3777a054165 100644 --- a/Kernel_23/doc/Kernel_23/Kernel_23.txt +++ b/Kernel_23/doc/Kernel_23/Kernel_23.txt @@ -493,23 +493,19 @@ especially integer types and rationals. \subsection Kernel_23VariantReturnValues Intersections and Variant Return Types -Some functions, for example \link intersection_linear_grp `intersection()`\endlink, can return different types of objects. To achieve this -in a type-safe way \cgal uses return values of type -`boost::optional< boost::variant< T... > >` were `T...` is a -list of all possible resulting geometric objects. The exact result -type of an intersection can be determined through the metafunction -`CGAL::cpp11::result_of` or -`CGAL::cpp11::result_of`, where -`Type1` and `Type2` are the types of the objects used in the -intersection computation. +Some functions, for example \link intersection_linear_grp `intersection()`\endlink, +can return different types of objects. To achieve this in a type-safe way \cgal uses +return values of type `boost::optional< boost::variant< T... > >` where `T...` is a +list of all possible resulting geometric objects. The exact result type of an intersection +can be specified through the placeholder type specifier `auto`. Example ------- -In the following example, `result_of` is used to query the type of the -return value for the intersection computation: +In the following example, `auto` is used to specify the type of the return value +for the intersection computation: \code{.cpp} typedef Cartesian K; @@ -521,13 +517,9 @@ Segment_2 segment_1, segment_2; std::cin >> segment_1 >> segment_2; -/* C++11 */ -// auto v = intersection(segment_1, segment_2); - -/* C++03 */ -CGAL::cpp11::result_of::type -v = intersection(segment_1, segment_2); -if(v) { +/* use auto */ +auto v = intersection(segment_1, segment_2); +if (v) { /* not empty */ if (const Point_2 *p = boost::get(&*v) ) { /* do something with *p */ diff --git a/Kernel_d/doc/Kernel_d/CGAL/intersections_d.h b/Kernel_d/doc/Kernel_d/CGAL/intersections_d.h index 5949422420c..1ac4f08cf2d 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/intersections_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/intersections_d.h @@ -34,14 +34,16 @@ The same functionality is also available through the functor `Kernel::Intersect_ The following table gives the possible values for `Type1` and `Type2`. -The return type can be obtained through `cpp11::result_of::%type`. -It is equivalent to `boost::optional< boost::variant< T... > >`, the last column in the table providing the template parameter pack. - +The return type of intersecting two objects of the types `Type1` and `Type2` can be +specified through the placeholder type specifier `auto`. It is equivalent to +`boost::optional< boost::variant< T... > >`, the last column in the table providing +the template parameter pack.
Type1
Type1 Type2 Return Type: `T...`
- + + @@ -143,13 +145,8 @@ struct Intersection_visitor { template void foo(Segment_d seg, Line_d lin) { - // with C++11 support - // auto result = intersection(seg, lin); - - // without C++11 support - typename CGAL::cpp11::result_of, Line_d)>::type - result = intersection(seg, lin); - + // use auto + auto result = intersection(seg, lin); if(result) { boost::apply_visitor(Intersection_visitor(), *result); } else { // no intersection } @@ -160,10 +157,10 @@ void foo(Segment_d seg, Line_d lin) \sa `Kernel_d::Intersect_d` \sa `boost::optional` \sa `boost::variant` -\sa `cpp11::result_of` */ -cpp11::result_of, Type2)>::type intersection(Type1 f1, Type2 f2); +decltype(auto) +intersection(Type1 f1, Type2 f2); } /* namespace CGAL */ diff --git a/Kernel_d/doc/Kernel_d/Concepts/Kernel--Intersect_d.h b/Kernel_d/doc/Kernel_d/Concepts/Kernel--Intersect_d.h index 79d9ec8d323..92f272da256 100644 --- a/Kernel_d/doc/Kernel_d/Concepts/Kernel--Intersect_d.h +++ b/Kernel_d/doc/Kernel_d/Concepts/Kernel--Intersect_d.h @@ -23,7 +23,7 @@ For a list of the possible return types, see `CGAL::intersection()`. \pre `p` and `q` have the same dimension. */ template -CGAL::cpp11::result_of::type +decltype(auto) operator()(const Type1& p, const Type2& q); /// @} diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index f61d9de2636..ebccd581875 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -480,17 +480,14 @@ that are part of flats (`R::Segment_d`, `R::Ray_d`, returns a `boost::optional< boost::variant< T... > >` where `T...` is a list of all possible resulting geometric objects. -The exact result type of an intersection can be determined by using -`CGAL::cpp11::result_of::%type` -where `Type1` and `Type2` are the types of the objects -used in the intersection computation. +The return type of intersecting two objects of the types `Type1` and `Type2` can be +specified through the placeholder type specifier `auto`. \subsubsection Kernel_dExample Example -In the following example, the object type is used as a return value for -the intersection computation, as there are -possibly different return values. +In the following example, the `auto` is used for the intersection computation, +as there are possibly different return values. \code{.cpp} typedef Cartesian_d K; @@ -500,9 +497,9 @@ typedef Segment_d Segment; Segment s1, s2; std::cin >> s1 >> s2; -CGAL::cpp11::result_of::type - v = intersection(s1, s2); -if(v) { +/* use auto */ +auto v = intersection(s1, s2); +if (v) { // not empty if (const Point *p = boost::get(&*v) ) { // do something with *p diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h index 507e4144694..701cbff1efc 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h @@ -32,7 +32,6 @@ template struct Orientation_of_points_2 : private Store_k struct Point_2 { R_ const&r; CC const&c; Point const& p; Point_2(R_ const&r_, CC const&c_, Point const&p_):r(r_),c(c_),p(p_){} - // use result_of instead? typename CC::result_type x()const{return c(p,0);} typename CC::result_type y()const{return c(p,1);} }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h index c3d2281ad96..0265a9239e7 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h @@ -58,7 +58,6 @@ public: typedef C2E To_exact_converter; typedef C2A To_approximate_converter; - // FIXME: should use result_of, see emails by Nico typedef typename EP::result_type result_type; // AP::result_type must be convertible to EP::result_type. diff --git a/NewKernel_d/include/CGAL/NewKernel_d/KernelD_converter.h b/NewKernel_d/include/CGAL/NewKernel_d/KernelD_converter.h index d48f3dc7ffc..5f2481695af 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/KernelD_converter.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/KernelD_converter.h @@ -134,7 +134,7 @@ typename typeset_intersection(a),Store_kernel2(b){} - // For boost::result_of, used in transforming_iterator + // For the (not anymore used in CGAL) boost result of, used in transforming_iterator template::value?42:0> struct result:Base::template result{}; template struct result { typedef transforming_iterator type; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h index 23e2fad48d0..c4d0bd80e4b 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h @@ -127,15 +127,15 @@ template struct Kernel_d_interface : public Base_ { typedef typename Get_functor >::type CPI; typedef typename Get_functor >::type CVI; // FIXME: The following sometimes breaks compilation. The typedef below forces instantiation of this, which forces Point_d, which itself (in the wrapper) needs the derived kernel to tell it what the base kernel is, and that's a cycle. The exact circumstances are not clear, g++ and clang++ are ok in both C++03 and C++11, it is only clang in C++11 without CGAL_CXX11 that breaks. Relying on CPI::result_type is great for Epick_d but not Epeck_d. - //typedef typename CGAL::decay::type>::type result_type; - //typedef typename CGAL::decay::type result_type; - //typedef decltype(std::declval()(std::declval(),Begin_tag{})) result_type; + // typedef typename CGAL::decay()(std::declval(), std::declval()))>::type result_type; + // typedef typename CGAL::decay::type result_type; + // typedef decltype(std::declval()(std::declval(),Begin_tag{})) result_type; // HACK typedef typename Base::Point_cartesian_const_iterator result_type; // Kernel_d requires a common iterator type for points and vectors // TODO: provide this mixed functor in preKernel? - //CGAL_static_assertion((boost::is_same::type>::type, result_type>::value)); - //CGAL_static_assertion((boost::is_same::type, result_type>::value)); + // CGAL_static_assertion((boost::is_same()(std::declval(), std::declval()))>::type, result_type>::value)); + // CGAL_static_assertion((boost::is_same::type, result_type>::value)); template auto operator()(Point_d const&p, Tag_ t)const{ return CPI(this->kernel())(p,t); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h index 7716c54bf05..90bb34da3de 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -49,7 +49,7 @@ public: typedef Dimension_tag<0> Feature_dimension; typedef typename Get_type::type Rep; - //typedef typename CGAL::decay::type>::type Cartesian_const_iterator; + // typedef typename CGAL::decay()(std::declval(), std::declval()))>::type Cartesian_const_iterator; const Rep& rep() const noexcept { diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h index 16174e9a4cb..de13385758d 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h @@ -22,7 +22,6 @@ #include #include #include -#include namespace CGAL { namespace Wrap { diff --git a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_3.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_3.h index 030d0f9d409..63ab4c6be9b 100644 --- a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_3.h +++ b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_3.h @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -498,7 +497,7 @@ public: // Spatial sorting can only be applied to bare points, so we need an adaptor typedef typename Geom_traits::Construct_point_3 Construct_point_3; - typedef typename cpp11::result_of::type Ret; + typedef decltype(std::declval()(std::declval())) Ret; typedef boost::function_property_map fpmap; typedef CGAL::Spatial_sort_traits_adapter_3 Search_traits_3; diff --git a/STL_Extension/doc/STL_Extension/CGAL/result_of.h b/STL_Extension/doc/STL_Extension/CGAL/result_of.h index e39e27c35f3..507efb3645c 100644 --- a/STL_Extension/doc/STL_Extension/CGAL/result_of.h +++ b/STL_Extension/doc/STL_Extension/CGAL/result_of.h @@ -3,16 +3,18 @@ namespace cpp11 { /*! \ingroup PkgSTLExtensionRef - Alias to the tr1 implementation from boost of the `result_of` mechanism. - When all compilers supported by %CGAL will have a Standard compliant implemention of the - the \cpp11 `decltype` feature, it will become an alias to std::result_of. + Alias to the implementation of the `std::result_of` mechanism. When all compilers + supported by \cgal have a Standard compliant implemention of the `std::invoke_result` + mechanism, it will become an alias to the std::invoke_result. - \sa boost::result_of + \sa std::result_of */ template - struct result_of{ - /// starting from boost version 1.44, it is `boost::tr1_result_of::%type`, and - /// `boost::result_of::%type` otherwise. + struct result_of { + + /*! + It is a type `std::result_of::%type`. + */ typedef unspecified_type type; }; diff --git a/STL_Extension/include/CGAL/transforming_iterator.h b/STL_Extension/include/CGAL/transforming_iterator.h index 16bf7649da5..c77e36669fa 100644 --- a/STL_Extension/include/CGAL/transforming_iterator.h +++ b/STL_Extension/include/CGAL/transforming_iterator.h @@ -12,7 +12,6 @@ #ifndef CGAL_TRANSFORMING_ITERATOR_H #define CGAL_TRANSFORMING_ITERATOR_H #include -#include #include #include #include From 371db977c85a29583124a433fb9e559b5089dc3a Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Thu, 20 Aug 2020 14:12:16 +0200 Subject: [PATCH 014/130] better kernel checker --- Kernel_23/include/CGAL/Kernel_checker.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Kernel_23/include/CGAL/Kernel_checker.h b/Kernel_23/include/CGAL/Kernel_checker.h index a4753265266..bd35c115a08 100644 --- a/Kernel_23/include/CGAL/Kernel_checker.h +++ b/Kernel_23/include/CGAL/Kernel_checker.h @@ -84,10 +84,8 @@ public: { auto res1 = p1(a.first...); auto res2 = p2(a.second...); - if (! cmp(res1, res2)) - { - CGAL_kernel_assertion(false); - } + + CGAL_kernel_assertion(cmp(res1, res2)); return Pairify()(res1, res2); } }; From 263ad6bc991f28fdf00f3d0e893ac23b5cc1d9e7 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Thu, 20 Aug 2020 18:25:01 +0200 Subject: [PATCH 015/130] fixed ch3, inter3, otr2, psp, pmp, smsp, mesh3 + cleanup --- .../CGAL/Extreme_points_traits_adapter_3.h | 7 +-- .../test/Intersections_3/call_test.cpp | 12 ++-- Mesh_3/benchmark/Mesh_3/StdAfx.h | 1 - .../Concepts/MeshTriangulationTraits_3.h | 6 +- Mesh_3/include/CGAL/Labeled_mesh_domain_3.h | 9 +-- .../Mesh_3/Robust_intersection_traits_3.h | 62 ++++++++----------- .../Sizing_field_with_aabb_tree.h | 5 +- .../include/CGAL/Polyhedral_mesh_domain_3.h | 4 +- .../OTR_2/Reconstruction_triangulation_2.h | 3 +- .../include/CGAL/structure_point_set.h | 15 ++--- .../Corefinement/intersection_nodes.h | 8 +-- .../internal/Corefinement/predicates.h | 9 +-- .../include/CGAL/Polygon_mesh_slicer.h | 3 +- .../Concepts/SurfaceMeshShortestPathTraits.h | 2 +- .../Surface_mesh_shortest_path.h | 14 ++--- .../function_objects.h | 7 +-- 16 files changed, 61 insertions(+), 106 deletions(-) diff --git a/Convex_hull_3/include/CGAL/Extreme_points_traits_adapter_3.h b/Convex_hull_3/include/CGAL/Extreme_points_traits_adapter_3.h index adeb88c6e26..dfc0b27c7ba 100644 --- a/Convex_hull_3/include/CGAL/Extreme_points_traits_adapter_3.h +++ b/Convex_hull_3/include/CGAL/Extreme_points_traits_adapter_3.h @@ -22,7 +22,6 @@ #include #include -#include namespace CGAL { namespace Convex_hull_3 { @@ -37,14 +36,14 @@ struct Forward_functor Forward_functor(const PointPropertyMap& vpm, const F& f) : F(f), vpm_(vpm) {} template - typename cpp11::result_of::type + decltype(auto) operator()(const Vertex& p, const Vertex& q) const { return static_cast(this)->operator()(get(vpm_, p), get(vpm_, q)); } template - typename cpp11::result_of::type + decltype(auto) operator()(const Vertex& p, const Vertex& q, const Vertex& r) const { return static_cast(this)->operator()(get(vpm_, p), @@ -53,7 +52,7 @@ struct Forward_functor } template - typename cpp11::result_of::type + decltype(auto) operator()(const Vertex& p, const Vertex& q, const Vertex& r, const Vertex& s) const { return static_cast(this)->operator()(get(vpm_, p), diff --git a/Intersections_3/test/Intersections_3/call_test.cpp b/Intersections_3/test/Intersections_3/call_test.cpp index 34c45488e5b..90f595bcbb6 100644 --- a/Intersections_3/test/Intersections_3/call_test.cpp +++ b/Intersections_3/test/Intersections_3/call_test.cpp @@ -25,9 +25,9 @@ typedef CGAL::Bbox_3 Bbox_3; template void call_intersection_global(const A& a, const B& b) { - typename CGAL::cpp11::result_of::type x = CGAL::intersection(a, b); - typename CGAL::cpp11::result_of::type y = CGAL::intersection(b, a); - typename CGAL::cpp11::result_of::type z = CGAL::intersection(b, a); + const auto x = CGAL::intersection(a, b); + const auto y = CGAL::intersection(b, a); + const auto z = CGAL::intersection(b, a); CGAL_USE(x); CGAL_USE(y); CGAL_USE(z); @@ -42,8 +42,8 @@ void call_do_intersect_global(const A& a, const B& b) { template void call_intersection_with_kernel(const A& a, const B& b, const K&) { typedef typename K::Intersect_3 Intersect; - typename CGAL::cpp11::result_of::type x = Intersect()(a, b); - typename CGAL::cpp11::result_of::type y = Intersect()(b, a); + const auto x = Intersect()(a, b); + const auto y = Intersect()(b, a); } template @@ -83,7 +83,7 @@ int main(int argc, char**) // call_intersection_global(Pl(), Cub()); // special - CGAL::cpp11::result_of::type plplpl = CGAL::intersection(Pl(), Pl(), Pl()); + const auto plplpl = CGAL::intersection(Pl(), Pl(), Pl()); call_intersection_global(Tr(), S()); call_intersection_global(Tr(), L()); diff --git a/Mesh_3/benchmark/Mesh_3/StdAfx.h b/Mesh_3/benchmark/Mesh_3/StdAfx.h index 6fee6450e2f..ac0f9e1b5b2 100644 --- a/Mesh_3/benchmark/Mesh_3/StdAfx.h +++ b/Mesh_3/benchmark/Mesh_3/StdAfx.h @@ -145,7 +145,6 @@ #include #include #include -#include #include #include diff --git a/Mesh_3/doc/Mesh_3/Concepts/MeshTriangulationTraits_3.h b/Mesh_3/doc/Mesh_3/Concepts/MeshTriangulationTraits_3.h index 0fdacdb302c..4d1af263528 100644 --- a/Mesh_3/doc/Mesh_3/Concepts/MeshTriangulationTraits_3.h +++ b/Mesh_3/doc/Mesh_3/Concepts/MeshTriangulationTraits_3.h @@ -312,11 +312,11 @@ public: /*! A constructor object that must provide the function operators: - `CGAL::cpp11::result_of< Kernel::Intersect_3(Segment_3, Plane_3)>::%type operator()(Segment_3 s, Plane_3 p)` + `boost::optional< boost::variant< T... > > operator()(Segment_3 s, Plane_3 p)` - `CGAL::cpp11::result_of< Kernel::Intersect_3(Ray_3, Iso_cuboid_3)>::%type operator()(Ray_3 r, Iso_cuboid i)` + `boost::optional< boost::variant< T... > > operator()(Ray_3 r, Iso_cuboid i)` - `CGAL::cpp11::result_of< Kernel::Intersect_3(Segment_3, Iso_cuboid_3)>::%type operator()(Segment_3 s, Iso_cuboid i)` + `boost::optional< boost::variant< T... > > operator()(Segment_3 s, Iso_cuboid i)` which returns the intersection region of two geometrical objects. */ diff --git a/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h b/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h index 0e4cf7822ab..0dceef7f282 100644 --- a/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h +++ b/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h @@ -31,7 +31,6 @@ #include #include -#include #include #include @@ -590,9 +589,7 @@ public: template Surface_patch clip_to_segment(const Query& query) const { - typename cpp11::result_of::type - clipped = CGAL::intersection(query, r_domain_.bbox_); - + const auto clipped = CGAL::intersection(query, r_domain_.bbox_); if(clipped) if(const Segment_3* s = boost::get(&*clipped)) return this->operator()(*s); @@ -720,9 +717,7 @@ public: template Intersection clip_to_segment(const Query& query) const { - typename cpp11::result_of::type - clipped = CGAL::intersection(query, r_domain_.bbox_); - + const auto clipped = CGAL::intersection(query, r_domain_.bbox_); if(clipped) if(const Segment_3* s = boost::get(&*clipped)) return this->operator()(*s); diff --git a/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h b/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h index 6611d928a00..3178ebcbb9c 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h @@ -261,15 +261,15 @@ lp_intersection(const typename K::Point_3& p, const typename K::Point_3& q, // returns a point or the empty Object. In case of degeneracy, the empty // Object is returned as well. template -typename cpp11::result_of< - typename K::Intersect_3(typename K::Segment_3, typename K::Triangle_3)>::type +decltype(auto) ts_intersection(const typename K::Triangle_3 &t, const typename K::Segment_3 &s, const K & k) { - typedef typename cpp11::result_of< - typename K::Intersect_3(typename K::Segment_3, typename K::Triangle_3) - >::type result_type; + typedef decltype( + std::declval()( + std::declval(), + std::declval())) result_type; CGAL_MESH_3_BRANCH_PROFILER(std::string("coplanar/calls in : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); @@ -399,8 +399,7 @@ ts_intersection(const typename K::Triangle_3 &t, template -typename cpp11::result_of< - typename K::Intersect_3(typename K::Ray_3, typename K::Triangle_3)>::type +decltype(auto) tr_intersection(const typename K::Triangle_3 &t, const typename K::Ray_3 &r, const K& k) @@ -410,9 +409,10 @@ tr_intersection(const typename K::Triangle_3 &t, CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ; CGAL_kernel_precondition( ! k.is_degenerate_3_object()(r) ) ; - typedef typename cpp11::result_of< - typename K::Intersect_3(typename K::Ray_3, typename K::Triangle_3) - >::type result_type; + typedef decltype( + std::declval()( + std::declval(), + std::declval())) result_type; typedef typename K::Point_3 Point_3; @@ -471,20 +471,12 @@ public: typedef typename K_::Segment_3 Segment_3; typedef typename K_::Ray_3 Ray_3; - template - struct result; - - template - struct result { - typedef typename cpp11::result_of::type type; - }; - typedef Exact_predicates_exact_constructions_kernel EK; typedef Cartesian_converter To_exact; typedef Cartesian_converter Back_from_exact; template - typename cpp11::result_of::type + decltype(auto) operator() (const T1& t, const T2& s) const { // Switch to exact @@ -493,28 +485,31 @@ public: EK::Intersect_3 exact_intersection = EK().intersect_3_object(); // Cartesian converters have an undocumented, optional< variant > operator - return typename cpp11::result_of::type - (back_from_exact(exact_intersection(to_exact(t), to_exact(s)))); + typedef decltype( + std::declval()( + std::declval(), std::declval())) result_type; + + return result_type(back_from_exact(exact_intersection(to_exact(t), to_exact(s)))); } - typename cpp11::result_of::type + decltype(auto) operator()(const Segment_3& s, const Triangle_3& t) const { return ts_intersection(t, s, K_()); } - typename cpp11::result_of::type + decltype(auto) operator()(const Triangle_3& t, const Segment_3& s) const { return ts_intersection(t, s, K_()); } - typename cpp11::result_of::type + decltype(auto) operator()(const Ray_3& r, const Triangle_3& t) const { return tr_intersection(t, r, K_()); } - typename cpp11::result_of::type + decltype(auto) operator()(const Triangle_3& t, const Ray_3& r) const { return tr_intersection(t, r, K_()); @@ -531,20 +526,12 @@ public: typedef typename K_::Triangle_3 Triangle_3; typedef typename K_::Segment_3 Segment_3; - template - struct result; - - template - struct result { - typedef typename cpp11::result_of::type type; - }; - typedef Exact_predicates_exact_constructions_kernel EK; typedef Cartesian_converter To_exact; typedef Cartesian_converter Back_from_exact; template - typename cpp11::result_of::type + decltype(auto) operator() (const T1& t, const T2& s) const { // Switch to exact @@ -553,8 +540,11 @@ public: EK::Intersect_3 exact_intersection = EK().intersect_3_object(); // Cartesian converters have an undocumented, optional< variant > operator - return typename cpp11::result_of::type - (back_from_exact(exact_intersection(to_exact(t), to_exact(s)))); + typedef decltype( + std::declval()( + std::declval(), std::declval())) result_type; + + return result_type(back_from_exact(exact_intersection(to_exact(t), to_exact(s)))); } }; diff --git a/Mesh_3/include/CGAL/Mesh_3/experimental/Sizing_field_with_aabb_tree.h b/Mesh_3/include/CGAL/Mesh_3/experimental/Sizing_field_with_aabb_tree.h index c27f99353ec..bda94612b75 100644 --- a/Mesh_3/include/CGAL/Mesh_3/experimental/Sizing_field_with_aabb_tree.h +++ b/Mesh_3/include/CGAL/Mesh_3/experimental/Sizing_field_with_aabb_tree.h @@ -384,8 +384,6 @@ struct Sizing_field_with_aabb_tree //Compute distance to the curve on which p lies typedef typename GeomTraits::Segment_3 Segment_3; typedef typename GeomTraits::Plane_3 Plane_3; - typedef typename CGAL::cpp11::result_of< - typename GeomTraits::Intersect_3(Segment_3, Plane_3)>::type Intersection_result; const typename Input_curves_AABB_tree_::Point_and_primitive_id& ppid = domain.curves_aabb_tree().closest_point_and_primitive(p); @@ -416,8 +414,7 @@ struct Sizing_field_with_aabb_tree if (curve_id != prim.id().first->first) continue;//don't deal with the same curves as what is done above - Intersection_result int_res - = CGAL::intersection(prim.datum(), curr_ortho_plane); + const auto int_res = CGAL::intersection(prim.datum(), curr_ortho_plane); if (int_res) { if (const Point_3* pp = boost::get(&*int_res)) diff --git a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h index 7b9fbd23f95..ce7d0088fe3 100644 --- a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h +++ b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h @@ -439,9 +439,7 @@ public: if(r_domain_.query_is_cached(q)) { const AABB_primitive_id primitive_id = r_domain_.cached_primitive_id(); - typename cpp11::result_of< - typename IGT::Intersect_3(typename Primitive::Datum, Query)>::type o - = IGT().intersect_3_object()(Primitive(primitive_id).datum(),q); + const auto o = IGT().intersect_3_object()(Primitive(primitive_id).datum(),q); intersection = o ? Intersection_and_primitive_id(*o, primitive_id) : AABB_intersection(); diff --git a/Optimal_transportation_reconstruction_2/include/CGAL/OTR_2/Reconstruction_triangulation_2.h b/Optimal_transportation_reconstruction_2/include/CGAL/OTR_2/Reconstruction_triangulation_2.h index 33c956e19cb..f952c9232e8 100644 --- a/Optimal_transportation_reconstruction_2/include/CGAL/OTR_2/Reconstruction_triangulation_2.h +++ b/Optimal_transportation_reconstruction_2/include/CGAL/OTR_2/Reconstruction_triangulation_2.h @@ -787,8 +787,7 @@ public: pt, geom_traits().construct_vector_2_object()(pt, ps)); boost::optional Dqt; - typename CGAL::cpp11::result_of::type - result = intersection(lab, lts); + const auto result = intersection(lab, lts); if (result) { const Point* iq = boost::get(&(*result)); diff --git a/Point_set_processing_3/include/CGAL/structure_point_set.h b/Point_set_processing_3/include/CGAL/structure_point_set.h index c9f882617df..7aa3fc27957 100644 --- a/Point_set_processing_3/include/CGAL/structure_point_set.h +++ b/Point_set_processing_3/include/CGAL/structure_point_set.h @@ -780,9 +780,7 @@ private: double angle_A = std::acos (CGAL::abs (plane1.orthogonal_vector() * plane2.orthogonal_vector())); double angle_B = CGAL_PI - angle_A; - typename cpp11::result_of::type - result = CGAL::intersection(plane1, plane2); - + const auto result = CGAL::intersection(plane1, plane2); if (!result) { #ifdef CGAL_PSP3_VERBOSE @@ -1009,8 +1007,7 @@ private: pts2.push_back (m_points[inde]); } - typename cpp11::result_of::type - result = CGAL::intersection (plane1, ortho); + auto result = CGAL::intersection (plane1, ortho); if (result) { if (const Line* l = boost::get(&*result)) @@ -1174,16 +1171,12 @@ private: const Plane& plane2 = m_planes[m_corners[i].planes[1]]; const Plane& plane3 = m_planes[m_corners[i].planes[2]]; - typename cpp11::result_of::type - result = CGAL::intersection(plane1, plane2); - + const auto result = CGAL::intersection(plane1, plane2); if (result) { if (const Line* l = boost::get(&*result)) { - typename cpp11::result_of::type - result2 = CGAL::intersection(*l, plane3); - + const auto result2 = CGAL::intersection(*l, plane3); if (result2) { if (const Point* p = boost::get(&*result2)) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_nodes.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_nodes.h index 9d43f9cc043..22fda45ad20 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_nodes.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_nodes.h @@ -246,9 +246,7 @@ public: p3(to_exact( get(vpm, source(h3,tm)) ), to_exact( get(vpm, target(h3,tm)) ), to_exact( get(vpm, target(next(h3,tm),tm)))); - typename cpp11::result_of< - Exact_kernel::Intersect_3(Plane_3, Plane_3, Plane_3) - >::type inter_res = exact_intersection(p1, p2, p3); + const auto inter_res = exact_intersection(p1, p2, p3); CGAL_assertion(inter_res != boost::none); const Exact_kernel::Point_3* pt = @@ -363,9 +361,7 @@ public: p3(get(vpm, source(h3,tm)), get(vpm, target(h3,tm)), get(vpm, target(next(h3,tm),tm))); - typename cpp11::result_of< - typename Exact_kernel::Intersect_3(Plane_3, Plane_3, Plane_3) - >::type inter_res = intersection(p1, p2, p3); + const auto inter_res = intersection(p1, p2, p3); CGAL_assertion(inter_res != boost::none); const Point_3* pt = diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/predicates.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/predicates.h index a296e8de90a..5ac3ff63be9 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/predicates.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/predicates.h @@ -84,11 +84,8 @@ bool sorted_around_edge( typename Kernel::Orientation_3 orientation; typedef typename Kernel::Point_3 Point_3; - typedef typename cpp11::result_of< - typename Kernel::Orientation_3(Point_3, Point_3, Point_3, Point_3)>::type - Orientation; - Orientation s0 = orientation(o_prime, o, p1, p2); + const auto s0 = orientation(o_prime, o, p1, p2); if ( s0==COPLANAR ) { //o, o_prime, p1 and p2 are coplanar @@ -98,8 +95,8 @@ bool sorted_around_edge( } //o, o_prime, p1 and p2 are not coplanar - Orientation s1 = orientation(o_prime, o, p1, q); - Orientation s2 = orientation(o_prime, o, q , p2); + const auto s1 = orientation(o_prime, o, p1, q); + const auto s2 = orientation(o_prime, o, q , p2); if (s0 == POSITIVE) // the angle p1,o,p2 is smaller that Pi. return ( s1 == POSITIVE ) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_slicer.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_slicer.h index 499ed2506a4..9c80a2e630a 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_slicer.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_slicer.h @@ -276,8 +276,7 @@ class Polygon_mesh_slicer get(m_vpmap, source(ed, m_tmesh)), get(m_vpmap,target(ed, m_tmesh)) ); - typename cpp11::result_of::type - inter = intersect_3(m_plane, s); + const auto inter = intersect_3(m_plane, s); CGAL_assertion(inter != boost::none); const Point_3* pt_ptr = boost::get(&(*inter)); current_poly.push_back( *pt_ptr ); diff --git a/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/Concepts/SurfaceMeshShortestPathTraits.h b/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/Concepts/SurfaceMeshShortestPathTraits.h index 811ad3de64c..ff38140189c 100644 --- a/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/Concepts/SurfaceMeshShortestPathTraits.h +++ b/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/Concepts/SurfaceMeshShortestPathTraits.h @@ -152,7 +152,7 @@ public: /*! Function object type. Must provide - `CGAL::cpp11::result_of::%type operator()(A obj1, B obj2)` + `boost::optional< boost::variant< T... > > operator()(A obj1, B obj2)` to compute the intersection between `obj1` and `obj2`, where `A` and `B` can be any type amongst `Line_2`, `Ray_2`, `Segment_2`. */ diff --git a/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path.h b/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path.h index 6d24ecfcab3..bcb3c685778 100644 --- a/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path.h +++ b/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path.h @@ -977,8 +977,6 @@ private: typename Traits::Construct_point_on_2 cpo2(m_traits.construct_point_on_2_object()); typename Traits::Compute_parametric_distance_along_segment_2 pdas2(m_traits.compute_parametric_distance_along_segment_2_object()); - typedef typename cpp11::result_of::type LineLineIntersectResult; - Point_2 leftPoint; Point_2 rightPoint; @@ -1003,7 +1001,7 @@ private: } else { - LineLineIntersectResult cgalIntersection = i2(cl2(segment), cl2(leftBoundary)); + const auto cgalIntersection = i2(cl2(segment), cl2(leftBoundary)); if (!cgalIntersection || !boost::get(&*cgalIntersection)) { @@ -1015,7 +1013,7 @@ private: } else { - Point_2* result = boost::get(&*cgalIntersection); + const Point_2* result = boost::get(&*cgalIntersection); FT t0 = pdas2(cs2(segment), ct2(segment), *result); if (t0 >= FT(1)) @@ -1061,7 +1059,7 @@ private: } else { - LineLineIntersectResult cgalIntersection = i2(cl2(segment), cl2(rightBoundary)); + const auto cgalIntersection = i2(cl2(segment), cl2(rightBoundary)); if (!cgalIntersection || !boost::get(&*cgalIntersection)) { @@ -1073,7 +1071,7 @@ private: } else { - Point_2* result = boost::get(&*cgalIntersection); + const Point_2* result = boost::get(&*cgalIntersection); FT t0 = pdas2(cs2(segment), ct2(segment), *result); if (t0 <= FT(0)) @@ -1695,8 +1693,6 @@ private: typename Traits::Construct_target_2 construct_target_2(m_traits.construct_target_2_object()); typename Traits::Intersect_2 intersect_2(m_traits.intersect_2_object()); - typedef typename cpp11::result_of::type LineLineIntersectResult; - Cone_tree_node* current = startNode; Point_2 currentLocation(startLocation); @@ -1711,7 +1707,7 @@ private: const Point_2& currentSourceImage = current->source_image(); Ray_2 rayToLocation(construct_ray_2(currentSourceImage, currentLocation)); - LineLineIntersectResult cgalIntersection = intersect_2(construct_line_2(entrySegment), construct_line_2(rayToLocation)); + const auto cgalIntersection = intersect_2(construct_line_2(entrySegment), construct_line_2(rayToLocation)); CGAL_assertion(bool(cgalIntersection)); diff --git a/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/function_objects.h b/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/function_objects.h index b637938b366..6dd44eec600 100644 --- a/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/function_objects.h +++ b/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/function_objects.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -459,12 +458,10 @@ public: result_type operator () (const Segment_2& s1, const Line_2& l1, const Segment_2& s2, const Line_2& l2) const { - typedef typename CGAL::cpp11::result_of::type LineLineIntersectResult; - Line_2 s1Line(m_construct_line_2(s1)); Line_2 s2Line(m_construct_line_2(s2)); - LineLineIntersectResult intersectResult1(m_intersect_2(s1Line, l1)); + const auto intersectResult1 = m_intersect_2(s1Line, l1); CGAL_assertion(bool(intersectResult1)); if (!intersectResult1) return CGAL::SMALLER; @@ -476,7 +473,7 @@ public: CGAL_assertion_code(FT t1 = m_parametric_distance_along_segment_2(s1, *p1_ptr);) CGAL_assertion(t1 >= FT(-1)/FT(100000) && t1 <= FT(1)+FT(1)/FT(100000)); - LineLineIntersectResult intersectResult2 = m_intersect_2(s2Line, l2); + const auto intersectResult2 = m_intersect_2(s2Line, l2); CGAL_assertion(bool(intersectResult2)); if (!intersectResult2) return CGAL::SMALLER; From 005f237f5515b81dbc6eba460cab3decd7c46692 Mon Sep 17 00:00:00 2001 From: oboes Date: Tue, 29 Sep 2020 16:31:56 +0200 Subject: [PATCH 016/130] Add mollification step to avoid degenerate faces Degenerate faces (which can cause an infinite loop in `loop_over_edges`) are handled by using the mollification step described in section 4.5 of N. Sharp & K. Crane "A Laplacian for Nonmanifold Triangle Meshes" (2020). The tolerance value is set to 1/1000 of the minimum non-zero edge length. --- .../Intrinsic_Delaunay_triangulation_3.h | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h b/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h index bbea606cf8b..9187345144a 100644 --- a/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h +++ b/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h @@ -285,6 +285,29 @@ private: return CGAL::sqrt(S*(S-a)*(S-b)*(S-c)); } + // Mollification strategy to avoid degeneracies + void + mollify(double delta) + { + // compute smallest length epsilon we can add to + // all edges to ensure that the strict triangle + // inequality holds with a tolerance of delta + double epsilon = 0; + for(halfedge_descriptor hd : halfedges(m_intrinsic_tm)) { + halfedge_descriptor hd2 = next(hd, m_intrinsic_tm); + halfedge_descriptor hd3 = next(hd2,m_intrinsic_tm); + Index i = get(edge_id_map, edge(hd,m_intrinsic_tm)); + Index j = get(edge_id_map, edge(hd2,m_intrinsic_tm)); + Index k = get(edge_id_map, edge(hd3,m_intrinsic_tm)); + double ineq = edge_lengths[j] + edge_lengths[k] - edge_lengths[i]; + epsilon = std::max(epsilon, std::max(0., delta-ineq)); + } + // update edge lengths + for(edge_descriptor ed : edges(m_intrinsic_tm)) { + Index i = get(edge_id_map, ed); + edge_lengths[i] += epsilon; + } + } void loop_over_edges(edge_stack stack, std::vector& marked_edges) @@ -365,13 +388,16 @@ private: Index edge_i = 0; VertexPointMap vpm_intrinsic_tm = get(boost::vertex_point,m_intrinsic_tm); + double min_length = (std::numeric_limits::max)(); for(edge_descriptor ed : edges(m_intrinsic_tm)) { edge_lengths[edge_i] = CGAL::sqrt(to_double(squared_distance(get(vpm_intrinsic_tm, source(ed,m_intrinsic_tm)), get(vpm_intrinsic_tm, target(ed,m_intrinsic_tm))))); // Polygon_mesh_processing::edge_length(halfedge(ed,m_intrinsic_tm),m_intrinsic_tm); + if (edge_lengths[edge_i] != 0 && edge_lengths[edge_i] < min_length) min_length = edge_lengths[edge_i]; put(edge_id_map, ed, edge_i++); stack.push(ed); } + mollify(min_length*1e-4); loop_over_edges(stack, mark_edges); //now that edges are calculated, go through and for each face, calculate the vertex positions around it From 6aa3d6d5833e964e64849d5f3886a3cf427e0725 Mon Sep 17 00:00:00 2001 From: Olivier Boes Date: Mon, 5 Oct 2020 16:54:11 +0200 Subject: [PATCH 017/130] Update Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h Co-authored-by: Sebastien Loriot --- .../Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h b/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h index 9187345144a..d9ec5147f53 100644 --- a/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h +++ b/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h @@ -300,7 +300,7 @@ private: Index j = get(edge_id_map, edge(hd2,m_intrinsic_tm)); Index k = get(edge_id_map, edge(hd3,m_intrinsic_tm)); double ineq = edge_lengths[j] + edge_lengths[k] - edge_lengths[i]; - epsilon = std::max(epsilon, std::max(0., delta-ineq)); + epsilon = (std::max)(epsilon, (std::max)(0., delta-ineq)); } // update edge lengths for(edge_descriptor ed : edges(m_intrinsic_tm)) { From a8a1b2de3e60a884e6445fa8e5f33d0822d4a430 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 13 Nov 2020 16:33:46 +0100 Subject: [PATCH 018/130] degenerate faces are allowed with Intrinsic_Delaunay Mode thanks to mollification step --- .../Heat_method_3/Surface_mesh_geodesic_distances_3.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h b/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h index d1499bbca35..f193d28ab07 100644 --- a/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h +++ b/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h @@ -769,11 +769,11 @@ struct Base_helper * time after changes to the set of sources. * * \tparam TriangleMesh a triangulated surface mesh, model of `FaceListGraph` and `HalfedgeListGraph` - * with no degenerate faces * \tparam Mode must be `Intrinsic_Delaunay` to indicate that an intrinsic Delaunay triangulation is internally constructed * or `Direct` to indicate that the input mesh should be used as is. * If `Intrinsic_Delaunay`, then the type `TriangleMesh` must have an internal property for `vertex_point` * and its value type must be the same as the value type of `VertexPointMap`. + * If `Direct`, then the input mesh should not have any degenerate faces. * \tparam VertexPointMap a model of `ReadablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` as key and * `Traits::Point_3` as value type. @@ -940,7 +940,7 @@ public: * \tparam VertexDistanceMap a property map model of `WritablePropertyMap` * with `vertex_descriptor` as key type and `double` as value type. * \param vdm the vertex distance map to be filled - * \pre the support triangle mesh does not have any degenerate faces + * \pre If `Mode` is `Direct`, the support triangle mesh does not have any degenerate faces * \warning The key type is `double` even when used with an exact kernel. **/ template @@ -961,7 +961,7 @@ public: /// \tparam Mode either the tag `Direct` or `Intrinsic_Delaunay`, which determines if the geodesic distance /// is computed directly on the mesh or if the intrinsic Delaunay triangulation is applied first. /// The default is `Intrinsic_Delaunay`. -/// \pre `tm` does not have any degenerate faces +/// \pre If `Mode` is `Direct`, `tm` does not have any degenerate faces /// \warning The return type is `double` even when used with an exact kernel. /// /// \sa `CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3` @@ -1003,7 +1003,7 @@ estimate_geodesic_distances(const TriangleMesh& tm, /// \tparam Mode either the tag `Direct` or `Intrinsic_Delaunay`, which determines if the geodesic distance /// is computed directly on the mesh or if the intrinsic Delaunay triangulation is applied first. /// The default is `Intrinsic_Delaunay`. -/// \pre `tm` does not have any degenerate faces +/// \pre If `Mode` is `Direct`, `tm` mesh does not have any degenerate faces /// \warning The return type is `double` even when used with an exact kernel. /// \sa `CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3` template From 14cc8714baf6c6261019a19edbafdc0b505a2d67 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 20 Nov 2020 15:33:25 +0100 Subject: [PATCH 019/130] with mollification degenerate faces are allowed with Mode=Intrinsic_Delaunay --- .../Heat_method_3/Surface_mesh_geodesic_distances_3.h | 9 +++------ .../internal/Intrinsic_Delaunay_triangulation_3.h | 7 +++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h b/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h index f193d28ab07..96f7846baa6 100644 --- a/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h +++ b/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h @@ -485,9 +485,6 @@ public: template void estimate_geodesic_distances(VertexDistanceMap vdm) { - CGAL_precondition( - !CGAL::Heat_method_3::internal::has_degenerate_faces(triangle_mesh(), Traits())); - if(is_empty(tm)){ return; } @@ -666,6 +663,9 @@ struct Base_helper template void estimate_geodesic_distances(VertexDistanceMap vdm) { + CGAL_assertion( + !CGAL::Heat_method_3::internal::has_degenerate_faces( + base().triangle_mesh(), Traits())); base().estimate_geodesic_distances(vdm); } }; @@ -751,9 +751,6 @@ struct Base_helper template void estimate_geodesic_distances(VertexDistanceMap vdm) { - CGAL_precondition( - !CGAL::Heat_method_3::internal::has_degenerate_faces( - this->m_idt.triangle_mesh(), Traits())); base().estimate_geodesic_distances(this->m_idt.vertex_distance_map(vdm)); } }; diff --git a/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h b/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h index d9ec5147f53..b5aff168bb7 100644 --- a/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h +++ b/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h @@ -287,7 +287,7 @@ private: // Mollification strategy to avoid degeneracies void - mollify(double delta) + mollify(const double delta) { // compute smallest length epsilon we can add to // all edges to ensure that the strict triangle @@ -397,7 +397,10 @@ private: put(edge_id_map, ed, edge_i++); stack.push(ed); } - mollify(min_length*1e-4); + + if(internal::has_degenerate_faces(m_intrinsic_tm, Traits())) + mollify(min_length*1e-4); + loop_over_edges(stack, mark_edges); //now that edges are calculated, go through and for each face, calculate the vertex positions around it From bc18b7d331d18554ba98b5865b5fe524e4b4ee5a Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 20 Nov 2020 15:35:28 +0100 Subject: [PATCH 020/130] add a test for Intrinsic_Delaunay Mode with an input with degenerate faces --- .../test/Heat_method_3/CMakeLists.txt | 3 + .../data/rectangle_with_degenerate_faces.off | 762 ++++++++++++++++++ ...eat_method_surface_mesh_intrinsic_test.cpp | 115 +++ 3 files changed, 880 insertions(+) create mode 100644 Heat_method_3/test/Heat_method_3/data/rectangle_with_degenerate_faces.off create mode 100644 Heat_method_3/test/Heat_method_3/heat_method_surface_mesh_intrinsic_test.cpp diff --git a/Heat_method_3/test/Heat_method_3/CMakeLists.txt b/Heat_method_3/test/Heat_method_3/CMakeLists.txt index 962f84378b1..aa9a6963ac5 100644 --- a/Heat_method_3/test/Heat_method_3/CMakeLists.txt +++ b/Heat_method_3/test/Heat_method_3/CMakeLists.txt @@ -48,3 +48,6 @@ target_link_libraries(heat_method_surface_mesh_test PUBLIC CGAL::Eigen_support) create_single_source_cgal_program("heat_method_surface_mesh_direct_test.cpp") target_link_libraries(heat_method_surface_mesh_direct_test PUBLIC CGAL::Eigen_support) +create_single_source_cgal_program("heat_method_surface_mesh_intrinsic_test.cpp") +target_link_libraries(heat_method_surface_mesh_intrinsic_test + PUBLIC CGAL::Eigen_support) diff --git a/Heat_method_3/test/Heat_method_3/data/rectangle_with_degenerate_faces.off b/Heat_method_3/test/Heat_method_3/data/rectangle_with_degenerate_faces.off new file mode 100644 index 00000000000..40ce808fa7b --- /dev/null +++ b/Heat_method_3/test/Heat_method_3/data/rectangle_with_degenerate_faces.off @@ -0,0 +1,762 @@ +OFF +270 490 0 +0 0 0 +1 1 0 +2 1 0 +0 1 0 +1 0 0 +2 0 0 +1 0.5 0 +0.53125 0.47916666666666669 0 +1.5 0.5 0 +0.48958333333333331 0.22916666666666666 0 +0.5 1 0 +0 0.5 0 +1.5 0 0 +2 0.5 0 +1.5 1 0 +1 0.5 0 +0.5 0 0 +0.75 0.75 0 +0.28749999999999998 0.25 0 +0.25 0.75 0 +1.75 0.75 0 +1.25 0.25 0 +1.75 0.25 0 +1.25 0.75 0 +0.23958333333333334 0.10416666666666667 0 +0.75 0.375 0 +0.75 0.125 0 +1 0.75 0 +1 0.25 0 +0.75 0.48214285714285715 0 +0.75 1 0 +0.25 1 0 +0.5 0.75 0 +0 0.75 0 +0 0.25 0 +0.25 0.5 0 +1.25 0 0 +1.75 0 0 +1.5 0.25 0 +2 0.25 0 +2 0.75 0 +1.75 0.5 0 +1.75 1 0 +1.25 1 0 +1.5 0.75 0 +1 0.75 0 +1 0.25 0 +1.25 0.5 0 +0.25 0 0 +0.75 0 0 +0.875 0.1875 0 +0.85416666666666663 0.85416666666666663 0 +0.625 0.6428571428571429 0 +0.85416666666666663 0.64583333333333337 0 +0.625 0.8571428571428571 0 +0.35714285714285715 0.375 0 +0.125 0.15625 0 +0.14285714285714285 0.375 0 +0.375 0.625 0 +0.14583333333333334 0.85416666666666663 0 +0.14285714285714285 0.625 0 +0.375 0.8571428571428571 0 +1.8541666666666667 0.85416666666666663 0 +1.625 0.625 0 +1.8571428571428572 0.625 0 +1.625 0.8571428571428571 0 +1.375 0.375 0 +1.1458333333333333 0.14583333333333334 0 +1.375 0.14285714285714285 0 +1.1428571428571428 0.375 0 +1.625 0.375 0 +1.8541666666666667 0.14583333333333334 0 +1.8571428571428572 0.375 0 +1.625 0.14285714285714285 0 +1.375 0.625 0 +1.1458333333333333 0.85416666666666663 0 +1.1428571428571428 0.625 0 +1.375 0.8571428571428571 0 +0.125 0.0625 0 +0.3482142857142857 0.17857142857142858 0 +0.375 0.072916666666666671 0 +0.5982142857142857 0.3125 0 +0.875 0.42708333333333331 0 +0.625 0.42708333333333331 0 +0.625 0.1875 0 +0.875 0.072916666666666671 0 +0.625 0.072916666666666671 0 +0.875 0.3125 0 +0.52500000000000002 0.40000000000000002 0 +0.5 0.125 0 +0.375 0.28125 0 +0.75 0.25 0 +1 0.625 0 +1 0.875 0 +0.875 0.75 0 +1 0.125 0 +1 0.375 0 +0.625 0.51249999999999996 0 +0.875 0.51249999999999996 0 +0.75 0.625 0 +0.875 1 0 +0.625 1 0 +0.75 0.875 0 +0.375 1 0 +0.125 1 0 +0.25 0.875 0 +0.5 0.875 0 +0.5 0.625 0 +0.625 0.75 0 +0.375 0.75 0 +0 0.875 0 +0 0.625 0 +0.125 0.75 0 +0 0.375 0 +0 0.125 0 +0.125 0.25 0 +0.125 0.5 0 +0.375 0.5 0 +0.25 0.625 0 +0.25 0.375 0 +1.125 0 0 +1.375 0 0 +1.25 0.125 0 +1.625 0 0 +1.875 0 0 +1.75 0.125 0 +1.5 0.125 0 +1.5 0.375 0 +1.375 0.25 0 +1.625 0.25 0 +2 0.125 0 +2 0.375 0 +1.875 0.25 0 +2 0.625 0 +2 0.875 0 +1.875 0.75 0 +1.875 0.5 0 +1.625 0.5 0 +1.75 0.375 0 +1.75 0.625 0 +1.875 1 0 +1.625 1 0 +1.75 0.875 0 +1.375 1 0 +1.125 1 0 +1.25 0.875 0 +1.5 0.875 0 +1.5 0.625 0 +1.625 0.75 0 +1.375 0.75 0 +1 0.875 0 +1 0.625 0 +1.125 0.75 0 +1 0.375 0 +1 0.125 0 +1.125 0.25 0 +1.125 0.5 0 +1.375 0.5 0 +1.25 0.625 0 +1.25 0.375 0 +0.125 0 0 +0.375 0 0 +0.625 0 0 +0.875 0 0 +1.4583333333333333 0.79166666666666663 0 +1.3125 0.9375 0 +1.4375 0.9375 0 +1.2916666666666667 0.79166666666666663 0 +1.0625 0.6875 0 +1.2083333333333333 0.54166666666666663 0 +1.0625 0.5625 0 +0.91666666666666663 0.91666666666666663 0 +0.79166666666666663 0.79166666666666663 0 +0.9375 0.8125 0 +0.8125 0.9375 0 +0.70833333333333337 0.70833333333333337 0 +0.5625 0.5625 0 +0.6875 0.5625 0 +0.54166666666666663 0.70833333333333337 0 +0.79166666666666663 0.70833333333333337 0 +0.91666666666666663 0.58333333333333337 0 +0.9375 0.6875 0 +0.8125 0.5625 0 +0.70833333333333337 0.79166666666666663 0 +0.5625 0.9375 0 +0.54166666666666663 0.79166666666666663 0 +0.6875 0.9375 0 +0.4375 0.4375 0 +0.28749999999999998 0.3125 0 +0.46875 0.33333333333333331 0 +0.29166666666666669 0.45833333333333331 0 +0.21875 0.20833333333333334 0 +1.2083333333333333 0.70833333333333337 0 +0.0625 0.21249999999999999 0 +0.20833333333333334 0.29166666666666669 0 +0.0625 0.4375 0 +0.0625 0.3125 0 +0.20833333333333334 0.45833333333333331 0 +0.45833333333333331 0.54166666666666663 0 +0.29166666666666669 0.70833333333333337 0 +0.29166666666666669 0.54166666666666663 0 +0.45833333333333331 0.70833333333333337 0 +0.20833333333333334 0.79166666666666663 0 +0.083333333333333329 0.91666666666666663 0 +0.0625 0.8125 0 +0.1875 0.9375 0 +0.20833333333333334 0.70833333333333337 0 +0.0625 0.5625 0 +0.20833333333333334 0.54166666666666663 0 +0.0625 0.6875 0 +0.29166666666666669 0.79166666666666663 0 +0.4375 0.9375 0 +0.3125 0.9375 0 +0.45833333333333331 0.79166666666666663 0 +1.9166666666666667 0.91666666666666663 0 +1.7916666666666667 0.79166666666666663 0 +1.9375 0.8125 0 +1.8125 0.9375 0 +1.7083333333333333 0.70833333333333337 0 +1.5416666666666667 0.54166666666666663 0 +1.7083333333333333 0.54166666666666663 0 +1.5416666666666667 0.70833333333333337 0 +1.7916666666666667 0.70833333333333337 0 +1.9375 0.5625 0 +1.9375 0.6875 0 +1.7916666666666667 0.54166666666666663 0 +1.7083333333333333 0.79166666666666663 0 +1.5625 0.9375 0 +1.5416666666666667 0.79166666666666663 0 +1.6875 0.9375 0 +1.4583333333333333 0.45833333333333331 0 +1.2916666666666667 0.29166666666666669 0 +1.4583333333333333 0.29166666666666669 0 +1.2916666666666667 0.45833333333333331 0 +1.2083333333333333 0.20833333333333334 0 +1.0833333333333333 0.083333333333333329 0 +1.1875 0.0625 0 +1.0625 0.1875 0 +1.2916666666666667 0.20833333333333334 0 +1.4375 0.0625 0 +1.4583333333333333 0.20833333333333334 0 +1.3125 0.0625 0 +1.2083333333333333 0.29166666666666669 0 +1.0625 0.4375 0 +1.0625 0.3125 0 +1.2083333333333333 0.45833333333333331 0 +1.5416666666666667 0.45833333333333331 0 +1.7083333333333333 0.29166666666666669 0 +1.7083333333333333 0.45833333333333331 0 +1.5416666666666667 0.29166666666666669 0 +1.7916666666666667 0.20833333333333334 0 +1.9166666666666667 0.083333333333333329 0 +1.9375 0.1875 0 +1.8125 0.0625 0 +1.7916666666666667 0.29166666666666669 0 +1.9375 0.4375 0 +1.7916666666666667 0.45833333333333331 0 +1.9375 0.3125 0 +1.7083333333333333 0.20833333333333334 0 +1.5625 0.0625 0 +1.6875 0.0625 0 +1.5416666666666667 0.20833333333333334 0 +1.4583333333333333 0.54166666666666663 0 +1.2916666666666667 0.70833333333333337 0 +1.2916666666666667 0.54166666666666663 0 +1.4583333333333333 0.70833333333333337 0 +1.2083333333333333 0.79166666666666663 0 +1.0833333333333333 0.91666666666666663 0 +1.0625 0.8125 0 +1.1875 0.9375 0 +3 94 172 179 +3 118 199 206 +3 138 247 254 +3 158 263 192 +3 91 26 50 +3 15 6 96 +3 90 9 189 +3 108 175 183 +3 128 231 238 +3 148 218 226 +3 167 263 149 +3 228 65 146 +3 105 202 210 +3 115 191 194 +3 125 250 258 +3 135 215 222 +3 145 266 167 +3 155 234 242 +3 27 15 151 +3 95 28 50 +3 99 53 179 +3 179 53 94 +3 90 55 188 +3 188 18 90 +3 112 60 206 +3 206 60 118 +3 139 64 222 +3 222 64 135 +3 122 68 238 +3 238 68 128 +3 132 72 254 +3 254 72 138 +3 152 76 192 +3 192 76 158 +3 48 161 80 +3 24 79 191 +3 88 187 189 +3 166 14 143 +3 91 81 84 +3 165 166 143 +3 94 53 181 +3 15 27 92 +3 149 265 164 +3 46 28 95 +3 181 173 94 +3 99 52 177 +3 211 61 106 +3 209 60 112 +3 182 53 99 +3 212 205 105 +3 207 195 116 +3 114 0 78 +3 117 187 198 +3 196 193 115 +3 259 73 126 +3 257 72 132 +3 127 70 246 +3 260 253 125 +3 255 223 136 +3 135 64 224 +3 137 219 246 +3 224 216 135 +3 166 77 146 +3 168 76 152 +3 246 70 137 +3 165 269 145 +3 170 243 156 +3 93 45 150 +3 241 68 122 +3 28 46 153 +3 157 230 262 +3 244 237 155 +3 80 24 48 +3 85 26 49 +3 227 14 166 +3 85 4 95 +3 173 171 51 +3 93 1 171 +3 107 58 198 +3 52 176 177 +3 99 177 182 +3 53 180 181 +3 185 178 108 +3 106 61 213 +3 189 187 55 +3 88 7 187 +3 263 74 149 +3 115 57 196 +3 116 60 207 +3 57 195 196 +3 200 190 117 +3 118 60 208 +3 105 61 212 +3 59 203 204 +3 208 200 118 +3 116 197 208 +3 106 184 211 +3 61 211 212 +3 216 214 62 +3 134 2 214 +3 225 64 139 +3 137 70 248 +3 136 72 255 +3 64 223 224 +3 228 221 148 +3 146 77 164 +3 249 70 127 +3 128 68 240 +3 155 69 244 +3 67 235 236 +3 240 232 128 +3 126 73 261 +3 156 76 170 +3 69 243 244 +3 248 220 137 +3 138 72 256 +3 125 73 260 +3 71 251 252 +3 256 248 138 +3 136 225 256 +3 126 239 259 +3 73 259 260 +3 264 233 157 +3 158 76 169 +3 145 77 165 +3 75 267 268 +3 169 264 158 +3 156 245 169 +3 146 227 166 +3 77 166 165 +3 89 9 79 +3 78 0 160 +3 91 25 81 +3 191 56 24 +3 80 161 16 +3 78 160 48 +3 98 180 182 +3 189 9 81 +3 87 28 96 +3 91 50 87 +3 97 29 177 +3 96 6 82 +3 86 162 49 +3 80 16 89 +3 95 50 85 +3 84 9 89 +3 86 84 89 +3 87 25 91 +3 164 228 146 +3 87 50 28 +3 88 81 83 +3 89 16 86 +3 83 7 88 +3 89 79 80 +3 90 18 79 +3 18 188 194 +3 97 7 83 +3 49 163 85 +3 173 51 94 +3 92 6 15 +3 173 27 93 +3 93 27 45 +3 17 175 179 +3 93 171 173 +3 96 82 87 +3 95 4 154 +3 92 27 181 +3 153 15 96 +3 83 25 29 +3 7 176 198 +3 98 29 82 +3 29 25 82 +3 17 172 183 +3 82 6 98 +3 102 51 174 +3 106 54 184 +3 94 51 172 +3 101 184 186 +3 205 59 105 +3 205 31 104 +3 206 199 19 +3 104 203 205 +3 178 52 108 +3 103 31 212 +3 83 29 97 +3 109 58 201 +3 179 172 17 +3 107 52 178 +3 118 58 199 +3 32 185 213 +3 112 59 204 +3 195 57 116 +3 19 199 210 +3 111 207 209 +3 193 56 115 +3 78 56 114 +3 191 79 18 +3 114 56 193 +3 190 35 197 +3 113 34 196 +3 189 81 88 +3 119 55 190 +3 19 202 206 +3 190 55 117 +3 79 9 90 +3 200 58 118 +3 122 67 236 +3 126 68 239 +3 21 231 242 +3 121 239 241 +3 253 71 125 +3 253 37 124 +3 254 247 22 +3 124 251 253 +3 232 66 128 +3 123 37 260 +3 8 219 262 +3 129 70 249 +3 21 234 238 +3 127 66 232 +3 138 70 247 +3 38 240 261 +3 132 71 252 +3 223 64 136 +3 22 247 258 +3 131 255 257 +3 216 62 135 +3 216 40 134 +3 20 218 222 +3 134 214 216 +3 220 41 225 +3 133 40 224 +3 8 230 246 +3 139 63 220 +3 22 250 254 +3 220 63 137 +3 20 215 226 +3 248 70 138 +3 142 62 217 +3 146 65 227 +3 135 62 215 +3 141 227 229 +3 269 75 145 +3 269 43 144 +3 192 263 23 +3 144 267 269 +3 221 63 148 +3 143 43 165 +3 137 63 219 +3 149 74 265 +3 222 215 20 +3 147 63 221 +3 158 74 263 +3 44 228 164 +3 152 75 268 +3 150 1 93 +3 243 69 156 +3 151 45 27 +3 23 263 167 +3 151 170 168 +3 237 67 155 +3 96 28 153 +3 237 46 154 +3 154 46 95 +3 238 231 21 +3 154 235 237 +3 233 47 245 +3 153 46 244 +3 246 219 8 +3 159 66 233 +3 23 266 192 +3 233 66 157 +3 128 66 231 +3 264 74 158 +3 48 24 78 +3 16 162 86 +3 49 26 86 +3 163 4 85 +3 192 266 152 +3 84 26 91 +3 268 45 168 +3 50 26 85 +3 152 268 168 +3 79 24 80 +3 169 245 47 +3 81 25 83 +3 151 15 170 +3 81 9 84 +3 168 45 151 +3 82 25 87 +3 266 75 152 +3 86 26 84 +3 186 54 102 +3 100 30 174 +3 183 175 17 +3 51 171 174 +3 181 27 173 +3 102 54 183 +3 174 171 100 +3 171 1 100 +3 201 58 107 +3 108 52 175 +3 198 187 7 +3 108 54 185 +3 177 176 97 +3 176 7 97 +3 185 32 178 +3 183 54 108 +3 182 180 53 +3 175 52 99 +3 182 29 98 +3 98 6 180 +3 181 180 92 +3 180 6 92 +3 177 29 182 +3 179 175 99 +3 186 184 54 +3 172 51 102 +3 186 30 101 +3 101 10 184 +3 201 32 213 +3 102 174 186 +3 174 30 186 +3 183 172 102 +3 197 57 119 +3 117 55 187 +3 194 191 18 +3 117 58 200 +3 189 55 90 +3 119 57 194 +3 200 35 190 +3 198 58 117 +3 193 34 114 +3 115 56 191 +3 168 170 76 +3 78 24 56 +3 196 34 193 +3 194 57 115 +3 208 60 116 +3 188 55 119 +3 207 11 195 +3 119 190 197 +3 196 195 113 +3 195 11 113 +3 116 57 197 +3 194 188 119 +3 213 61 109 +3 176 52 107 +3 210 202 19 +3 107 178 201 +3 208 35 200 +3 109 61 210 +3 178 32 201 +3 198 176 107 +3 205 203 59 +3 105 59 202 +3 110 33 204 +3 104 3 203 +3 204 203 110 +3 203 3 110 +3 212 31 205 +3 210 61 105 +3 209 207 60 +3 202 59 112 +3 209 33 111 +3 111 11 207 +3 208 197 35 +3 112 204 209 +3 204 33 209 +3 206 202 112 +3 213 185 106 +3 199 58 109 +3 184 10 211 +3 109 201 213 +3 212 211 103 +3 211 10 103 +3 185 54 106 +3 210 199 109 +3 229 65 142 +3 140 42 217 +3 226 218 20 +3 62 214 217 +3 224 40 216 +3 142 65 226 +3 217 214 140 +3 214 2 140 +3 265 74 147 +3 148 63 218 +3 262 230 8 +3 148 65 228 +3 248 41 220 +3 147 74 262 +3 228 44 221 +3 226 65 148 +3 256 72 136 +3 218 63 139 +3 255 13 223 +3 139 220 225 +3 224 223 133 +3 223 13 133 +3 136 64 225 +3 222 218 139 +3 229 227 65 +3 215 62 142 +3 229 42 141 +3 141 14 227 +3 265 44 164 +3 142 217 229 +3 217 42 229 +3 226 215 142 +3 245 69 159 +3 157 66 230 +3 242 234 21 +3 157 74 264 +3 240 38 232 +3 159 69 242 +3 264 47 233 +3 262 74 157 +3 237 235 67 +3 155 67 234 +3 120 36 236 +3 154 4 235 +3 236 235 120 +3 235 4 120 +3 244 46 237 +3 242 69 155 +3 241 239 68 +3 234 67 122 +3 241 36 121 +3 121 12 239 +3 249 38 261 +3 122 236 241 +3 236 36 241 +3 238 234 122 +3 169 76 156 +3 231 66 159 +3 170 15 243 +3 159 233 245 +3 244 243 153 +3 243 15 153 +3 156 69 245 +3 242 231 159 +3 261 73 129 +3 230 66 127 +3 258 250 22 +3 127 232 249 +3 256 41 248 +3 129 73 258 +3 232 38 249 +3 246 230 127 +3 253 251 71 +3 125 71 250 +3 130 39 252 +3 124 5 251 +3 252 251 130 +3 251 5 130 +3 260 37 253 +3 258 73 125 +3 257 255 72 +3 250 71 132 +3 257 39 131 +3 131 13 255 +3 256 225 41 +3 132 252 257 +3 252 39 257 +3 254 250 132 +3 261 240 126 +3 247 70 129 +3 239 12 259 +3 129 249 261 +3 260 259 123 +3 259 12 123 +3 240 68 126 +3 258 247 129 +3 164 77 149 +3 219 63 147 +3 167 266 23 +3 147 221 265 +3 169 47 264 +3 149 77 167 +3 221 44 265 +3 262 219 147 +3 269 267 75 +3 145 75 266 +3 150 45 268 +3 144 1 267 +3 268 267 150 +3 267 1 150 +3 165 43 269 +3 167 77 145 diff --git a/Heat_method_3/test/Heat_method_3/heat_method_surface_mesh_intrinsic_test.cpp b/Heat_method_3/test/Heat_method_3/heat_method_surface_mesh_intrinsic_test.cpp new file mode 100644 index 00000000000..e4aeb76dd2c --- /dev/null +++ b/Heat_method_3/test/Heat_method_3/heat_method_surface_mesh_intrinsic_test.cpp @@ -0,0 +1,115 @@ +#include +#include +#include +#include +#include + + +typedef CGAL::Simple_cartesian Kernel; +typedef Kernel::Point_3 Point_3; +typedef CGAL::Surface_mesh Surface_mesh; + +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef Surface_mesh::Property_map Vertex_distance_map; +typedef CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 Heat_method; + + + +int main(int argc, char* argv[]) +{ + //read in mesh + Surface_mesh sm; + const char* filename = (argc > 1) ? argv[1] : "./data/rectangle_with_degenerate_faces.off"; + std::ifstream in(filename); + in >> sm; + //property map for the distance values to the source set + Vertex_distance_map vertex_distance = sm.add_property_map("v:distance", 0).first; + + Heat_method hm(sm); + + //add the first vertex as the source set + vertex_descriptor source = *(vertices(sm).first); + hm.add_source(source); + assert(hm.sources().size() == 1); + hm.estimate_geodesic_distances(vertex_distance); + + Point_3 sp = sm.point(source); + + std::cout << "source: " << sp << " " << source << std::endl; + vertex_descriptor vfar; + double sdistance = 0; + + for(vertex_descriptor vd : vertices(sm)){ + if(get(vertex_distance,vd) > sdistance){ + vfar = vd; + sdistance = get(vertex_distance,vd); + } + } + assert(sdistance > 1.); + assert(sdistance < 2.26);//2.236 = sqrt(5) + + hm.add_source(vfar); + assert(hm.sources().size() == 2); + hm.estimate_geodesic_distances(vertex_distance); + + sdistance = 0; + for(vertex_descriptor vd : vertices(sm)){ + if(get(vertex_distance,vd) > sdistance){ + sdistance = get(vertex_distance,vd); + } + } + + assert(sdistance > 1.); + assert(sdistance < 2.26);//2.236 = sqrt(5) + + hm.remove_source(vfar); + assert(hm.sources().size() == 1); + + hm.clear_sources(); + + // add range of sources + std::vector vrange; + vrange.push_back(source); + vrange.push_back(vfar); + hm.add_sources(vrange); + assert(hm.sources().size() == 2); + hm.estimate_geodesic_distances(vertex_distance); + sdistance = 0; + for(vertex_descriptor vd : vertices(sm)){ + if(get(vertex_distance,vd) > sdistance){ + sdistance = get(vertex_distance,vd); + } + } + + assert(sdistance > 1.); + assert(sdistance < 2.26);//2.236 = sqrt(5) + + // do it again for one source + hm.clear_sources(); + assert(hm.sources().size() == 0); + hm.add_source(source); + hm.estimate_geodesic_distances(vertex_distance); + for(vertex_descriptor vd : vertices(sm)){ + if(get(vertex_distance,vd) > sdistance){ + sdistance = get(vertex_distance,vd); + } + } + assert(sdistance > 1.); + assert(sdistance < 2.26);//2.236 = sqrt(5) + + + CGAL::Heat_method_3::estimate_geodesic_distances(sm, vertex_distance, source, + CGAL::Heat_method_3::Intrinsic_Delaunay()); + sdistance = 0; + for(vertex_descriptor vd : vertices(sm)){ + if(get(vertex_distance,vd) > sdistance){ + sdistance = get(vertex_distance,vd); + } + } + assert(sdistance > 1.); + assert(sdistance < 2.26);//2.236 = sqrt(5) + + std::cout << "done" << std::endl; + return 0; +} From f2f10e7a22465f86e0247e031c3640b705049975 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 20 Nov 2020 16:18:11 +0100 Subject: [PATCH 021/130] add missing namespace --- .../Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h b/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h index b5aff168bb7..6ce491def7b 100644 --- a/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h +++ b/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h @@ -398,7 +398,7 @@ private: stack.push(ed); } - if(internal::has_degenerate_faces(m_intrinsic_tm, Traits())) + if(CGAL::Heat_method_3::internal::has_degenerate_faces(m_intrinsic_tm, Traits())) mollify(min_length*1e-4); loop_over_edges(stack, mark_edges); From 78bbe1532563c6746ad672487d69218e96818540 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sat, 28 Nov 2020 14:17:59 +0000 Subject: [PATCH 022/130] Add a destructor assertion catch macro --- STL_Extension/include/CGAL/assertions.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/STL_Extension/include/CGAL/assertions.h b/STL_Extension/include/CGAL/assertions.h index caa0237fc7d..e13f181f970 100644 --- a/STL_Extension/include/CGAL/assertions.h +++ b/STL_Extension/include/CGAL/assertions.h @@ -79,6 +79,7 @@ inline bool possibly(Uncertain c); #if defined(CGAL_NO_ASSERTIONS) # define CGAL_assertion(EX) (static_cast(0)) # define CGAL_destructor_assertion(EX) (static_cast(0)) +# define CGAL_destructor_assertion_catch(CODE) CODE # define CGAL_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_assertion_code(CODE) # ifdef CGAL_ASSUME @@ -94,9 +95,11 @@ inline bool possibly(Uncertain c); # if __cpp_lib_uncaught_exceptions || ( _MSVC_LANG >= 201703L ) // C++17 # define CGAL_destructor_assertion(EX) \ (CGAL::possibly(EX)||(std::uncaught_exceptions() > 0)?(static_cast(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__)) +# define CGAL_destructor_assertion_catch(CODE) try{ CODE } catch(...) { if(std::uncaught_exceptions() <= 0) throw; } # else // use C++03 `std::uncaught_exception()` # define CGAL_destructor_assertion(EX) \ (CGAL::possibly(EX)||std::uncaught_exception()?(static_cast(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__)) +# define CGAL_destructor_assertion_catch(CODE) try{ CODE } catch(...) { if(!std::uncaught_exception()) throw; } # endif // use C++03 `std::uncaught_exception()` # define CGAL_assertion_msg(EX,MSG) \ (CGAL::possibly(EX)?(static_cast(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__, MSG)) @@ -293,11 +296,19 @@ inline bool possibly(Uncertain c); #if defined(CGAL_NO_WARNINGS) # define CGAL_warning(EX) (static_cast(0)) +# define CGAL_destructor_warning(EX) (static_cast(0)) # define CGAL_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_warning_code(CODE) #else # define CGAL_warning(EX) \ (CGAL::possibly(EX)?(static_cast(0)): ::CGAL::warning_fail( # EX , __FILE__, __LINE__)) +# if __cpp_lib_uncaught_exceptions || ( _MSVC_LANG >= 201703L ) // C++17 +# define CGAL_destructor_warning(EX) \ + (CGAL::possibly(EX)||(std::uncaught_exceptions() > 0)?(static_cast(0)): ::CGAL::warning_fail( # EX , __FILE__, __LINE__)) +# else // use C++03 `std::uncaught_exception()` +# define CGAL_destructor_warning(EX) \ + (CGAL::possibly(EX)||std::uncaught_exception()?(static_cast(0)): ::CGAL::warning_fail( # EX , __FILE__, __LINE__)) +# endif // use C++03 `std::uncaught_exception()` # define CGAL_warning_msg(EX,MSG) \ (CGAL::possibly(EX)?(static_cast(0)): ::CGAL::warning_fail( # EX , __FILE__, __LINE__, MSG)) # define CGAL_warning_code(CODE) CODE From 96024d1bb1bea1e98fc49808fa70c9f7cc3c8873 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sat, 28 Nov 2020 14:25:25 +0000 Subject: [PATCH 023/130] Fix uncaught exception in K3_tree.h --- Nef_3/include/CGAL/Nef_3/K3_tree.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/K3_tree.h b/Nef_3/include/CGAL/Nef_3/K3_tree.h index c3b8aaecffc..b551b5c1625 100644 --- a/Nef_3/include/CGAL/Nef_3/K3_tree.h +++ b/Nef_3/include/CGAL/Nef_3/K3_tree.h @@ -442,12 +442,15 @@ friend std::ostream& operator<< } -~Node() { +~Node() CGAL_NOEXCEPT(CGAL_NO_ASSERTIONS_BOOL) +{ CGAL_NEF_TRACEN("~Node: deleting node..."); - if( !is_leaf()) { - delete left_node; - delete right_node; - } + CGAL_destructor_assertion_catch( + if( !is_leaf()) { + delete left_node; + delete right_node; + } + ); } private: @@ -1103,9 +1106,12 @@ bool update( Node* node, return (left_updated || right_updated); } -~K3_tree() { +~K3_tree() CGAL_NOEXCEPT(CGAL_NO_ASSERTIONS_BOOL) +{ CGAL_NEF_TRACEN("~K3_tree: deleting root..."); - delete root; + CGAL_destructor_assertion_catch( + delete root; + ); } private: From 9d442f26c783a6e3416c3b5b2d56b0ec28ffe3d4 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sat, 28 Nov 2020 17:48:05 +0000 Subject: [PATCH 024/130] Fix uncaught exception in VRML_2_ostream.h --- Stream_support/include/CGAL/IO/VRML/VRML_2_ostream.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Stream_support/include/CGAL/IO/VRML/VRML_2_ostream.h b/Stream_support/include/CGAL/IO/VRML/VRML_2_ostream.h index 08e8fdd7e49..d200643068d 100644 --- a/Stream_support/include/CGAL/IO/VRML/VRML_2_ostream.h +++ b/Stream_support/include/CGAL/IO/VRML/VRML_2_ostream.h @@ -30,7 +30,12 @@ class VRML_2_ostream public: VRML_2_ostream() : m_os(nullptr) {} VRML_2_ostream(std::ostream& o) : m_os(&o) { header(); } - ~VRML_2_ostream() { close(); } + ~VRML_2_ostream() CGAL_NOEXCEPT(CGAL_NO_ASSERTIONS_BOOL) + { + CGAL_destructor_assertion_catch( + close(); + ); + } void open(std::ostream& o) { m_os = &o; header(); } void close() From 35c148078ce711321d7c557319d8516a3028c8fc Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sat, 28 Nov 2020 20:26:00 +0000 Subject: [PATCH 025/130] Fix uncaught exception in Sphere_map.h --- Nef_S2/include/CGAL/Nef_S2/Sphere_map.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Nef_S2/include/CGAL/Nef_S2/Sphere_map.h b/Nef_S2/include/CGAL/Nef_S2/Sphere_map.h index 93670a125e2..0ee5d431292 100644 --- a/Nef_S2/include/CGAL/Nef_S2/Sphere_map.h +++ b/Nef_S2/include/CGAL/Nef_S2/Sphere_map.h @@ -229,7 +229,12 @@ public: Sphere_map(bool = false) : boundary_item_(boost::none), svertices_(), sedges_(), sfaces_(), shalfloop_() {} - ~Sphere_map() { clear(); } + ~Sphere_map() CGAL_NOEXCEPT(CGAL_NO_ASSERTIONS_BOOL) + { + CGAL_destructor_assertion_catch( + clear(); + ); + } Sphere_map(const Self& D) : boundary_item_(boost::none), svertices_(D.svertices_), From e222a423aff1070ae92d0e443bd3459b19620f9d Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sun, 29 Nov 2020 11:30:21 +0000 Subject: [PATCH 026/130] Fix uncaught exception in Nef_polyhedron_S2.h --- Nef_S2/include/CGAL/Nef_polyhedron_S2.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Nef_S2/include/CGAL/Nef_polyhedron_S2.h b/Nef_S2/include/CGAL/Nef_polyhedron_S2.h index 10003b5b47a..59613249388 100644 --- a/Nef_S2/include/CGAL/Nef_polyhedron_S2.h +++ b/Nef_S2/include/CGAL/Nef_polyhedron_S2.h @@ -73,7 +73,12 @@ class Nef_polyhedron_S2_rep { public: Nef_polyhedron_S2_rep() : sm_() {} Nef_polyhedron_S2_rep(const Self&) : sm_() {} - ~Nef_polyhedron_S2_rep() { sm_.clear(); } + ~Nef_polyhedron_S2_rep() CGAL_NOEXCEPT(CGAL_NO_ASSERTIONS_BOOL) + { + CGAL_destructor_assertion_catch( + sm_.clear(); + ); + } }; /*{\Moptions print_title=yes }*/ From ce26378d5431dd1f89eb482fef246edd11ec1d6f Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sun, 29 Nov 2020 12:11:37 +0000 Subject: [PATCH 027/130] Fix uncaught exception in SNC_point_locator.h --- Nef_3/include/CGAL/Nef_3/SNC_point_locator.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h b/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h index 3b81b1119c0..e381a9ae60a 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h @@ -126,7 +126,8 @@ public: virtual void add_vertex(Vertex_handle) {} - virtual ~SNC_point_locator() { + virtual ~SNC_point_locator() CGAL_NOEXCEPT(CGAL_NO_ASSERTIONS_BOOL) + { CGAL_NEF_CLOG(""); CGAL_NEF_CLOG("construction_time: "< Date: Sun, 29 Nov 2020 14:42:55 +0000 Subject: [PATCH 028/130] Fix uncaught exception in Handle_for.h --- STL_Extension/include/CGAL/Handle_for.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/STL_Extension/include/CGAL/Handle_for.h b/STL_Extension/include/CGAL/Handle_for.h index 537096b6e73..97543f58db8 100644 --- a/STL_Extension/include/CGAL/Handle_for.h +++ b/STL_Extension/include/CGAL/Handle_for.h @@ -149,12 +149,14 @@ public: return *this; } - ~Handle_for() + ~Handle_for() noexcept { - if (--(ptr_->count) == 0) { - Allocator_traits::destroy(allocator, ptr_); - allocator.deallocate( ptr_, 1); - } + try{ + if (--(ptr_->count) == 0) { + Allocator_traits::destroy(allocator, ptr_); + allocator.deallocate( ptr_, 1); + } + } catch(...) {} } void From a7abec0a422a145fe73a18735bc3ceddfb3c244b Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sun, 29 Nov 2020 15:21:49 +0000 Subject: [PATCH 029/130] Add noexcept to Ref_counted_base in Straight_skeleton_aux.h --- .../include/CGAL/Straight_skeleton_2/Straight_skeleton_aux.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_aux.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_aux.h index 532d72e3a88..7e642e8b10b 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_aux.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_aux.h @@ -164,7 +164,7 @@ private: Ref_counted_base& operator=( Ref_counted_base const &); protected: Ref_counted_base(): mCount(0) {} - virtual ~Ref_counted_base() {} + virtual ~Ref_counted_base() CGAL_NOEXCEPT(CGAL_NO_ASSERTIONS_BOOL) {} public: void AddRef() const { ++mCount; } void Release() const From e7aebc424ec965a2e5231edfaf517d6c62e74831 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sun, 29 Nov 2020 14:42:55 +0000 Subject: [PATCH 030/130] Fix uncaught exception in In_place_list.h --- STL_Extension/include/CGAL/In_place_list.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/STL_Extension/include/CGAL/In_place_list.h b/STL_Extension/include/CGAL/In_place_list.h index 89fd3da3c82..e19c8ca5e4d 100644 --- a/STL_Extension/include/CGAL/In_place_list.h +++ b/STL_Extension/include/CGAL/In_place_list.h @@ -445,9 +445,11 @@ public: (*node).prev_link = node; insert(begin(), x.begin(), x.end()); } - ~In_place_list() { - erase(begin(), end()); - put_node(node); + ~In_place_list() noexcept { + try { + erase(begin(), end()); + put_node(node); + } catch(...) {} } Self& operator=(const Self& x); From 1373150f1da4ad94ac12890b682688a2dca6e1f4 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sun, 29 Nov 2020 14:42:55 +0000 Subject: [PATCH 031/130] Fix uncaught exception in HalfedgeDS_list.h --- HalfedgeDS/include/CGAL/HalfedgeDS_list.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/HalfedgeDS/include/CGAL/HalfedgeDS_list.h b/HalfedgeDS/include/CGAL/HalfedgeDS_list.h index aecf7b7e29b..664be1c2c30 100644 --- a/HalfedgeDS/include/CGAL/HalfedgeDS_list.h +++ b/HalfedgeDS/include/CGAL/HalfedgeDS_list.h @@ -395,7 +395,11 @@ public: // halfedges, and f faces. The reservation sizes are a hint for // optimizing storage allocation. They are not used here. - ~HalfedgeDS_list() { clear(); } + ~HalfedgeDS_list() noexcept { + try { + clear(); + } catch (...) {} + } HalfedgeDS_list( const Self& hds) : vertices( hds.vertices), From 3127190bcf4f1b017468fa022349c6f13fa2088d Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Tue, 8 Dec 2020 12:48:04 +0100 Subject: [PATCH 032/130] marc's review --- .../include/CGAL/AABB_segment_primitive.h | 13 +++++--- .../include/CGAL/AABB_triangle_primitive.h | 15 +++++---- .../AABB_triangulation_3_cell_primitive.h | 15 +++++---- Filtered_kernel/include/CGAL/Lazy.h | 29 ++++++++++------- .../CGAL/Circular_kernel_intersections.h | 7 ++-- .../CGAL/Spherical_kernel_intersections.h | 5 ++- Kernel_23/include/CGAL/Kernel/Type_mapper.h | 1 + .../Mesh_3/Robust_intersection_traits_3.h | 32 +++++++++++-------- .../NewKernel_d/Cartesian_static_filters.h | 1 + .../CGAL/NewKernel_d/Filtered_predicate2.h | 1 + .../CGAL/NewKernel_d/Kernel_d_interface.h | 4 +-- .../CGAL/NewKernel_d/Wrapper/Point_d.h | 2 +- 12 files changed, 73 insertions(+), 52 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive.h b/AABB_tree/include/CGAL/AABB_segment_primitive.h index d28c681c4c3..a4627c8592e 100644 --- a/AABB_tree/include/CGAL/AABB_segment_primitive.h +++ b/AABB_tree/include/CGAL/AABB_segment_primitive.h @@ -30,14 +30,17 @@ namespace internal { //classical typedefs typedef Iterator key_type; typedef typename GeomTraits::Point_3 value_type; + // typedef decltype( + // std::declval()( + // std::declval())) reference; typedef decltype( - std::declval()( - std::declval())) reference; + typename GeomTraits::Construct_source_3()( + *std::declval())) reference; typedef boost::readable_property_map_tag category; + typedef Source_of_segment_3_iterator_property_map Self; - inline friend - typename Source_of_segment_3_iterator_property_map::reference - get(Source_of_segment_3_iterator_property_map, Iterator it) + inline friend reference + get(Self, key_type it) { return typename GeomTraits::Construct_source_3()( *it ); } diff --git a/AABB_tree/include/CGAL/AABB_triangle_primitive.h b/AABB_tree/include/CGAL/AABB_triangle_primitive.h index 89b45f940be..b1b1bd1fe79 100644 --- a/AABB_tree/include/CGAL/AABB_triangle_primitive.h +++ b/AABB_tree/include/CGAL/AABB_triangle_primitive.h @@ -30,15 +30,18 @@ namespace internal { //classical typedefs typedef Iterator key_type; typedef typename GeomTraits::Point_3 value_type; + // typedef decltype( + // std::declval()( + // std::declval(), + // std::declval())) reference; typedef decltype( - std::declval()( - std::declval(), - std::declval())) reference; + typename GeomTraits::Construct_vertex_3()( + *std::declval(), 0)) reference; typedef boost::readable_property_map_tag category; + typedef Point_from_triangle_3_iterator_property_map Self; - inline friend - typename Point_from_triangle_3_iterator_property_map::reference - get(Point_from_triangle_3_iterator_property_map, Iterator it) + inline friend reference + get(Self, key_type it) { return typename GeomTraits::Construct_vertex_3()( *it, 0 ); } diff --git a/AABB_tree/include/CGAL/AABB_triangulation_3_cell_primitive.h b/AABB_tree/include/CGAL/AABB_triangulation_3_cell_primitive.h index 90d520061a4..1db91627815 100644 --- a/AABB_tree/include/CGAL/AABB_triangulation_3_cell_primitive.h +++ b/AABB_tree/include/CGAL/AABB_triangulation_3_cell_primitive.h @@ -30,15 +30,18 @@ namespace CGAL //classical typedefs typedef Iterator key_type; typedef typename GeomTraits::Point_3 value_type; + // typedef decltype( + // std::declval()( + // std::declval(), + // std::declval())) reference; typedef decltype( - std::declval()( - std::declval(), - std::declval())) reference; + typename GeomTraits::Construct_vertex_3()( + *std::declval(), 0)) reference; typedef boost::readable_property_map_tag category; + typedef Point_from_cell_iterator_proprety_map Self; - inline friend - typename Point_from_cell_iterator_proprety_map::reference - get(Point_from_cell_iterator_proprety_map, Iterator it) + inline friend reference + get(Self, key_type it) { typename GeomTraits::Construct_point_3 point; return point(it->vertex(1)->point()); diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 1fa84f44ceb..73c5195a330 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -1486,10 +1486,13 @@ struct Lazy_construction_variant { operator()(const L1& l1, const L2& l2) const { typedef typename result::type result_type; - typedef decltype(std::declval()(std::declval::type>(), - std::declval::type>())) AT; - typedef decltype(std::declval()(std::declval::type>(), - std::declval::type>())) ET; + // typedef decltype(std::declval()(std::declval::type>(), + // std::declval::type>())) AT; + // typedef decltype(std::declval()(std::declval::type>(), + // std::declval::type>())) ET; + + typedef decltype(std::declval()(CGAL::approx(l1), CGAL::approx(l2))) AT; + typedef decltype(std::declval()( CGAL::exact(l1), CGAL::exact(l2))) ET; CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; @@ -1534,15 +1537,19 @@ struct Lazy_construction_variant { operator()(const L1& l1, const L2& l2, const L3& l3) const { typedef typename result::type result_type; - typedef decltype(std::declval()(std::declval::type>(), - std::declval::type>(), - std::declval::type>())) AT; - typedef decltype(std::declval()(std::declval::type>(), - std::declval::type>(), - std::declval::type>())) ET; + // typedef decltype(std::declval()(std::declval::type>(), + // std::declval::type>(), + // std::declval::type>())) AT; + // typedef decltype(std::declval()(std::declval::type>(), + // std::declval::type>(), + // std::declval::type>())) ET; + + typedef decltype(std::declval()(CGAL::approx(l1), CGAL::approx(l2), CGAL::approx(l3))) AT; + typedef decltype(std::declval()( CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3))) ET; CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; + try { Lazy lazy(new Lazy_rep_n(AC(), EC(), l1, l2, l3)); @@ -1594,7 +1601,7 @@ struct Lazy_construction { typedef typename boost::remove_cv< typename boost::remove_reference < typename AC::result_type >::type >::type AT; typedef typename boost::remove_cv< - typename boost::remove_reference < typename EC::result_type >::type >::type ET; + typename boost::remove_reference < typename EC::result_type >::type >::type ET; typedef typename Default::Get::type E2A; diff --git a/Kernel_23/doc/Kernel_23/CGAL/Circular_kernel_intersections.h b/Kernel_23/doc/Kernel_23/CGAL/Circular_kernel_intersections.h index 52b6131ddbc..7024d483aa1 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Circular_kernel_intersections.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Circular_kernel_intersections.h @@ -46,10 +46,9 @@ the following function overloads are also available. The iterator versions of those functions can be used in conjunction with `Dispatch_output_iterator`. -Since both the number of intersections, if any, and their types, depend -on the arguments, the function expects an output iterator on -`decltype(std::declval()(std::declval(), std::declval()))`, as -presented below. +Since both the number of intersections, if any, and types of the interesection results +depend on the arguments, the function expects an output iterator on `K::Intersect_2(Type1, Type2)` +as presented below. */ /// @{ diff --git a/Kernel_23/doc/Kernel_23/CGAL/Spherical_kernel_intersections.h b/Kernel_23/doc/Kernel_23/CGAL/Spherical_kernel_intersections.h index 63b75823a33..0c1a977f305 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Spherical_kernel_intersections.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Spherical_kernel_intersections.h @@ -57,9 +57,8 @@ the following function overloads are also available. The iterator versions of those functions can be used in conjunction with `Dispatch_output_iterator`. -Since both the number of intersections, if any, and their types, depend -on the arguments, the function expects an output iterator on -`decltype(std::declval()(std::declval(), std::declval()))`, +Since both the number of intersections, if any, and types of the interesection results +depend on the arguments, the function expects an output iterator on `Kernel::Intersect_3(Type1, Type2)` as presented below. */ /// @{ diff --git a/Kernel_23/include/CGAL/Kernel/Type_mapper.h b/Kernel_23/include/CGAL/Kernel/Type_mapper.h index 3dda35168d6..683b7fe9255 100644 --- a/Kernel_23/include/CGAL/Kernel/Type_mapper.h +++ b/Kernel_23/include/CGAL/Kernel/Type_mapper.h @@ -87,6 +87,7 @@ BOOST_PP_REPEAT_FROM_TO(1, 10, CGAL_VARIANT_TYPEMAP, _) //}; // Then we specialize for all kernel objects. +// More details on why it is like that are here: https://github.com/CGAL/cgal/pull/4878#discussion_r459986501 #define CGAL_Kernel_obj(X) \ template < typename K1, typename K2 > \ struct Type_mapper_impl < typename K1::X, K1, K2 > \ diff --git a/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h b/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h index 3178ebcbb9c..b76e75a8f04 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h @@ -266,10 +266,11 @@ ts_intersection(const typename K::Triangle_3 &t, const typename K::Segment_3 &s, const K & k) { - typedef decltype( - std::declval()( - std::declval(), - std::declval())) result_type; + // typedef decltype( + // std::declval()( + // std::declval(), + // std::declval())) result_type; + typedef decltype(typename K::Intersect_3()(s, t)) result_type; CGAL_MESH_3_BRANCH_PROFILER(std::string("coplanar/calls in : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); @@ -409,10 +410,11 @@ tr_intersection(const typename K::Triangle_3 &t, CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ; CGAL_kernel_precondition( ! k.is_degenerate_3_object()(r) ) ; - typedef decltype( - std::declval()( - std::declval(), - std::declval())) result_type; + // typedef decltype( + // std::declval()( + // std::declval(), + // std::declval())) result_type; + typedef decltype(typename K::Intersect_3()(r, t)) result_type; typedef typename K::Point_3 Point_3; @@ -485,9 +487,10 @@ public: EK::Intersect_3 exact_intersection = EK().intersect_3_object(); // Cartesian converters have an undocumented, optional< variant > operator - typedef decltype( - std::declval()( - std::declval(), std::declval())) result_type; + // typedef decltype( + // std::declval()( + // std::declval(), std::declval())) result_type; + typedef decltype(typename K_::Intersect_3()(t, s)) result_type; return result_type(back_from_exact(exact_intersection(to_exact(t), to_exact(s)))); } @@ -540,9 +543,10 @@ public: EK::Intersect_3 exact_intersection = EK().intersect_3_object(); // Cartesian converters have an undocumented, optional< variant > operator - typedef decltype( - std::declval()( - std::declval(), std::declval())) result_type; + // typedef decltype( + // std::declval()( + // std::declval(), std::declval())) result_type; + typedef decltype(typename K_::Intersect_3()(t, s)) result_type; return result_type(back_from_exact(exact_intersection(to_exact(t), to_exact(s)))); } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h index 701cbff1efc..381e4e752a4 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h @@ -32,6 +32,7 @@ template struct Orientation_of_points_2 : private Store_k struct Point_2 { R_ const&r; CC const&c; Point const& p; Point_2(R_ const&r_, CC const&c_, Point const&p_):r(r_),c(c_),p(p_){} + // use result_of instead or better decltype(auto)? typename CC::result_type x()const{return c(p,0);} typename CC::result_type y()const{return c(p,1);} }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h index 0265a9239e7..66c2029f5a6 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h @@ -58,6 +58,7 @@ public: typedef C2E To_exact_converter; typedef C2A To_approximate_converter; + // FIXME: should use result_of or decltype(auto), see emails by Nico typedef typename EP::result_type result_type; // AP::result_type must be convertible to EP::result_type. diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h index c4d0bd80e4b..96a33b33c14 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h @@ -127,14 +127,14 @@ template struct Kernel_d_interface : public Base_ { typedef typename Get_functor >::type CPI; typedef typename Get_functor >::type CVI; // FIXME: The following sometimes breaks compilation. The typedef below forces instantiation of this, which forces Point_d, which itself (in the wrapper) needs the derived kernel to tell it what the base kernel is, and that's a cycle. The exact circumstances are not clear, g++ and clang++ are ok in both C++03 and C++11, it is only clang in C++11 without CGAL_CXX11 that breaks. Relying on CPI::result_type is great for Epick_d but not Epeck_d. - // typedef typename CGAL::decay()(std::declval(), std::declval()))>::type result_type; + // typedef typename CGAL::decay::type>::type result_type; // typedef typename CGAL::decay::type result_type; // typedef decltype(std::declval()(std::declval(),Begin_tag{})) result_type; // HACK typedef typename Base::Point_cartesian_const_iterator result_type; // Kernel_d requires a common iterator type for points and vectors // TODO: provide this mixed functor in preKernel? - // CGAL_static_assertion((boost::is_same()(std::declval(), std::declval()))>::type, result_type>::value)); + // CGAL_static_assertion((boost::is_same::type>::type, result_type>::value)); // CGAL_static_assertion((boost::is_same::type, result_type>::value)); template auto operator()(Point_d const&p, Tag_ t)const{ diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h index 90bb34da3de..f21a7f6b4ba 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -49,7 +49,7 @@ public: typedef Dimension_tag<0> Feature_dimension; typedef typename Get_type::type Rep; - // typedef typename CGAL::decay()(std::declval(), std::declval()))>::type Cartesian_const_iterator; + // typedef typename CGAL::decay::type>::type Cartesian_const_iterator; const Rep& rep() const noexcept { From 40197ade1ab4a394762ff22213e0956a58db0a39 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 8 Dec 2020 16:33:01 +0100 Subject: [PATCH 033/130] add missing forward declaration --- .../internal/Intrinsic_Delaunay_triangulation_3.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h b/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h index 6ce491def7b..9b71bb1e286 100644 --- a/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h +++ b/Heat_method_3/include/CGAL/Heat_method_3/internal/Intrinsic_Delaunay_triangulation_3.h @@ -43,8 +43,6 @@ namespace CGAL { namespace Heat_method_3 { - - // forward declaration template struct IDT_vertex_point_property_map; @@ -53,6 +51,12 @@ struct IDT_vertex_point_property_map; template struct IDT_vertex_distance_property_map; +// forward declaration +namespace internal { + template + bool has_degenerate_faces(const TriangleMesh& tm, const Traits& traits); +} + template struct Intrinsic_Delaunay_triangulation_3_vertex_descriptor { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; From e2ea93dbc572c9d816163b5ad46ccc6510f9f104 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Tue, 19 Jan 2021 13:06:16 +0100 Subject: [PATCH 034/130] fixed wrong reference type in aabb tree --- .../CGAL/AABB_triangulation_3_cell_primitive.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_triangulation_3_cell_primitive.h b/AABB_tree/include/CGAL/AABB_triangulation_3_cell_primitive.h index 1db91627815..4400335e8e3 100644 --- a/AABB_tree/include/CGAL/AABB_triangulation_3_cell_primitive.h +++ b/AABB_tree/include/CGAL/AABB_triangulation_3_cell_primitive.h @@ -30,13 +30,13 @@ namespace CGAL //classical typedefs typedef Iterator key_type; typedef typename GeomTraits::Point_3 value_type; - // typedef decltype( - // std::declval()( - // std::declval(), - // std::declval())) reference; typedef decltype( - typename GeomTraits::Construct_vertex_3()( - *std::declval(), 0)) reference; + std::declval()( + std::declval(), + std::declval())) reference; + // typedef decltype( + // typename GeomTraits::Construct_vertex_3()( + // *std::declval(), 0)) reference; // fails polyhedron demo! typedef boost::readable_property_map_tag category; typedef Point_from_cell_iterator_proprety_map Self; From af3f6dd07fad9e8e4fc477d3a59f00b4ea7a813e Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Tue, 9 Feb 2021 17:30:06 +0100 Subject: [PATCH 035/130] fixed warnings with Intersect_3 and result_of --- Kernel_23/include/CGAL/Kernel/function_objects.h | 9 ++++----- STL_Extension/include/CGAL/result_of.h | 10 +++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index 41e978b703b..21e1db34de4 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -3292,11 +3292,10 @@ namespace CommonKernelFunctors { bool operator()(const Sphere_3& s1, const Sphere_3& s2, const Point_3& a, const Point_3& b) const { - typedef typename K::Circle_3 Circle_3; - typedef typename K::Point_3 Point_3; - typedef typename K::Segment_3 Segment_3; - typedef typename K::Plane_3 Plane_3; - typedef typename K::Intersect_3 Intersect_3; + typedef typename K::Circle_3 Circle_3; + typedef typename K::Point_3 Point_3; + typedef typename K::Segment_3 Segment_3; + typedef typename K::Plane_3 Plane_3; const Has_on_bounded_side_3& has_on_bounded_side = *this; diff --git a/STL_Extension/include/CGAL/result_of.h b/STL_Extension/include/CGAL/result_of.h index 1ed20008f20..863ddb90806 100644 --- a/STL_Extension/include/CGAL/result_of.h +++ b/STL_Extension/include/CGAL/result_of.h @@ -21,7 +21,11 @@ #include #include -#if CGAL_CXX11 +#if CGAL_CXX20 || __cpp_lib_is_invocable>=201703L + + // C++>=17 + +#elif CGAL_CXX11 #include @@ -45,7 +49,7 @@ namespace CGAL { namespace cpp11 { -#if CGAL_CXX20 +#if CGAL_CXX20 || __cpp_lib_is_invocable>=201703L template class result_of; template @@ -59,7 +63,7 @@ namespace cpp11 { using boost::result_of; -#endif +#endif // end C++<11 } // end cpp11 } // end CGAL From 0f751faa24e570c437b5561dcfab48fc9f6dfaee Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Wed, 4 Nov 2020 17:57:15 +0000 Subject: [PATCH 036/130] Implement hash of halffacet_pair for ID support handler --- Nef_3/include/CGAL/Nef_3/ID_support_handler.h | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/ID_support_handler.h b/Nef_3/include/CGAL/Nef_3/ID_support_handler.h index a62e50c78e6..33696cc9120 100644 --- a/Nef_3/include/CGAL/Nef_3/ID_support_handler.h +++ b/Nef_3/include/CGAL/Nef_3/ID_support_handler.h @@ -38,8 +38,23 @@ class ID_support_handler { typedef typename Decorator::SHalfloop_const_handle SHalfloop_const_handle; typedef typename Decorator::Halffacet_const_handle Halffacet_const_handle; - typedef CGAL::Unique_hash_map F2E; - CGAL::Unique_hash_map f2m; + struct Halffacet_pair + { + Halffacet_const_handle f1; + Halffacet_const_handle f2; + bool operator==(const Halffacet_pair& r) const + { return f1==r.f1 && f2==r.f2; } + }; + + struct Handle_pair_hash_function { + std::size_t operator() (const Halffacet_pair& p) const { + std::size_t hash = 53; + hash = 97 * hash + Handle_hash_function()(p.f1); + hash = 97 * hash + Handle_hash_function()(p.f2); + return hash; + } + }; + CGAL::Unique_hash_map f2m; std::map hash; public: @@ -76,17 +91,17 @@ class ID_support_handler { CGAL_NEF_TRACEN("hash_facet_pair " << sv->point() << std::endl << " " << f1->plane() << &f1 << std::endl << " " << f2->plane() << &f2); - - if(f2m[f1][f2]==0) { + int& idx=f2m[{f1,f2}]; + if(idx==0) { sv->set_index(); - f2m[f1][f2] = sv->get_index(); + idx = sv->get_index(); CGAL_NEF_TRACEN("insert " << sv->point() << &*sv - << ": " << f2m[f1][f2]); + << ": " << idx); CGAL_NEF_TRACEN("not defined, yet"); } else { CGAL_NEF_TRACEN("access " << sv->point() << &*sv); - sv->set_index(f2m[f1][f2]); + sv->set_index(idx); } } From 2718072e0f364ea3e60e26020dc869d797e26413 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Wed, 10 Feb 2021 10:20:21 +0100 Subject: [PATCH 037/130] projection traits removed result_of --- Kernel_23/include/CGAL/internal/Projection_traits_3.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Kernel_23/include/CGAL/internal/Projection_traits_3.h b/Kernel_23/include/CGAL/internal/Projection_traits_3.h index eb94a85caf6..8e20d4fd2d1 100644 --- a/Kernel_23/include/CGAL/internal/Projection_traits_3.h +++ b/Kernel_23/include/CGAL/internal/Projection_traits_3.h @@ -327,8 +327,7 @@ public: //compute intersection points in projected plane //We know that none of the segment is degenerate - typename CGAL::cpp11::result_of::type - o = intersection(s1_2,s2_2); + auto o = intersection(s1_2,s2_2); if(! o){ return boost::none; } From c970c4a7588a404e0f3c76a87113e5c5677e2cdd Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Thu, 11 Feb 2021 09:48:27 +0100 Subject: [PATCH 038/130] removed unused Point_3 type in PMP --- .../Polygon_mesh_processing/internal/Corefinement/predicates.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/predicates.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/predicates.h index 49aa3ed8a57..916677bf00e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/predicates.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/predicates.h @@ -83,8 +83,6 @@ bool sorted_around_edge( || coplanar_orientation(o,o_prime,p2,q)==NEGATIVE ); typename Kernel::Orientation_3 orientation; - typedef typename Kernel::Point_3 Point_3; - const auto s0 = orientation(o_prime, o, p1, p2); if ( s0==COPLANAR ) { From 393b49f96d8488a55627199d63d47a9c3dd78dfc Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Thu, 11 Feb 2021 18:29:44 +0000 Subject: [PATCH 039/130] Use boost::hash_combine and std::unordered_map for ID support handler --- Nef_3/include/CGAL/Nef_3/ID_support_handler.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/ID_support_handler.h b/Nef_3/include/CGAL/Nef_3/ID_support_handler.h index 33696cc9120..b1c64341c80 100644 --- a/Nef_3/include/CGAL/Nef_3/ID_support_handler.h +++ b/Nef_3/include/CGAL/Nef_3/ID_support_handler.h @@ -18,7 +18,8 @@ #include #include -#include +#include +#include #include #undef CGAL_NEF_DEBUG @@ -48,13 +49,13 @@ class ID_support_handler { struct Handle_pair_hash_function { std::size_t operator() (const Halffacet_pair& p) const { - std::size_t hash = 53; - hash = 97 * hash + Handle_hash_function()(p.f1); - hash = 97 * hash + Handle_hash_function()(p.f2); + std::size_t hash = 0; + boost::hash_combine(hash,Handle_hash_function()(p.f1)); + boost::hash_combine(hash,Handle_hash_function()(p.f2)); return hash; } }; - CGAL::Unique_hash_map f2m; + std::unordered_map f2m; std::map hash; public: From 3f4c1c4628af0f2d621878def5ca690bb1ecfb3c Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Fri, 12 Feb 2021 11:31:03 +0100 Subject: [PATCH 040/130] moved point/vertex/[] definitions of Segment_2/3 inside the class --- Kernel_23/include/CGAL/Segment_2.h | 32 ++++++------------------------ Kernel_23/include/CGAL/Segment_3.h | 11 ++-------- 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/Kernel_23/include/CGAL/Segment_2.h b/Kernel_23/include/CGAL/Segment_2.h index acb75fd5374..ba533d050d2 100644 --- a/Kernel_23/include/CGAL/Segment_2.h +++ b/Kernel_23/include/CGAL/Segment_2.h @@ -101,13 +101,16 @@ public: max BOOST_PREVENT_MACRO_SUBSTITUTION () const; decltype(auto) - vertex(int i) const; + vertex(int i) const + { return (i%2 == 0) ? source() : target(); } decltype(auto) - point(int i) const; + point(int i) const + { return vertex(i); } decltype(auto) - operator[](int i) const; + operator[](int i) const + { return vertex(i); } bool is_horizontal() const; bool is_vertical() const; @@ -187,29 +190,6 @@ Segment_2::max BOOST_PREVENT_MACRO_SUBSTITUTION () const return less_xy(source(),target()) ? target() : source(); } -template < class R_ > -CGAL_KERNEL_INLINE -decltype(auto) -Segment_2::vertex(int i) const -{ - return (i%2 == 0) ? source() : target(); -} - -template < class R_ > -inline -decltype(auto) -Segment_2::point(int i) const -{ - return vertex(i); -} - -template < class R_ > -inline -decltype(auto) -Segment_2::operator[](int i) const -{ - return vertex(i); -} template < class R_ > CGAL_KERNEL_INLINE diff --git a/Kernel_23/include/CGAL/Segment_3.h b/Kernel_23/include/CGAL/Segment_3.h index 9bece158b35..a15d3439874 100644 --- a/Kernel_23/include/CGAL/Segment_3.h +++ b/Kernel_23/include/CGAL/Segment_3.h @@ -99,7 +99,8 @@ public: max BOOST_PREVENT_MACRO_SUBSTITUTION () const; decltype(auto) - vertex(int i) const; + vertex(int i) const + { return (i%2 == 0) ? source() : target(); } decltype(auto) point(int i) const @@ -179,14 +180,6 @@ Segment_3::max BOOST_PREVENT_MACRO_SUBSTITUTION () const return less_xyz(source(),target()) ? target() : source(); } -template < class R_ > -CGAL_KERNEL_INLINE -decltype(auto) -Segment_3::vertex(int i) const -{ - return (i%2 == 0) ? source() : target(); -} - template < class R > std::ostream & From 8264096ee758ae0fbcb15baac683a990f07a09f1 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 23 Feb 2021 08:49:18 +0100 Subject: [PATCH 041/130] Remove TensorFlow support from Classification --- .../doc/Classification/Classification.txt | 35 +- .../doc/Classification/Concepts/Classifier.h | 1 - .../doc/Classification/PackageDescription.txt | 6 - .../doc/Classification/examples.txt | 1 - .../examples/Classification/CMakeLists.txt | 17 - .../example_tensorflow_neural_network.cpp | 140 --- Classification/include/CGAL/Classification.h | 4 - .../TensorFlow/Neural_network_classifier.h | 1119 ----------------- .../doc/Documentation/Third_party.txt | 21 - .../advanced/Configuration_variables.txt | 9 - .../modules/CGAL_TensorFlow_support.cmake | 7 - .../cmake/modules/FindTensorFlow.cmake | 25 - .../modules/list_of_whitelisted_headers.cmake | 1 - 13 files changed, 1 insertion(+), 1385 deletions(-) delete mode 100644 Classification/examples/Classification/example_tensorflow_neural_network.cpp delete mode 100644 Classification/include/CGAL/Classification/TensorFlow/Neural_network_classifier.h delete mode 100644 Installation/cmake/modules/CGAL_TensorFlow_support.cmake delete mode 100644 Installation/cmake/modules/FindTensorFlow.cmake diff --git a/Classification/doc/Classification/Classification.txt b/Classification/doc/Classification/Classification.txt index c1a578a8420..4ec5a7e73c8 100644 --- a/Classification/doc/Classification/Classification.txt +++ b/Classification/doc/Classification/Classification.txt @@ -199,7 +199,7 @@ Example of cluster classification mesh (left: input, middle: clusters computed f %Classification relies on a classifier: this classifier is an object that, from the set of values taken by the features at an input item, computes the probability that an input item belongs to one label or another. A model of the concept `CGAL::Classification::Classifier` must take the index of an input item and store the probability associated to each label in a vector. If a classifier returns the value 1 for a pair of label and input item, it means that this item belongs to this label with certainty; values close to 0 mean that this item is not likely to belong to this label. -\cgal provides four models for this concept, [ETHZ::Random_forest_classifier](@ref CGAL::Classification::ETHZ::Random_forest_classifier), [OpenCV::Random_forest_classifier](@ref CGAL::Classification::OpenCV::Random_forest_classifier), [TensorFlow::Neural_network_classifier](@ref CGAL::Classification::TensorFlow::Neural_network_classifier) and [Sum_of_weighted_features_classifier](@ref CGAL::Classification::Sum_of_weighted_features_classifier). +\cgal provides three models for this concept, [ETHZ::Random_forest_classifier](@ref CGAL::Classification::ETHZ::Random_forest_classifier), [OpenCV::Random_forest_classifier](@ref CGAL::Classification::OpenCV::Random_forest_classifier), and [Sum_of_weighted_features_classifier](@ref CGAL::Classification::Sum_of_weighted_features_classifier). \note Currently, [ETHZ::Random_forest_classifier](@ref CGAL::Classification::ETHZ::Random_forest_classifier) is the best classifier available in \cgal and we strongly advise users @@ -255,31 +255,6 @@ use this classifier. For more details about the algorithm, please refer to [the official documentation](https://docs.opencv.org/2.4/modules/ml/doc/random_trees.html) of OpenCV. -\subsection Classification_TensorFlow_neural_network TensorFlow Neural Network - -\cgal provides [TensorFlow::Neural_network_classifier](@ref CGAL::Classification::TensorFlow::Neural_network_classifier). - -It uses the C++ API of the \ref thirdpartyTensorFlow library. - -\warning This feature is still experimental: it may not be stable -and is likely to undergo substantial changes in future releases of -\cgal. The API changes will be announced in the release notes. - -The provided interface is a feature-based neural network: a set of -features is used as an input layer followed by a user-specified number -of hidden layers with a user-specified activation function. The output -layer is a softmax layer providing, for each label, the probability -that an input item belongs to it. - -This classifier cannot be set up by hand and requires a ground truth -training set. The training algorithm usually requires a higher number -of inliers than random forest. The quality of the results, so far, is -comparable to random forest. - -An [example](\ref Classification_example_tensorflow_neural_network) shows how to -use this classifier. For more details about the algorithm, please refer -to [the TensorFlow tutorials](https://www.tensorflow.org/tutorials/). - \subsection Classification_sowf Sum of Weighted Features This latest classifier defines the following attributes: @@ -524,14 +499,6 @@ The following example shows how to use the classifier [OpenCV::Random_forest_cla \cgalExample{Classification/example_opencv_random_forest.cpp} -\subsection Classification_example_tensorflow_neural_network TensorFlow Neural Network - -The following example shows how to use the classifier -[TensorFlow::Neural_network_classifier](@ref CGAL::Classification::TensorFlow::Neural_network_classifier) -using an input training set. - -\cgalExample{Classification/example_tensorflow_neural_network.cpp} - \subsection Classification_example_mesh Mesh Classification The following example: diff --git a/Classification/doc/Classification/Concepts/Classifier.h b/Classification/doc/Classification/Concepts/Classifier.h index 5f0059a7519..ca1f3cefc97 100644 --- a/Classification/doc/Classification/Concepts/Classifier.h +++ b/Classification/doc/Classification/Concepts/Classifier.h @@ -15,7 +15,6 @@ Concept describing a classifier used by classification functions (see \cgalHasModel `CGAL::Classification::Sum_of_weighted_features_classifier` \cgalHasModel `CGAL::Classification::ETHZ::Random_forest_classifier` \cgalHasModel `CGAL::Classification::OpenCV::Random_forest_classifier` -\cgalHasModel `CGAL::Classification::TensorFlow::Neural_network_classifier` */ class Classifier diff --git a/Classification/doc/Classification/PackageDescription.txt b/Classification/doc/Classification/PackageDescription.txt index 16c1b565b5e..32736fae273 100644 --- a/Classification/doc/Classification/PackageDescription.txt +++ b/Classification/doc/Classification/PackageDescription.txt @@ -24,11 +24,6 @@ Classifiers that use the ETHZ library. Classifiers that use the \ref thirdpartyOpenCV library. -\defgroup PkgClassificationClassifiersTensorFlow TensorFlow -\ingroup PkgClassificationClassifiers - -Classifiers that use the \ref thirdpartyTensorFlow library. - \defgroup PkgClassificationDataStructures Common Data Structures \ingroup PkgClassificationRef @@ -102,7 +97,6 @@ Data structures specialized to classify clusters. - `CGAL::Classification::ETHZ::Random_forest_classifier` - `CGAL::Classification::OpenCV::Random_forest_classifier` -- `CGAL::Classification::TensorFlow::Neural_network_classifier` - `CGAL::Classification::Sum_of_weighted_features_classifier` \cgalCRPSection{Common Data Structures} diff --git a/Classification/doc/Classification/examples.txt b/Classification/doc/Classification/examples.txt index e456d0bea17..c9a3e7bd478 100644 --- a/Classification/doc/Classification/examples.txt +++ b/Classification/doc/Classification/examples.txt @@ -5,7 +5,6 @@ \example Classification/example_ethz_random_forest.cpp \example Classification/example_deprecated_conversion.cpp \example Classification/example_opencv_random_forest.cpp -\example Classification/example_tensorflow_neural_network.cpp \example Classification/example_mesh_classification.cpp \example Classification/example_cluster_classification.cpp */ diff --git a/Classification/examples/Classification/CMakeLists.txt b/Classification/examples/Classification/CMakeLists.txt index 3d2e6ebfc28..7009bb9fa57 100644 --- a/Classification/examples/Classification/CMakeLists.txt +++ b/Classification/examples/Classification/CMakeLists.txt @@ -46,15 +46,6 @@ if(NOT TARGET CGAL::OpenCV_support) ) endif() -find_package(TensorFlow QUIET) -include(CGAL_TensorFlow_support) -if(NOT TARGET CGAL::TensorFlow_support) - message( - STATUS - "NOTICE: TensorFlow was not found. TensorFlow neural network predicate for classification won't be available." - ) -endif() - find_package(Eigen3 3.1.0 REQUIRED) #(3.1.0 or greater) include(CGAL_Eigen3_support) if(NOT TARGET CGAL::Eigen3_support) @@ -85,13 +76,6 @@ if (TARGET CGAL::OpenCV_support) PUBLIC CGAL::OpenCV_support) endif() -if(TARGET CGAL::TensorFlow_support) - create_single_source_cgal_program("example_tensorflow_neural_network.cpp") - target_link_libraries(example_opencv_random_forest - PUBLIC CGAL::TensorFlow_support) -endif() - - foreach(target example_classification example_ethz_random_forest @@ -100,7 +84,6 @@ foreach(target example_mesh_classification example_cluster_classification example_opencv_random_forest - example_tensorflow_neural_network gis_tutorial_example example_deprecated_conversion) if(TARGET ${target}) diff --git a/Classification/examples/Classification/example_tensorflow_neural_network.cpp b/Classification/examples/Classification/example_tensorflow_neural_network.cpp deleted file mode 100644 index 27df2c663f5..00000000000 --- a/Classification/examples/Classification/example_tensorflow_neural_network.cpp +++ /dev/null @@ -1,140 +0,0 @@ -#if defined (_MSC_VER) && !defined (_WIN64) -#pragma warning(disable:4244) // boost::number_distance::distance() - // converts 64 to 32 bits integers -#endif - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -typedef CGAL::Simple_cartesian Kernel; -typedef Kernel::Point_3 Point; -typedef CGAL::Point_set_3 Point_set; -typedef Kernel::Iso_cuboid_3 Iso_cuboid_3; - -typedef Point_set::Point_map Pmap; -typedef Point_set::Property_map Imap; -typedef Point_set::Property_map UCmap; - -namespace Classification = CGAL::Classification; - -typedef Classification::Label_handle Label_handle; -typedef Classification::Feature_handle Feature_handle; -typedef Classification::Label_set Label_set; -typedef Classification::Feature_set Feature_set; - -typedef Classification::Point_set_feature_generator Feature_generator; - - -int main (int argc, char** argv) -{ - std::string filename = (argc > 1) ? argv[1] : "data/b9_training.ply"; - - std::cerr << "Reading input" << std::endl; - std::ifstream in (filename.c_str(), std::ios::binary); - Point_set pts; - in >> pts; - - Imap label_map; - bool lm_found = false; - std::tie (label_map, lm_found) = pts.property_map ("label"); - if (!lm_found) - { - std::cerr << "Error: \"label\" property not found in input file." << std::endl; - return EXIT_FAILURE; - } - - Feature_set features; - - std::cerr << "Generating features" << std::endl; - CGAL::Real_timer t; - t.start(); - Feature_generator generator (pts, pts.point_map(), - 5); // using 5 scales - - features.begin_parallel_additions(); - generator.generate_point_based_features (features); - features.end_parallel_additions(); - - t.stop(); - std::cerr << "Done in " << t.time() << " second(s)" << std::endl; - - // Add labels - Label_set labels; - Label_handle ground = labels.add ("ground"); - Label_handle vegetation = labels.add ("vegetation"); - Label_handle roof = labels.add ("roof"); - - std::vector label_indices(pts.size(), -1); - - std::cerr << "Using TensorFlow neural network Classifier" << std::endl; - Classification::TensorFlow::Neural_network_classifier<> classifier (labels, features); - - std::cerr << "Training" << std::endl; - t.reset(); - t.start(); - classifier.train (pts.range(ground_truth), - true, // restart from scratch - 100); // 100 iterations - t.stop(); - std::cerr << "Done in " << t.time() << " second(s)" << std::endl; - - t.reset(); - t.start(); - Classification::classify_with_graphcut - (pts, pts.point_map(), labels, classifier, - generator.neighborhood().k_neighbor_query(12), - 0.2f, 1, label_indices); - t.stop(); - - std::cerr << "Classification with graphcut done in " << t.time() << " second(s)" << std::endl; - - std::cerr << "Precision, recall, F1 scores and IoU:" << std::endl; - Classification::Evaluation evaluation (labels, pts.range(ground_truth), label_indices); - - for (Label_handle l : labels) - { - std::cerr << " * " << l->name() << ": " - << evaluation.precision(l) << " ; " - << evaluation.recall(l) << " ; " - << evaluation.f1_score(l) << " ; " - << evaluation.intersection_over_union(l) << std::endl; - } - - std::cerr << "Accuracy = " << evaluation.accuracy() << std::endl - << "Mean F1 score = " << evaluation.mean_f1_score() << std::endl - << "Mean IoU = " << evaluation.mean_intersection_over_union() << std::endl; - - // Color point set according to class - UCmap red = pts.add_property_map("red", 0).first; - UCmap green = pts.add_property_map("green", 0).first; - UCmap blue = pts.add_property_map("blue", 0).first; - - for (std::size_t i = 0; i < label_indices.size(); ++ i) - { - label_map[i] = label_indices[i]; // update label map with computed classification - - Label_handle label = labels[label_indices[i]]; - const CGAL::Color& color = label->color(); - red[i] = color.red(); - green[i] = color.green(); - blue[i] = color.blue(); - } - - // Write result - std::ofstream f ("classification.ply"); - f.precision(18); - f << pts; - - std::cerr << "All done" << std::endl; - - return EXIT_SUCCESS; -} diff --git a/Classification/include/CGAL/Classification.h b/Classification/include/CGAL/Classification.h index e5d761f4651..2b694d1b066 100644 --- a/Classification/include/CGAL/Classification.h +++ b/Classification/include/CGAL/Classification.h @@ -22,10 +22,6 @@ #include #endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW -#include -#endif - #include #include #include diff --git a/Classification/include/CGAL/Classification/TensorFlow/Neural_network_classifier.h b/Classification/include/CGAL/Classification/TensorFlow/Neural_network_classifier.h deleted file mode 100644 index c24dba334a3..00000000000 --- a/Classification/include/CGAL/Classification/TensorFlow/Neural_network_classifier.h +++ /dev/null @@ -1,1119 +0,0 @@ -// Copyright (c) 2018 GeometryFactory Sarl (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// -// Author(s) : Simon Giraudot - -#ifndef CGAL_CLASSIFICATION_TENSORFLOW_NEURAL_NETWORK_CLASSIFIER_H -#define CGAL_CLASSIFICATION_TENSORFLOW_NEURAL_NETWORK_CLASSIFIER_H - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#define CGAL_NEURAL_NETWORK_VERSION "0.1" - -namespace CGAL { - -namespace Classification { - -namespace TensorFlow { - -namespace TF = tensorflow; -namespace TFops = tensorflow::ops; - -/*! - \ingroup PkgClassificationClassifiersTensorFlow - - \brief %Classifier based on the TensorFlow version of the neural - network algorithm. - - This class provides an interface to a feature-based neural network: - a set of features is used as an input layer followed by a - user-specified number of hidden layers with a user-specified - activation function. The output layer is a softmax layer providing, - for each label, the probability that an input item belongs to it. - - \warning This feature is still experimental: it may not be stable - and is likely to undergo substantial changes in future releases of - \cgal. The API changes will be announced in the release notes. - - \note This class requires the \ref thirdpartyTensorFlow library. - - \tparam ActivationFunction Chosen activation function for the hidden - layers. `Relu` is used as default. The following functions can be - used (please refer to the documentation of \ref thirdpartyTensorFlow - for more information): - - `tensorflow::ops::Elu` - - `tensorflow::ops::Relu6` - - `tensorflow::ops::Relu` - - `tensorflow::ops::Selu` - - `tensorflow::ops::Sigmoid` - - `tensorflow::ops::Tanh` - - \cgalModels `CGAL::Classification::Classifier` -*/ -template -class Neural_network_classifier -{ - bool m_verbose; - - const Label_set& m_labels; - const Feature_set& m_features; - std::vector m_feature_means; - std::vector m_feature_sd; - - TF::Scope* m_root; - TFops::Placeholder* m_ph_ft; - TFops::Placeholder* m_ph_gt; - - TFops::ReduceMean* m_loss; - - std::vector > m_weights; - std::vector > m_bias; - float m_learning_rate; - std::vector m_layers; - -#define CGAL_CLASSIFICATION_TENSORFLOW_USE_ADAM -#ifdef CGAL_CLASSIFICATION_TENSORFLOW_USE_ADAM - std::vector m_optimizer; -#else - std::vector m_optimizer; -#endif - - TF::ClientSession* m_session; - -public: - - /// \cond SKIP_IN_MANUAL - const Feature_set& features() const { return m_features; } - /// \endcond - - /// \name Constructor - /// @{ - - /*! - \brief instantiates the classifier using the sets of `labels` and `features`. - - */ - Neural_network_classifier (const Label_set& labels, - const Feature_set& features) - : m_verbose (true), m_labels (labels), m_features (features) - , m_root (nullptr), m_ph_ft (nullptr), m_ph_gt (nullptr), m_loss(nullptr), m_session (nullptr) - { } - - /// \cond SKIP_IN_MANUAL - ~Neural_network_classifier () - { - clear(); - } - - bool initialized() const { return (m_root != nullptr); } - - bool& verbose() { return m_verbose; } - - void clear() - { - clear (m_ph_gt); - clear (m_ph_ft); - clear (m_loss); - clear (m_session); - clear (m_root); - m_weights.clear(); - m_bias.clear(); - m_optimizer.clear(); - m_layers.clear(); - } - - template - void clear (T* t) - { - if (t != nullptr) - delete t; - t = nullptr; - } - - void compute_normalization_coefficients (const std::vector& indices) - { -//#define DO_NOT_NORMALIZE_FEATURES -#ifdef DO_NOT_NORMALIZE_FEATURES - m_feature_means.clear(); - m_feature_means.resize (m_features.size(), 0.f); - m_feature_sd.clear(); - m_feature_sd.resize (m_features.size(), 1.f); -#else - m_feature_means.clear(); - m_feature_means.resize (m_features.size(), 0.f); - - for (std::size_t i = 0; i < indices.size(); ++ i) - for (std::size_t f = 0; f < m_features.size(); ++ f) - m_feature_means[f] += m_features[f]->value(indices[i]); - for (std::size_t f = 0; f < m_features.size(); ++ f) - m_feature_means[f] /= indices.size(); - - m_feature_sd.clear(); - m_feature_sd.resize (m_features.size(), 0.f); - - for (std::size_t i = 0; i < indices.size(); ++ i) - for (std::size_t f = 0; f < m_features.size(); ++ f) - m_feature_sd[f] += - (m_features[f]->value(indices[i]) - m_feature_means[f]) * - (m_features[f]->value(indices[i]) - m_feature_means[f]); - for (std::size_t f = 0; f < m_features.size(); ++ f) - { - m_feature_sd[f] = std::sqrt (m_feature_sd[f] / indices.size()); - if (m_feature_sd[f] == 0.f) - m_feature_sd[f] = 1.f; - - if (std::isnan(m_feature_means[f])) - m_feature_means[f] = 0.f; - if (std::isnan(m_feature_sd[f])) - m_feature_sd[f] = 1.f; - - // if (m_verbose) - // std::cerr << "#" << f << ": " << m_features[f]->name() << " = " - // << m_feature_means[f] << " +/- " << m_feature_sd[f] << std::endl; - } -#endif - } - /// \endcond - - /// @} - - /// \name Training - - /// @{ - /*! - \brief runs the training algorithm. - - From the set of provided ground truth, this algorithm constructs a - neural network and applies an Adam optimizer to set up the weights - and bias that produce the most accurate result with respect to - this ground truth. - - \pre At least one ground truth item should be assigned to each - label. - - \param ground_truth vector of label indices. It should contain for - each input item, in the same order as the input set, the index of - the corresponding label in the `Label_set` provided in the - constructor. Input items that do not have a ground truth - information should be given the value `-1`. - - \param restart_from_scratch should be set to `false` if the user - wants to continue adjusting weights and bias based, and set to - `true` if the neural network should be re-created from scratch - (discarding all previous training results). - - \param number_of_iterations number of times the optimizer is - called. - - \param learning_rate describes the rate at which the optimizer - changes the weights and bias. - - \param batch_size size of the random subset of inliers used for - optimizing at each iteration. - - \param hidden_layers vector containing the consecutive sizes - (number of neurons) of the hidden layers of the network. If no - vector is given, the behavior used is the following: 2 hidden - layers are used. The first layer has as many neurons as the number - of features; the second layer has a number of neurons equal to the - average value between the number of features and the number of - labels. - */ - template - void train (const LabelIndexRange& ground_truth, - bool restart_from_scratch = true, - std::size_t number_of_iterations = 5000, - float learning_rate = 0.01, - std::size_t batch_size = 1000, - const std::vector& hidden_layers - = std::vector()) - { - CGAL_precondition (m_labels.is_valid_ground_truth (ground_truth)); - - if (restart_from_scratch) - clear(); - - std::vector > random_indices (m_labels.size()); - - std::vector indices; - std::vector raw_gt; - std::size_t i = 0; - for (const auto& gt_value : ground_truth) - { - int gc = int(gt_value); - if (gc != -1) - { - indices.push_back (i); - raw_gt.push_back (gc); - random_indices[std::size_t(gc)].push_back (indices.size() - 1); - } - ++ i; - } - - if (!initialized()) - { - m_learning_rate = learning_rate; - build_architecture (hidden_layers); - if (m_verbose) std::cerr << "II - NORMALIZING FEATURES" << std::endl; - compute_normalization_coefficients (indices); - } - - if (m_verbose) std::cerr << "III - TRAINING NEURAL NETWORK" << std::endl; - - std::vector operations; - for (std::size_t i = 0; i < m_optimizer.size(); ++ i) - operations.push_back (m_optimizer[i]); - operations.push_back (m_layers.back()); - - std::vector outputs; - - m_weights.clear(); - m_bias.clear(); - // std::ofstream log ("loss.log"); - // log.precision(18); - - for (std::size_t i = 0; i < number_of_iterations; ++ i) - { - std::size_t total_batch_size = 0; - for (std::size_t j = 0; j < random_indices.size(); ++ j) - { - if (random_indices[j].empty()) - continue; - std::size_t local_batch_size = std::min (std::size_t(batch_size / m_labels.size()), - random_indices[j].size()); - random_unique (random_indices[j].begin(), random_indices[j].end(), local_batch_size); - total_batch_size += local_batch_size; - - if (i == 0) - { - if (m_verbose) std::cerr << " * Size of batch for " << m_labels[j]->name() << ": " - << local_batch_size << std::endl; - } - } - - TF::Tensor ft - (TF::DataTypeToEnum::v(), - TF::TensorShape {(long long)(total_batch_size), (long long)(m_features.size())}); - TF::Tensor gt - (TF::DataTypeToEnum::v(), - TF::TensorShape {(long long)(total_batch_size), (long long)(m_labels.size())}); - - float* ft_data = ft.flat().data(); - float* gt_data = gt.flat().data(); - - // Fill input tensors - std::size_t current_i = 0; - for (std::size_t j = 0; j < random_indices.size(); ++ j) - { - if (random_indices[j].empty()) - continue; - std::size_t local_batch_size = std::min (std::size_t(batch_size / m_labels.size()), - random_indices[j].size()); - for (std::size_t k = 0; k < local_batch_size; ++ k) - { - std::size_t idx = indices[random_indices[j][k]]; - int g = raw_gt[random_indices[j][k]]; - - for (std::size_t f = 0; f < m_features.size(); ++ f) - ft_data[current_i * m_features.size() + f] - = (m_features[f]->value(idx) - m_feature_means[f]) / m_feature_sd[f]; - - for (std::size_t l = 0; l < m_labels.size(); ++ l) - if (std::size_t(g) == l) - gt_data[current_i * m_labels.size() + l] = 1.f; - else - gt_data[current_i * m_labels.size() + l] = 0.f; - - ++ current_i; - } - } - - TF_CHECK_OK (m_session->Run ({{*m_ph_ft, ft}, {*m_ph_gt, gt}}, {*m_loss}, &outputs)); - - if ((i+1) % (number_of_iterations / 20) == 0) - { - if (m_verbose) std::cerr << " * Step " << i+1 << "/" << number_of_iterations << ": loss = " - << outputs[0].scalar() << std::endl; - } - if (!std::isfinite(*outputs[0].scalar().data())) - { - if (m_verbose) - std::cerr << "Loss is " << outputs[0].scalar() << ", aborting" << std::endl; - return; - } - - if (i == number_of_iterations - 1) - { - TF_CHECK_OK(m_session->Run({{*m_ph_ft, ft}, {*m_ph_gt, gt}}, operations, &outputs)); - for (std::size_t o = 0; o < outputs.size() - 1; ++ o) - { - std::size_t size = outputs[o].dim_size(0) * outputs[o].dim_size(1); - if (o < outputs.size() / 2) - { - m_weights.push_back (std::vector(size)); - float* weights_data = outputs[o].flat().data(); - std::copy_n (weights_data, size, m_weights.back().begin()); - } - else - { - m_bias.push_back (std::vector(size)); - float* bias_data = outputs[o].flat().data(); - std::copy_n (bias_data, size, m_bias.back().begin()); - } - } - } - else - TF_CHECK_OK(m_session->Run({{*m_ph_ft, ft}, {*m_ph_gt, gt}}, operations, nullptr)); - } - - } - - /// \cond SKIP_IN_MANUAL - void operator() (std::size_t item_index, std::vector& out) const - { - out.resize (m_labels.size(), 0.); - - TF::Tensor ft - (TF::DataTypeToEnum::v(), - TF::TensorShape {(long long)(1), (long long)(m_features.size())}); - - float* ft_data = ft.flat().data(); - - // Fill input tensor - for (std::size_t f = 0; f < m_features.size(); ++ f) - ft_data[f] = (m_features[f]->value(item_index) - m_feature_means[f]) / m_feature_sd[f]; - - std::vector outputs; - TF_CHECK_OK(m_session->Run({{*m_ph_ft, ft}}, {m_layers.back()}, &outputs)); - - float* output_data = outputs[0].flat().data(); - - for (std::size_t i = 0; i < m_labels.size(); ++ i) - out[i] = output_data[i]; - } - - - void operator() (const std::vector& item_indices, - std::vector >& out) const - { - out.resize (item_indices.size(), std::vector(m_labels.size(), 0.)); - - TF::Tensor ft - (TF::DataTypeToEnum::v(), - TF::TensorShape {(long long)(item_indices.size()), (long long)(m_features.size())}); - - float* ft_data = ft.flat().data(); - - // Fill input tensor - for (std::size_t i = 0; i < item_indices.size(); ++ i) - for (std::size_t f = 0; f < m_features.size(); ++ f) - ft_data[i * m_features.size() + f] - = (m_features[f]->value(item_indices[i]) - m_feature_means[f]) / m_feature_sd[f]; - - std::vector outputs; - TF_CHECK_OK(m_session->Run({{*m_ph_ft, ft}}, {m_layers.back()}, &outputs)); - - float* output_data = outputs[0].flat().data(); - - for (std::size_t i = 0; i < item_indices.size(); ++ i) - for (std::size_t l = 0; l < m_labels.size(); ++ l) - out[i][l] = output_data[i * m_labels.size() + l]; - } - /// \endcond - - /// @} - - /// \name Input/Output - /// @{ - - /*! - \brief saves the current configuration in the stream `output`. - - This allows to easily save and recover a specific classification - configuration, that is to say: - - - The statistics of features (mean and standard deviation) - - The number of hiddens layers and their respectives sizes - - The weights and bias of the neurons - - The output file is written in an XML format that is readable by - the `load_configuration()` method. - */ - void save_configuration (std::ostream& output) - { - boost::property_tree::ptree tree; - - { - boost::property_tree::ptree ptr; - ptr.put("classifier_version", CGAL_NEURAL_NETWORK_VERSION); - ptr.put("number_of_features", m_features.size()); - ptr.put("number_of_labels", m_labels.size()); - ptr.put("number_of_hidden_layers", m_layers.size() - 1); - ptr.put("learning_rate", m_learning_rate); - tree.add_child("classification.metadata", ptr); - } - - for (std::size_t i = 0; i < m_features.size(); ++ i) - { - boost::property_tree::ptree ptr; - ptr.put("name", m_features[i]->name()); - ptr.put("mean", m_feature_means[i]); - ptr.put("standard_deviation", m_feature_sd[i]); - tree.add_child("classification.features.feature", ptr); - } - - for (std::size_t i = 0; i < m_labels.size(); ++ i) - { - boost::property_tree::ptree ptr; - ptr.put("name", m_labels[i]->name()); - tree.add_child("classification.labels.label", ptr); - } - - for (std::size_t i = 0; i < m_weights.size(); ++ i) - { - boost::property_tree::ptree ptr; - ptr.put("height", (m_weights[i].size() / m_bias[i].size())); - ptr.put("width", m_bias[i].size()); - - std::ostringstream oss; - oss.precision(std::numeric_limits::digits10 + 2); - for (std::size_t j = 0; j < m_weights[i].size(); ++ j) - { - oss << m_weights[i][j]; - if (j != m_weights[i].size() - 1) - oss << " "; - } - ptr.put("weights", oss.str()); - - oss = std::ostringstream(); - oss.precision(std::numeric_limits::digits10 + 2); - for (std::size_t j = 0; j < m_bias[i].size(); ++ j) - { - oss << m_bias[i][j]; - if (j != m_bias[i].size() - 1) - oss << " "; - } - ptr.put("bias", oss.str()); - - tree.add_child("classification.layers.layer", ptr); - } - - // Write property tree to XML file - boost::property_tree::write_xml(output, tree, -#if BOOST_VERSION >= 105600 - boost::property_tree::xml_writer_make_settings(' ', 3)); -#else - boost::property_tree::xml_writer_make_settings(' ', 3)); -#endif - } - - /*! - \brief loads a configuration from the stream `input`. - - The input file should be in the XML format written by the - `save_configuration()` method. The feature set of the classifier - should contain the exact same features in the exact same order as - the ones present when the file was generated using - `save_configuration()`. - */ - bool load_configuration (std::istream& input, bool verbose = false) - { - clear(); - - bool out = true; - - boost::property_tree::ptree tree; - boost::property_tree::read_xml(input, tree); - - std::string version = tree.get("classification.metadata.classifier_version"); - if (version != CGAL_NEURAL_NETWORK_VERSION) - { - if (verbose) - std::cerr << "Error: CGAL Neural Network version mismatch " << version << "/" << CGAL_NEURAL_NETWORK_VERSION << std::endl; - return false; - } - std::size_t nb_features = std::size_t(tree.get("classification.metadata.number_of_features")); - if (nb_features != m_features.size()) - { - if (verbose) - std::cerr << "Error: number of features mismatch " << nb_features << "/" << m_features.size() << std::endl; - return false; - } - - std::size_t nb_labels = std::size_t(tree.get("classification.metadata.number_of_labels")); - if (nb_labels != m_labels.size()) - { - if (verbose) - std::cerr << "Error: number of labels mismatch " << nb_labels << "/" << m_labels.size() << std::endl; - return false; - } - - std::size_t nb_layers = std::size_t(tree.get("classification.metadata.number_of_hidden_layers")) + 1; - m_learning_rate = tree.get("classification.metadata.learning_rate"); - - std::size_t idx = 0; - for(boost::property_tree::ptree::value_type& v : tree.get_child("classification.features")) - { - std::string name = v.second.get("name"); - - if (name != m_features[idx]->name()) - { - if (verbose) - std::cerr << "Warning: feature mismatch " << name << "/" << m_features[idx]->name() << std::endl; - out = false; - } - - m_feature_means.push_back(v.second.get("mean")); - m_feature_sd.push_back(v.second.get("standard_deviation")); - - ++ idx; - } - - if (idx != nb_features) - { - if (verbose) - std::cerr << "Error: number of features mismatch " << nb_features << "/" << idx << std::endl; - return false; - } - - idx = 0; - for(boost::property_tree::ptree::value_type& v : tree.get_child("classification.labels")) - { - std::string name = v.second.get("name"); - if (name != m_labels[idx]->name()) - { - if (verbose) - std::cerr << "Warning: label mismatch " << name << "/" << m_labels[idx]->name() << std::endl; - out = false; - } - ++ idx; - } - - if (idx != nb_labels) - { - if (verbose) - std::cerr << "Error: number of labels mismatch " << nb_labels << "/" << idx << std::endl; - return false; - } - - idx = 0; - m_weights.resize (nb_layers); - m_bias.resize (nb_layers); - - std::vector hidden_layers; - for(boost::property_tree::ptree::value_type& v : tree.get_child("classification.layers")) - { - if (idx >= nb_layers) - { - if (verbose) - std::cerr << "Error: number of layers mismatch " << nb_layers << "/" << idx << std::endl; - return false; - } - std::size_t height = std::size_t(v.second.get("height")); - std::size_t width = std::size_t(v.second.get("width")); - std::size_t size = height * width; - m_weights[idx].reserve (size); - m_bias[idx].reserve (width); - - std::string weights = v.second.get("weights"); - std::istringstream iss (weights); - float f; - while (iss >> f) - m_weights[idx].push_back (f); - - std::string bias = v.second.get("bias"); - iss = std::istringstream (bias); - while (iss >> f) - m_bias[idx].push_back (f); - - if (idx != nb_layers - 1) - hidden_layers.push_back (width); - - ++ idx; - } - - if (idx != nb_layers) - { - if (verbose) - std::cerr << "Error: number of layers mismatch " << nb_layers << "/" << idx << std::endl; - return false; - } - - build_architecture(hidden_layers); - - return out; - } - -/// @} - -private: - - template - BidiIter random_unique(BidiIter begin, BidiIter end, size_t num_random) { - size_t left = std::distance(begin, end); - while (num_random--) { - BidiIter r = begin; - std::advance(r, rand()%left); - std::swap(*begin, *r); - ++begin; - --left; - } - return begin; - } - - void build_architecture (const std::vector& hidden_layers) - { - m_root = new TF::Scope (TF::Scope::NewRootScope()); - - - if (m_verbose) std::cerr << "I - BUILDING NEURAL NETWORK ARCHITECTURE" << std::endl; - - // Get layers and sizes or init with default values - std::vector hl = hidden_layers; - if (hl.empty()) - { - hl.push_back (m_features.size()); - hl.push_back ((m_features.size() + m_labels.size()) / 2); - } - - if (m_verbose) std::cerr << " 1) Initializing architecture:" << std::endl - << " * Layer 0: " << m_features.size() << " neuron(s) (input features)" << std::endl; - - if (m_verbose) - for (std::size_t i = 0; i < hl.size(); ++ i) - std::cerr << " * Layer " << i+1 << ": " << hl[i] << " neuron(s)" << std::endl; - - if (m_verbose) std::cerr << " * Layer " << hl.size() + 1 << ": " - << m_labels.size() << " neuron(s) (output labels)" << std::endl; - - - - m_ph_ft = new TFops::Placeholder (*m_root, TF::DT_FLOAT); - m_ph_gt = new TFops::Placeholder (*m_root, TF::DT_FLOAT); - - if (m_verbose) std::cerr << " 2) Creating weight matrices and bias" << std::endl; - - // create weight matrices and bias for each layer transition - std::vector weights; - std::vector bias; - std::vector assign_weights; - std::vector assign_bias; - - for (std::size_t i = 0; i <= hl.size(); ++ i) - { - long long size_from = 0; - long long size_to = 0; - if (i == 0) - { - size_from = m_features.size(); - size_to = hl[0]; - } - else if (i == hl.size()) - { - size_from = hl.back(); - size_to = m_labels.size(); - } - else - { - size_from = hl[i-1]; - size_to = hl[i]; - } - - if (m_verbose) std::cerr << " * Weight matrix " << i << " [" << size_from << ";" << size_to << "]" << std::endl; - weights.push_back (TFops::Variable (*m_root, { size_from, size_to }, TF::DT_FLOAT)); - - if (m_weights.empty()) - { - if (boost::is_same::value) // Weights initialized by Xavier method - assign_weights.push_back (TFops::Assign (*m_root, weights.back(), - TFops::Mul (*m_root, TFops::Const(*m_root, - std::sqrt (1.f / (float)(size_from))), - TFops::RandomNormal (*m_root, { size_from, size_to}, TF::DT_FLOAT)))); - else if (boost::is_same::value || - boost::is_same::value) // Weights initialized by He method - assign_weights.push_back (TFops::Assign (*m_root, weights.back(), - TFops::Mul (*m_root, TFops::Const(*m_root, - std::sqrt (2.f / (float)(size_from))), - TFops::RandomNormal (*m_root, { size_from, size_to}, TF::DT_FLOAT)))); - else // Default: weights truncated normal - assign_weights.push_back (TFops::Assign (*m_root, weights.back(), - TFops::TruncatedNormal (*m_root, { size_from, size_to}, TF::DT_FLOAT))); - } - else - { - TF::Tensor init_weight - (TF::DataTypeToEnum::v(), - TF::TensorShape {(long long)(size_from), (long long)(size_to)}); - float* init_weight_data = init_weight.flat().data(); - std::copy_n (m_weights[i].begin(), size_from * size_to, init_weight_data); - - assign_weights.push_back (TFops::Assign (*m_root, weights.back(), init_weight)); - } - - if (m_verbose) std::cerr << " * Bias " << i << " [" << size_to << "]" << std::endl; - bias.push_back (TFops::Variable (*m_root, { (long long)(1), size_to }, TF::DT_FLOAT)); - - TF::Tensor init_bias - (TF::DataTypeToEnum::v(), - TF::TensorShape {(long long)(1), (long long)(size_to)}); - float* init_bias_data = init_bias.flat().data(); - if (m_bias.empty()) - for (std::size_t s = 0; s < size_to; ++ s) - init_bias_data[s] = 0.f; - else - std::copy_n (m_bias[i].begin(), size_to, init_bias_data); - - assign_bias.push_back (TFops::Assign (*m_root, bias.back(), init_bias)); - } - - if (!m_root->status().ok()) - { - if (m_verbose) std::cerr << "Error: " << m_root->status().ToString() << std::endl; - return; - } - - if (m_verbose) std::cerr << " 3) Creating layers" << std::endl; - - for (std::size_t i = 0; i < weights.size(); ++ i) - { - if (i == 0) - m_layers.push_back (ActivationFunction (*m_root, TFops::Add - (*m_root, TFops::MatMul (*m_root, *m_ph_ft, weights[0]), - bias[0]))); - else if (i == weights.size() - 1) - m_layers.push_back (TFops::Softmax (*m_root, TFops::Add - (*m_root, TFops::MatMul (*m_root, m_layers.back(), weights[i]), - bias[i]))); - else - m_layers.push_back (ActivationFunction (*m_root, TFops::Add - (*m_root, TFops::MatMul (*m_root, m_layers.back(), weights[i]), - bias[i]))); - } - - if (!m_root->status().ok()) - { - if (m_verbose) std::cerr << "Error: " << m_root->status().ToString() << std::endl; - return; - } - - if (m_verbose) std::cerr << " 4) Setting up loss calculation" << std::endl; - - // loss calculation based on cross-entropy - TFops::Maximum truncated_ypred = TFops::Maximum (*m_root, TFops::Const(*m_root, 0.0001f), m_layers.back()); - TFops::Log log_ypred = TFops::Log (*m_root, truncated_ypred); - TFops::Mul ygt_times_log_ypred = TFops::Mul (*m_root, *m_ph_gt, log_ypred); - TFops::ReduceSum sum_ygt_times_log_ypred = TFops::ReduceSum(*m_root, ygt_times_log_ypred, {1}); - TFops::Mul minus_sum_ygt_times_log_ypred = TFops::Mul (*m_root, TFops::Const(*m_root, -1.f), sum_ygt_times_log_ypred); - - m_loss = new TFops::ReduceMean (*m_root, minus_sum_ygt_times_log_ypred, {0}); - - if (!m_root->status().ok()) - { - if (m_verbose) std::cerr << "Error: " << m_root->status().ToString() << std::endl; - return; - } - - if (m_verbose) std::cerr << " 5) Setting up gradient descent" << std::endl; - - std::vector weights_and_bias; - for (std::size_t i = 0; i < weights.size(); ++ i) - weights_and_bias.push_back (TF::Output(weights[i])); - for (std::size_t i = 0; i < bias.size(); ++ i) - weights_and_bias.push_back (TF::Output(bias[i])); - - std::vector gradients; - - TF_CHECK_OK(TF::AddSymbolicGradients(*m_root, {*m_loss}, - weights_and_bias, - &gradients)); - - if (!m_root->status().ok()) - { - if (m_verbose) std::cerr << "Error: " << m_root->status().ToString() << std::endl; - return; - } - - std::vector assigners; - -#ifdef CGAL_CLASSIFICATION_TENSORFLOW_USE_ADAM - for (std::size_t i = 0; i < weights.size(); ++ i) - { - long long size_from = 0; - long long size_to = 0; - if (i == 0) - { - size_from = m_features.size(); - size_to = hl[0]; - } - else if (i == weights.size() - 1) - { - size_from = hl.back(); - size_to = m_labels.size(); - } - else - { - size_from = hl[i-1]; - size_to = hl[i]; - } - - TFops::Variable m (*m_root, { size_from, size_to}, TF::DT_FLOAT); - TF::Tensor init_m - (TF::DataTypeToEnum::v(), - TF::TensorShape {(long long)(size_from), (long long)(size_to)}); - float* init_m_data = init_m.flat().data(); - for (std::size_t s = 0; s < size_from; ++ s) - for (std::size_t ss = 0; ss < size_to; ++ ss) - init_m_data[ss * size_from + s] = 0.f; - assigners.push_back (TFops::Assign (*m_root, m, init_m)); - - TFops::Variable v (*m_root, { size_from, size_to}, TF::DT_FLOAT); - TF::Tensor init_v - (TF::DataTypeToEnum::v(), - TF::TensorShape {(long long)(size_from), (long long)(size_to)}); - float* init_v_data = init_v.flat().data(); - for (std::size_t s = 0; s < size_from; ++ s) - for (std::size_t ss = 0; ss < size_to; ++ ss) - init_v_data[ss * size_from + s] = 0.f; - assigners.push_back (TFops::Assign (*m_root, v, init_v)); - - m_optimizer.push_back (TFops::ApplyAdam - (*m_root, - weights[i], - m, - v, - TFops::Cast(*m_root, 0.9, TF::DT_FLOAT), - TFops::Cast(*m_root, 0.999, TF::DT_FLOAT), - TFops::Cast(*m_root, m_learning_rate, TF::DT_FLOAT), - TFops::Cast(*m_root, 0.9, TF::DT_FLOAT), - TFops::Cast(*m_root, 0.999, TF::DT_FLOAT), - TFops::Cast(*m_root, 1e-8, TF::DT_FLOAT), - {gradients[i]})); - } - - for (std::size_t i = 0; i < bias.size(); ++ i) - { - long long size_from = 0; - long long size_to = 0; - if (i == 0) - size_to = hl[0]; - else if (i == bias.size() - 1) - size_to = m_labels.size(); - else - size_to = hl[i]; - - TFops::Variable m (*m_root, { 1, size_to}, TF::DT_FLOAT); - TF::Tensor init_m - (TF::DataTypeToEnum::v(), - TF::TensorShape {(long long)(1), (long long)(size_to)}); - float* init_m_data = init_m.flat().data(); - for (std::size_t s = 0; s < size_to; ++ s) - init_m_data[s] = 0.f; - assigners.push_back (TFops::Assign (*m_root, m, init_m)); - - TFops::Variable v (*m_root, { 1, size_to}, TF::DT_FLOAT); - TF::Tensor init_v - (TF::DataTypeToEnum::v(), - TF::TensorShape {(long long)(1), (long long)(size_to)}); - float* init_v_data = init_v.flat().data(); - for (std::size_t s = 0; s < size_to; ++ s) - init_v_data[s] = 0.f; - assigners.push_back (TFops::Assign (*m_root, v, init_v)); - - m_optimizer.push_back (TFops::ApplyAdam - (*m_root, - bias[i], - m, - v, - TFops::Cast(*m_root, 0.9, TF::DT_FLOAT), - TFops::Cast(*m_root, 0.999, TF::DT_FLOAT), - TFops::Cast(*m_root, m_learning_rate, TF::DT_FLOAT), - TFops::Cast(*m_root, 0.9, TF::DT_FLOAT), - TFops::Cast(*m_root, 0.999, TF::DT_FLOAT), - TFops::Cast(*m_root, 1e-8, TF::DT_FLOAT), - {gradients[weights.size() + i]})); - } - -#else - for (std::size_t i = 0; i < weights.size(); ++ i) - m_optimizer.push_back (TFops::ApplyGradientDescent - (*m_root, weights[i], - TFops::Cast(*m_root, m_learning_rate, TF::DT_FLOAT), {gradients[i]})); - for (std::size_t i = 0; i < bias.size(); ++ i) - m_optimizer.push_back (TFops::ApplyGradientDescent - (*m_root, bias[i], - TFops::Cast(*m_root, m_learning_rate, TF::DT_FLOAT), {gradients[weights.size() + i]})); -#endif - if (!m_root->status().ok()) - { - if (m_verbose) std::cerr << "Error: " << m_root->status().ToString() << std::endl; - return; - } - - if (m_verbose) std::cerr << " 6) Starting session" << std::endl; - - TF::SessionOptions options = TF::SessionOptions(); - - options.config.mutable_gpu_options()->set_allow_growth(true); - options.config.mutable_gpu_options()->set_per_process_gpu_memory_fraction(0.8); - options.config.mutable_gpu_options()->set_force_gpu_compatible(true); - - m_session = new TF::ClientSession (*m_root, options); - if (!m_root->status().ok()) - { - if (m_verbose) std::cerr << "Error: " << m_root->status().ToString() << std::endl; - return; - } - - std::vector outputs; - - for (std::size_t i = 0; i < assign_weights.size(); ++ i) - assigners.push_back (TF::Output(assign_weights[i])); - for (std::size_t i = 0; i < assign_bias.size(); ++ i) - assigners.push_back (TF::Output(assign_bias[i])); - TF_CHECK_OK (m_session->Run(assigners, nullptr)); - - if (!m_root->status().ok()) - { - if (m_verbose) std::cerr << "Error: " << m_root->status().ToString() << std::endl; - return; - } - } -}; - - -/// \cond SKIP_IN_MANUAL -#ifdef CGAL_CLASSIFICATION_TENSORFLOW_ENABLE_GPU_SPECIALIZATION -// Specialization to use GPU parallelization -template -void classify (const ItemRange& input, - const Label_set& labels, - const TensorFlow::Neural_network_classifier& classifier, - LabelIndexRange& output, - ProbabilitiesRanges& probabilities) -{ - std::cerr << "Classify with TensorFlow classifier" << std::endl; - - output.resize(input.size()); - probabilities.resize (labels.size()); - for (std::size_t i = 0; i < probabilities.size(); ++ i) - probabilities[i].resize (input.size()); - - const std::size_t mem_allocated = sizeof(float) * input.size() * (labels.size() + classifier.features().size()); - const std::size_t size_max = 512 * 1024 * 1024; - const std::size_t nb_subdivisions = (mem_allocated / size_max) + 1; - std::cerr << nb_subdivisions << " subdivision(s) for GPU processing" << std::endl; - - std::size_t idx = 0; - for (std::size_t n = 0; n < nb_subdivisions; ++ n) - { - std::vector indices; - indices.reserve (input.size() / nb_subdivisions); - for (std::size_t i = 0; i < input.size() / nb_subdivisions && idx < input.size(); ++ i) - indices.push_back(idx ++); - - std::vector > values; - classifier (indices, values); - for(std::size_t i = 0; i < indices.size(); ++ i) - { - std::size_t nb_class_best = 0; - float val_class_best = 0.f; - - for (std::size_t j = 0; j < labels.size(); ++ j) - { - probabilities[j][indices[i]] = values[i][j]; - - if(val_class_best < values[i][j]) - { - val_class_best = values[i][j]; - nb_class_best = j; - } - } - - output[indices[i]] = nb_class_best; - } - } -} - -// Specialization to use GPU parallelization -template -void classify (const ItemRange& input, - const Label_set& labels, - const TensorFlow::Neural_network_classifier& classifier, - LabelIndexRange& output) -{ - std::cerr << "Classify with TensorFlow classifier" << std::endl; - - output.resize(input.size()); - - const std::size_t mem_allocated = sizeof(float) * input.size() * (labels.size() + classifier.features().size()); - const std::size_t size_max = 512 * 1024 * 1024; - const std::size_t nb_subdivisions = (mem_allocated / size_max) + 1; - std::cerr << nb_subdivisions << " subdivision(s) for GPU processing" << std::endl; - - std::size_t idx = 0; - for (std::size_t n = 0; n < nb_subdivisions; ++ n) - { - std::vector indices; - indices.reserve (input.size() / nb_subdivisions); - for (std::size_t i = 0; i < input.size() / nb_subdivisions && idx < input.size(); ++ i) - indices.push_back(idx ++); - - std::vector > values; - classifier (indices, values); - - for(std::size_t i = 0; i < indices.size(); ++ i) - { - std::size_t nb_class_best = 0; - float val_class_best = 0.f; - - for (std::size_t j = 0; j < labels.size(); ++ j) - { - if(val_class_best < values[i][j]) - { - val_class_best = values[i][j]; - nb_class_best = j; - } - } - - output[indices[i]] = nb_class_best; - } - } -} -#endif -/// \endcond - -} - -} - -} - -#endif // CGAL_CLASSIFICATION_TENSORFLOW_NEURAL_NETWORK_CLASSIFIER_H diff --git a/Documentation/doc/Documentation/Third_party.txt b/Documentation/doc/Documentation/Third_party.txt index 57422452984..af301e37d20 100644 --- a/Documentation/doc/Documentation/Third_party.txt +++ b/Documentation/doc/Documentation/Third_party.txt @@ -256,27 +256,6 @@ executables should be linked with the CMake imported target The \sc{OpenCV} web site is `https://opencv.org/`. -\subsection thirdpartyTensorFlow TensorFlow - -\sc{TensorFlow} is a library designed for machine learning and deep learning. - -In \cgal, the C++ API of \sc{TensorFlow} is used by the \ref -PkgClassification package for neural network. The C++ API can be -compiled using CMake: it is distributed as part of the official -package and is located in `tensorflow/contrib/cmake`. Be sure to -enable and compile the following targets: - -- `tensorflow_BUILD_ALL_KERNELS` -- `tensorflow_BUILD_PYTHON_BINDINGS` -- `tensorflow_BUILD_SHARED_LIB`. - -In order to use \sc{TensorFlow} in \cgal programs, the executables -should be linked with the CMake imported target -`CGAL::TensorFlow_support` provided in -`CGAL_TensorFlow_support.cmake`. - -The \sc{TensorFlow} web site is `https://www.tensorflow.org/`. - \subsection thirdpartyMETIS METIS Version 5.1 or later diff --git a/Documentation/doc/Documentation/advanced/Configuration_variables.txt b/Documentation/doc/Documentation/advanced/Configuration_variables.txt index 2a880f1e488..b8e2e16bb83 100644 --- a/Documentation/doc/Documentation/advanced/Configuration_variables.txt +++ b/Documentation/doc/Documentation/advanced/Configuration_variables.txt @@ -354,15 +354,6 @@ If LASLIB is not automatically found, the following variables must be set: The environment variable `OPENCV_DIR` should be set to the directory containing the file `OpenCVConfig.cmake` provided by OpenCV. -\subsection installation_TensorFlow TensorFlow library - -If TensorFlow is not automatically found, the following variables must be set: - -| Variable | Description | Type | -| :- | :- | :- | -| `TensorFlow_INCLUDE_DIR` | Directory containing the directories `tensorflow/core`, `tensorflow/cc`, etc. | CMake | -| `TensorFlow_LIBRARY` | Full pathname of the compiled TensorFlow C++ library | CMake | - \subsection installation_SCIP SCIP library The environment variable `SCIP_DIR` should be set to the directory diff --git a/Installation/cmake/modules/CGAL_TensorFlow_support.cmake b/Installation/cmake/modules/CGAL_TensorFlow_support.cmake deleted file mode 100644 index 2a910c1257e..00000000000 --- a/Installation/cmake/modules/CGAL_TensorFlow_support.cmake +++ /dev/null @@ -1,7 +0,0 @@ -if(TensorFlow_FOUND AND NOT TARGET CGAL::TensorFlow_support) - add_library(CGAL::TensorFlow_support INTERFACE IMPORTED) - set_target_properties(CGAL::TensorFlow_support PROPERTIES - INTERFACE_COMPILE_DEFINITIONS "CGAL_LINKED_WITH_TENSORFLOW" - INTERFACE_INCLUDE_DIRECTORIES "${TensorFlow_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "${TensorFlow_LIBRARY}") -endif() diff --git a/Installation/cmake/modules/FindTensorFlow.cmake b/Installation/cmake/modules/FindTensorFlow.cmake deleted file mode 100644 index 2d63a0ea237..00000000000 --- a/Installation/cmake/modules/FindTensorFlow.cmake +++ /dev/null @@ -1,25 +0,0 @@ -include(FindPackageHandleStandardArgs) - -unset(TENSORFLOW_FOUND) - -find_path(TensorFlow_INCLUDE_DIR - NAMES - tensorflow/core - tensorflow/cc - third_party - HINTS - /usr/include/ - /usr/local/include/) - -find_library(TensorFlow_LIBRARY NAMES tensorflow_all - HINTS - /usr/lib - /usr/local/lib) - -find_package_handle_standard_args(TensorFlow DEFAULT_MSG TensorFlow_INCLUDE_DIR TensorFlow_LIBRARY) - -if(TENSORFLOW_FOUND) - set(TensorFlow_LIBRARIES ${TensorFlow_LIBRARY}) - set(TensorFlow_INCLUDE_DIRS ${TensorFlow_INCLUDE_DIR}) -endif() - diff --git a/Installation/cmake/modules/list_of_whitelisted_headers.cmake b/Installation/cmake/modules/list_of_whitelisted_headers.cmake index cf653a08abf..5aa71d9560b 100644 --- a/Installation/cmake/modules/list_of_whitelisted_headers.cmake +++ b/Installation/cmake/modules/list_of_whitelisted_headers.cmake @@ -1,7 +1,6 @@ set(list_of_whitelisted_headers_txt [=[ CGAL/SCIP_mixed_integer_program_traits.h CGAL/GLPK_mixed_integer_program_traits.h - CGAL/Classification/TensorFlow/Neural_network_classifier.h CGAL/Linear_cell_complex_constructors.h CGAL/CGAL_Ipelet_base.h CGAL/IO/read_las_points.h From 68a4aa3947f305fbb3e5337c3e94152b2823f967 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 23 Feb 2021 09:17:44 +0100 Subject: [PATCH 042/130] Remove TensorFlow from plugin --- .../Plugins/Classification/CMakeLists.txt | 19 ----- .../Classification/Classification_plugin.cpp | 39 ----------- .../Classification/Cluster_classification.cpp | 70 ------------------- .../Classification/Item_classification_base.h | 46 +----------- .../Point_set_item_classification.cpp | 70 ------------------- .../Surface_mesh_item_classification.cpp | 70 ------------------- 6 files changed, 2 insertions(+), 312 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/Classification/CMakeLists.txt index 04aff587cb9..7310bbee3b6 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/CMakeLists.txt @@ -26,21 +26,6 @@ if(TARGET CGAL::Eigen3_support) ) endif() - find_package(TensorFlow QUIET) - set_package_properties( - TensorFlow PROPERTIES - DESCRIPTION "A library for machine learning." - PURPOSE - "Enables the Neural Network predicate for the classification plugin.") - - include(CGAL_TensorFlow_support) - if(NOT TARGET CGAL::TensorFlow_support) - message( - STATUS - "NOTICE: TensorFlow not found, Neural Network predicate for classification won't be available." - ) - endif() - qt5_wrap_ui(classificationUI_FILES Classification_widget.ui Classification_advanced_widget.ui) polyhedron_demo_plugin( @@ -72,10 +57,6 @@ if(TARGET CGAL::Eigen3_support) target_link_libraries(classification_plugin PUBLIC CGAL::OpenCV_support) endif() - if(TARGET CGAL::TensorFlow_support) - target_link_libraries(classification_plugin PUBLIC CGAL::TensorFlow_support) - endif() - if(TARGET CGAL::TBB_support) target_link_libraries(classification_plugin PUBLIC CGAL::TBB_support) endif() diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Classification_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Classification/Classification_plugin.cpp index 209ced92bfe..2d410ceb0d4 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Classification_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Classification_plugin.cpp @@ -542,8 +542,6 @@ public Q_SLOTS: { if (classifier->text() == QString(CGAL_CLASSIFICATION_ETHZ_ID)) return CGAL_CLASSIFICATION_ETHZ_NUMBER; - if (classifier->text() == QString(CGAL_CLASSIFICATION_TENSORFLOW_ID)) - return CGAL_CLASSIFICATION_TENSORFLOW_NUMBER; if (classifier->text() == QString(CGAL_CLASSIFICATION_OPENCV_ID)) return CGAL_CLASSIFICATION_OPENCV_NUMBER; if (classifier->text() == QString(CGAL_CLASSIFICATION_SOWF_ID)) @@ -667,13 +665,6 @@ public Q_SLOTS: .arg(CV_MAJOR_VERSION) .arg(CV_MINOR_VERSION)); #endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - else if (classifier == CGAL_CLASSIFICATION_TENSORFLOW_NUMBER) // Neural Network (TensorFlow) - filename = QFileDialog::getSaveFileName(mw, - tr("Save classification configuration"), - tr("%1 (CGAL Neural Network config).xml").arg(classif->item()->name()), - "CGAL TensorFlow Neural Network classification configuration (*.xml);;"); -#endif if (filename == QString()) return; @@ -725,13 +716,6 @@ public Q_SLOTS: .arg(CV_MAJOR_VERSION) .arg(CV_MINOR_VERSION)); #endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - else if (classifier == CGAL_CLASSIFICATION_TENSORFLOW_NUMBER) // Neural Network (TensorFlow) - filename = QFileDialog::getOpenFileName(mw, - tr("Open CGAL Neural Network classification configuration"), - ".", - tr("CGAL Neural Network classification configuration (*.xml);;All Files (*)")); -#endif if (filename == QString()) return; @@ -1299,10 +1283,6 @@ public Q_SLOTS: QRadioButton* sowf = dialog.add (CGAL_CLASSIFICATION_SOWF_ID); -#ifdef CGAL_LINKED_WITH_TENSORFLOW - QRadioButton* tensorflow = dialog.add (CGAL_CLASSIFICATION_TENSORFLOW_ID); -#endif - #ifdef CGAL_LINKED_WITH_OPENCV QRadioButton* opencv = dialog.add (CGAL_CLASSIFICATION_OPENCV_ID); #endif @@ -1314,10 +1294,6 @@ public Q_SLOTS: classifier->setText(CGAL_CLASSIFICATION_ETHZ_ID); else if (sowf->isChecked()) classifier->setText(CGAL_CLASSIFICATION_SOWF_ID); -#ifdef CGAL_LINKED_WITH_TENSORFLOW - else if (tensorflow->isChecked()) - classifier->setText(CGAL_CLASSIFICATION_TENSORFLOW_ID); -#endif #ifdef CGAL_LINKED_WITH_OPENCV else if (opencv->isChecked()) classifier->setText(CGAL_CLASSIFICATION_OPENCV_ID); @@ -1361,21 +1337,6 @@ public Q_SLOTS: depth->setRange (1, 9999); depth->setValue (20); } - else if (classifier == CGAL_CLASSIFICATION_TENSORFLOW_NUMBER) // Neural Network (TensorFlow) - { - QSpinBox* trials = dialog.add ("Number of trials: ", "trials"); - trials->setRange (1, 99999); - trials->setValue (500); - DoubleEdit* rate = dialog.add ("Learning rate: ", "learning_rate"); - rate->setRange (0.00001, 10000.0); - rate->setValue (0.001); - QSpinBox* batch = dialog.add ("Batch size: ", "batch_size"); - batch->setRange (1, 2000000000); - batch->setValue (1000); - dialog.add ("Hidden layer size(s): ", "hidden_layers"); - QCheckBox* restart = dialog.add ("Restart from scratch: ", "restart"); - restart->setChecked (false); - } if (dialog.exec() != QDialog::Accepted) return; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp b/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp index cadc596ced0..f4456c791a4 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp @@ -230,9 +230,6 @@ Cluster_classification::Cluster_classification(Scene_points_with_normal_item* po #ifdef CGAL_LINKED_WITH_OPENCV m_random_forest = NULL; #endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - m_neural_network = NULL; -#endif // Compute neighborhood #if 0 @@ -288,10 +285,6 @@ Cluster_classification::~Cluster_classification() #ifdef CGAL_LINKED_WITH_OPENCV if (m_random_forest != NULL) delete m_random_forest; -#endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - if (m_neural_network != NULL) - delete m_neural_network; #endif if (m_points != NULL) { @@ -724,13 +717,6 @@ void Cluster_classification::compute_features (std::size_t nb_scales, float voxe m_random_forest = NULL; } #endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - if (m_neural_network != NULL) - { - delete m_neural_network; - m_neural_network = NULL; - } -#endif std::cerr << "Features = " << m_features.size() << std::endl; } @@ -871,51 +857,6 @@ void Cluster_classification::train(int classifier, const QMultipleInputDialog& d indices, m_label_probabilities); #endif } - else if (classifier == CGAL_CLASSIFICATION_TENSORFLOW_NUMBER) - { -#ifdef CGAL_LINKED_WITH_TENSORFLOW - if (m_neural_network != NULL) - { - if (m_neural_network->initialized()) - { - if (dialog.get("restart")->isChecked()) - { - delete m_neural_network; - m_neural_network = new Neural_network (m_labels, m_features); - } - } - else - { - delete m_neural_network; - m_neural_network = new Neural_network (m_labels, m_features); - } - } - else - m_neural_network = new Neural_network (m_labels, m_features); - - std::vector hidden_layers; - - std::string hl_input = dialog.get("hidden_layers")->text().toStdString(); - if (hl_input != "") - { - std::istringstream iss(hl_input); - int s; - while (iss >> s) - hidden_layers.push_back (std::size_t(s)); - } - - m_neural_network->train (training, - dialog.get("restart")->isChecked(), - dialog.get("trials")->value(), - dialog.get("learning_rate")->value(), - dialog.get("batch_size")->value(), - hidden_layers); - - CGAL::Classification::classify (m_clusters, - m_labels, *m_neural_network, - indices, m_label_probabilities); -#endif - } for (std::size_t i = 0; i < m_clusters.size(); ++ i) m_clusters[i].label() = indices[i]; @@ -957,17 +898,6 @@ bool Cluster_classification::run (int method, int classifier, run (method, *m_random_forest, subdivisions, smoothing); #endif } - else if (classifier == CGAL_CLASSIFICATION_TENSORFLOW_NUMBER) - { -#ifdef CGAL_LINKED_WITH_TENSORFLOW - if (m_neural_network == NULL) - { - std::cerr << "Error: TensorFlow Neural Network must be trained or have a configuration loaded first" << std::endl; - return false; - } - run (method, *m_neural_network, subdivisions, smoothing); -#endif - } return true; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h b/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h index 25fe070004d..876d73a94a4 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h @@ -15,10 +15,6 @@ #include #include -#ifdef CGAL_LINKED_WITH_TENSORFLOW -# include -#endif - #ifdef CGAL_LINKED_WITH_OPENCV # include #endif @@ -26,14 +22,11 @@ #define CGAL_CLASSIFICATION_ETHZ_ID "Random Forest (ETHZ)" #define CGAL_CLASSIFICATION_ETHZ_NUMBER 0 -#define CGAL_CLASSIFICATION_TENSORFLOW_ID "Neural Network (TensorFlow)" -#define CGAL_CLASSIFICATION_TENSORFLOW_NUMBER 1 - #define CGAL_CLASSIFICATION_OPENCV_ID "Random Forest (OpenCV)" -#define CGAL_CLASSIFICATION_OPENCV_NUMBER 2 +#define CGAL_CLASSIFICATION_OPENCV_NUMBER 1 #define CGAL_CLASSIFICATION_SOWF_ID "Sum of Weighted Features" -#define CGAL_CLASSIFICATION_SOWF_NUMBER 3 +#define CGAL_CLASSIFICATION_SOWF_NUMBER 2 class Item_classification_base @@ -49,9 +42,6 @@ public: #ifdef CGAL_LINKED_WITH_OPENCV typedef CGAL::Classification::OpenCV::Random_forest_classifier Random_forest; #endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - typedef CGAL::Classification::TensorFlow::Neural_network_classifier<> Neural_network; -#endif public: @@ -113,11 +103,6 @@ public: m_random_forest = new Random_forest (m_labels, m_features); #endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - delete m_neural_network; - m_neural_network = new Neural_network (m_labels, m_features); -#endif - return label_qcolor (m_labels[m_labels.size() - 1]); } virtual void remove_label (std::size_t position) @@ -135,10 +120,6 @@ public: m_random_forest = new Random_forest (m_labels, m_features); #endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - delete m_neural_network; - m_neural_network = new Neural_network (m_labels, m_features); -#endif } virtual void clear_labels () @@ -156,10 +137,6 @@ public: m_random_forest = new Random_forest (m_labels, m_features); #endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - delete m_neural_network; - m_neural_network = new Neural_network (m_labels, m_features); -#endif } std::size_t number_of_labels() const { return m_labels.size(); } Label_handle label(std::size_t i) { return m_labels[i]; } @@ -206,13 +183,6 @@ public: { #ifdef CGAL_LINKED_WITH_OPENCV m_random_forest->save_configuration (filename); -#endif - } - else if (classifier == CGAL_CLASSIFICATION_TENSORFLOW_NUMBER) - { -#ifdef CGAL_LINKED_WITH_TENSORFLOW - std::ofstream f (filename); - m_neural_network->save_configuration (f); #endif } } @@ -247,15 +217,6 @@ public: { #ifdef CGAL_LINKED_WITH_OPENCV m_random_forest->load_configuration (filename); -#endif - } - else if (classifier == CGAL_CLASSIFICATION_TENSORFLOW_NUMBER) - { -#ifdef CGAL_LINKED_WITH_TENSORFLOW - if (m_neural_network == NULL) - m_neural_network = new Neural_network (m_labels, m_features); - std::ifstream f (filename); - m_neural_network->load_configuration (f, true); #endif } } @@ -283,9 +244,6 @@ protected: #ifdef CGAL_LINKED_WITH_OPENCV Random_forest* m_random_forest; #endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - Neural_network* m_neural_network; -#endif }; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.cpp b/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.cpp index 6b0ef75dbfc..7fed79d5f35 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.cpp @@ -217,9 +217,6 @@ Point_set_item_classification::Point_set_item_classification(Scene_points_with_n #ifdef CGAL_LINKED_WITH_OPENCV m_random_forest = NULL; #endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - m_neural_network = NULL; -#endif } @@ -232,10 +229,6 @@ Point_set_item_classification::~Point_set_item_classification() #ifdef CGAL_LINKED_WITH_OPENCV if (m_random_forest != NULL) delete m_random_forest; -#endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - if (m_neural_network != NULL) - delete m_neural_network; #endif if (m_generator != NULL) delete m_generator; @@ -578,13 +571,6 @@ void Point_set_item_classification::compute_features (std::size_t nb_scales, flo m_random_forest = NULL; } #endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - if (m_neural_network != NULL) - { - delete m_neural_network; - m_neural_network = NULL; - } -#endif t.stop(); std::cerr << m_features.size() << " feature(s) computed in " << t.time() << " second(s)" << std::endl; @@ -766,51 +752,6 @@ void Point_set_item_classification::train(int classifier, const QMultipleInputDi indices, m_label_probabilities); #endif } - else if (classifier == CGAL_CLASSIFICATION_TENSORFLOW_NUMBER) - { -#ifdef CGAL_LINKED_WITH_TENSORFLOW - if (m_neural_network != NULL) - { - if (m_neural_network->initialized()) - { - if (dialog.get("restart")->isChecked()) - { - delete m_neural_network; - m_neural_network = new Neural_network (m_labels, m_features); - } - } - else - { - delete m_neural_network; - m_neural_network = new Neural_network (m_labels, m_features); - } - } - else - m_neural_network = new Neural_network (m_labels, m_features); - - std::vector hidden_layers; - - std::string hl_input = dialog.get("hidden_layers")->text().toStdString(); - if (hl_input != "") - { - std::istringstream iss(hl_input); - int s; - while (iss >> s) - hidden_layers.push_back (std::size_t(s)); - } - - m_neural_network->train (training, - dialog.get("restart")->isChecked(), - dialog.get("trials")->value(), - dialog.get("learning_rate")->value(), - dialog.get("batch_size")->value(), - hidden_layers); - - CGAL::Classification::classify (*(m_points->point_set()), - m_labels, *m_neural_network, - indices, m_label_probabilities); -#endif - } for (Point_set::const_iterator it = m_points->point_set()->begin(); it != m_points->point_set()->first_selected(); ++ it) @@ -853,17 +794,6 @@ bool Point_set_item_classification::run (int method, int classifier, run (method, *m_random_forest, subdivisions, smoothing); #endif } - else if (classifier == CGAL_CLASSIFICATION_TENSORFLOW_NUMBER) - { -#ifdef CGAL_LINKED_WITH_TENSORFLOW - if (m_neural_network == NULL) - { - std::cerr << "Error: TensorFlow Neural Network must be trained or have a configuration loaded first" << std::endl; - return false; - } - run (method, *m_neural_network, subdivisions, smoothing); -#endif - } return true; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Surface_mesh_item_classification.cpp b/Polyhedron/demo/Polyhedron/Plugins/Classification/Surface_mesh_item_classification.cpp index a8e28ab15fb..376d767c1e9 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Surface_mesh_item_classification.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Surface_mesh_item_classification.cpp @@ -34,9 +34,6 @@ Surface_mesh_item_classification::Surface_mesh_item_classification(Scene_surface #ifdef CGAL_LINKED_WITH_OPENCV m_random_forest = NULL; #endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - m_neural_network = NULL; -#endif } @@ -49,10 +46,6 @@ Surface_mesh_item_classification::~Surface_mesh_item_classification() #ifdef CGAL_LINKED_WITH_OPENCV if (m_random_forest != NULL) delete m_random_forest; -#endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - if (m_neural_network != NULL) - delete m_neural_network; #endif if (m_generator != NULL) delete m_generator; @@ -248,13 +241,6 @@ void Surface_mesh_item_classification::compute_features (std::size_t nb_scales, delete m_random_forest; m_random_forest = NULL; } -#endif -#ifdef CGAL_LINKED_WITH_TENSORFLOW - if (m_neural_network != NULL) - { - delete m_neural_network; - m_neural_network = NULL; - } #endif std::cerr << "Features = " << m_features.size() << std::endl; } @@ -327,51 +313,6 @@ void Surface_mesh_item_classification::train (int classifier, const QMultipleInp indices, m_label_probabilities); #endif } - else if (classifier == CGAL_CLASSIFICATION_TENSORFLOW_NUMBER) - { -#ifdef CGAL_LINKED_WITH_TENSORFLOW - if (m_neural_network != NULL) - { - if (m_neural_network->initialized()) - { - if (dialog.get("restart")->isChecked()) - { - delete m_neural_network; - m_neural_network = new Neural_network (m_labels, m_features); - } - } - else - { - delete m_neural_network; - m_neural_network = new Neural_network (m_labels, m_features); - } - } - else - m_neural_network = new Neural_network (m_labels, m_features); - - std::vector hidden_layers; - - std::string hl_input = dialog.get("hidden_layers")->text().toStdString(); - if (hl_input != "") - { - std::istringstream iss(hl_input); - int s; - while (iss >> s) - hidden_layers.push_back (std::size_t(s)); - } - - m_neural_network->train (training, - dialog.get("restart")->isChecked(), - dialog.get("trials")->value(), - dialog.get("learning_rate")->value(), - dialog.get("batch_size")->value(), - hidden_layers); - - CGAL::Classification::classify (m_mesh->polyhedron()->faces(), - m_labels, *m_neural_network, - indices, m_label_probabilities); -#endif - } for(face_descriptor fd : faces(*(m_mesh->polyhedron()))) m_classif[fd] = indices[fd]; @@ -411,17 +352,6 @@ bool Surface_mesh_item_classification::run (int method, int classifier, run (method, *m_random_forest, subdivisions, smoothing); #endif } - else if (classifier == CGAL_CLASSIFICATION_TENSORFLOW_NUMBER) - { -#ifdef CGAL_LINKED_WITH_TENSORFLOW - if (m_neural_network == NULL) - { - std::cerr << "Error: TensorFlow Neural Network must be trained or have a configuration loaded first" << std::endl; - return false; - } - run (method, *m_neural_network, subdivisions, smoothing); -#endif - } return true; } From 19e5e4a16e1331ade755b4c29b2b2fe8a2b4264c Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 2 Mar 2021 12:25:28 +0000 Subject: [PATCH 043/130] Use flaat_set and put it outside the loop --- .../Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h index 51b6ebba683..9e704870c18 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -177,14 +178,16 @@ bool is_polygon_soup_a_polygon_mesh(const PolygonRange& polygons) //check there is no duplicated ordered edge, and //check there is no polygon with twice the same vertex std::set > edge_set; + boost::container::flat_set polygon_vertices; V_ID max_id = 0; + for(const Polygon& polygon : polygons) { std::size_t nb_edges = boost::size(polygon); if(nb_edges < 3) return false; - std::set polygon_vertices; + polygon_vertices.clear(); V_ID prev = *std::prev(boost::end(polygon)); for(V_ID id : polygon) { From 10f454d98384dfacb2cd5a06b1f7df6a7ff6ea4a Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 2 Mar 2021 13:09:45 +0000 Subject: [PATCH 044/130] reserve(8) for incident faces to a vertex --- .../include/CGAL/Polygon_mesh_processing/compute_normal.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h index e31e91db8cd..7f438d4d5bf 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h @@ -506,6 +506,7 @@ compute_vertex_normal_most_visible_min_circle(typename boost::graph_traits incident_faces; + incident_faces.reserve(8); for(face_descriptor f : CGAL::faces_around_target(halfedge(v, pmesh), pmesh)) { if(f == boost::graph_traits::null_face()) From 5e2a580551527336ff8dd13357b1465ad4334d23 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 2 Mar 2021 13:17:53 +0000 Subject: [PATCH 045/130] map -> unordered_map --- .../include/CGAL/Polygon_mesh_processing/compute_normal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h index 7f438d4d5bf..bfb8f831238 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef CGAL_PMP_COMPUTE_NORMAL_DEBUG_PP # ifndef CGAL_PMP_COMPUTE_NORMAL_DEBUG @@ -670,7 +671,7 @@ compute_vertex_normal(typename boost::graph_traits::vertex_descript VPMap vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(vertex_point, pmesh)); - typedef std::map Face_vector_map; + typedef std::unordered_map Face_vector_map; typedef boost::associative_property_map Default_map; typedef typename internal_np::Lookup_named_param_def Date: Tue, 2 Mar 2021 23:28:48 +0900 Subject: [PATCH 046/130] Patch for intervals on wasm --- Number_types/include/CGAL/FPU.h | 57 ++++++++++++++++--- Number_types/include/CGAL/Interval_nt.h | 3 +- .../Polygon_mesh_processing/CMakeLists.txt | 1 + .../corefinement_polyhedron_union.cpp | 6 +- 4 files changed, 56 insertions(+), 11 deletions(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index 6d5f02a3075..e4e45430f98 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -1,3 +1,8 @@ +// TODO: Remove +#ifndef CGAL_ALWAYS_ROUND_TO_NEAREST +#define CGAL_ALWAYS_ROUND_TO_NEAREST +#endif + // Copyright (c) 1998-2019 // Utrecht University (The Netherlands), // ETH Zurich (Switzerland), @@ -117,7 +122,7 @@ extern "C" { #if defined(CGAL_HAS_SSE2) && (defined(__x86_64__) || defined(_M_X64)) # define CGAL_USE_SSE2 1 #endif - +#undef CGAL_USE_SSE2 #ifdef CGAL_CFG_DENORMALS_COMPILE_BUG double& get_static_minimin(); // Defined in Interval_arithmetic_impl.h #endif @@ -347,16 +352,17 @@ inline double IA_bug_sqrt(double d) // With GCC, we can do slightly better : test with __builtin_constant_p() // that both arguments are constant before stopping one of them. // Use inline functions instead ? -#define CGAL_IA_ADD(a,b) CGAL_IA_FORCE_TO_DOUBLE((a)+CGAL_IA_STOP_CPROP(b)) -#define CGAL_IA_SUB(a,b) CGAL_IA_FORCE_TO_DOUBLE(CGAL_IA_STOP_CPROP(a)-(b)) -#define CGAL_IA_MUL(a,b) CGAL_IA_FORCE_TO_DOUBLE(CGAL_IA_STOP_CPROP(a)*CGAL_IA_STOP_CPROP(b)) -#define CGAL_IA_DIV(a,b) CGAL_IA_FORCE_TO_DOUBLE(CGAL_IA_STOP_CPROP(a)/CGAL_IA_STOP_CPROP(b)) +inline double CGAL_IA_UP(double d){return nextafter(d,std::numeric_limits::infinity());} +#define CGAL_IA_ADD(a,b) CGAL_IA_UP((a)+CGAL_IA_STOP_CPROP(b)) +#define CGAL_IA_SUB(a,b) CGAL_IA_UP(CGAL_IA_STOP_CPROP(a)-(b)) +#define CGAL_IA_MUL(a,b) CGAL_IA_UP(CGAL_IA_STOP_CPROP(a)*CGAL_IA_STOP_CPROP(b)) +#define CGAL_IA_DIV(a,b) CGAL_IA_UP(CGAL_IA_STOP_CPROP(a)/CGAL_IA_STOP_CPROP(b)) inline double CGAL_IA_SQUARE(double a){ double b = CGAL_IA_STOP_CPROP(a); // only once - return CGAL_IA_FORCE_TO_DOUBLE(b*b); + return CGAL_IA_UP(b*b); } #define CGAL_IA_SQRT(a) \ - CGAL_IA_FORCE_TO_DOUBLE(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(a))) + CGAL_IA_UP(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(a))) #if defined CGAL_SAFE_SSE2 @@ -478,6 +484,9 @@ FPU_get_cw (void) { FPU_CW_t cw; CGAL_IA_GETFPCW(cw); +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + assert(cw == CGAL_FE_TONEAREST); +#endif return cw; } @@ -487,15 +496,29 @@ inline void FPU_set_cw (FPU_CW_t cw) { +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + assert(cw == CGAL_FE_TONEAREST); + assert(FPU_get_cw() == CGAL_FE_TONEAREST); +#endif CGAL_IA_SETFPCW(cw); +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + assert(FPU_get_cw() == CGAL_FE_TONEAREST); +#endif } inline FPU_CW_t FPU_get_and_set_cw (FPU_CW_t cw) { +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + assert(cw == CGAL_FE_TONEAREST); + assert(FPU_get_cw() == CGAL_FE_TONEAREST); +#endif FPU_CW_t old = FPU_get_cw(); FPU_set_cw(cw); +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + assert(FPU_get_cw() == CGAL_FE_TONEAREST); +#endif return old; } @@ -508,7 +531,13 @@ template struct Protect_FPU_rounding; template <> struct Protect_FPU_rounding { - Protect_FPU_rounding(FPU_CW_t r = CGAL_FE_UPWARD) + Protect_FPU_rounding( +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + FPU_CW_t r = CGAL_FE_TONEAREST +#else + FPU_CW_t r = CGAL_FE_UPWARD +#endif + ) : backup( FPU_get_and_set_cw(r) ) {} ~Protect_FPU_rounding() @@ -524,7 +553,11 @@ template <> struct Protect_FPU_rounding { Protect_FPU_rounding() {} +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + Protect_FPU_rounding(FPU_CW_t /*= CGAL_FE_TONEAREST*/) {} +#else Protect_FPU_rounding(FPU_CW_t /*= CGAL_FE_UPWARD*/) {} +#endif }; @@ -538,13 +571,21 @@ struct Checked_protect_FPU_rounding { Checked_protect_FPU_rounding() { +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST); +#else CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_UPWARD); +#endif } Checked_protect_FPU_rounding(FPU_CW_t r) : Protect_FPU_rounding(r) { +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST); +#else CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_UPWARD); +#endif } }; diff --git a/Number_types/include/CGAL/Interval_nt.h b/Number_types/include/CGAL/Interval_nt.h index 8a51e7cd860..e94d1c6cb2b 100644 --- a/Number_types/include/CGAL/Interval_nt.h +++ b/Number_types/include/CGAL/Interval_nt.h @@ -722,6 +722,7 @@ private: Interval_nt operator/ (const Interval_nt &a, const Interval_nt & b) { + assert(FPU_get_cw() == CGAL_FE_TONEAREST); #if 0 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88626 if(CGAL_CST_TRUE(a.is_point())) @@ -1148,7 +1149,7 @@ namespace INTERN_INTERVAL_NT { // - compute y = CGAL_IA_SQUARE(x) // - if y==d.inf() use x, else use -CGAL_IA_SUB(CGAL_IA_MIN_DOUBLE,x) FPU_set_cw(CGAL_FE_DOWNWARD); - double i = (d.inf() > 0.0) ? CGAL_IA_SQRT(d.inf()) : 0.0; + double i = (d.inf() > 0.0) ? nextafter(std::sqrt(d.inf()), 0.) : 0.0; FPU_set_cw(CGAL_FE_UPWARD); #endif return Interval_nt(i, CGAL_IA_SQRT(d.sup())); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index e34c91b8892..3615a74a4ef 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -76,6 +76,7 @@ create_single_source_cgal_program("corefinement_SM.cpp") create_single_source_cgal_program("corefinement_consecutive_bool_op.cpp") create_single_source_cgal_program("corefinement_difference_remeshed.cpp") create_single_source_cgal_program("corefinement_mesh_union.cpp") +create_single_source_cgal_program("cgal.cc") create_single_source_cgal_program( "corefinement_mesh_union_and_intersection.cpp") create_single_source_cgal_program("corefinement_mesh_union_with_attributes.cpp") diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_polyhedron_union.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_polyhedron_union.cpp index 71bdd4cd2f7..d337bdf637a 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_polyhedron_union.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_polyhedron_union.cpp @@ -1,4 +1,5 @@ -#include +// #include +#include #include #include @@ -8,7 +9,8 @@ #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +// typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Exact_predicates_exact_constructions_kernel K; typedef CGAL::Polyhedron_3 Mesh; namespace PMP = CGAL::Polygon_mesh_processing; From 95ea922de87b84f7ba2ed08d97d01f6b06048b81 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 2 Mar 2021 14:40:22 +0000 Subject: [PATCH 047/130] Important gain for Euler::add_face() --- BGL/include/CGAL/boost/graph/Euler_operations.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/Euler_operations.h b/BGL/include/CGAL/boost/graph/Euler_operations.h index 8d5268da6e0..beed0ecfb39 100644 --- a/BGL/include/CGAL/boost/graph/Euler_operations.h +++ b/BGL/include/CGAL/boost/graph/Euler_operations.h @@ -737,9 +737,9 @@ add_face(const VertexRange& vr, Graph& g) patch_start, patch_end; // cache for set_next and vertex' set_halfedge typedef std::pair NextCacheEntry; - typedef std::vector NextCache; + typedef boost::container::small_vector NextCache; NextCache next_cache; - next_cache.reserve(3 * n); + //next_cache.reserve(3 * n); Unfortunately small_vector has no reserve // re-link patches if necessary for (unsigned int i = 0, ii = 1; i Date: Wed, 3 Mar 2021 00:32:09 +0900 Subject: [PATCH 048/130] wip --- Number_types/include/CGAL/Interval_nt.h | 10 +++++++--- ...aunay_triangulation_cell_base_with_circumcenter_3.h | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Number_types/include/CGAL/Interval_nt.h b/Number_types/include/CGAL/Interval_nt.h index e94d1c6cb2b..1b7a836c14e 100644 --- a/Number_types/include/CGAL/Interval_nt.h +++ b/Number_types/include/CGAL/Interval_nt.h @@ -1142,16 +1142,20 @@ namespace INTERN_INTERVAL_NT { // it helps significantly, it might even hurt by introducing a // dependency. } -#else +#else // no __AVX512F__ // TODO: Alternative for computing CGAL_IA_SQRT_DOWN(d.inf()) exactly // without changing the rounding mode: // - compute x = CGAL_IA_SQRT(d.inf()) // - compute y = CGAL_IA_SQUARE(x) // - if y==d.inf() use x, else use -CGAL_IA_SUB(CGAL_IA_MIN_DOUBLE,x) - FPU_set_cw(CGAL_FE_DOWNWARD); +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST double i = (d.inf() > 0.0) ? nextafter(std::sqrt(d.inf()), 0.) : 0.0; +#else // no CGAL_ALWAYS_ROUND_TO_NEAREST + FPU_set_cw(CGAL_FE_DOWNWARD); + double i = (d.inf() > 0.0) ? CGAL_IA_SQRT(d.inf()) : 0.0; FPU_set_cw(CGAL_FE_UPWARD); -#endif +#endif // no CGAL_ALWAYS_ROUND_TO_NEAREST +#endif // no __AVX512F__ return Interval_nt(i, CGAL_IA_SQRT(d.sup())); } diff --git a/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h b/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h index 14fc74d8490..1c437177712 100644 --- a/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h +++ b/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h @@ -130,7 +130,7 @@ public: circumcenter_ = new Point(this->Cb::circumcenter(gt)); } else { CGAL_expensive_assertion( - this->Cb::circumcenter(gt) == *circumcenter); + this->Cb::circumcenter(gt) == *circumcenter_); } return *circumcenter_; From a945c4f840f8ee89f4ef4f4be2c040c3e98fb8ba Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 2 Mar 2021 21:30:36 +0000 Subject: [PATCH 049/130] small_vector has reserve() --- BGL/include/CGAL/boost/graph/Euler_operations.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BGL/include/CGAL/boost/graph/Euler_operations.h b/BGL/include/CGAL/boost/graph/Euler_operations.h index beed0ecfb39..d26d6a4bceb 100644 --- a/BGL/include/CGAL/boost/graph/Euler_operations.h +++ b/BGL/include/CGAL/boost/graph/Euler_operations.h @@ -739,7 +739,7 @@ add_face(const VertexRange& vr, Graph& g) typedef std::pair NextCacheEntry; typedef boost::container::small_vector NextCache; NextCache next_cache; - //next_cache.reserve(3 * n); Unfortunately small_vector has no reserve + next_cache.reserve(3 * n); // re-link patches if necessary for (unsigned int i = 0, ii = 1; i Date: Tue, 2 Mar 2021 21:56:54 +0000 Subject: [PATCH 050/130] Replace geometric by combinatorial test --- .../internal/Isotropic_remeshing/remesh_impl.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h index 1a0fa1d3b8f..ce1636b62d0 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h @@ -1393,6 +1393,7 @@ private: bool collapse_would_invert_face(const halfedge_descriptor& h) const { + vertex_descriptor tv = target(h, mesh_); typename boost::property_traits::reference s = get(vpmap_, source(h, mesh_)); //s for source typename boost::property_traits::reference @@ -1409,16 +1410,21 @@ private: if (face(hd, mesh_) == boost::graph_traits::null_face()) continue; + vertex_descriptor tnhd = target(next(hd, mesh_), mesh_); + vertex_descriptor tnnhd = target(next(next(hd, mesh_), mesh_), mesh_); typename boost::property_traits::reference - p = get(vpmap_, target(next(hd, mesh_), mesh_)); + p = get(vpmap_, tnhd); typename boost::property_traits::reference - q = get(vpmap_, target(next(next(hd, mesh_), mesh_), mesh_)); + q = get(vpmap_, tnnhd); #ifdef CGAL_PMP_REMESHING_DEBUG CGAL_assertion((Triangle_3(t, p, q).is_degenerate()) == GeomTraits().collinear_3_object()(t, p, q)); #endif + if((tv == tnnhd) || (tv == tnhd)) + continue; + if ( GeomTraits().collinear_3_object()(s, p, q) || GeomTraits().collinear_3_object()(t, p, q)) continue; From d3d24faf040bb2ce7f5cee4851e03155bc8abf61 Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Wed, 3 Mar 2021 19:45:40 +0900 Subject: [PATCH 051/130] Add tests --- Number_types/include/CGAL/FPU.h | 66 ++++++---------- Number_types/test/Number_types/CMakeLists.txt | 1 + .../test/Number_types/Interval_nt.cpp | 75 ++++++++++++++++++- .../test/Number_types/Interval_nt_nearest.cpp | 2 + .../Polygon_mesh_processing/CMakeLists.txt | 1 + ...t_corefinement_and_constraints_nearest.cpp | 2 + 6 files changed, 103 insertions(+), 44 deletions(-) create mode 100644 Number_types/test/Number_types/Interval_nt_nearest.cpp create mode 100644 Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_and_constraints_nearest.cpp diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index e4e45430f98..0d7bf61e60c 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -1,8 +1,3 @@ -// TODO: Remove -#ifndef CGAL_ALWAYS_ROUND_TO_NEAREST -#define CGAL_ALWAYS_ROUND_TO_NEAREST -#endif - // Copyright (c) 1998-2019 // Utrecht University (The Netherlands), // ETH Zurich (Switzerland), @@ -122,7 +117,6 @@ extern "C" { #if defined(CGAL_HAS_SSE2) && (defined(__x86_64__) || defined(_M_X64)) # define CGAL_USE_SSE2 1 #endif -#undef CGAL_USE_SSE2 #ifdef CGAL_CFG_DENORMALS_COMPILE_BUG double& get_static_minimin(); // Defined in Interval_arithmetic_impl.h #endif @@ -352,7 +346,17 @@ inline double IA_bug_sqrt(double d) // With GCC, we can do slightly better : test with __builtin_constant_p() // that both arguments are constant before stopping one of them. // Use inline functions instead ? -inline double CGAL_IA_UP(double d){return nextafter(d,std::numeric_limits::infinity());} +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST +inline double CGAL_IA_UP(double d) +{ + return nextafter(d,std::numeric_limits::infinity()); +} +#else +inline double CGAL_IA_UP(double d) +{ + return d; +} +#endif #define CGAL_IA_ADD(a,b) CGAL_IA_UP((a)+CGAL_IA_STOP_CPROP(b)) #define CGAL_IA_SUB(a,b) CGAL_IA_UP(CGAL_IA_STOP_CPROP(a)-(b)) #define CGAL_IA_MUL(a,b) CGAL_IA_UP(CGAL_IA_STOP_CPROP(a)*CGAL_IA_STOP_CPROP(b)) @@ -496,29 +500,15 @@ inline void FPU_set_cw (FPU_CW_t cw) { -#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - assert(cw == CGAL_FE_TONEAREST); - assert(FPU_get_cw() == CGAL_FE_TONEAREST); -#endif CGAL_IA_SETFPCW(cw); -#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - assert(FPU_get_cw() == CGAL_FE_TONEAREST); -#endif } inline FPU_CW_t FPU_get_and_set_cw (FPU_CW_t cw) { -#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - assert(cw == CGAL_FE_TONEAREST); - assert(FPU_get_cw() == CGAL_FE_TONEAREST); -#endif FPU_CW_t old = FPU_get_cw(); FPU_set_cw(cw); -#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - assert(FPU_get_cw() == CGAL_FE_TONEAREST); -#endif return old; } @@ -526,18 +516,18 @@ FPU_get_and_set_cw (FPU_CW_t cw) // A class whose constructor sets the FPU mode to +inf, saves a backup of it, // and whose destructor resets it back to the saved state. +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST +#define CGAL_FE_PROTECTED CGAL_FE_TONEAREST +#else +#define CGAL_FE_PROTECTED CGAL_FE_UPWARD +#endif + template struct Protect_FPU_rounding; template <> struct Protect_FPU_rounding { - Protect_FPU_rounding( -#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - FPU_CW_t r = CGAL_FE_TONEAREST -#else - FPU_CW_t r = CGAL_FE_UPWARD -#endif - ) + Protect_FPU_rounding(FPU_CW_t r = CGAL_FE_PROTECTED) : backup( FPU_get_and_set_cw(r) ) {} ~Protect_FPU_rounding() @@ -553,11 +543,7 @@ template <> struct Protect_FPU_rounding { Protect_FPU_rounding() {} -#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - Protect_FPU_rounding(FPU_CW_t /*= CGAL_FE_TONEAREST*/) {} -#else - Protect_FPU_rounding(FPU_CW_t /*= CGAL_FE_UPWARD*/) {} -#endif + Protect_FPU_rounding(FPU_CW_t /*= CGAL_FE_PROTECTED */) {} }; @@ -571,21 +557,13 @@ struct Checked_protect_FPU_rounding { Checked_protect_FPU_rounding() { -#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST); -#else - CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_UPWARD); -#endif + CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_PROTECTED); } Checked_protect_FPU_rounding(FPU_CW_t r) : Protect_FPU_rounding(r) { -#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST); -#else - CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_UPWARD); -#endif + CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_PROTECTED); } }; @@ -596,6 +574,8 @@ struct Checked_protect_FPU_rounding // Its destructor restores the FPU state as it was previously. // Note that this affects "long double" as well, and other potential side effects. // And note that it does not (cannot) "fix" the same problem for the exponent. +// +// (How should this interact with ALWAYS_ROUND_TO_NEAREST?) struct Set_ieee_double_precision #ifdef CGAL_FPU_HAS_EXCESS_PRECISION diff --git a/Number_types/test/Number_types/CMakeLists.txt b/Number_types/test/Number_types/CMakeLists.txt index fdc0448365e..aa51590da93 100644 --- a/Number_types/test/Number_types/CMakeLists.txt +++ b/Number_types/test/Number_types/CMakeLists.txt @@ -31,6 +31,7 @@ create_single_source_cgal_program("Gmpz.cpp") create_single_source_cgal_program("Gmpzf_new.cpp") create_single_source_cgal_program("int.cpp") create_single_source_cgal_program("Interval_nt.cpp") +create_single_source_cgal_program("Interval_nt_nearest.cpp") create_single_source_cgal_program("Interval_nt_new.cpp") create_single_source_cgal_program("ioformat.cpp") create_single_source_cgal_program("known_bit_size_integers.cpp") diff --git a/Number_types/test/Number_types/Interval_nt.cpp b/Number_types/test/Number_types/Interval_nt.cpp index d0a470c1320..4a56129d31f 100644 --- a/Number_types/test/Number_types/Interval_nt.cpp +++ b/Number_types/test/Number_types/Interval_nt.cpp @@ -36,41 +36,71 @@ bool spiral_test() // Tests for constant propagation through intervals. // This must not be performed otherwise rounding modes are ignored. -// Non-inlined operators usually stop cprop (*, /, sqrt). +// On the other hand, if we always round to nearest, then constant propagation +// is desirable. +// Note: Non-inlined operators usually stop cprop (*, /, sqrt). template < typename IA_nt > bool cprop_test() { // Testing cprop through +. IA_nt add = IA_nt(0.00001)+10.1; bool good_add = !add.is_point(); +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + if (good_add) + std::cerr << "ERROR : No constant propagation through operator+." < 2/(double(1<<30)*(1<<22))) { + return false; + } + if (-2/(double(1<<30)*(1<<22)) > a.inf()) { + return false; + } + return true; +#else DEBUG ( std::cout << "i = " << i << std::endl; std::cout << "sup = -inf : " << (a.sup() == -a.inf()) << std::endl; std::cout << "width ok ? : " << (-a.inf() == 1/(double(1<<30)*(1<<22))) << std::endl; ) // DEBUG return i==54 && a.sup() == - a.inf() && a.sup() == 1/(double(1<<30)*(1<<22)); +#endif } @@ -139,6 +189,15 @@ bool overflow_test() DEBUG( std::cout << "f = " << f << std::endl; ) } +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + return a.is_same(IA_nt(std::numeric_limits::infinity(), std::numeric_limits::infinity())) && + b.is_same(IA_nt(std::numeric_limits::infinity(), std::numeric_limits::infinity())) && + c.is_same(IA_nt(-std::numeric_limits::infinity(), std::numeric_limits::infinity())) && + d.is_same(IA_nt(-std::numeric_limits::infinity(), std::numeric_limits::infinity())) && + e.is_same(IA_nt(-std::numeric_limits::infinity(), std::numeric_limits::infinity())) && + f.is_same(IA_nt(std::numeric_limits::infinity(), std::numeric_limits::infinity())) && + g.is_same(-f); +#else return a.is_same(IA_nt(CGAL_IA_MAX_DOUBLE, std::numeric_limits::infinity())) && b.is_same(IA_nt(CGAL_IA_MAX_DOUBLE, std::numeric_limits::infinity())) && c.is_same(IA_nt::largest()) && @@ -146,6 +205,7 @@ bool overflow_test() e.is_same(IA_nt::largest()) && f.is_same(IA_nt(CGAL_IA_MAX_DOUBLE, std::numeric_limits::infinity())) && g.is_same(-f); +#endif } @@ -164,9 +224,15 @@ bool underflow_test() for (i=0; i<20; i++) b = b * b; for (i=0; i<20; i++) c = CGAL_NTS square(c); +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + return a.is_same(IA_nt(0, 0)) + && b.is_same(IA_nt(0, 0)) + && c.is_same(IA_nt(0, 0)); +#else return a.is_same(IA_nt(0, CGAL_IA_MIN_DOUBLE)) && b.is_same(IA_nt::smallest()) && c.is_same(IA_nt(0, CGAL_IA_MIN_DOUBLE)); +#endif } @@ -432,10 +498,17 @@ bool test () int main() { +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + std::cout << "Stress-testing the class Interval_nt<> always rounding to nearest.\n"; + bool ok = test >(); + std::cout << "\nStress-testing the class Interval_nt_advanced always rounding to nearest.\n"; + ok &= test(); +#else std::cout << "Stress-testing the class Interval_nt<>.\n"; bool ok = test >(); std::cout << "\nStress-testing the class Interval_nt_advanced.\n"; ok &= test(); +#endif return !ok; } diff --git a/Number_types/test/Number_types/Interval_nt_nearest.cpp b/Number_types/test/Number_types/Interval_nt_nearest.cpp new file mode 100644 index 00000000000..fe5ce657c6e --- /dev/null +++ b/Number_types/test/Number_types/Interval_nt_nearest.cpp @@ -0,0 +1,2 @@ +#define CGAL_ALWAYS_ROUND_TO_NEAREST +#include "Interval_nt.cpp" diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index 08a65b9ffc4..103d6eedb72 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -77,6 +77,7 @@ create_single_source_cgal_program("triangulate_faces_hole_filling_all_search_tes create_single_source_cgal_program("test_pmp_remove_border_edge.cpp") create_single_source_cgal_program("test_pmp_distance.cpp") create_single_source_cgal_program("test_corefinement_and_constraints.cpp") +create_single_source_cgal_program("test_corefinement_and_constraints_nearest.cpp") create_single_source_cgal_program("test_corefinement_bool_op.cpp") create_single_source_cgal_program("test_corefine.cpp") create_single_source_cgal_program("test_coref_epic_points_identity.cpp") diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_and_constraints_nearest.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_and_constraints_nearest.cpp new file mode 100644 index 00000000000..b3c56b5c542 --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_and_constraints_nearest.cpp @@ -0,0 +1,2 @@ +#define CGAL_ALWAYS_ROUND_TO_NEAREST +#include "test_corefinement_and_constraints.cpp" From ecda444672c6b6922f0c96bfcd9ec655721e75b6 Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Wed, 3 Mar 2021 19:51:58 +0900 Subject: [PATCH 052/130] Clean up --- Number_types/include/CGAL/FPU.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index 0d7bf61e60c..501b63999a9 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -349,11 +349,16 @@ inline double IA_bug_sqrt(double d) #ifdef CGAL_ALWAYS_ROUND_TO_NEAREST inline double CGAL_IA_UP(double d) { - return nextafter(d,std::numeric_limits::infinity()); + // In round-to-nearest mode we find the successor instead. + // This preserves the interval invariants, but is more + // expensive and conservative. + return nextafter(d, std::numeric_limits::infinity()); } #else inline double CGAL_IA_UP(double d) { + // In round-upward mode we can rely on the hardware + // to do the job. return d; } #endif @@ -488,9 +493,6 @@ FPU_get_cw (void) { FPU_CW_t cw; CGAL_IA_GETFPCW(cw); -#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - assert(cw == CGAL_FE_TONEAREST); -#endif return cw; } From 605a4463631bde2851d4db7446c8b3f35e8b68fd Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Wed, 3 Mar 2021 19:55:06 +0900 Subject: [PATCH 053/130] A little bit more --- Number_types/include/CGAL/Interval_nt.h | 1 - Number_types/test/Number_types/Interval_nt.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/Number_types/include/CGAL/Interval_nt.h b/Number_types/include/CGAL/Interval_nt.h index 1b7a836c14e..1eeb2a56e73 100644 --- a/Number_types/include/CGAL/Interval_nt.h +++ b/Number_types/include/CGAL/Interval_nt.h @@ -722,7 +722,6 @@ private: Interval_nt operator/ (const Interval_nt &a, const Interval_nt & b) { - assert(FPU_get_cw() == CGAL_FE_TONEAREST); #if 0 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88626 if(CGAL_CST_TRUE(a.is_point())) diff --git a/Number_types/test/Number_types/Interval_nt.cpp b/Number_types/test/Number_types/Interval_nt.cpp index 4a56129d31f..b2e9b512dfa 100644 --- a/Number_types/test/Number_types/Interval_nt.cpp +++ b/Number_types/test/Number_types/Interval_nt.cpp @@ -127,7 +127,6 @@ bool square_root_test() std::cout << "i = " << i << std::endl; std::cout << "sup : " << a.sup() << std::endl; std::cout << "inf : " << a.inf() << std::endl; - std::cout << "width ok ? : " << (-a.inf() == 1/(double(1<<30)*(1<<22))) << std::endl; ) // DEBUG if (i != 54) { return false; From 85c6b3b3b64b8a9f25419e31868581ba7ac12d2c Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Wed, 3 Mar 2021 19:57:51 +0900 Subject: [PATCH 054/130] Revert PMP example --- .../corefinement_polyhedron_union.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_polyhedron_union.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_polyhedron_union.cpp index d337bdf637a..71bdd4cd2f7 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_polyhedron_union.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_polyhedron_union.cpp @@ -1,5 +1,4 @@ -// #include -#include +#include #include #include @@ -9,8 +8,7 @@ #include #include -// typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Exact_predicates_exact_constructions_kernel K; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Polyhedron_3 Mesh; namespace PMP = CGAL::Polygon_mesh_processing; From 4a6706755dc3f23e9428004f774c2f882c563cb4 Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Wed, 3 Mar 2021 19:58:56 +0900 Subject: [PATCH 055/130] Cleanup --- .../examples/Polygon_mesh_processing/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index 3615a74a4ef..e34c91b8892 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -76,7 +76,6 @@ create_single_source_cgal_program("corefinement_SM.cpp") create_single_source_cgal_program("corefinement_consecutive_bool_op.cpp") create_single_source_cgal_program("corefinement_difference_remeshed.cpp") create_single_source_cgal_program("corefinement_mesh_union.cpp") -create_single_source_cgal_program("cgal.cc") create_single_source_cgal_program( "corefinement_mesh_union_and_intersection.cpp") create_single_source_cgal_program("corefinement_mesh_union_with_attributes.cpp") From 62d1f6b0f02397230fb3f118c8fcb8353c64c590 Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Wed, 3 Mar 2021 20:29:21 +0900 Subject: [PATCH 056/130] Revert out-of-scope fix --- .../CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h b/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h index 1c437177712..14fc74d8490 100644 --- a/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h +++ b/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h @@ -130,7 +130,7 @@ public: circumcenter_ = new Point(this->Cb::circumcenter(gt)); } else { CGAL_expensive_assertion( - this->Cb::circumcenter(gt) == *circumcenter_); + this->Cb::circumcenter(gt) == *circumcenter); } return *circumcenter_; From 2ac977b7c5df414979a515033bb07c0d16cc02de Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 3 Mar 2021 13:21:24 +0000 Subject: [PATCH 057/130] Early exit in do_intersect of Sphere/Bbox_3 --- .../internal/Bbox_3_Sphere_3_do_intersect.h | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Sphere_3_do_intersect.h b/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Sphere_3_do_intersect.h index b15270e5294..49eaf967ad5 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Sphere_3_do_intersect.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Sphere_3_do_intersect.h @@ -35,39 +35,59 @@ namespace internal { typedef typename K::Point_3 Point; FT d = FT(0); FT distance = FT(0); + FT sr = sphere.squared_radius(); + Point center = sphere.center(); if(center.x() < (FT)bbox.xmin()) { d = (FT)bbox.xmin() - center.x(); - distance += d * d; + d = square(d); + if(d > sr){ + return false; + } + distance = d; } else if(center.x() > (FT)bbox.xmax()) { d = center.x() - (FT)bbox.xmax(); - distance += d * d; + d = square(d); + if(d > sr){ + return false; + } + distance = d; } if(center.y() < (FT)bbox.ymin()) { d = (FT)bbox.ymin() - center.y(); - distance += d * d; + d = square(d); + if(d > sr){ + return false; + } + distance += d ; } else if(center.y() > (FT)bbox.ymax()) { d = center.y() - (FT)bbox.ymax(); - distance += d * d; + d = square(d); + if(d > sr){ + return false; + } + distance += d; } if(center.z() < (FT)bbox.zmin()) { d = (FT)bbox.zmin() - center.z(); - distance += d * d; + d = square(d); + distance += d; } else if(center.z() > (FT)bbox.zmax()) { d = center.z() - (FT)bbox.zmax(); - distance += d * d; + d = square(d); + distance += d; } // For unknown reason this causes a syntax error on VC2005 @@ -87,7 +107,7 @@ namespace internal { // } //} - return distance <= sphere.squared_radius(); + return distance <= sr; } template From 82e5b3a02d51ec2ce672bc00736799a80ba3c809 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 3 Mar 2021 14:23:56 +0000 Subject: [PATCH 058/130] Do not collect in a vector per patch, but do the tests directly (@janetournois please double-check this commit) --- .../Isotropic_remeshing/remesh_impl.h | 39 ++++++------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h index ce1636b62d0..edb6f3e0dbc 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -1885,8 +1886,8 @@ private: bool check_normals(const HalfedgeRange& hedges) const { std::size_t nb_patches = patch_id_to_index_map.size(); + std::vector > normal_per_patch(nb_patches,boost::none); - std::vector< std::vector > normals_per_patch(nb_patches); for(halfedge_descriptor hd : hedges) { Halfedge_status s = status(hd); @@ -1898,18 +1899,15 @@ private: if (n == CGAL::NULL_VECTOR) //for degenerate faces continue; Patch_id pid = get_patch_id(face(hd, mesh_)); - normals_per_patch[patch_id_to_index_map.at(pid)].push_back(n); - } - - //on each surface patch, - //check all normals have same orientation - for (std::size_t i=0; i < nb_patches; ++i) - { - const std::vector& normals = normals_per_patch[i]; - if (normals.empty()) continue; - - if (!check_orientation(normals)) - return false; + std::size_t index = patch_id_to_index_map.at(pid); + if(normal_per_patch[index]){ + const Vector_3& vec = *normal_per_patch[index]; + double dot = to_double(n * vec); + if (dot <= 0.){ + return false; + } + } + normal_per_patch[index] = boost::make_optional(n); } return true; } @@ -1922,20 +1920,7 @@ private: Vector_3 no = compute_normal(face(opposite(h, mesh_), mesh_)); return n * no > 0.; } - - bool check_orientation(const std::vector& normals) const - { - if (normals.size() < 2) - return true; - for (std::size_t i = 1; i < normals.size(); ++i)/*start at 1 on purpose*/ - { - double dot = to_double(normals[i - 1] * normals[i]); - if (dot <= 0.) - return false; - } - return true; - } - + public: const Triangle_list& input_triangles() const { return input_triangles_; From dad0287b69b5b347b1c687f8fc363b343bc42f73 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 3 Mar 2021 14:34:56 +0000 Subject: [PATCH 059/130] Remove trailing whitespace --- .../internal/Isotropic_remeshing/remesh_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h index edb6f3e0dbc..d0bd9bf2a00 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h @@ -1920,7 +1920,7 @@ private: Vector_3 no = compute_normal(face(opposite(h, mesh_), mesh_)); return n * no > 0.; } - + public: const Triangle_list& input_triangles() const { return input_triangles_; From e7f18dff56952c7a3e4999eac4ae0fd14fff3eaa Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 3 Mar 2021 15:00:59 +0000 Subject: [PATCH 060/130] No need for calling abs for a squared distance --- .../include/CGAL/internal/Static_filters/Do_intersect_3.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h index 92cbd3ebf3f..88875d6d311 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h @@ -245,18 +245,17 @@ public: } double double_tmp_result = (distance - ssr); - double max2 = CGAL::abs(ssr); - if ((max1 < 3.33558365626356687717e-147) || (max2 < 1.11261183279326254436e-293)){ + if ((max1 < 3.33558365626356687717e-147) || (ssr < 1.11261183279326254436e-293)){ CGAL_BRANCH_PROFILER_BRANCH_2(tmp); return Base::operator()(s,b); } - if ((max1 > 1.67597599124282407923e+153) || (max2 > 2.80889552322236673473e+306)){ + if ((max1 > 1.67597599124282407923e+153) || (ssr > 2.80889552322236673473e+306)){ CGAL_BRANCH_PROFILER_BRANCH_2(tmp); return Base::operator()(s,b); } - double eps = 1.99986535548615598560e-15 * (std::max) (max2, (max1 * max1)); + double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); if (double_tmp_result > eps) return false; @@ -265,6 +264,7 @@ public: if (double_tmp_result < -eps) return true; else { + return true; // AF: just to test conservative approach CGAL_BRANCH_PROFILER_BRANCH_2(tmp); return Base::operator()(s,b); } From 431c5b81322801ad6740c68987d65d2bca1a7e3a Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 3 Mar 2021 15:02:13 +0000 Subject: [PATCH 061/130] Comment something experimental that sneaked in --- .../include/CGAL/internal/Static_filters/Do_intersect_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h index 88875d6d311..9c09fe2ecb3 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h @@ -264,7 +264,7 @@ public: if (double_tmp_result < -eps) return true; else { - return true; // AF: just to test conservative approach + // return true; // AF: just to test conservative approach CGAL_BRANCH_PROFILER_BRANCH_2(tmp); return Base::operator()(s,b); } From 7785a9c2b142e2034811b7bd8a47ae2864581ef0 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 3 Mar 2021 15:25:30 +0000 Subject: [PATCH 062/130] Use certainly() --- .../internal/Bbox_3_Sphere_3_do_intersect.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Sphere_3_do_intersect.h b/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Sphere_3_do_intersect.h index 49eaf967ad5..7f74ddf1c8e 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Sphere_3_do_intersect.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Sphere_3_do_intersect.h @@ -43,7 +43,7 @@ namespace internal { { d = (FT)bbox.xmin() - center.x(); d = square(d); - if(d > sr){ + if(certainly(d > sr)){ return false; } distance = d; @@ -52,7 +52,7 @@ namespace internal { { d = center.x() - (FT)bbox.xmax(); d = square(d); - if(d > sr){ + if(certainly(d > sr)){ return false; } distance = d; @@ -62,7 +62,7 @@ namespace internal { { d = (FT)bbox.ymin() - center.y(); d = square(d); - if(d > sr){ + if(certainly(d > sr)){ return false; } distance += d ; @@ -71,7 +71,7 @@ namespace internal { { d = center.y() - (FT)bbox.ymax(); d = square(d); - if(d > sr){ + if(certainly(d > sr)){ return false; } distance += d; From 71bfcce226bab9ab8bcdcdabe20723a338fd25a4 Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Thu, 4 Mar 2021 00:26:36 +0900 Subject: [PATCH 063/130] Keep CGAL_IA_FORCE_TO_DOUBLE for the normal case --- Number_types/include/CGAL/FPU.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index 501b63999a9..8d610586960 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -359,7 +359,7 @@ inline double CGAL_IA_UP(double d) { // In round-upward mode we can rely on the hardware // to do the job. - return d; + return CGAL_IA_FORCE_TO_DOUBLE(d); } #endif #define CGAL_IA_ADD(a,b) CGAL_IA_UP((a)+CGAL_IA_STOP_CPROP(b)) From 4fab8430dad1506bc6c7eb36c0f4dbb993a81e55 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 3 Mar 2021 21:14:39 +0000 Subject: [PATCH 064/130] Add static filter for Equal_3::operator()(Vector_3, Null_vector) --- .../CGAL/internal/Static_filters/Equal_3.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Equal_3.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Equal_3.h index 102199d5633..d4e3c3099ed 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Equal_3.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Equal_3.h @@ -82,6 +82,24 @@ public: return Base::operator()(p, q); } + + result_type operator()(const Vector_3 &p, const Null_vector &q) const + { + CGAL_BRANCH_PROFILER(std::string("semi-static attempts/calls to : ") + + std::string(CGAL_PRETTY_FUNCTION), tmp); + + Get_approx get_approx; // Identity functor for all points + // but lazy points + double px, py, pz; + + if (fit_in_double(get_approx(p).x(), px) && fit_in_double(get_approx(p).y(), py) && + fit_in_double(get_approx(p).z(), pz) ) + { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + return px == 0 && py == 0 && pz == 0; + } + return Base::operator()(p, q); + } }; // end class Equal_3 } // end namespace Static_filters_predicates From e545fcf624a9489c8a609c01bcdb19000b72f700 Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Thu, 4 Mar 2021 09:51:04 +0900 Subject: [PATCH 065/130] Clean up sqrt. --- Number_types/include/CGAL/FPU.h | 40 +++++++++++++++---------- Number_types/include/CGAL/Interval_nt.h | 10 ++----- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index 8d610586960..85d03e09c10 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -346,34 +346,27 @@ inline double IA_bug_sqrt(double d) // With GCC, we can do slightly better : test with __builtin_constant_p() // that both arguments are constant before stopping one of them. // Use inline functions instead ? -#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST -inline double CGAL_IA_UP(double d) +inline double IA_up(double d) { +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST // In round-to-nearest mode we find the successor instead. // This preserves the interval invariants, but is more // expensive and conservative. return nextafter(d, std::numeric_limits::infinity()); -} #else -inline double CGAL_IA_UP(double d) -{ // In round-upward mode we can rely on the hardware // to do the job. return CGAL_IA_FORCE_TO_DOUBLE(d); -} #endif -#define CGAL_IA_ADD(a,b) CGAL_IA_UP((a)+CGAL_IA_STOP_CPROP(b)) -#define CGAL_IA_SUB(a,b) CGAL_IA_UP(CGAL_IA_STOP_CPROP(a)-(b)) -#define CGAL_IA_MUL(a,b) CGAL_IA_UP(CGAL_IA_STOP_CPROP(a)*CGAL_IA_STOP_CPROP(b)) -#define CGAL_IA_DIV(a,b) CGAL_IA_UP(CGAL_IA_STOP_CPROP(a)/CGAL_IA_STOP_CPROP(b)) +} +#define CGAL_IA_ADD(a,b) IA_up((a)+CGAL_IA_STOP_CPROP(b)) +#define CGAL_IA_SUB(a,b) IA_up(CGAL_IA_STOP_CPROP(a)-(b)) +#define CGAL_IA_MUL(a,b) IA_up(CGAL_IA_STOP_CPROP(a)*CGAL_IA_STOP_CPROP(b)) +#define CGAL_IA_DIV(a,b) IA_up(CGAL_IA_STOP_CPROP(a)/CGAL_IA_STOP_CPROP(b)) inline double CGAL_IA_SQUARE(double a){ double b = CGAL_IA_STOP_CPROP(a); // only once - return CGAL_IA_UP(b*b); + return IA_up(b*b); } -#define CGAL_IA_SQRT(a) \ - CGAL_IA_UP(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(a))) - - #if defined CGAL_SAFE_SSE2 #define CGAL_IA_SETFPCW(CW) _MM_SET_ROUNDING_MODE(CW) @@ -602,6 +595,23 @@ inline void force_ieee_double_precision() #endif } +// Implementation (not part of the user interface) + +inline double IA_sqrt_up(double a) { + return IA_up(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(a))); +} + +inline double IA_sqrt_toward_zero(double d) { +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + return (d > 0.0) ? nextafter(std::sqrt(d), 0.) : 0.0; +#else + FPU_set_cw(CGAL_FE_DOWNWARD); + double i = (d > 0.0) ? CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(d)) : 0.0; + FPU_set_cw(CGAL_FE_UPWARD); + return i; +#endif +} + } //namespace CGAL #ifdef CGAL_HEADER_ONLY diff --git a/Number_types/include/CGAL/Interval_nt.h b/Number_types/include/CGAL/Interval_nt.h index 1eeb2a56e73..690f1cc4c74 100644 --- a/Number_types/include/CGAL/Interval_nt.h +++ b/Number_types/include/CGAL/Interval_nt.h @@ -1147,15 +1147,9 @@ namespace INTERN_INTERVAL_NT { // - compute x = CGAL_IA_SQRT(d.inf()) // - compute y = CGAL_IA_SQUARE(x) // - if y==d.inf() use x, else use -CGAL_IA_SUB(CGAL_IA_MIN_DOUBLE,x) -#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - double i = (d.inf() > 0.0) ? nextafter(std::sqrt(d.inf()), 0.) : 0.0; -#else // no CGAL_ALWAYS_ROUND_TO_NEAREST - FPU_set_cw(CGAL_FE_DOWNWARD); - double i = (d.inf() > 0.0) ? CGAL_IA_SQRT(d.inf()) : 0.0; - FPU_set_cw(CGAL_FE_UPWARD); -#endif // no CGAL_ALWAYS_ROUND_TO_NEAREST + double i = IA_sqrt_toward_zero(d.inf()); #endif // no __AVX512F__ - return Interval_nt(i, CGAL_IA_SQRT(d.sup())); + return Interval_nt(i, IA_sqrt_up(d.sup())); } template From 2e3bfa8743a9721abd4be13f3e271af5f2f0eb7c Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 4 Mar 2021 09:27:05 +0000 Subject: [PATCH 066/130] Reduce calls to target @sloriot please double check the correctness --- .../CGAL/Polygon_mesh_processing/compute_normal.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h index bfb8f831238..0f5840f6667 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h @@ -91,12 +91,16 @@ void sum_normals(const PM& pmesh, halfedge_descriptor he = halfedge(f, pmesh); vertex_descriptor v = source(he, pmesh); + vertex_descriptor the = target(he,pmesh); + he = next(he, pmesh); + vertex_descriptor tnhe = target(he,pmesh); + const Point_ref pv = get(vpmap, v); - while(v != target(next(he, pmesh), pmesh)) + while(v != tnhe) { - const Point_ref pvn = get(vpmap, target(he, pmesh)); - const Point_ref pvnn = get(vpmap, target(next(he, pmesh), pmesh)); + const Point_ref pvn = get(vpmap, the); + const Point_ref pvnn = get(vpmap, tnhe); const Vector n = internal::triangle_normal(pv, pvn, pvnn, traits); @@ -107,7 +111,9 @@ void sum_normals(const PM& pmesh, sum = traits.construct_sum_of_vectors_3_object()(sum, n); + the = tnhe; he = next(he, pmesh); + tnhe = target(he,pmesh); } } From 45265a7e342955f498a062ffb9845c532efd119b Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 4 Mar 2021 10:46:46 +0000 Subject: [PATCH 067/130] Replace vector with optional by two vectors. No idea what is better yet --- .../internal/Isotropic_remeshing/remesh_impl.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h index d0bd9bf2a00..e2399b115e7 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h @@ -1886,7 +1886,9 @@ private: bool check_normals(const HalfedgeRange& hedges) const { std::size_t nb_patches = patch_id_to_index_map.size(); - std::vector > normal_per_patch(nb_patches,boost::none); + //std::vector > normal_per_patch(nb_patches,boost::none); + std::vector initialized(nb_patches,false); + std::vector normal_per_patch(nb_patches); for(halfedge_descriptor hd : hedges) { @@ -1900,14 +1902,17 @@ private: continue; Patch_id pid = get_patch_id(face(hd, mesh_)); std::size_t index = patch_id_to_index_map.at(pid); - if(normal_per_patch[index]){ - const Vector_3& vec = *normal_per_patch[index]; + //if(normal_per_patch[index]){ + if(initialized[index]){ + const Vector_3& vec = normal_per_patch[index]; double dot = to_double(n * vec); if (dot <= 0.){ return false; } } - normal_per_patch[index] = boost::make_optional(n); + //normal_per_patch[index] = boost::make_optional(n); + normal_per_patch[index] = n; + initialized[index] = true; } return true; } From 0f573cd1806dca324146d3001852a234fe4c7159 Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Fri, 5 Mar 2021 23:46:24 +0900 Subject: [PATCH 068/130] Prevent CGAL_USE_SSE2 with CGAL_ALWAYS_ROUND_TO_NEAREST --- Number_types/include/CGAL/FPU.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index 85d03e09c10..f876ac3c46b 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -114,9 +114,13 @@ extern "C" { // Only define CGAL_USE_SSE2 for 64 bits where malloc has a suitable // alignment, 32 bits is too dangerous. -#if defined(CGAL_HAS_SSE2) && (defined(__x86_64__) || defined(_M_X64)) +#if defined CGAL_HAS_SSE2 +#if defined __x86_64__ || defined _M_X64 +#if !defined CGAL_ALWAYS_ROUND_TO_NEAREST # define CGAL_USE_SSE2 1 #endif +#endif +#endif #ifdef CGAL_CFG_DENORMALS_COMPILE_BUG double& get_static_minimin(); // Defined in Interval_arithmetic_impl.h #endif From bb67237b5b7dea9df81d52a26ec0943b45050e8f Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Sat, 6 Mar 2021 00:22:52 +0900 Subject: [PATCH 069/130] Style --- Number_types/include/CGAL/FPU.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index f876ac3c46b..36e458bc969 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -114,13 +114,11 @@ extern "C" { // Only define CGAL_USE_SSE2 for 64 bits where malloc has a suitable // alignment, 32 bits is too dangerous. -#if defined CGAL_HAS_SSE2 -#if defined __x86_64__ || defined _M_X64 -#if !defined CGAL_ALWAYS_ROUND_TO_NEAREST +#if defined CGAL_HAS_SSE2 && \ + (defined __x86_64__ || defined _M_X64) && \ + !defined CGAL_ALWAYS_ROUND_TO_NEAREST # define CGAL_USE_SSE2 1 #endif -#endif -#endif #ifdef CGAL_CFG_DENORMALS_COMPILE_BUG double& get_static_minimin(); // Defined in Interval_arithmetic_impl.h #endif From b1c2dd8db67f5149c6080a91359ad3a81d38b5bc Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Sun, 7 Mar 2021 18:25:18 +0000 Subject: [PATCH 070/130] WIP: early exit in the static filter --- AABB_tree/include/CGAL/AABB_traits.h | 20 +++ .../internal/Static_filters/Do_intersect_3.h | 132 +++++++++++++++++- .../isotropic_remeshing_example.cpp | 23 ++- 3 files changed, 169 insertions(+), 6 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_traits.h b/AABB_tree/include/CGAL/AABB_traits.h index 613d08c174b..1a3fdde1055 100644 --- a/AABB_tree/include/CGAL/AABB_traits.h +++ b/AABB_tree/include/CGAL/AABB_traits.h @@ -423,6 +423,26 @@ public: CGAL::SMALLER : CGAL::LARGER; } + /* + template <> + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& pr, const Point& bound) const + { + return GeomTraits().do_intersect_3_object() + (GeomTraits().construct_sphere_3_object() + (p, GeomTraits().compute_squared_distance_3_object()(p, bound)).bbox(), pr)? + CGAL::SMALLER : CGAL::LARGER; + } + + template <> + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& pr, const FT& sq_distance) const + { + return GeomTraits().do_intersect_3_object() + (GeomTraits().construct_sphere_3_object()(p, sq_distance).bbox(), + pr) ? + CGAL::SMALLER : + CGAL::LARGER; + } + */ }; Closest_point closest_point_object() const {return Closest_point(*this);} diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h index 9c09fe2ecb3..8c899a32c18 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h @@ -192,6 +192,10 @@ public: { CGAL_BRANCH_PROFILER_BRANCH_1(tmp); + if ((ssr < 1.11261183279326254436e-293) || (ssr > 2.80889552322236673473e+306)){ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } double distance = 0; double max1 = 0; @@ -201,6 +205,25 @@ public: max1 = bxmin_scx; distance = square(bxmin_scx); +#ifdef EARLY + { + double double_tmp_result = (distance - ssr); + + if (max1 < 3.33558365626356687717e-147){ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } + if (max1 > 1.67597599124282407923e+153){ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } + + double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); + + if (double_tmp_result > eps) + return false; + } +#endif } else if(scx > bxmax) { @@ -208,8 +231,31 @@ public: max1 = scx_bxmax; distance = square(scx_bxmax); +#ifdef EARLY + { + double double_tmp_result = (distance - ssr); + + if (max1 < 3.33558365626356687717e-147){ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } + if (max1 > 1.67597599124282407923e+153){ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } + + double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); + + if (double_tmp_result > eps) + return false; + } +#endif } + + + + if(scy < bymin) { double bymin_scy = bymin - scy; @@ -217,6 +263,25 @@ public: max1 = bymin_scy; distance += square(bymin_scy); +#ifdef EARLY + { + double double_tmp_result = (distance - ssr); + + if (max1 < 3.33558365626356687717e-147){ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } + if ((max1 > 1.67597599124282407923e+153)){ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } + + double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); + + if (double_tmp_result > eps) + return false; + } +#endif } else if(scy > bymax) { @@ -225,6 +290,26 @@ public: max1 = scy_bymax; distance += square(scy_bymax); +#ifdef EARLY + + { + double double_tmp_result = (distance - ssr); + + if ((max1 < 3.33558365626356687717e-147)){ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } + if ((max1 > 1.67597599124282407923e+153)){ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } + + double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); + + if (double_tmp_result > eps) + return false; + } +#endif } if(scz < bzmin) @@ -234,6 +319,25 @@ public: max1 = bzmin_scz; distance += square(bzmin_scz); +#ifdef EARLY + { + double double_tmp_result = (distance - ssr); + + if ((max1 < 3.33558365626356687717e-147)){ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } + if ((max1 > 1.67597599124282407923e+153)){ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } + + double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); + + if (double_tmp_result > eps) + return false; + } +#endif } else if(scz > bzmax) { @@ -242,19 +346,39 @@ public: max1 = scz_bzmax; distance += square(scz_bzmax); +#ifdef EARLY + { + double double_tmp_result = (distance - ssr); + + if ((max1 < 3.33558365626356687717e-147)){ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } + if ((max1 > 1.67597599124282407923e+153)){ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } + + double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); + + if (double_tmp_result > eps) + return false; + } +#endif } double double_tmp_result = (distance - ssr); - if ((max1 < 3.33558365626356687717e-147) || (ssr < 1.11261183279326254436e-293)){ +#ifndef EARLY + if (max1 < 3.33558365626356687717e-147){ CGAL_BRANCH_PROFILER_BRANCH_2(tmp); return Base::operator()(s,b); } - if ((max1 > 1.67597599124282407923e+153) || (ssr > 2.80889552322236673473e+306)){ + if (max1 > 1.67597599124282407923e+153){ CGAL_BRANCH_PROFILER_BRANCH_2(tmp); return Base::operator()(s,b); } - +#endif double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); if (double_tmp_result > eps) @@ -264,7 +388,7 @@ public: if (double_tmp_result < -eps) return true; else { - // return true; // AF: just to test conservative approach + return true; // AF: just to test conservative approach CGAL_BRANCH_PROFILER_BRANCH_2(tmp); return Base::operator()(s,b); } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp index c5811a87d2b..bb246a9393c 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp @@ -1,6 +1,7 @@ +#define EARLY #include #include - +#include #include #include #include @@ -9,6 +10,7 @@ #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Surface_mesh Mesh; @@ -35,6 +37,9 @@ int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/pig.off"; + CGAL::Timer t; + t.start(); + Mesh mesh; if(!PMP::read_polygon_mesh(filename, mesh) || !CGAL::is_triangle_mesh(mesh)) { @@ -42,7 +47,10 @@ int main(int argc, char* argv[]) return 1; } - double target_edge_length = 0.04; + std::cout << "Read: " << t.time() << " sec" << std::endl; + t.reset(); + + double target_edge_length = (argc > 2) ? std::stod(std::string(argv[2])) : 1.0; unsigned int nb_iter = 3; std::cout << "Split border..."; @@ -53,6 +61,9 @@ int main(int argc, char* argv[]) std::cout << "done." << std::endl; + std::cout << "took " << t.time() << " sec" << std::endl; + t.reset(); + std::cout << "Start remeshing of " << filename << " (" << num_faces(mesh) << " faces)..." << std::endl; @@ -62,5 +73,13 @@ int main(int argc, char* argv[]) std::cout << "Remeshing done." << std::endl; + std::cout << "took " << t.time() << " sec" << std::endl; + t.reset(); + + std::ofstream out("out.off"); + out.precision(17); + //out << mesh << std::endl; + out.close(); + return 0; } From 5b7a78d84c929b0b7a8f50b4364176cb21a8426c Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Tue, 9 Mar 2021 18:20:23 +0900 Subject: [PATCH 071/130] Assert mode instead of setting & update tests --- Number_types/include/CGAL/FPU.h | 15 ++++++ .../test/Number_types/Interval_nt.cpp | 50 +++++-------------- .../test/Number_types/Interval_nt_nearest.cpp | 2 + 3 files changed, 30 insertions(+), 37 deletions(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index 36e458bc969..68ad6a98a47 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -486,9 +486,15 @@ inline FPU_CW_t FPU_get_cw (void) { +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + FPU_CW_t cw; + CGAL_assertion((CGAL_IA_GETFPCW(cw), cw == CGAL_FE_TONEAREST)); + return CGAL_FE_TONEAREST; +#else FPU_CW_t cw; CGAL_IA_GETFPCW(cw); return cw; +#endif } // User interface (cont): @@ -497,16 +503,25 @@ inline void FPU_set_cw (FPU_CW_t cw) { +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + CGAL_assertion(cw == CGAL_FE_TONEAREST); +#else CGAL_IA_SETFPCW(cw); +#endif } inline FPU_CW_t FPU_get_and_set_cw (FPU_CW_t cw) { +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + CGAL_assertion(cw == CGAL_FE_TONEAREST); + return CGAL_FE_TONEAREST; +#else FPU_CW_t old = FPU_get_cw(); FPU_set_cw(cw); return old; +#endif } diff --git a/Number_types/test/Number_types/Interval_nt.cpp b/Number_types/test/Number_types/Interval_nt.cpp index b2e9b512dfa..0d771f8b6cf 100644 --- a/Number_types/test/Number_types/Interval_nt.cpp +++ b/Number_types/test/Number_types/Interval_nt.cpp @@ -31,7 +31,11 @@ bool spiral_test() break; }; +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + return i == 365; +#else return i == 396; +#endif } // Tests for constant propagation through intervals. @@ -45,62 +49,34 @@ bool cprop_test() // Testing cprop through +. IA_nt add = IA_nt(0.00001)+10.1; bool good_add = !add.is_point(); -#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - if (good_add) - std::cerr << "ERROR : No constant propagation through operator+." < 2/(double(1<<30)*(1<<22))) { + if (a.sup() > 3/(double(1<<30)*(1<<22))) { return false; } - if (-2/(double(1<<30)*(1<<22)) > a.inf()) { + if (-3/(double(1<<30)*(1<<22)) > a.inf()) { return false; } return true; @@ -188,12 +164,12 @@ bool overflow_test() DEBUG( std::cout << "f = " << f << std::endl; ) } -#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST_XX return a.is_same(IA_nt(std::numeric_limits::infinity(), std::numeric_limits::infinity())) && b.is_same(IA_nt(std::numeric_limits::infinity(), std::numeric_limits::infinity())) && - c.is_same(IA_nt(-std::numeric_limits::infinity(), std::numeric_limits::infinity())) && - d.is_same(IA_nt(-std::numeric_limits::infinity(), std::numeric_limits::infinity())) && - e.is_same(IA_nt(-std::numeric_limits::infinity(), std::numeric_limits::infinity())) && + c.is_same(IA_nt::largest()) && + d.is_same(IA_nt::largest()) && + e.is_same(IA_nt::largest()) && f.is_same(IA_nt(std::numeric_limits::infinity(), std::numeric_limits::infinity())) && g.is_same(-f); #else @@ -224,9 +200,9 @@ bool underflow_test() for (i=0; i<20; i++) c = CGAL_NTS square(c); #ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - return a.is_same(IA_nt(0, 0)) - && b.is_same(IA_nt(0, 0)) - && c.is_same(IA_nt(0, 0)); + return a.is_same(IA_nt(-CGAL_IA_MIN_DOUBLE, CGAL_IA_MIN_DOUBLE)) + && b.is_same(IA_nt::smallest()) + && c.is_same(IA_nt(0, CGAL_IA_MIN_DOUBLE)); #else return a.is_same(IA_nt(0, CGAL_IA_MIN_DOUBLE)) && b.is_same(IA_nt::smallest()) diff --git a/Number_types/test/Number_types/Interval_nt_nearest.cpp b/Number_types/test/Number_types/Interval_nt_nearest.cpp index fe5ce657c6e..c2ae592c57f 100644 --- a/Number_types/test/Number_types/Interval_nt_nearest.cpp +++ b/Number_types/test/Number_types/Interval_nt_nearest.cpp @@ -1,2 +1,4 @@ #define CGAL_ALWAYS_ROUND_TO_NEAREST +#define CGAL_DEBUG +#define CGAL_CHECK_EXPENSIVE #include "Interval_nt.cpp" From a3a610ba511a50cfa645d00f59ab3e812fea57d2 Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Tue, 9 Mar 2021 19:43:47 +0900 Subject: [PATCH 072/130] Avoid warnings with NDEBUG --- Number_types/include/CGAL/FPU.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index 68ad6a98a47..8e724756917 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -487,8 +487,8 @@ FPU_CW_t FPU_get_cw (void) { #ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - FPU_CW_t cw; - CGAL_assertion((CGAL_IA_GETFPCW(cw), cw == CGAL_FE_TONEAREST)); + CGAL_assertion_code(FPU_CW_t cw; CGAL_IA_GETFPCW(cw);) + CGAL_assertion(cw == CGAL_FE_TONEAREST); return CGAL_FE_TONEAREST; #else FPU_CW_t cw; From 643810f310f4df42c48b68fe410560866f8db006 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 9 Mar 2021 13:15:49 +0000 Subject: [PATCH 073/130] WIP for not hard coding conservative. Todo: Use of Has_filtered --- AABB_tree/include/CGAL/AABB_traits.h | 27 ++++++------------- .../internal/Static_filters/Do_intersect_3.h | 8 ++++-- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_traits.h b/AABB_tree/include/CGAL/AABB_traits.h index 1a3fdde1055..6bcf44a18af 100644 --- a/AABB_tree/include/CGAL/AABB_traits.h +++ b/AABB_tree/include/CGAL/AABB_traits.h @@ -414,6 +414,14 @@ public: CGAL::SMALLER : CGAL::LARGER; } + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const + { + return GeomTraits().do_intersect_3_object() + (GeomTraits().construct_sphere_3_object() + (p, GeomTraits().compute_squared_distance_3_object()(p, bound)), bb,true)? + CGAL::SMALLER : CGAL::LARGER; + } + template CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const FT& sq_distance) const { @@ -423,26 +431,7 @@ public: CGAL::SMALLER : CGAL::LARGER; } - /* - template <> - CGAL::Comparison_result operator()(const Point& p, const Bounding_box& pr, const Point& bound) const - { - return GeomTraits().do_intersect_3_object() - (GeomTraits().construct_sphere_3_object() - (p, GeomTraits().compute_squared_distance_3_object()(p, bound)).bbox(), pr)? - CGAL::SMALLER : CGAL::LARGER; - } - template <> - CGAL::Comparison_result operator()(const Point& p, const Bounding_box& pr, const FT& sq_distance) const - { - return GeomTraits().do_intersect_3_object() - (GeomTraits().construct_sphere_3_object()(p, sq_distance).bbox(), - pr) ? - CGAL::SMALLER : - CGAL::LARGER; - } - */ }; Closest_point closest_point_object() const {return Closest_point(*this);} diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h index 8c899a32c18..d09972a871a 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h @@ -168,9 +168,11 @@ public: return this->operator()(s, b); } + // The parameter overestimate is used to avoid a filter failure in AABB_tree::closest_point() result_type - operator()(const Sphere_3 &s, const Bbox_3& b) const + operator()(const Sphere_3 &s, const Bbox_3& b, bool overestimate = false) const { + std::cout << "." << std::flush; CGAL_BRANCH_PROFILER_3(std::string("semi-static failures/attempts/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); @@ -388,7 +390,9 @@ public: if (double_tmp_result < -eps) return true; else { - return true; // AF: just to test conservative approach + if(overestimate){ + return true; + } CGAL_BRANCH_PROFILER_BRANCH_2(tmp); return Base::operator()(s,b); } From 9274503f125ad0082ca101e0f2055a9ce19b9276 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 9 Mar 2021 13:18:50 +0000 Subject: [PATCH 074/130] remove debug code --- .../include/CGAL/internal/Static_filters/Do_intersect_3.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h index d09972a871a..f5149d93f15 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h @@ -172,7 +172,6 @@ public: result_type operator()(const Sphere_3 &s, const Bbox_3& b, bool overestimate = false) const { - std::cout << "." << std::flush; CGAL_BRANCH_PROFILER_3(std::string("semi-static failures/attempts/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); From cea8cca6af0be8e1bfc8974b6540a78a008fe02f Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 9 Mar 2021 15:45:18 +0000 Subject: [PATCH 075/130] WIP: less computations of degree --- .../Isotropic_remeshing/remesh_impl.h | 50 +++++++++++++++++-- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h index e2399b115e7..551c1294cfa 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -826,6 +827,22 @@ namespace internal { #ifdef CGAL_PMP_REMESHING_VERBOSE std::cout << "Equalize valences..." << std::endl; #endif + +#define VALE +#ifdef VALE + typedef typename boost::property_map >::type Vertex_degree; + Vertex_degree degree = get(CGAL::dynamic_vertex_property_t(), mesh_); + + for(vertex_descriptor v : vertices(mesh_)){ + put(degree,v,0); + } + for(halfedge_descriptor h : halfedges(mesh_)) + { + vertex_descriptor t = target(h, mesh_); + put(degree, t, get(degree,t)+1); + } +#endif + unsigned int nb_flips = 0; for(edge_descriptor e : edges(mesh_)) { @@ -838,11 +855,17 @@ namespace internal { vertex_descriptor vb = target(he, mesh_); vertex_descriptor vc = target(next(he, mesh_), mesh_); vertex_descriptor vd = target(next(opposite(he, mesh_), mesh_), mesh_); - - int vva = valence(va), tvva = target_valence(va); - int vvb = valence(vb), tvvb = target_valence(vb); - int vvc = valence(vc), tvvc = target_valence(vc); - int vvd = valence(vd), tvvd = target_valence(vd); +#ifdef VALE + int vva = get(degree,va), tvva = target_valence(va); + int vvb = get(degree, vb), tvvb = target_valence(vb); + int vvc = get(degree,vc), tvvc = target_valence(vc); + int vvd = get(degree,vd), tvvd = target_valence(vd); +#else + int vva = valence(va), tvva = target_valence(va); + int vvb = valence( vb), tvvb = target_valence(vb); + int vvc = valence(vc), tvvc = target_valence(vc); + int vvd = valence(vd), tvvd = target_valence(vd); +#endif int deviation_pre = CGAL::abs(vva - tvva) + CGAL::abs(vvb - tvvb) + CGAL::abs(vvc - tvvc) @@ -860,6 +883,12 @@ namespace internal { vvb -= 1; vvc += 1; vvd += 1; +#ifdef VALE + put(degree, va, vva); + put(degree, vb, vvb); + put(degree, vc, vvc); + put(degree, vd, vvd); +#endif ++nb_flips; #ifdef CGAL_PMP_REMESHING_VERBOSE_PROGRESS @@ -895,6 +924,17 @@ namespace internal { CGAL_assertion( is_flip_topologically_allowed(edge(he, mesh_)) ); CGAL_assertion( !get(ecmap_, edge(he, mesh_)) ); CGAL::Euler::flip_edge(he, mesh_); +#ifdef VALE + vva += 1; + vvb += 1; + vvc -= 1; + vvd -= 1; + + put(degree, va, vva); + put(degree, vb, vvb); + put(degree, vc, vvc); + put(degree, vd, vvd); +#endif --nb_flips; CGAL_assertion_code(Halfedge_status s3 = status(he)); From d6d5fd26054250adf81441d0b2af2107c250b8c2 Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Wed, 10 Mar 2021 09:11:44 +0900 Subject: [PATCH 076/130] Clean up test code --- Number_types/test/Number_types/Interval_nt.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Number_types/test/Number_types/Interval_nt.cpp b/Number_types/test/Number_types/Interval_nt.cpp index 0d771f8b6cf..7af20f02874 100644 --- a/Number_types/test/Number_types/Interval_nt.cpp +++ b/Number_types/test/Number_types/Interval_nt.cpp @@ -164,15 +164,6 @@ bool overflow_test() DEBUG( std::cout << "f = " << f << std::endl; ) } -#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST_XX - return a.is_same(IA_nt(std::numeric_limits::infinity(), std::numeric_limits::infinity())) && - b.is_same(IA_nt(std::numeric_limits::infinity(), std::numeric_limits::infinity())) && - c.is_same(IA_nt::largest()) && - d.is_same(IA_nt::largest()) && - e.is_same(IA_nt::largest()) && - f.is_same(IA_nt(std::numeric_limits::infinity(), std::numeric_limits::infinity())) && - g.is_same(-f); -#else return a.is_same(IA_nt(CGAL_IA_MAX_DOUBLE, std::numeric_limits::infinity())) && b.is_same(IA_nt(CGAL_IA_MAX_DOUBLE, std::numeric_limits::infinity())) && c.is_same(IA_nt::largest()) && @@ -180,7 +171,6 @@ bool overflow_test() e.is_same(IA_nt::largest()) && f.is_same(IA_nt(CGAL_IA_MAX_DOUBLE, std::numeric_limits::infinity())) && g.is_same(-f); -#endif } From b5239161c46576daccc7d37b991c43974c656f27 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Mar 2021 10:51:24 +0000 Subject: [PATCH 077/130] Check that the kernel has static filters --- AABB_tree/include/CGAL/AABB_traits.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/AABB_tree/include/CGAL/AABB_traits.h b/AABB_tree/include/CGAL/AABB_traits.h index 6bcf44a18af..78959df857b 100644 --- a/AABB_tree/include/CGAL/AABB_traits.h +++ b/AABB_tree/include/CGAL/AABB_traits.h @@ -414,7 +414,7 @@ public: CGAL::SMALLER : CGAL::LARGER; } - CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_true&) const { return GeomTraits().do_intersect_3_object() (GeomTraits().construct_sphere_3_object() @@ -422,6 +422,19 @@ public: CGAL::SMALLER : CGAL::LARGER; } + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_false&) const + { + return GeomTraits().do_intersect_3_object() + (GeomTraits().construct_sphere_3_object() + (p, GeomTraits().compute_squared_distance_3_object()(p, bound)), bb)? + CGAL::SMALLER : CGAL::LARGER; + } + + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const + { + return (*this)(p, bb, bound, typename GeomTraits::Has_filtered_predicates_tag()); + } + template CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const FT& sq_distance) const { From ac708f6625e4a6448f88ac414cbf3c0fcc917c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 10 Mar 2021 13:59:00 +0100 Subject: [PATCH 078/130] use nested class for dispatch --- AABB_tree/include/CGAL/AABB_traits.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_traits.h b/AABB_tree/include/CGAL/AABB_traits.h index 78959df857b..a022070a654 100644 --- a/AABB_tree/include/CGAL/AABB_traits.h +++ b/AABB_tree/include/CGAL/AABB_traits.h @@ -24,6 +24,8 @@ #include #include #include +#include + #include @@ -414,7 +416,7 @@ public: CGAL::SMALLER : CGAL::LARGER; } - CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_true&) const + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, const Tag_true&) const { return GeomTraits().do_intersect_3_object() (GeomTraits().construct_sphere_3_object() @@ -422,7 +424,7 @@ public: CGAL::SMALLER : CGAL::LARGER; } - CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_false&) const + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, const Tag_false&) const { return GeomTraits().do_intersect_3_object() (GeomTraits().construct_sphere_3_object() @@ -430,10 +432,22 @@ public: CGAL::SMALLER : CGAL::LARGER; } - CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const - { - return (*this)(p, bb, bound, typename GeomTraits::Has_filtered_predicates_tag()); - } + template ::value> + struct Use_conservative_static_filters + { + typedef CGAL::Tag_false type; + }; + + template + struct Use_conservative_static_filters + { + typedef CGAL::Boolean_tag type; + }; + + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const + { + return (*this)(p, bb, bound, typename Use_conservative_static_filters::type()); + } template CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const FT& sq_distance) const From 3614dee0fbe1fd4b414b32aef8c4b82f060d3756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 10 Mar 2021 14:01:55 +0100 Subject: [PATCH 079/130] don't reinvent the wheel --- AABB_tree/include/CGAL/AABB_traits.h | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_traits.h b/AABB_tree/include/CGAL/AABB_traits.h index a022070a654..85c86355c57 100644 --- a/AABB_tree/include/CGAL/AABB_traits.h +++ b/AABB_tree/include/CGAL/AABB_traits.h @@ -432,21 +432,9 @@ public: CGAL::SMALLER : CGAL::LARGER; } - template ::value> - struct Use_conservative_static_filters - { - typedef CGAL::Tag_false type; - }; - - template - struct Use_conservative_static_filters - { - typedef CGAL::Boolean_tag type; - }; - CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const { - return (*this)(p, bb, bound, typename Use_conservative_static_filters::type()); + return (*this)(p, bb, bound, CGAL::Boolean_tag::value>()); } template From 2b5cb2da9f08cc1fdbed23886c227dac16e5eaad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 10 Mar 2021 14:23:58 +0100 Subject: [PATCH 080/130] copy tags --- AABB_tree/include/CGAL/AABB_traits.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_traits.h b/AABB_tree/include/CGAL/AABB_traits.h index 85c86355c57..7cabbdae1df 100644 --- a/AABB_tree/include/CGAL/AABB_traits.h +++ b/AABB_tree/include/CGAL/AABB_traits.h @@ -416,7 +416,7 @@ public: CGAL::SMALLER : CGAL::LARGER; } - CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, const Tag_true&) const + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_true) const { return GeomTraits().do_intersect_3_object() (GeomTraits().construct_sphere_3_object() @@ -424,7 +424,7 @@ public: CGAL::SMALLER : CGAL::LARGER; } - CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, const Tag_false&) const + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_false) const { return GeomTraits().do_intersect_3_object() (GeomTraits().construct_sphere_3_object() @@ -434,7 +434,7 @@ public: CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const { - return (*this)(p, bb, bound, CGAL::Boolean_tag::value>()); + return (*this)(p, bb, bound, Boolean_tag::value>()); } template From e6c2e5c9499c4c94fb994e1de15f9daca51ce8af Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Mar 2021 13:23:01 +0000 Subject: [PATCH 081/130] Simplify. todo: tighter bounds per case or factorization with a lambda --- .../internal/Static_filters/Do_intersect_3.h | 245 ++++++++---------- 1 file changed, 103 insertions(+), 142 deletions(-) diff --git a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h index f5149d93f15..8f755a05965 100644 --- a/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h +++ b/Filtered_kernel/include/CGAL/internal/Static_filters/Do_intersect_3.h @@ -178,18 +178,14 @@ public: Get_approx get_approx; // Identity functor for all points const Point_3& c = s.center(); - double scx, scy, scz, ssr, bxmin, bymin, bzmin, bxmax, bymax, bzmax; + double scx, scy, scz, ssr; + double bxmin = b.xmin() , bymin = b.ymin() , bzmin = b.zmin() , + bxmax = b.xmax() , bymax = b.ymax() , bzmax = b.zmax() ; if (fit_in_double(get_approx(c).x(), scx) && fit_in_double(get_approx(c).y(), scy) && fit_in_double(get_approx(c).z(), scz) && - fit_in_double(s.squared_radius(), ssr) && - fit_in_double(b.xmin(), bxmin) && - fit_in_double(b.ymin(), bymin) && - fit_in_double(b.zmin(), bzmin) && - fit_in_double(b.xmax(), bxmax) && - fit_in_double(b.ymax(), bymax) && - fit_in_double(b.zmax(), bzmax)) + fit_in_double(s.squared_radius(), ssr)) { CGAL_BRANCH_PROFILER_BRANCH_1(tmp); @@ -199,32 +195,30 @@ public: } double distance = 0; double max1 = 0; - + double double_tmp_result = 0; + double eps = 0; if(scx < bxmin) { double bxmin_scx = bxmin - scx; max1 = bxmin_scx; distance = square(bxmin_scx); -#ifdef EARLY - { - double double_tmp_result = (distance - ssr); + double_tmp_result = (distance - ssr); - if (max1 < 3.33558365626356687717e-147){ + if( (max1 < 3.33558365626356687717e-147) || (max1 > 1.67597599124282407923e+153) ){ + if(overestimate){ + return true; + }else{ CGAL_BRANCH_PROFILER_BRANCH_2(tmp); return Base::operator()(s,b); } - if (max1 > 1.67597599124282407923e+153){ - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); - } - - double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); - - if (double_tmp_result > eps) - return false; } -#endif + + eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); + + if (double_tmp_result > eps){ + return false; + } } else if(scx > bxmax) { @@ -232,169 +226,136 @@ public: max1 = scx_bxmax; distance = square(scx_bxmax); -#ifdef EARLY - { - double double_tmp_result = (distance - ssr); + double_tmp_result = (distance - ssr); - if (max1 < 3.33558365626356687717e-147){ + if( (max1 < 3.33558365626356687717e-147) || (max1 > 1.67597599124282407923e+153)){ + if(overestimate){ + return true; + }else{ CGAL_BRANCH_PROFILER_BRANCH_2(tmp); return Base::operator()(s,b); } - if (max1 > 1.67597599124282407923e+153){ - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); - } - - double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); - - if (double_tmp_result > eps) - return false; } -#endif + + eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); + + if (double_tmp_result > eps){ + return false; + } } - - - if(scy < bymin) { double bymin_scy = bymin - scy; - if(max1 < bymin_scy) + if(max1 < bymin_scy){ max1 = bymin_scy; + } distance += square(bymin_scy); -#ifdef EARLY - { - double double_tmp_result = (distance - ssr); + double_tmp_result = (distance - ssr); - if (max1 < 3.33558365626356687717e-147){ + if( (max1 < 3.33558365626356687717e-147) || ((max1 > 1.67597599124282407923e+153)) ){ + if(overestimate){ + return true; + }else{ CGAL_BRANCH_PROFILER_BRANCH_2(tmp); return Base::operator()(s,b); } - if ((max1 > 1.67597599124282407923e+153)){ - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); - } - - double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); - - if (double_tmp_result > eps) - return false; } -#endif + + eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); + + if (double_tmp_result > eps){ + return false; + } } else if(scy > bymax) { double scy_bymax = scy - bymax; - if(max1 < scy_bymax) + if(max1 < scy_bymax){ max1 = scy_bymax; - - distance += square(scy_bymax); -#ifdef EARLY - - { - double double_tmp_result = (distance - ssr); - - if ((max1 < 3.33558365626356687717e-147)){ - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); - } - if ((max1 > 1.67597599124282407923e+153)){ - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); - } - - double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); - - if (double_tmp_result > eps) - return false; } -#endif + distance += square(scy_bymax); + double_tmp_result = (distance - ssr); + + if( ((max1 < 3.33558365626356687717e-147)) || ((max1 > 1.67597599124282407923e+153)) ){ + if(overestimate){ + return true; + }else{ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } + } + + eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); + + if (double_tmp_result > eps){ + return false; + } } + if(scz < bzmin) { double bzmin_scz = bzmin - scz; - if(max1 < bzmin_scz) + if(max1 < bzmin_scz){ max1 = bzmin_scz; - - distance += square(bzmin_scz); -#ifdef EARLY - { - double double_tmp_result = (distance - ssr); - - if ((max1 < 3.33558365626356687717e-147)){ - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); - } - if ((max1 > 1.67597599124282407923e+153)){ - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); - } - - double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); - - if (double_tmp_result > eps) - return false; } -#endif + distance += square(bzmin_scz); + double_tmp_result = (distance - ssr); + + if( ((max1 < 3.33558365626356687717e-147)) || ((max1 > 1.67597599124282407923e+153))){ + if(overestimate){ + return true; + }else{ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); + } + } + + eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); + + if (double_tmp_result > eps){ + return false; + } } else if(scz > bzmax) { double scz_bzmax = scz - bzmax; - if(max1 < scz_bzmax) + if(max1 < scz_bzmax){ max1 = scz_bzmax; + } distance += square(scz_bzmax); -#ifdef EARLY - { - double double_tmp_result = (distance - ssr); + double_tmp_result = (distance - ssr); - if ((max1 < 3.33558365626356687717e-147)){ - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); - } - if ((max1 > 1.67597599124282407923e+153)){ - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); - } - - double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); - - if (double_tmp_result > eps) - return false; - } -#endif - } - - double double_tmp_result = (distance - ssr); - -#ifndef EARLY - if (max1 < 3.33558365626356687717e-147){ - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); - } - if (max1 > 1.67597599124282407923e+153){ - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); - } -#endif - double eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); - - if (double_tmp_result > eps) - return false; - else - { - if (double_tmp_result < -eps) - return true; - else { + if( ((max1 < 3.33558365626356687717e-147)) || ((max1 > 1.67597599124282407923e+153)) ){ if(overestimate){ return true; + }else{ + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); } - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); } + + eps = 1.99986535548615598560e-15 * (std::max) (ssr, square(max1)); + + if (double_tmp_result > eps){ + return false; + } + } + + // double_tmp_result and eps were growing all the time + // no need to test for > eps as done earlier in at least one case + if (double_tmp_result < -eps){ + return true; + } else { + if(overestimate){ + return true; + } + CGAL_BRANCH_PROFILER_BRANCH_2(tmp); + return Base::operator()(s,b); } CGAL_BRANCH_PROFILER_BRANCH_2(tmp); From da17681a0630c01e2e1fa458117919c082bded89 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Mar 2021 13:26:32 +0000 Subject: [PATCH 082/130] Avoid computing degree several times --- .../internal/Isotropic_remeshing/remesh_impl.h | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h index 551c1294cfa..16f46e7cb7c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h @@ -828,8 +828,6 @@ namespace internal { std::cout << "Equalize valences..." << std::endl; #endif -#define VALE -#ifdef VALE typedef typename boost::property_map >::type Vertex_degree; Vertex_degree degree = get(CGAL::dynamic_vertex_property_t(), mesh_); @@ -841,7 +839,6 @@ namespace internal { vertex_descriptor t = target(h, mesh_); put(degree, t, get(degree,t)+1); } -#endif unsigned int nb_flips = 0; for(edge_descriptor e : edges(mesh_)) @@ -855,17 +852,12 @@ namespace internal { vertex_descriptor vb = target(he, mesh_); vertex_descriptor vc = target(next(he, mesh_), mesh_); vertex_descriptor vd = target(next(opposite(he, mesh_), mesh_), mesh_); -#ifdef VALE + int vva = get(degree,va), tvva = target_valence(va); int vvb = get(degree, vb), tvvb = target_valence(vb); int vvc = get(degree,vc), tvvc = target_valence(vc); int vvd = get(degree,vd), tvvd = target_valence(vd); -#else - int vva = valence(va), tvva = target_valence(va); - int vvb = valence( vb), tvvb = target_valence(vb); - int vvc = valence(vc), tvvc = target_valence(vc); - int vvd = valence(vd), tvvd = target_valence(vd); -#endif + int deviation_pre = CGAL::abs(vva - tvva) + CGAL::abs(vvb - tvvb) + CGAL::abs(vvc - tvvc) @@ -1227,11 +1219,6 @@ private: out.close(); } - int valence(const vertex_descriptor& v) const - { - return static_cast(degree(v, mesh_)); - } - int target_valence(const vertex_descriptor& v) const { return (has_border_ && is_border(v, mesh_)) ? 4 : 6; From 6d9ff5978ee6993b8e4b4f23e16a226d861741c2 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Mar 2021 16:19:32 +0000 Subject: [PATCH 083/130] Do not test has_on for a constructed point where we know that it will be true --- Nef_S2/include/CGAL/Nef_S2/Sphere_segment.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Nef_S2/include/CGAL/Nef_S2/Sphere_segment.h b/Nef_S2/include/CGAL/Nef_S2/Sphere_segment.h index 7823c2a99f7..d9404603373 100644 --- a/Nef_S2/include/CGAL/Nef_S2/Sphere_segment.h +++ b/Nef_S2/include/CGAL/Nef_S2/Sphere_segment.h @@ -210,7 +210,7 @@ bool has_on(const Sphere_point& p) const; /*{\Mop return true iff |\Mvar| contains |p|.}*/ bool has_on_after_intersection(const Sphere_point& p) const; -bool has_in_relative_interior(const Sphere_point& p) const; + bool has_in_relative_interior(const Sphere_point& p, bool check_has_on = true) const; /*{\Mop return true iff |\Mvar| contains |p| in its relative interior.}*/ @@ -315,8 +315,8 @@ has_on_after_intersection(const CGAL::Sphere_point& p) const { template bool Sphere_segment:: -has_in_relative_interior(const CGAL::Sphere_point& p) const -{ if ( !sphere_circle().has_on(p) ) return false; +has_in_relative_interior(const CGAL::Sphere_point& p, bool check_has_on) const +{ if (check_has_on &&( !sphere_circle().has_on(p) ) ) return false; if ( !is_long() ) { return orientation(Point_3(0,0,0), CGAL::ORIGIN + sphere_circle().orthogonal_vector(), @@ -360,11 +360,11 @@ bool do_intersect_internally(const Sphere_segment& s1, if ( equal_as_sets(s1.sphere_circle(),s2.sphere_circle()) ) return false; p = CGAL::intersection(s1.sphere_circle(),s2.sphere_circle()); - if ( s1.has_in_relative_interior(p) && - s2.has_in_relative_interior(p) ) return true; + if ( s1.has_in_relative_interior(p, false) && + s2.has_in_relative_interior(p, false) ) return true; p = p.antipode(); - if ( s1.has_in_relative_interior(p) && - s2.has_in_relative_interior(p) ) return true; + if ( s1.has_in_relative_interior(p, false) && + s2.has_in_relative_interior(p, false) ) return true; return false; } @@ -377,9 +377,9 @@ bool do_intersect_internally(const Sphere_circle& c1, if ( equal_as_sets(c1,s2.sphere_circle()) ) return false; p = CGAL::intersection(c1,s2.sphere_circle()); - if ( s2.has_in_relative_interior(p) ) return true; + if ( s2.has_in_relative_interior(p, false) ) return true; p = p.antipode(); - if ( s2.has_in_relative_interior(p) ) return true; + if ( s2.has_in_relative_interior(p, false) ) return true; return false; } From 2334ec5f4b70d42372c74037921fddc6803d7f15 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Mar 2021 18:40:03 +0000 Subject: [PATCH 084/130] s gets constructed from a vertex some lines above --- Nef_S2/include/CGAL/Nef_S2/SM_point_locator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nef_S2/include/CGAL/Nef_S2/SM_point_locator.h b/Nef_S2/include/CGAL/Nef_S2/SM_point_locator.h index c26d0ad7bae..8dbce0ced5e 100644 --- a/Nef_S2/include/CGAL/Nef_S2/SM_point_locator.h +++ b/Nef_S2/include/CGAL/Nef_S2/SM_point_locator.h @@ -257,7 +257,7 @@ public: Unique_hash_map visited(false); CGAL_forall_svertices(v,*this) { Sphere_point vp = v->point(); - if ( s.has_on(vp) ) { + if ( (v == v_res) || s.has_on(vp) ) { CGAL_NEF_TRACEN(" location via vertex at "< Date: Thu, 11 Mar 2021 13:32:46 +0000 Subject: [PATCH 085/130] Avoid a geometric test --- Nef_3/include/CGAL/Nef_3/SNC_point_locator.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h b/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h index 3b81b1119c0..b11861428cb 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h @@ -849,7 +849,24 @@ public: _CGAL_NEF_TRACEN("found on facet..."); return make_object(f); } - if( is.does_intersect_internally(s,f,ip)) { + + // We next check if v is a vertex on the face to avoid a geometric test + bool v_vertex_of_f = false; + Halffacet_cycle_iterator fci; + for(fci=f->facet_cycles_begin(); fci!=f->facet_cycles_end(); ++fci) { + if(fci.is_shalfedge()) { + SHalfedge_around_facet_circulator sfc(fci), send(sfc); + CGAL_For_all(sfc,send) { + if(sfc->source()->center_vertex() == v){ + v_vertex_of_f = true; + break; + } + } + } + } + + + if( (! v_vertex_of_f) && is.does_intersect_internally(s,f,ip) ) { s = Segment_3(p, normalized(ip)); result = make_object(f); } From 6b50fb2f10d137fa0abb03ad900e01bebba7f3a8 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 11 Mar 2021 15:14:34 +0100 Subject: [PATCH 086/130] disable nbSmoothing_spinbox when splitEdgesOnly_checkbox is checked --- .../Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp index 5bcf30de208..6fbf8082fef 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp @@ -954,9 +954,11 @@ private: ui.nbIterations_spinbox, SLOT(setDisabled(bool))); connect(ui.splitEdgesOnly_checkbox, SIGNAL(toggled(bool)), ui.protect_checkbox, SLOT(setDisabled(bool))); - connect(ui.protect_checkbox, SIGNAL(toggled(bool)), + connect(ui.splitEdgesOnly_checkbox, SIGNAL(toggled(bool)), ui.smooth1D_checkbox, SLOT(setDisabled(bool))); connect(ui.splitEdgesOnly_checkbox, SIGNAL(toggled(bool)), + ui.nbSmoothing_spinbox, SLOT(setDisabled(bool))); + connect(ui.protect_checkbox, SIGNAL(toggled(bool)), ui.smooth1D_checkbox, SLOT(setDisabled(bool))); connect(ui.preserveDuplicates_checkbox, SIGNAL(toggled(bool)), ui.protect_checkbox, SLOT(setChecked(bool))); From b0d871bf8f4df1b67453bb8cbe29bf2755556ef2 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 11 Mar 2021 15:21:08 +0100 Subject: [PATCH 087/130] change the tab-order for options in UI --- .../demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_dialog.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_dialog.ui b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_dialog.ui index 68b8ee3a92f..a35ec28d966 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_dialog.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_dialog.ui @@ -245,12 +245,12 @@ splitEdgesOnly_checkbox + edgeLength_dspinbox nbIterations_spinbox nbSmoothing_spinbox protect_checkbox smooth1D_checkbox preserveDuplicates_checkbox - buttonBox From bd1b96e73b62ff8f2849cded6c3b6a4d1a73174a Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 11 Mar 2021 16:27:37 +0000 Subject: [PATCH 088/130] Do not compute a scalar product to determine best projection direction --- Nef_3/include/CGAL/Nef_3/bounded_side_3.h | 39 +++++++++++++---------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/bounded_side_3.h b/Nef_3/include/CGAL/Nef_3/bounded_side_3.h index e8d575d5582..549c1b47d3a 100644 --- a/Nef_3/include/CGAL/Nef_3/bounded_side_3.h +++ b/Nef_3/include/CGAL/Nef_3/bounded_side_3.h @@ -30,17 +30,17 @@ namespace CGAL { template -Point_2 point_3_get_x_y_point_2(Point_3 p) { +Point_2 point_3_get_x_y_point_2(const Point_3& p) { return( Point_2(p.hx(), p.hy(), p.hw()) ); } template -Point_2 point_3_get_y_z_point_2(Point_3 p) { +Point_2 point_3_get_y_z_point_2(const Point_3& p) { return( Point_2(p.hy(), p.hz(), p.hw()) ); } template -Point_2 point_3_get_z_x_point_2(Point_3 p) { +Point_2 point_3_get_z_x_point_2(const Point_3& p) { return( Point_2(p.hz(), p.hx(), p.hw()) ); } @@ -70,21 +70,27 @@ Bounded_side bounded_side_3(IteratorForward first, + auto apv = approx(plane.orthogonal_vector()); + + int dir = 0; + auto max = CGAL::abs(apv.x()); + if(CGAL::abs(apv.y()) > max){ + dir = 1; + max = CGAL::abs(apv.y()); + } + if(CGAL::abs(apv.z()) > max){ + dir = 2; + } + + CGAL_assertion(!plane.is_degenerate()); - Point_2 (*t)(Point_3); - Vector_3 pv(plane.orthogonal_vector()), pxy(0,0,1), pyz(1,0,0), pzx(0,1,0); - CGAL_NEF_TRACEN("pv*pxz: "<; - else if( !CGAL_NTS is_zero(pv*pyz) ) - /* the plane is not perpendicular to the YZ plane */ + Point_2 (*t)(const Point_3&); + + if(dir == 0){ t = &point_3_get_y_z_point_2< Point_2, Point_3>; - else { - CGAL_assertion( !CGAL_NTS is_zero(pv*pxy) ); - /* the plane is not perpendicular to the XY plane */ + }else if(dir == 1){ + t = &point_3_get_z_x_point_2< Point_2, Point_3>; + }else{ t = &point_3_get_x_y_point_2< Point_2, Point_3>; } @@ -95,7 +101,6 @@ Bounded_side bounded_side_3(IteratorForward first, points.push_back( t(*first)); } Bounded_side side = bounded_side_2( points.begin(), points.end(), t(point)); - points.clear(); return side; } From 54b55e0a48f824c4f4b5a04b23647728aa5f51ef Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Sat, 13 Mar 2021 16:55:32 +0000 Subject: [PATCH 089/130] Stupid me, after even have explained how interval arithmetic sometimes does not work --- Nef_3/include/CGAL/Nef_3/bounded_side_3.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/bounded_side_3.h b/Nef_3/include/CGAL/Nef_3/bounded_side_3.h index 549c1b47d3a..a20ac42f948 100644 --- a/Nef_3/include/CGAL/Nef_3/bounded_side_3.h +++ b/Nef_3/include/CGAL/Nef_3/bounded_side_3.h @@ -73,12 +73,12 @@ Bounded_side bounded_side_3(IteratorForward first, auto apv = approx(plane.orthogonal_vector()); int dir = 0; - auto max = CGAL::abs(apv.x()); - if(CGAL::abs(apv.y()) > max){ + double max = CGAL::abs(apv.x().sup()); + if(CGAL::abs(apv.y().sup()) > max){ dir = 1; - max = CGAL::abs(apv.y()); + max = CGAL::abs(apv.y().sup()); } - if(CGAL::abs(apv.z()) > max){ + if(CGAL::abs(apv.z().sup()) > max){ dir = 2; } From 6a27761f4fae07fcfd9f2e98fa868c3f09e84a5f Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sat, 13 Mar 2021 16:52:11 +0000 Subject: [PATCH 090/130] Add homogeneous/cartesian specialisations --- Nef_3/include/CGAL/Nef_3/bounded_side_3.h | 43 +++++++++++++++++++---- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/bounded_side_3.h b/Nef_3/include/CGAL/Nef_3/bounded_side_3.h index a20ac42f948..a34ed350fd4 100644 --- a/Nef_3/include/CGAL/Nef_3/bounded_side_3.h +++ b/Nef_3/include/CGAL/Nef_3/bounded_side_3.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #undef CGAL_NEF_DEBUG @@ -30,20 +31,50 @@ namespace CGAL { template -Point_2 point_3_get_x_y_point_2(const Point_3& p) { +Point_2 point_3_get_x_y_point_2(const Point_3& p, const Homogeneous_tag&) { return( Point_2(p.hx(), p.hy(), p.hw()) ); } template -Point_2 point_3_get_y_z_point_2(const Point_3& p) { +Point_2 point_3_get_y_z_point_2(const Point_3& p, const Homogeneous_tag&) { return( Point_2(p.hy(), p.hz(), p.hw()) ); } template -Point_2 point_3_get_z_x_point_2(const Point_3& p) { +Point_2 point_3_get_z_x_point_2(const Point_3& p, const Homogeneous_tag&) { return( Point_2(p.hz(), p.hx(), p.hw()) ); } +template +Point_2 point_3_get_x_y_point_2(const Point_3& p, const Cartesian_tag&) { + return( Point_2(p.x(), p.y()) ); +} + +template +Point_2 point_3_get_y_z_point_2(const Point_3& p, const Cartesian_tag&) { + return( Point_2(p.y(), p.z()) ); +} + +template +Point_2 point_3_get_z_x_point_2(const Point_3& p, const Cartesian_tag&) { + return( Point_2(p.z(), p.x()) ); +} + +template +Point_2 point_3_get_x_y_point_2(const Point_3& p) { + return point_3_get_x_y_point_2(p,typename R::Kernel_tag()); +} + +template +Point_2 point_3_get_y_z_point_2(const Point_3& p) { + return point_3_get_y_z_point_2(p,typename R::Kernel_tag()); +} + +template +Point_2 point_3_get_z_x_point_2(const Point_3& p) { + return point_3_get_z_x_point_2(p,typename R::Kernel_tag()); +} + template Bounded_side bounded_side_3(IteratorForward first, IteratorForward last, @@ -87,11 +118,11 @@ Bounded_side bounded_side_3(IteratorForward first, Point_2 (*t)(const Point_3&); if(dir == 0){ - t = &point_3_get_y_z_point_2< Point_2, Point_3>; + t = &point_3_get_y_z_point_2< Point_2, Point_3, R>; }else if(dir == 1){ - t = &point_3_get_z_x_point_2< Point_2, Point_3>; + t = &point_3_get_z_x_point_2< Point_2, Point_3, R>; }else{ - t = &point_3_get_x_y_point_2< Point_2, Point_3>; + t = &point_3_get_x_y_point_2< Point_2, Point_3, R>; } std::vector< Point_2> points; From 5235fd6d2ccbe5447172cb30308a0219f7603cee Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Mon, 15 Mar 2021 10:50:14 +0100 Subject: [PATCH 091/130] moved min/max definitions of Segment_2/3 inside the class --- Kernel_23/include/CGAL/Segment_2.h | 31 +++++++++--------------------- Kernel_23/include/CGAL/Segment_3.h | 28 ++++++++------------------- 2 files changed, 17 insertions(+), 42 deletions(-) diff --git a/Kernel_23/include/CGAL/Segment_2.h b/Kernel_23/include/CGAL/Segment_2.h index ba533d050d2..8143beeb5c0 100644 --- a/Kernel_23/include/CGAL/Segment_2.h +++ b/Kernel_23/include/CGAL/Segment_2.h @@ -93,12 +93,17 @@ public: return target(); } + decltype(auto) + min BOOST_PREVENT_MACRO_SUBSTITUTION() const { + typename R_::Less_xy_2 less_xy; + return less_xy(source(), target()) ? source() : target(); + } decltype(auto) - min BOOST_PREVENT_MACRO_SUBSTITUTION() const; - - decltype(auto) - max BOOST_PREVENT_MACRO_SUBSTITUTION () const; + max BOOST_PREVENT_MACRO_SUBSTITUTION() const { + typename R_::Less_xy_2 less_xy; + return less_xy(source(), target()) ? target() : source(); + } decltype(auto) vertex(int i) const @@ -172,24 +177,6 @@ public: } }; -template < class R_ > -CGAL_KERNEL_INLINE -decltype(auto) -Segment_2::min BOOST_PREVENT_MACRO_SUBSTITUTION () const -{ - typename R_::Less_xy_2 less_xy; - return less_xy(source(),target()) ? source() : target(); -} - -template < class R_ > -CGAL_KERNEL_INLINE -decltype(auto) -Segment_2::max BOOST_PREVENT_MACRO_SUBSTITUTION () const -{ - typename R_::Less_xy_2 less_xy; - return less_xy(source(),target()) ? target() : source(); -} - template < class R_ > CGAL_KERNEL_INLINE diff --git a/Kernel_23/include/CGAL/Segment_3.h b/Kernel_23/include/CGAL/Segment_3.h index a15d3439874..fa0e4e7569d 100644 --- a/Kernel_23/include/CGAL/Segment_3.h +++ b/Kernel_23/include/CGAL/Segment_3.h @@ -93,10 +93,16 @@ public: } decltype(auto) - min BOOST_PREVENT_MACRO_SUBSTITUTION () const; + min BOOST_PREVENT_MACRO_SUBSTITUTION() const { + typename R_::Less_xyz_3 less_xyz; + return less_xyz(source(), target()) ? source() : target(); + } decltype(auto) - max BOOST_PREVENT_MACRO_SUBSTITUTION () const; + max BOOST_PREVENT_MACRO_SUBSTITUTION() const { + typename R_::Less_xyz_3 less_xyz; + return less_xyz(source(), target()) ? target() : source(); + } decltype(auto) vertex(int i) const @@ -162,24 +168,6 @@ public: }; -template < class R_ > -CGAL_KERNEL_INLINE -decltype(auto) -Segment_3::min BOOST_PREVENT_MACRO_SUBSTITUTION () const -{ - typename R_::Less_xyz_3 less_xyz; - return less_xyz(source(),target()) ? source() : target(); -} - -template < class R_ > -CGAL_KERNEL_INLINE -decltype(auto) -Segment_3::max BOOST_PREVENT_MACRO_SUBSTITUTION () const -{ - typename R_::Less_xyz_3 less_xyz; - return less_xyz(source(),target()) ? target() : source(); -} - template < class R > std::ostream & From ed4198d67d23a5f58b6324b821103b437aafdb75 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Tue, 16 Mar 2021 17:07:09 +0100 Subject: [PATCH 092/130] fixed the doc warning related to the ref of Chapter_dD_Geometry_Kernel --- Kernel_d/doc/Kernel_d/Kernel_d.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index ebccd581875..30c46dbc277 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -497,7 +497,7 @@ typedef Segment_d Segment; Segment s1, s2; std::cin >> s1 >> s2; -/* use auto */ +// use auto auto v = intersection(s1, s2); if (v) { // not empty From ac15312260ba9209332f5095b0dade4a88144653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 18 Mar 2021 14:47:56 +0100 Subject: [PATCH 093/130] add Ceres support cmake file --- Installation/cmake/modules/CGAL_Ceres_support.cmake | 7 +++++++ .../examples/Polygon_mesh_processing/CMakeLists.txt | 9 ++++----- .../test/Polygon_mesh_processing/CMakeLists.txt | 8 ++++---- Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt | 6 +++--- 4 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 Installation/cmake/modules/CGAL_Ceres_support.cmake diff --git a/Installation/cmake/modules/CGAL_Ceres_support.cmake b/Installation/cmake/modules/CGAL_Ceres_support.cmake new file mode 100644 index 00000000000..bd4d6c8de1e --- /dev/null +++ b/Installation/cmake/modules/CGAL_Ceres_support.cmake @@ -0,0 +1,7 @@ +if(CERES_FOUND AND NOT TARGET CGAL::Ceres_support) + add_library(CGAL::Ceres_support INTERFACE IMPORTED) + set_target_properties(CGAL::Ceres_support PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "CGAL_PMP_USE_CERES_SOLVER" + INTERFACE_INCLUDE_DIRECTORIES "${CERES_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "ceres") +endif() diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index f979cf8cad3..1227234619e 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -136,8 +136,7 @@ else() endif() find_package(Ceres QUIET) -if(TARGET ceres) - target_compile_definitions(mesh_smoothing_example - PRIVATE CGAL_PMP_USE_CERES_SOLVER) - target_link_libraries(mesh_smoothing_example PRIVATE ceres) -endif(TARGET ceres) +include(CGAL_Ceres_support) +if(TARGET CGAL::Ceres_support) + target_link_libraries(mesh_smoothing_example PUBLIC CGAL::Ceres_support) +endif(TARGET CGAL::Ceres_support) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index 08a65b9ffc4..8fffbb6afbe 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -125,14 +125,14 @@ if(OpenMesh_FOUND) endif() find_package(Ceres QUIET) +include(CGAL_Ceres_support) -if(TARGET ceres AND TARGET CGAL::Eigen3_support) - target_compile_definitions( test_mesh_smoothing PRIVATE CGAL_PMP_USE_CERES_SOLVER ) - target_link_libraries( test_mesh_smoothing PUBLIC CGAL::Eigen3_support PRIVATE ceres ) +if(TARGET CGAL::Ceres_support AND TARGET CGAL::Eigen3_support) + target_link_libraries( test_mesh_smoothing PUBLIC CGAL::Eigen3_support CGAL::Ceres_support) # target_compile_definitions( test_pmp_repair_self_intersections PRIVATE CGAL_PMP_USE_CERES_SOLVER ) # target_link_libraries( test_pmp_repair_self_intersections PRIVATE ceres ) -endif(TARGET ceres AND TARGET CGAL::Eigen3_support) +endif(TARGET CGAL::Ceres_support AND TARGET CGAL::Eigen3_support) if(BUILD_TESTING) set_tests_properties( diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt index 0d3dea93625..577c980c628 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt @@ -42,9 +42,9 @@ if(TARGET CGAL::Eigen3_support) polyhedron_demo_plugin(smoothing_plugin Smoothing_plugin ${smoothingUI_FILES}) target_link_libraries(smoothing_plugin PUBLIC scene_surface_mesh_item scene_selection_item CGAL::Eigen3_support) find_package(Ceres QUIET) - if(TARGET ceres) - target_compile_definitions( smoothing_plugin PRIVATE CGAL_PMP_USE_CERES_SOLVER ) - target_link_libraries(smoothing_plugin PUBLIC ceres) + include(CGAL_Ceres_support) + if(TARGET CGAL::Ceres_support) + target_link_libraries(smoothing_plugin PUBLIC CGAL::Ceres_support) endif() set_package_properties( From 887b7d0eaa33b8ead4cbedd6623c60eab3caf9a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 18 Mar 2021 14:58:04 +0100 Subject: [PATCH 094/130] add METIS cmake support file --- BGL/examples/BGL_polyhedron_3/CMakeLists.txt | 12 +++++------- BGL/examples/BGL_surface_mesh/CMakeLists.txt | 6 +++--- Installation/cmake/modules/CGAL_METIS_support.cmake | 6 ++++++ Polyhedron/demo/Polyhedron/CMakeLists.txt | 5 +---- .../Plugins/Operations_on_polyhedra/CMakeLists.txt | 4 ++-- 5 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 Installation/cmake/modules/CGAL_METIS_support.cmake diff --git a/BGL/examples/BGL_polyhedron_3/CMakeLists.txt b/BGL/examples/BGL_polyhedron_3/CMakeLists.txt index f63a444cc7c..5f537a13683 100644 --- a/BGL/examples/BGL_polyhedron_3/CMakeLists.txt +++ b/BGL/examples/BGL_polyhedron_3/CMakeLists.txt @@ -51,12 +51,10 @@ else() endif() find_package( METIS ) -if( METIS_FOUND ) +include(CGAL_METIS_support) +if( TARGET CGAL::METIS_support ) create_single_source_cgal_program( "polyhedron_partition.cpp" ) - if( METIS_FOUND ) - target_include_directories( polyhedron_partition PRIVATE ${METIS_INCLUDE_DIRS} ) - target_link_libraries( polyhedron_partition PRIVATE ${METIS_LIBRARIES} ) - else() - message( STATUS "Examples that use the METIS library will not be compiled." ) - endif() + target_link_libraries( polyhedron_partition PUBLIC CGAL::METIS_support) +else() + message( STATUS "Examples that use the METIS library will not be compiled." ) endif() diff --git a/BGL/examples/BGL_surface_mesh/CMakeLists.txt b/BGL/examples/BGL_surface_mesh/CMakeLists.txt index f07081a0cd8..cc33dd58a0b 100644 --- a/BGL/examples/BGL_surface_mesh/CMakeLists.txt +++ b/BGL/examples/BGL_surface_mesh/CMakeLists.txt @@ -13,10 +13,10 @@ create_single_source_cgal_program("surface_mesh_dual.cpp") create_single_source_cgal_program("connected_components.cpp") find_package(METIS) -if( METIS_FOUND ) +include(CGAL_METIS_support) +if( TARGET CGAL::METIS_support ) create_single_source_cgal_program( "surface_mesh_partition.cpp" ) - target_include_directories( surface_mesh_partition PRIVATE ${METIS_INCLUDE_DIRS} ) - target_link_libraries( surface_mesh_partition PRIVATE ${METIS_LIBRARIES} ) + target_link_libraries( surface_mesh_partition PUBLIC CGAL::METIS_support ) else() message(STATUS "Examples that use the METIS library will not be compiled.") endif() diff --git a/Installation/cmake/modules/CGAL_METIS_support.cmake b/Installation/cmake/modules/CGAL_METIS_support.cmake new file mode 100644 index 00000000000..563bec6fc7f --- /dev/null +++ b/Installation/cmake/modules/CGAL_METIS_support.cmake @@ -0,0 +1,6 @@ +if(METIS_FOUND AND NOT TARGET CGAL::METIS_support) + add_library(CGAL::METIS_support INTERFACE IMPORTED) + set_target_properties(CGAL::METIS_support PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${METIS_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${METIS_LIBRARIES}") +endif() diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index 0bb7d129c9e..7645481f1f9 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -75,15 +75,12 @@ set_package_properties( include(CGAL_Eigen3_support) find_package(METIS) +include(CGAL_METIS_support) set_package_properties( METIS PROPERTIES DESCRIPTION "A library for partitionning." PURPOSE "Requiered for the partition plugin.") -if(METIS_FOUND) - include_directories(${METIS_INCLUDE_DIRS}) -endif() - # Activate concurrency? option(POLYHEDRON_DEMO_ACTIVATE_CONCURRENCY "Enable concurrency" ON) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/CMakeLists.txt index 2439f47b443..82d8554f6e3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/CMakeLists.txt @@ -20,10 +20,10 @@ target_link_libraries(diff_between_meshes_plugin PUBLIC scene_surface_mesh_item) polyhedron_demo_plugin(animate_mesh_plugin Animate_mesh_plugin ${animateUI_FILES}) target_link_libraries(animate_mesh_plugin PUBLIC scene_surface_mesh_item) - if( METIS_FOUND ) + if( TARGET CGAL::METIS_support ) qt5_wrap_ui( partitionUI_FILES PartitionDialog.ui ) polyhedron_demo_plugin(partition_plugin Partition_graph_plugin ${partitionUI_FILES}) - target_link_libraries(partition_plugin PUBLIC scene_surface_mesh_item ${METIS_LIBRARIES} ) + target_link_libraries(partition_plugin PUBLIC scene_surface_mesh_item CGAL::METIS_support ) else() message( "NOTICE : the Partition plugin needs METIS libraries and will not be compiled." From 109a893657c18d80216f6177f6301523f4557581 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 19 Mar 2021 11:30:05 +0100 Subject: [PATCH 095/130] remove #ifdef that should be defined --- .../internal/Isotropic_remeshing/remesh_impl.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h index 16f46e7cb7c..fa93c69d8de 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h @@ -875,12 +875,12 @@ namespace internal { vvb -= 1; vvc += 1; vvd += 1; -#ifdef VALE + put(degree, va, vva); put(degree, vb, vvb); put(degree, vc, vvc); put(degree, vd, vvd); -#endif + ++nb_flips; #ifdef CGAL_PMP_REMESHING_VERBOSE_PROGRESS @@ -916,17 +916,17 @@ namespace internal { CGAL_assertion( is_flip_topologically_allowed(edge(he, mesh_)) ); CGAL_assertion( !get(ecmap_, edge(he, mesh_)) ); CGAL::Euler::flip_edge(he, mesh_); -#ifdef VALE + vva += 1; vvb += 1; vvc -= 1; vvd -= 1; - put(degree, va, vva); - put(degree, vb, vvb); - put(degree, vc, vvc); - put(degree, vd, vvd); -#endif + put(degree, va, vva); + put(degree, vb, vvb); + put(degree, vc, vvc); + put(degree, vd, vvd); + --nb_flips; CGAL_assertion_code(Halfedge_status s3 = status(he)); From 29a40dc40b982465b42f72826590902d0f59aab8 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 19 Mar 2021 15:47:12 +0100 Subject: [PATCH 096/130] Remove the timer and the output of the result --- .../isotropic_remeshing_example.cpp | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp index bb246a9393c..2fb29d976ef 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp @@ -1,7 +1,5 @@ -#define EARLY #include #include -#include #include #include #include @@ -37,9 +35,6 @@ int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/pig.off"; - CGAL::Timer t; - t.start(); - Mesh mesh; if(!PMP::read_polygon_mesh(filename, mesh) || !CGAL::is_triangle_mesh(mesh)) { @@ -47,10 +42,7 @@ int main(int argc, char* argv[]) return 1; } - std::cout << "Read: " << t.time() << " sec" << std::endl; - t.reset(); - - double target_edge_length = (argc > 2) ? std::stod(std::string(argv[2])) : 1.0; + double target_edge_length = (argc > 2) ? std::stod(std::string(argv[2])) : 0.04; unsigned int nb_iter = 3; std::cout << "Split border..."; @@ -60,26 +52,14 @@ int main(int argc, char* argv[]) PMP::split_long_edges(border, target_edge_length, mesh); std::cout << "done." << std::endl; - - std::cout << "took " << t.time() << " sec" << std::endl; - t.reset(); - std::cout << "Start remeshing of " << filename << " (" << num_faces(mesh) << " faces)..." << std::endl; PMP::isotropic_remeshing(faces(mesh), target_edge_length, mesh, PMP::parameters::number_of_iterations(nb_iter) - .protect_constraints(true)); //i.e. protect border, here + .protect_constraints(true)); //i.e. protect border, here std::cout << "Remeshing done." << std::endl; - std::cout << "took " << t.time() << " sec" << std::endl; - t.reset(); - - std::ofstream out("out.off"); - out.precision(17); - //out << mesh << std::endl; - out.close(); - return 0; } From 97ae3cbcc0b5d563b22a5e3ddde8df4e82baad63 Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Sat, 20 Mar 2021 18:14:02 +0900 Subject: [PATCH 097/130] Work through expansions to find test failure --- Number_types/include/CGAL/FPU.h | 43 +++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index 8e724756917..79b757047a9 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -612,18 +612,57 @@ inline void force_ieee_double_precision() #endif } -// Implementation (not part of the user interface) +/* +NOTE: Remove before merge. + +Originally this was: + +#define CGAL_IA_SQRT(a) \ + CGAL_IA_FORCE_TO_DOUBLE(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(a))) + +In the normal path, IA_up is + return CGAL_IA_FORCE_TO_DOUBLE(d); + +So in the normal path this should be equivalent to + +return CGAL_IA_FORCE_TO_DOUBLE(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(a))); + +Unless there is some issue that I don't understand that's introduced by the function call. +*/ inline double IA_sqrt_up(double a) { return IA_up(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(a))); } +/* +NOTE: Remove before merge. + +Originally this was: + +FPU_set_cw(CGAL_FE_DOWNWARD); +double i = (d.inf() > 0.0) ? CGAL_IA_SQRT(d.inf()) : 0.0; +FPU_set_cw(CGAL_FE_UPWARD); + +define CGAL_IA_SQRT(a) \ + CGAL_IA_FORCE_TO_DOUBLE(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(a))) + +We pass d.inf() in + +So this should be equivalent to + +double i = (d.inf() > 0.0) ? CGAL_IA_FORCE_TO_DOUBLE(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(d))) : 0.0; + +but we see that the CGAL_IA_FORCE_TO_DOUBLE has been omitted. + +Let's remedy that and see if that addresses the test failure. +*/ + inline double IA_sqrt_toward_zero(double d) { #ifdef CGAL_ALWAYS_ROUND_TO_NEAREST return (d > 0.0) ? nextafter(std::sqrt(d), 0.) : 0.0; #else FPU_set_cw(CGAL_FE_DOWNWARD); - double i = (d > 0.0) ? CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(d)) : 0.0; + double i = (d > 0.0) ? CGAL_IA_FORCE_TO_DOUBLE(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(d))) : 0.0; FPU_set_cw(CGAL_FE_UPWARD); return i; #endif From 6b75fed7db2a2a9657ab615f259e5431b78bc6ac Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Sat, 20 Mar 2021 18:32:05 +0900 Subject: [PATCH 098/130] Clean up whitespace --- Number_types/include/CGAL/FPU.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index 79b757047a9..3b0157a0612 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -623,7 +623,7 @@ Originally this was: In the normal path, IA_up is return CGAL_IA_FORCE_TO_DOUBLE(d); -So in the normal path this should be equivalent to +So in the normal path this should be equivalent to return CGAL_IA_FORCE_TO_DOUBLE(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(a))); From 504e4cf08bead231a0752fdb820587dce6c4ed5e Mon Sep 17 00:00:00 2001 From: Doug Roeper Date: Sat, 20 Mar 2021 19:34:55 -0400 Subject: [PATCH 099/130] Linear_cell_complex_incremental_builder include Adds a missing include. This file uses `Generalized_map_tag` on line 50, which is defined in `Linear_cell_complex_base.h`. --- .../include/CGAL/Linear_cell_complex_incremental_builder.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h index 86328a5deb8..8f4ed8b1846 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h @@ -14,6 +14,7 @@ #include #include +#include namespace CGAL { template Date: Tue, 23 Mar 2021 08:12:11 +0100 Subject: [PATCH 100/130] Update CHANGED.md --- Installation/CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 5787fc1441b..26ff408f622 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -44,6 +44,10 @@ A comprehensive list of the supported file formats is available in the Stream_su ### [dD Triangulations](https://doc.cgal.org/5.3/Manual/packages.html#PkgTriangulations) - Added the function `insert_if_in_star()` to the class `CGAL::Regular_triangulation`, which enables users to insert a point `p` in a regular triangulation on the condition that `p` appears post-insertion in the star of a user-specified, existing vertex. +### [Classification](https://doc.cgal.org/5.3/Manual/packages.html#PkgClassification) +- **Breaking change**: the support for TensorFlow was dropped, the + classifier `CGAL::TensorFlow::Neural_network_classifier` was removed. + [Release 5.2](https://github.com/CGAL/cgal/releases/tag/v5.2) ----------- From 91de37ec3adb127b487cccc0bb6bdddd3e386f09 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 23 Mar 2021 11:25:53 +0100 Subject: [PATCH 101/130] Fix warning: std::pow(float, int) returns double instead of float in recent C++ --- .../include/CGAL/edge_aware_upsample_point_set.h | 2 +- .../CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h index 2beb500eb88..5a5ce0b0a33 100644 --- a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h +++ b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h @@ -437,7 +437,7 @@ edge_aware_upsample_point_set( // FT cos_sigma = static_cast(std::cos(FT(CGAL::to_double(sharpness_angle)) / FT(180) * FT(CGAL_PI))); - FT sharpness_bandwidth = std::pow((CGAL::max)((FT)1e-8, (FT)1.0 - cos_sigma), 2); + FT sharpness_bandwidth = static_cast(std::pow((CGAL::max)((FT)1e-8, (FT)1.0 - cos_sigma), 2)); FT sum_density = 0.0; unsigned int count_density = 1; diff --git a/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h b/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h index 820eee71576..e2e7bb38107 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h +++ b/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h @@ -1030,7 +1030,7 @@ namespace CGAL { } inline FT stop_probability(std::size_t largest_candidate, std::size_t num_pts, std::size_t num_candidates, std::size_t octree_depth) const { - return (std::min)(std::pow(FT(1) - FT(largest_candidate) + return (std::min)((FT)std::pow(FT(1) - FT(largest_candidate) / (FT(num_pts) * FT(octree_depth+1) * FT(1 << (m_required_samples - 1))), int(num_candidates)), FT(1)); From 60a568a03280f2abdb6220d250ce9e27c76c604e Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 23 Mar 2021 11:39:18 +0100 Subject: [PATCH 102/130] Do not compile PCA examples/tests without Eigen --- .../Principal_component_analysis/CMakeLists.txt | 10 ++++++---- .../test/Principal_component_analysis/CMakeLists.txt | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Principal_component_analysis/examples/Principal_component_analysis/CMakeLists.txt b/Principal_component_analysis/examples/Principal_component_analysis/CMakeLists.txt index 7499ccf9c83..0bb71659f24 100644 --- a/Principal_component_analysis/examples/Principal_component_analysis/CMakeLists.txt +++ b/Principal_component_analysis/examples/Principal_component_analysis/CMakeLists.txt @@ -9,6 +9,10 @@ find_package(CGAL REQUIRED) # Use Eigen find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater) include(CGAL_Eigen3_support) +if(NOT TARGET CGAL::Eigen3_support) + message(STATUS "NOTICE: This project requires Eigen 3.1 (or greater) and will not be compiled.") + return() +endif() # create a target per cppfile file( @@ -17,8 +21,6 @@ file( ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) foreach(cppfile ${cppfiles}) create_single_source_cgal_program("${cppfile}") - if(TARGET CGAL::Eigen3_support) - get_filename_component(target ${cppfile} NAME_WE) - target_link_libraries(${target} PUBLIC CGAL::Eigen3_support) - endif() + get_filename_component(target ${cppfile} NAME_WE) + target_link_libraries(${target} PUBLIC CGAL::Eigen3_support) endforeach() diff --git a/Principal_component_analysis/test/Principal_component_analysis/CMakeLists.txt b/Principal_component_analysis/test/Principal_component_analysis/CMakeLists.txt index 498476cdf5c..c81cffa2f8e 100644 --- a/Principal_component_analysis/test/Principal_component_analysis/CMakeLists.txt +++ b/Principal_component_analysis/test/Principal_component_analysis/CMakeLists.txt @@ -9,6 +9,10 @@ find_package(CGAL REQUIRED) # Use Eigen find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater) include(CGAL_Eigen3_support) +if(NOT TARGET CGAL::Eigen3_support) + message(STATUS "NOTICE: This project requires Eigen 3.1 (or greater) and will not be compiled.") + return() +endif() # create a target per cppfile file( @@ -17,8 +21,6 @@ file( ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) foreach(cppfile ${cppfiles}) create_single_source_cgal_program("${cppfile}") - if(TARGET CGAL::Eigen3_support) - get_filename_component(target ${cppfile} NAME_WE) - target_link_libraries(${target} PUBLIC CGAL::Eigen3_support) - endif() + get_filename_component(target ${cppfile} NAME_WE) + target_link_libraries(${target} PUBLIC CGAL::Eigen3_support) endforeach() From 9f1e0cb8d66666d3aaab0eadca50dbb62cfc26b3 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 23 Mar 2021 12:59:47 +0100 Subject: [PATCH 103/130] Fix Eigen in cmakelists --- Mesh_3/examples/Mesh_3/CMakeLists.txt | 303 +++++++++--------- .../Tetrahedral_remeshing/CMakeLists.txt | 11 +- 2 files changed, 161 insertions(+), 153 deletions(-) diff --git a/Mesh_3/examples/Mesh_3/CMakeLists.txt b/Mesh_3/examples/Mesh_3/CMakeLists.txt index 2f9ba7d5b27..f4ba1aab015 100644 --- a/Mesh_3/examples/Mesh_3/CMakeLists.txt +++ b/Mesh_3/examples/Mesh_3/CMakeLists.txt @@ -22,172 +22,175 @@ endif() # Use Eigen find_package(Eigen3 3.1.0 REQUIRED) #(3.1.0 or greater) include(CGAL_Eigen3_support) - -find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) -if(VTK_FOUND) - if(VTK_USE_FILE) - include(${VTK_USE_FILE}) - endif() - if("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) - message(STATUS "VTK found") - if(TARGET VTK::IOImage) - set(VTK_LIBRARIES VTK::ImagingGeneral VTK::IOImage) +if(TARGET CGAL::Eigen3_support) + find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) + if(VTK_FOUND) + if(VTK_USE_FILE) + include(${VTK_USE_FILE}) + endif() + if("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) + message(STATUS "VTK found") + if(TARGET VTK::IOImage) + set(VTK_LIBRARIES VTK::ImagingGeneral VTK::IOImage) + endif() + else() + message(STATUS "VTK version 6.0 or greater is required") endif() else() - message(STATUS "VTK version 6.0 or greater is required") - endif() -else() - message(STATUS "VTK was not found") -endif() - -create_single_source_cgal_program("mesh_hybrid_mesh_domain.cpp") -target_link_libraries(mesh_hybrid_mesh_domain PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program("mesh_implicit_sphere.cpp") -target_link_libraries(mesh_implicit_sphere PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program("mesh_implicit_sphere_variable_size.cpp") -target_link_libraries(mesh_implicit_sphere_variable_size - PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program("mesh_two_implicit_spheres_with_balls.cpp") -target_link_libraries(mesh_two_implicit_spheres_with_balls - PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program("mesh_implicit_domains_2.cpp" - "implicit_functions.cpp") -target_link_libraries(mesh_implicit_domains_2 PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program("mesh_cubes_intersection.cpp") -target_link_libraries(mesh_cubes_intersection PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program("mesh_cubes_intersection_with_features.cpp") -target_link_libraries(mesh_cubes_intersection_with_features - PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program("mesh_implicit_domains.cpp" - "implicit_functions.cpp") -target_link_libraries(mesh_implicit_domains PUBLIC CGAL::Eigen3_support) - -find_package( ITT QUIET ) -if(TARGET ITT::ITT) - target_link_libraries(mesh_implicit_domains PRIVATE ITT::ITT) - target_compile_definitions(mesh_implicit_domains PRIVATE CGAL_MESH_3_USE_INTEL_ITT) -endif() - -create_single_source_cgal_program( "mesh_polyhedral_domain.cpp" ) -target_link_libraries(mesh_polyhedral_domain PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program("mesh_polyhedral_domain_sm.cpp") -target_link_libraries(mesh_polyhedral_domain_sm PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program( - "mesh_polyhedral_domain_with_surface_inside.cpp") -target_link_libraries(mesh_polyhedral_domain_with_surface_inside - PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program("remesh_polyhedral_surface.cpp") -target_link_libraries(remesh_polyhedral_surface PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program("remesh_polyhedral_surface_sm.cpp") -target_link_libraries(remesh_polyhedral_surface_sm PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program("mesh_polyhedral_domain_with_features.cpp") -target_link_libraries(mesh_polyhedral_domain_with_features - PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program("mesh_polyhedral_domain_with_features_sm.cpp") -target_link_libraries(mesh_polyhedral_domain_with_features_sm - PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program( - "mesh_polyhedral_domain_with_lipschitz_sizing.cpp") -target_link_libraries(mesh_polyhedral_domain_with_lipschitz_sizing - PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program("mesh_polyhedral_complex.cpp") -target_link_libraries(mesh_polyhedral_complex PUBLIC CGAL::Eigen3_support) - -create_single_source_cgal_program("mesh_polyhedral_complex_sm.cpp") -target_link_libraries(mesh_polyhedral_complex_sm PUBLIC CGAL::Eigen3_support) - -if(TARGET CGAL::CGAL_ImageIO) - if(VTK_FOUND AND ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION - VERSION_GREATER 5)) - add_executable(mesh_3D_gray_vtk_image mesh_3D_gray_vtk_image.cpp) - target_link_libraries( - mesh_3D_gray_vtk_image - PUBLIC CGAL::Eigen3_support CGAL::CGAL CGAL::CGAL_ImageIO - ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ${VTK_LIBRARIES}) - cgal_add_test(mesh_3D_gray_vtk_image) - add_to_cached_list(CGAL_EXECUTABLE_TARGETS mesh_3D_gray_vtk_image) + message(STATUS "VTK was not found") endif() - create_single_source_cgal_program("mesh_3D_gray_image.cpp") - target_link_libraries(mesh_3D_gray_image PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("mesh_hybrid_mesh_domain.cpp") + target_link_libraries(mesh_hybrid_mesh_domain PUBLIC CGAL::Eigen3_support) - create_single_source_cgal_program("mesh_3D_gray_image_multiple_values.cpp") - target_link_libraries(mesh_3D_gray_image_multiple_values + create_single_source_cgal_program("mesh_implicit_sphere.cpp") + target_link_libraries(mesh_implicit_sphere PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program("mesh_implicit_sphere_variable_size.cpp") + target_link_libraries(mesh_implicit_sphere_variable_size PUBLIC CGAL::Eigen3_support) - create_single_source_cgal_program("mesh_3D_image_with_features.cpp") - target_link_libraries(mesh_3D_image_with_features PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("mesh_two_implicit_spheres_with_balls.cpp") + target_link_libraries(mesh_two_implicit_spheres_with_balls + PUBLIC CGAL::Eigen3_support) - if(CGAL_ImageIO_USE_ZLIB) - create_single_source_cgal_program("mesh_optimization_example.cpp") - target_link_libraries(mesh_optimization_example PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("mesh_implicit_domains_2.cpp" + "implicit_functions.cpp") + target_link_libraries(mesh_implicit_domains_2 PUBLIC CGAL::Eigen3_support) - create_single_source_cgal_program("mesh_optimization_lloyd_example.cpp") - target_link_libraries(mesh_optimization_lloyd_example + create_single_source_cgal_program("mesh_cubes_intersection.cpp") + target_link_libraries(mesh_cubes_intersection PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program("mesh_cubes_intersection_with_features.cpp") + target_link_libraries(mesh_cubes_intersection_with_features + PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program("mesh_implicit_domains.cpp" + "implicit_functions.cpp") + target_link_libraries(mesh_implicit_domains PUBLIC CGAL::Eigen3_support) + + find_package( ITT QUIET ) + if(TARGET ITT::ITT) + target_link_libraries(mesh_implicit_domains PRIVATE ITT::ITT) + target_compile_definitions(mesh_implicit_domains PRIVATE CGAL_MESH_3_USE_INTEL_ITT) + endif() + + create_single_source_cgal_program( "mesh_polyhedral_domain.cpp" ) + target_link_libraries(mesh_polyhedral_domain PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program("mesh_polyhedral_domain_sm.cpp") + target_link_libraries(mesh_polyhedral_domain_sm PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program( + "mesh_polyhedral_domain_with_surface_inside.cpp") + target_link_libraries(mesh_polyhedral_domain_with_surface_inside + PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program("remesh_polyhedral_surface.cpp") + target_link_libraries(remesh_polyhedral_surface PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program("remesh_polyhedral_surface_sm.cpp") + target_link_libraries(remesh_polyhedral_surface_sm PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program("mesh_polyhedral_domain_with_features.cpp") + target_link_libraries(mesh_polyhedral_domain_with_features + PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program("mesh_polyhedral_domain_with_features_sm.cpp") + target_link_libraries(mesh_polyhedral_domain_with_features_sm + PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program( + "mesh_polyhedral_domain_with_lipschitz_sizing.cpp") + target_link_libraries(mesh_polyhedral_domain_with_lipschitz_sizing + PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program("mesh_polyhedral_complex.cpp") + target_link_libraries(mesh_polyhedral_complex PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program("mesh_polyhedral_complex_sm.cpp") + target_link_libraries(mesh_polyhedral_complex_sm PUBLIC CGAL::Eigen3_support) + + if(TARGET CGAL::CGAL_ImageIO) + if(VTK_FOUND AND ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION + VERSION_GREATER 5)) + add_executable(mesh_3D_gray_vtk_image mesh_3D_gray_vtk_image.cpp) + target_link_libraries( + mesh_3D_gray_vtk_image + PUBLIC CGAL::Eigen3_support CGAL::CGAL CGAL::CGAL_ImageIO + ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ${VTK_LIBRARIES}) + cgal_add_test(mesh_3D_gray_vtk_image) + add_to_cached_list(CGAL_EXECUTABLE_TARGETS mesh_3D_gray_vtk_image) + endif() + + create_single_source_cgal_program("mesh_3D_gray_image.cpp") + target_link_libraries(mesh_3D_gray_image PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program("mesh_3D_gray_image_multiple_values.cpp") + target_link_libraries(mesh_3D_gray_image_multiple_values PUBLIC CGAL::Eigen3_support) - create_single_source_cgal_program("mesh_3D_image.cpp") - target_link_libraries(mesh_3D_image PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("mesh_3D_image_with_features.cpp") + target_link_libraries(mesh_3D_image_with_features PUBLIC CGAL::Eigen3_support) - create_single_source_cgal_program( - "mesh_3D_image_with_custom_initialization.cpp") - target_link_libraries(mesh_3D_image_with_custom_initialization - PUBLIC CGAL::Eigen3_support) + if(CGAL_ImageIO_USE_ZLIB) + create_single_source_cgal_program("mesh_optimization_example.cpp") + target_link_libraries(mesh_optimization_example PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program("mesh_optimization_lloyd_example.cpp") + target_link_libraries(mesh_optimization_lloyd_example + PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program("mesh_3D_image.cpp") + target_link_libraries(mesh_3D_image PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program( + "mesh_3D_image_with_custom_initialization.cpp") + target_link_libraries(mesh_3D_image_with_custom_initialization + PUBLIC CGAL::Eigen3_support) + + create_single_source_cgal_program("mesh_3D_image_variable_size.cpp") + target_link_libraries(mesh_3D_image_variable_size + PUBLIC CGAL::Eigen3_support) + else() + message( + STATUS + "NOTICE: The examples mesh_3D_image.cpp, mesh_3D_image_variable_size.cpp, mesh_optimization_example.cpp and mesh_optimization_lloyd_example.cpp need CGAL_ImageIO to be configured with ZLIB support, and will not be compiled." + ) + endif() - create_single_source_cgal_program("mesh_3D_image_variable_size.cpp") - target_link_libraries(mesh_3D_image_variable_size - PUBLIC CGAL::Eigen3_support) else() message( STATUS - "NOTICE: The examples mesh_3D_image.cpp, mesh_3D_image_variable_size.cpp, mesh_optimization_example.cpp and mesh_optimization_lloyd_example.cpp need CGAL_ImageIO to be configured with ZLIB support, and will not be compiled." + "NOTICE: Some examples need the CGAL_ImageIO library, and will not be compiled." ) endif() -else() - message( - STATUS - "NOTICE: Some examples need the CGAL_ImageIO library, and will not be compiled." - ) -endif() - -if(CGAL_ACTIVATE_CONCURRENT_MESH_3 AND TARGET CGAL::TBB_support) - foreach( - target - mesh_3D_image - mesh_3D_image_variable_size - mesh_3D_image_with_custom_initialization - mesh_3D_image_with_features - mesh_implicit_domains - mesh_implicit_sphere - mesh_implicit_sphere_variable_size - mesh_optimization_example - mesh_optimization_lloyd_example - mesh_polyhedral_complex - mesh_polyhedral_complex_sm - mesh_polyhedral_domain - mesh_polyhedral_domain_sm - mesh_polyhedral_domain_with_features - mesh_polyhedral_domain_with_features_sm - mesh_polyhedral_domain_with_lipschitz_sizing - mesh_two_implicit_spheres_with_balls) - if(TARGET ${target}) - target_link_libraries(${target} PUBLIC CGAL::TBB_support) - endif() - endforeach() -endif() + if(CGAL_ACTIVATE_CONCURRENT_MESH_3 AND TARGET CGAL::TBB_support) + foreach( + target + mesh_3D_image + mesh_3D_image_variable_size + mesh_3D_image_with_custom_initialization + mesh_3D_image_with_features + mesh_implicit_domains + mesh_implicit_sphere + mesh_implicit_sphere_variable_size + mesh_optimization_example + mesh_optimization_lloyd_example + mesh_polyhedral_complex + mesh_polyhedral_complex_sm + mesh_polyhedral_domain + mesh_polyhedral_domain_sm + mesh_polyhedral_domain_with_features + mesh_polyhedral_domain_with_features_sm + mesh_polyhedral_domain_with_lipschitz_sizing + mesh_two_implicit_spheres_with_balls) + if(TARGET ${target}) + target_link_libraries(${target} PUBLIC CGAL::TBB_support) + endif() + endforeach() + endif() +else() #CGAL::Eigen_3_support + message( STATUS "NOTICE: All examples need the Eigen_3 library, and will not be compiled." ) +endif() #CGAL::Eigen_3_support diff --git a/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/CMakeLists.txt b/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/CMakeLists.txt index 915f08fa948..417b560671c 100644 --- a/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/CMakeLists.txt +++ b/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/CMakeLists.txt @@ -36,9 +36,14 @@ create_single_source_cgal_program( "tetrahedral_remeshing_example.cpp" ) create_single_source_cgal_program( "tetrahedral_remeshing_with_features.cpp") create_single_source_cgal_program( "tetrahedral_remeshing_of_one_subdomain.cpp") create_single_source_cgal_program( "tetrahedral_remeshing_from_mesh.cpp") + +if(TARGET CGAL::Eigen3_support) create_single_source_cgal_program( "mesh_and_remesh_polyhedral_domain_with_features.cpp" ) -target_link_libraries(mesh_and_remesh_polyhedral_domain_with_features PUBLIC CGAL::Eigen3_support) -if(CGAL_ACTIVATE_CONCURRENT_MESH_3 AND TARGET CGAL::TBB_support) - target_link_libraries(mesh_and_remesh_polyhedral_domain_with_features PRIVATE CGAL::TBB_support) + target_link_libraries(mesh_and_remesh_polyhedral_domain_with_features PUBLIC CGAL::Eigen3_support) + if(CGAL_ACTIVATE_CONCURRENT_MESH_3 AND TARGET CGAL::TBB_support) + target_link_libraries(mesh_and_remesh_polyhedral_domain_with_features PRIVATE CGAL::TBB_support) + endif() +else() + message(STATUS "Some examples need the Eigen3 library, and will not be compiled.") endif() From ab14acff77dfb283366453be2cf5c8c59073832e Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 23 Mar 2021 13:14:41 +0100 Subject: [PATCH 104/130] Replace std::pow(x,2) by CGAL::square(x) --- Generator/include/CGAL/random_convex_hull_in_disc_2.h | 2 +- .../include/CGAL/bilateral_smooth_point_set.h | 4 ++-- .../include/CGAL/edge_aware_upsample_point_set.h | 4 ++-- .../include/CGAL/wlop_simplify_and_regularize_point_set.h | 2 +- .../CGAL/internal/Surface_mesh_segmentation/Disk_samplers.h | 2 +- .../Surface_mesh_segmentation/Expectation_maximization.h | 4 ++-- .../include/CGAL/internal/Surface_mesh_segmentation/Filters.h | 4 ++-- .../internal/Surface_mesh_segmentation/K_means_clustering.h | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Generator/include/CGAL/random_convex_hull_in_disc_2.h b/Generator/include/CGAL/random_convex_hull_in_disc_2.h index 0315a7108e4..4969ca9cb87 100644 --- a/Generator/include/CGAL/random_convex_hull_in_disc_2.h +++ b/Generator/include/CGAL/random_convex_hull_in_disc_2.h @@ -192,7 +192,7 @@ void random_convex_hull_in_disc_2(std::size_t n, double radius, std::list(std::floor(n / std::pow(std::log(static_cast(n)), 2))); + if (!fast) T = static_cast(std::floor(n / CGAL::square(std::log(static_cast(n))))); while (simulated_points < n) { // l is a list coming from a convex hull operation. we are moving the diff --git a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h index 420f8ecb833..8918301b6ee 100644 --- a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h @@ -90,7 +90,7 @@ compute_denoise_projection( Vector normal_sum = CGAL::NULL_VECTOR; FT cos_sigma = cos(sharpness_angle * CGAL_PI / 180.0); - FT sharpness_bandwidth = std::pow((CGAL::max)(1e-8, 1 - cos_sigma), 2); + FT sharpness_bandwidth = CGAL::square((CGAL::max)(1e-8, 1 - cos_sigma)); for (typename PointRange::iterator it : neighbor_pwns) { @@ -101,7 +101,7 @@ compute_denoise_projection( if (dist2 < radius2) { FT theta = std::exp(dist2 * iradius16); - FT psi = std::exp(-std::pow(1 - get(normal_map, vt) * nn, 2) + FT psi = std::exp(-CGAL::square(1 - get(normal_map, vt) * nn) / sharpness_bandwidth); weight = theta * psi; diff --git a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h index 5a5ce0b0a33..73c2484b1cd 100644 --- a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h +++ b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h @@ -212,7 +212,7 @@ update_new_point( for (unsigned int j = 0; j < candidate_num; j++) { - FT psi = std::exp(-std::pow(FT(1) - normal_cadidate[j] * t.normal, FT(2)) + FT psi = std::exp(-CGAL::square(FT(1) - normal_cadidate[j] * t.normal) / sharpness_bandwidth); FT project_diff_t_v = (t.pt - new_v.pt) * t.normal; FT weight = psi * theta; @@ -437,7 +437,7 @@ edge_aware_upsample_point_set( // FT cos_sigma = static_cast(std::cos(FT(CGAL::to_double(sharpness_angle)) / FT(180) * FT(CGAL_PI))); - FT sharpness_bandwidth = static_cast(std::pow((CGAL::max)((FT)1e-8, (FT)1.0 - cos_sigma), 2)); + FT sharpness_bandwidth = CGAL::square((CGAL::max)((FT)1e-8, (FT)1.0 - cos_sigma)); FT sum_density = 0.0; unsigned int count_density = 1; diff --git a/Point_set_processing_3/include/CGAL/wlop_simplify_and_regularize_point_set.h b/Point_set_processing_3/include/CGAL/wlop_simplify_and_regularize_point_set.h index a15bc4ec1ea..bd03a86ccf3 100644 --- a/Point_set_processing_3/include/CGAL/wlop_simplify_and_regularize_point_set.h +++ b/Point_set_processing_3/include/CGAL/wlop_simplify_and_regularize_point_set.h @@ -185,7 +185,7 @@ compute_update_sample_point( if (dist2 < 1e-10) continue; FT dist = std::sqrt(dist2); - weight = std::exp(dist2 * iradius16) * std::pow(FT(1.0) / dist, 2); // L1 + weight = std::exp(dist2 * iradius16) * CGAL::square(FT(1.0) / dist); // L1 if (!is_sample_densities_empty) { diff --git a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Disk_samplers.h b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Disk_samplers.h index cd8917ed12b..aca2e52cef4 100644 --- a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Disk_samplers.h +++ b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Disk_samplers.h @@ -88,7 +88,7 @@ public: for(std::size_t i = 0; i < number_of_points; ++i) { double Q = i * golden_ratio * CGAL_PI; double R = std::sqrt(static_cast(i) / number_of_points); - double weight = exp(-0.5 * (std::pow(R / CGAL_ANGLE_ST_DEV_DIVIDER, 2))); + double weight = exp(-0.5 * (CGAL::square(R / CGAL_ANGLE_ST_DEV_DIVIDER))); *out_it++ = Tuple(R * cos(Q), R * sin(Q), weight); } } else { diff --git a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Expectation_maximization.h b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Expectation_maximization.h index 0982f5eea0a..67dbfac4878 100644 --- a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Expectation_maximization.h +++ b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Expectation_maximization.h @@ -75,7 +75,7 @@ private: return x == mean ? 1.0 : 0.0; } - double e_over = -0.5 * std::pow((x - mean) / deviation, 2); + double e_over = -0.5 * CGAL::square((x - mean) / deviation); return exp(e_over) / deviation; } /** @@ -289,7 +289,7 @@ private: double new_deviation = 0.0; for(std::size_t point_i = 0; point_i < points.size(); ++point_i) { double membership = responsibility_matrix[center_i][point_i]; - new_deviation += membership * std::pow(points[point_i] - new_mean, 2); + new_deviation += membership * CGAL::square(points[point_i] - new_mean); } new_deviation = std::sqrt(new_deviation/total_membership); diff --git a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h index 6c6e231a604..ae2c7809284 100644 --- a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h +++ b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h @@ -92,7 +92,7 @@ public: double deviation = 0.0; for(typename std::map::iterator it = neighbors.begin(); it != neighbors.end(); ++it) { - deviation += std::pow(get(values, it->first) - current_sdf_value, 2); + deviation += CGAL::square(get(values, it->first) - current_sdf_value); } deviation = std::sqrt(deviation / neighbors.size()); if(deviation == 0.0) { @@ -133,7 +133,7 @@ public: private: /** Gaussian function for weighting. */ double gaussian_function(double value, double deviation) const { - return exp(-0.5 * (std::pow(value / deviation, 2))); + return exp(-0.5 * (CGAL::square(value / deviation))); } }; diff --git a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/K_means_clustering.h b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/K_means_clustering.h index c35b6301648..9ca194cac17 100644 --- a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/K_means_clustering.h +++ b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/K_means_clustering.h @@ -123,7 +123,7 @@ public: double cumulative_distance_square = 0.0; // distance_square holds closest distance that points have, so just test new coming center (i.e. centers.back()) for(std::size_t j = 0; j < points.size(); ++j) { - double new_distance = std::pow(centers.back() - points[j], 2); + double new_distance = CGAL::square(centers.back() - points[j]); if(new_distance < distance_square[j]) { distance_square[j] = new_distance; } @@ -422,7 +422,7 @@ private: double sum = 0.0; for(std::vector::const_iterator point_it = points.begin(); point_it != points.end(); ++point_it) { - sum += std::pow(centers[point_it->center_id].mean - point_it->data, 2); + sum += CGAL::square(centers[point_it->center_id].mean - point_it->data); } return sum; } From 12cf238ca2b4095c957ea740522722508291db09 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 23 Mar 2021 13:49:55 +0100 Subject: [PATCH 105/130] Don't REQUIRE Eigen --- Mesh_3/examples/Mesh_3/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mesh_3/examples/Mesh_3/CMakeLists.txt b/Mesh_3/examples/Mesh_3/CMakeLists.txt index f4ba1aab015..71f7bfc848e 100644 --- a/Mesh_3/examples/Mesh_3/CMakeLists.txt +++ b/Mesh_3/examples/Mesh_3/CMakeLists.txt @@ -20,7 +20,7 @@ if(CGAL_ACTIVATE_CONCURRENT_MESH_3 OR ENV{CGAL_ACTIVATE_CONCURRENT_MESH_3}) endif() # Use Eigen -find_package(Eigen3 3.1.0 REQUIRED) #(3.1.0 or greater) +find_package(Eigen3 3.1.0 QUIET) #(3.1.0 or greater) include(CGAL_Eigen3_support) if(TARGET CGAL::Eigen3_support) find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) From 5aa763e0559ae4e965ddf34900656c0d18711cd6 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 23 Mar 2021 14:57:15 +0100 Subject: [PATCH 106/130] Don't indent and use return() --- Mesh_3/examples/Mesh_3/CMakeLists.txt | 307 +++++++++++++------------- 1 file changed, 154 insertions(+), 153 deletions(-) diff --git a/Mesh_3/examples/Mesh_3/CMakeLists.txt b/Mesh_3/examples/Mesh_3/CMakeLists.txt index 71f7bfc848e..24d2dfd4f2c 100644 --- a/Mesh_3/examples/Mesh_3/CMakeLists.txt +++ b/Mesh_3/examples/Mesh_3/CMakeLists.txt @@ -22,175 +22,176 @@ endif() # Use Eigen find_package(Eigen3 3.1.0 QUIET) #(3.1.0 or greater) include(CGAL_Eigen3_support) -if(TARGET CGAL::Eigen3_support) - find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) - if(VTK_FOUND) - if(VTK_USE_FILE) - include(${VTK_USE_FILE}) - endif() - if("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) - message(STATUS "VTK found") - if(TARGET VTK::IOImage) - set(VTK_LIBRARIES VTK::ImagingGeneral VTK::IOImage) - endif() - else() - message(STATUS "VTK version 6.0 or greater is required") +if(NOT TARGET CGAL::Eigen3_support) + message( STATUS "NOTICE: All examples need the Eigen3 library, and will not be compiled." ) + return() +endif() #CGAL::Eigen_3_support + +find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) +if(VTK_FOUND) + if(VTK_USE_FILE) + include(${VTK_USE_FILE}) + endif() + if("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) + message(STATUS "VTK found") + if(TARGET VTK::IOImage) + set(VTK_LIBRARIES VTK::ImagingGeneral VTK::IOImage) endif() else() - message(STATUS "VTK was not found") + message(STATUS "VTK version 6.0 or greater is required") + endif() +else() + message(STATUS "VTK was not found") +endif() + +create_single_source_cgal_program("mesh_hybrid_mesh_domain.cpp") +target_link_libraries(mesh_hybrid_mesh_domain PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program("mesh_implicit_sphere.cpp") +target_link_libraries(mesh_implicit_sphere PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program("mesh_implicit_sphere_variable_size.cpp") +target_link_libraries(mesh_implicit_sphere_variable_size + PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program("mesh_two_implicit_spheres_with_balls.cpp") +target_link_libraries(mesh_two_implicit_spheres_with_balls + PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program("mesh_implicit_domains_2.cpp" + "implicit_functions.cpp") +target_link_libraries(mesh_implicit_domains_2 PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program("mesh_cubes_intersection.cpp") +target_link_libraries(mesh_cubes_intersection PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program("mesh_cubes_intersection_with_features.cpp") +target_link_libraries(mesh_cubes_intersection_with_features + PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program("mesh_implicit_domains.cpp" + "implicit_functions.cpp") +target_link_libraries(mesh_implicit_domains PUBLIC CGAL::Eigen3_support) + +find_package( ITT QUIET ) +if(TARGET ITT::ITT) + target_link_libraries(mesh_implicit_domains PRIVATE ITT::ITT) + target_compile_definitions(mesh_implicit_domains PRIVATE CGAL_MESH_3_USE_INTEL_ITT) +endif() + +create_single_source_cgal_program( "mesh_polyhedral_domain.cpp" ) +target_link_libraries(mesh_polyhedral_domain PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program("mesh_polyhedral_domain_sm.cpp") +target_link_libraries(mesh_polyhedral_domain_sm PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program( + "mesh_polyhedral_domain_with_surface_inside.cpp") +target_link_libraries(mesh_polyhedral_domain_with_surface_inside + PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program("remesh_polyhedral_surface.cpp") +target_link_libraries(remesh_polyhedral_surface PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program("remesh_polyhedral_surface_sm.cpp") +target_link_libraries(remesh_polyhedral_surface_sm PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program("mesh_polyhedral_domain_with_features.cpp") +target_link_libraries(mesh_polyhedral_domain_with_features + PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program("mesh_polyhedral_domain_with_features_sm.cpp") +target_link_libraries(mesh_polyhedral_domain_with_features_sm + PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program( + "mesh_polyhedral_domain_with_lipschitz_sizing.cpp") +target_link_libraries(mesh_polyhedral_domain_with_lipschitz_sizing + PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program("mesh_polyhedral_complex.cpp") +target_link_libraries(mesh_polyhedral_complex PUBLIC CGAL::Eigen3_support) + +create_single_source_cgal_program("mesh_polyhedral_complex_sm.cpp") +target_link_libraries(mesh_polyhedral_complex_sm PUBLIC CGAL::Eigen3_support) + +if(TARGET CGAL::CGAL_ImageIO) + if(VTK_FOUND AND ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION + VERSION_GREATER 5)) + add_executable(mesh_3D_gray_vtk_image mesh_3D_gray_vtk_image.cpp) + target_link_libraries( + mesh_3D_gray_vtk_image + PUBLIC CGAL::Eigen3_support CGAL::CGAL CGAL::CGAL_ImageIO + ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ${VTK_LIBRARIES}) + cgal_add_test(mesh_3D_gray_vtk_image) + add_to_cached_list(CGAL_EXECUTABLE_TARGETS mesh_3D_gray_vtk_image) endif() - create_single_source_cgal_program("mesh_hybrid_mesh_domain.cpp") - target_link_libraries(mesh_hybrid_mesh_domain PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("mesh_3D_gray_image.cpp") + target_link_libraries(mesh_3D_gray_image PUBLIC CGAL::Eigen3_support) - create_single_source_cgal_program("mesh_implicit_sphere.cpp") - target_link_libraries(mesh_implicit_sphere PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program("mesh_implicit_sphere_variable_size.cpp") - target_link_libraries(mesh_implicit_sphere_variable_size + create_single_source_cgal_program("mesh_3D_gray_image_multiple_values.cpp") + target_link_libraries(mesh_3D_gray_image_multiple_values PUBLIC CGAL::Eigen3_support) - create_single_source_cgal_program("mesh_two_implicit_spheres_with_balls.cpp") - target_link_libraries(mesh_two_implicit_spheres_with_balls - PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("mesh_3D_image_with_features.cpp") + target_link_libraries(mesh_3D_image_with_features PUBLIC CGAL::Eigen3_support) - create_single_source_cgal_program("mesh_implicit_domains_2.cpp" - "implicit_functions.cpp") - target_link_libraries(mesh_implicit_domains_2 PUBLIC CGAL::Eigen3_support) + if(CGAL_ImageIO_USE_ZLIB) + create_single_source_cgal_program("mesh_optimization_example.cpp") + target_link_libraries(mesh_optimization_example PUBLIC CGAL::Eigen3_support) - create_single_source_cgal_program("mesh_cubes_intersection.cpp") - target_link_libraries(mesh_cubes_intersection PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program("mesh_cubes_intersection_with_features.cpp") - target_link_libraries(mesh_cubes_intersection_with_features - PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program("mesh_implicit_domains.cpp" - "implicit_functions.cpp") - target_link_libraries(mesh_implicit_domains PUBLIC CGAL::Eigen3_support) - - find_package( ITT QUIET ) - if(TARGET ITT::ITT) - target_link_libraries(mesh_implicit_domains PRIVATE ITT::ITT) - target_compile_definitions(mesh_implicit_domains PRIVATE CGAL_MESH_3_USE_INTEL_ITT) - endif() - - create_single_source_cgal_program( "mesh_polyhedral_domain.cpp" ) - target_link_libraries(mesh_polyhedral_domain PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program("mesh_polyhedral_domain_sm.cpp") - target_link_libraries(mesh_polyhedral_domain_sm PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program( - "mesh_polyhedral_domain_with_surface_inside.cpp") - target_link_libraries(mesh_polyhedral_domain_with_surface_inside - PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program("remesh_polyhedral_surface.cpp") - target_link_libraries(remesh_polyhedral_surface PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program("remesh_polyhedral_surface_sm.cpp") - target_link_libraries(remesh_polyhedral_surface_sm PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program("mesh_polyhedral_domain_with_features.cpp") - target_link_libraries(mesh_polyhedral_domain_with_features - PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program("mesh_polyhedral_domain_with_features_sm.cpp") - target_link_libraries(mesh_polyhedral_domain_with_features_sm - PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program( - "mesh_polyhedral_domain_with_lipschitz_sizing.cpp") - target_link_libraries(mesh_polyhedral_domain_with_lipschitz_sizing - PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program("mesh_polyhedral_complex.cpp") - target_link_libraries(mesh_polyhedral_complex PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program("mesh_polyhedral_complex_sm.cpp") - target_link_libraries(mesh_polyhedral_complex_sm PUBLIC CGAL::Eigen3_support) - - if(TARGET CGAL::CGAL_ImageIO) - if(VTK_FOUND AND ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION - VERSION_GREATER 5)) - add_executable(mesh_3D_gray_vtk_image mesh_3D_gray_vtk_image.cpp) - target_link_libraries( - mesh_3D_gray_vtk_image - PUBLIC CGAL::Eigen3_support CGAL::CGAL CGAL::CGAL_ImageIO - ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ${VTK_LIBRARIES}) - cgal_add_test(mesh_3D_gray_vtk_image) - add_to_cached_list(CGAL_EXECUTABLE_TARGETS mesh_3D_gray_vtk_image) - endif() - - create_single_source_cgal_program("mesh_3D_gray_image.cpp") - target_link_libraries(mesh_3D_gray_image PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program("mesh_3D_gray_image_multiple_values.cpp") - target_link_libraries(mesh_3D_gray_image_multiple_values + create_single_source_cgal_program("mesh_optimization_lloyd_example.cpp") + target_link_libraries(mesh_optimization_lloyd_example PUBLIC CGAL::Eigen3_support) - create_single_source_cgal_program("mesh_3D_image_with_features.cpp") - target_link_libraries(mesh_3D_image_with_features PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("mesh_3D_image.cpp") + target_link_libraries(mesh_3D_image PUBLIC CGAL::Eigen3_support) - if(CGAL_ImageIO_USE_ZLIB) - create_single_source_cgal_program("mesh_optimization_example.cpp") - target_link_libraries(mesh_optimization_example PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program("mesh_optimization_lloyd_example.cpp") - target_link_libraries(mesh_optimization_lloyd_example - PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program("mesh_3D_image.cpp") - target_link_libraries(mesh_3D_image PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program( - "mesh_3D_image_with_custom_initialization.cpp") - target_link_libraries(mesh_3D_image_with_custom_initialization - PUBLIC CGAL::Eigen3_support) - - create_single_source_cgal_program("mesh_3D_image_variable_size.cpp") - target_link_libraries(mesh_3D_image_variable_size - PUBLIC CGAL::Eigen3_support) - else() - message( - STATUS - "NOTICE: The examples mesh_3D_image.cpp, mesh_3D_image_variable_size.cpp, mesh_optimization_example.cpp and mesh_optimization_lloyd_example.cpp need CGAL_ImageIO to be configured with ZLIB support, and will not be compiled." - ) - endif() + create_single_source_cgal_program( + "mesh_3D_image_with_custom_initialization.cpp") + target_link_libraries(mesh_3D_image_with_custom_initialization + PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("mesh_3D_image_variable_size.cpp") + target_link_libraries(mesh_3D_image_variable_size + PUBLIC CGAL::Eigen3_support) else() message( STATUS - "NOTICE: Some examples need the CGAL_ImageIO library, and will not be compiled." + "NOTICE: The examples mesh_3D_image.cpp, mesh_3D_image_variable_size.cpp, mesh_optimization_example.cpp and mesh_optimization_lloyd_example.cpp need CGAL_ImageIO to be configured with ZLIB support, and will not be compiled." ) endif() - if(CGAL_ACTIVATE_CONCURRENT_MESH_3 AND TARGET CGAL::TBB_support) - foreach( - target - mesh_3D_image - mesh_3D_image_variable_size - mesh_3D_image_with_custom_initialization - mesh_3D_image_with_features - mesh_implicit_domains - mesh_implicit_sphere - mesh_implicit_sphere_variable_size - mesh_optimization_example - mesh_optimization_lloyd_example - mesh_polyhedral_complex - mesh_polyhedral_complex_sm - mesh_polyhedral_domain - mesh_polyhedral_domain_sm - mesh_polyhedral_domain_with_features - mesh_polyhedral_domain_with_features_sm - mesh_polyhedral_domain_with_lipschitz_sizing - mesh_two_implicit_spheres_with_balls) - if(TARGET ${target}) - target_link_libraries(${target} PUBLIC CGAL::TBB_support) - endif() - endforeach() - endif() -else() #CGAL::Eigen_3_support - message( STATUS "NOTICE: All examples need the Eigen_3 library, and will not be compiled." ) -endif() #CGAL::Eigen_3_support +else() + message( + STATUS + "NOTICE: Some examples need the CGAL_ImageIO library, and will not be compiled." + ) +endif() + +if(CGAL_ACTIVATE_CONCURRENT_MESH_3 AND TARGET CGAL::TBB_support) + foreach( + target + mesh_3D_image + mesh_3D_image_variable_size + mesh_3D_image_with_custom_initialization + mesh_3D_image_with_features + mesh_implicit_domains + mesh_implicit_sphere + mesh_implicit_sphere_variable_size + mesh_optimization_example + mesh_optimization_lloyd_example + mesh_polyhedral_complex + mesh_polyhedral_complex_sm + mesh_polyhedral_domain + mesh_polyhedral_domain_sm + mesh_polyhedral_domain_with_features + mesh_polyhedral_domain_with_features_sm + mesh_polyhedral_domain_with_lipschitz_sizing + mesh_two_implicit_spheres_with_balls) + if(TARGET ${target}) + target_link_libraries(${target} PUBLIC CGAL::TBB_support) + endif() + endforeach() +endif() From e98198178f1278a87e4f65f45d9013fdcf05dc94 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 23 Mar 2021 15:45:54 +0100 Subject: [PATCH 107/130] Add the functor Non_zero_dimension_3 to the Kernel --- .../include/CGAL/Kernel/function_objects.h | 35 +++++++++++++++++++ .../include/CGAL/Kernel/interface_macros.h | 2 ++ Nef_3/include/CGAL/Nef_3/bounded_side_3.h | 7 ++-- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index 1d698f65b6e..4b06db737af 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -37,6 +37,41 @@ namespace CGAL { namespace CommonKernelFunctors { + + + template + class Non_zero_dimension_3 + { + typedef typename K::Vector_3 Vector_3; + + public: + typedef int result_type; + + int operator()(const Vector_3& vec) const + { + int dir = -1; + if(certainly_not(is_zero(vec.x()))){ + dir = 0; + } else if(certainly_not(is_zero(vec.y()))){ + dir = 1; + }else if(certainly_not(is_zero(vec.y()))){ + dir = 2; + } + + if(dir == -1){ + if(! is_zero(vec.x())){ + return 0; + } else if(! is_zero(vec.y())){ + return 1; + } else if(! is_zero(vec.z())){ + return 2; + } + } + return dir; + } + }; + + template class Are_ordered_along_line_2 { diff --git a/Kernel_23/include/CGAL/Kernel/interface_macros.h b/Kernel_23/include/CGAL/Kernel/interface_macros.h index a4caf77e7be..668749ff3d5 100644 --- a/Kernel_23/include/CGAL/Kernel/interface_macros.h +++ b/Kernel_23/include/CGAL/Kernel/interface_macros.h @@ -582,6 +582,8 @@ CGAL_Kernel_pred(Less_y_3, less_y_3_object) CGAL_Kernel_pred(Less_z_3, less_z_3_object) +CGAL_Kernel_pred(Non_zero_dimension_3, + non_zero_dimension_3_object) CGAL_Kernel_pred_RT(Orientation_2, orientation_2_object) CGAL_Kernel_pred_RT(Orientation_3, diff --git a/Nef_3/include/CGAL/Nef_3/bounded_side_3.h b/Nef_3/include/CGAL/Nef_3/bounded_side_3.h index a34ed350fd4..90ff227e88c 100644 --- a/Nef_3/include/CGAL/Nef_3/bounded_side_3.h +++ b/Nef_3/include/CGAL/Nef_3/bounded_side_3.h @@ -99,8 +99,9 @@ Bounded_side bounded_side_3(IteratorForward first, we don't need to care about the plane orientation */ } - - + typename R::Non_zero_dimension_3 non_zero_dimension_3; + int dir = non_zero_dimension_3(plane.orthogonal_vector()); +#if 0 auto apv = approx(plane.orthogonal_vector()); int dir = 0; @@ -112,7 +113,7 @@ Bounded_side bounded_side_3(IteratorForward first, if(CGAL::abs(apv.z().sup()) > max){ dir = 2; } - +#endif CGAL_assertion(!plane.is_degenerate()); Point_2 (*t)(const Point_3&); From a28a7cd44a690b0eef511d82015ed14af819cb90 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 23 Mar 2021 17:11:26 +0100 Subject: [PATCH 108/130] Return directly --- .../include/CGAL/Kernel/function_objects.h | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index 4b06db737af..b72ba5eb03b 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -49,26 +49,24 @@ namespace CommonKernelFunctors { int operator()(const Vector_3& vec) const { - int dir = -1; if(certainly_not(is_zero(vec.x()))){ - dir = 0; + return 0; } else if(certainly_not(is_zero(vec.y()))){ - dir = 1; + return 1; }else if(certainly_not(is_zero(vec.y()))){ - dir = 2; + return 2; } - if(dir == -1){ - if(! is_zero(vec.x())){ - return 0; - } else if(! is_zero(vec.y())){ - return 1; - } else if(! is_zero(vec.z())){ - return 2; - } + if(! is_zero(vec.x())){ + return 0; + } else if(! is_zero(vec.y())){ + return 1; + } else if(! is_zero(vec.z())){ + return 2; } - return dir; - } + + return -1; + } }; From 3b1dfc764bfd0ee1f3b3cdae51720caab930d4c4 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Wed, 24 Mar 2021 08:44:17 +0100 Subject: [PATCH 109/130] Add missing include --- Generator/include/CGAL/random_convex_hull_in_disc_2.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Generator/include/CGAL/random_convex_hull_in_disc_2.h b/Generator/include/CGAL/random_convex_hull_in_disc_2.h index 4969ca9cb87..0bac0f466e3 100644 --- a/Generator/include/CGAL/random_convex_hull_in_disc_2.h +++ b/Generator/include/CGAL/random_convex_hull_in_disc_2.h @@ -21,6 +21,7 @@ #include #include #include +#include #include namespace CGAL { From 20193092889f802929575282fd7e5a8440b3a59a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 24 Mar 2021 15:31:43 +0100 Subject: [PATCH 110/130] Replace Rep by a boost::tuple --- Cartesian_kernel/include/CGAL/Cartesian/Circle_3.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Circle_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Circle_3.h index 4b0bfbd9c47..96dac082ad3 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Circle_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Circle_3.h @@ -17,6 +17,7 @@ #define CGAL_CARTESIAN_CIRCLEC3_H #include +#include "boost/tuple/tuple.hpp" namespace CGAL { @@ -29,13 +30,8 @@ class CircleC3 { typedef typename R_::Direction_3 Direction_3; typedef typename R_::FT FT; - struct Rep - { - Sphere_3 first; - Plane_3 second; - Rep () : first(), second() { } - Rep (const Sphere_3& s, const Plane_3& p) : first(s), second(p) { } - }; + typedef boost::tuple Rep; + typedef typename R_::template Handle::type Base; Base base; @@ -125,7 +121,7 @@ public: const Plane_3& supporting_plane() const { - return get_pointee_or_identity(base).second; + return boost::get<1>(get_pointee_or_identity(base)); } const Sphere_3& supporting_sphere() const @@ -145,7 +141,7 @@ public: const Sphere_3& diametral_sphere() const { - return get_pointee_or_identity(base).first; + return boost::get<0>(get_pointee_or_identity(base)); } double approximate_area() const From e0b410e2e66f168b92dd915e5be18d7a95f7d488 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 24 Mar 2021 16:03:51 +0100 Subject: [PATCH 111/130] int -> result_type --- Kernel_23/include/CGAL/Kernel/function_objects.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index b72ba5eb03b..60044b9da6b 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -47,7 +47,7 @@ namespace CommonKernelFunctors { public: typedef int result_type; - int operator()(const Vector_3& vec) const + result_type operator()(const Vector_3& vec) const { if(certainly_not(is_zero(vec.x()))){ return 0; From e1a9cfc6ba33a3d7731683da616c416664f264b3 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 24 Mar 2021 16:10:06 +0100 Subject: [PATCH 112/130] Also break the outer loop --- Nef_3/include/CGAL/Nef_3/SNC_point_locator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h b/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h index b11861428cb..bc3af7976af 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h @@ -853,7 +853,7 @@ public: // We next check if v is a vertex on the face to avoid a geometric test bool v_vertex_of_f = false; Halffacet_cycle_iterator fci; - for(fci=f->facet_cycles_begin(); fci!=f->facet_cycles_end(); ++fci) { + for(fci=f->facet_cycles_begin(); (! v_vertex_of_f) && (fci!=f->facet_cycles_end()); ++fci) { if(fci.is_shalfedge()) { SHalfedge_around_facet_circulator sfc(fci), send(sfc); CGAL_For_all(sfc,send) { From c26cb0012d54bb0127366a4d66859d92a9c02919 Mon Sep 17 00:00:00 2001 From: Brian Spilsbury Date: Thu, 25 Mar 2021 12:52:20 +0900 Subject: [PATCH 113/130] Clean up temporary notes --- Number_types/include/CGAL/FPU.h | 41 --------------------------------- 1 file changed, 41 deletions(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index 3b0157a0612..0a324d451a6 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -612,51 +612,10 @@ inline void force_ieee_double_precision() #endif } -/* -NOTE: Remove before merge. - -Originally this was: - -#define CGAL_IA_SQRT(a) \ - CGAL_IA_FORCE_TO_DOUBLE(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(a))) - -In the normal path, IA_up is - return CGAL_IA_FORCE_TO_DOUBLE(d); - -So in the normal path this should be equivalent to - -return CGAL_IA_FORCE_TO_DOUBLE(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(a))); - -Unless there is some issue that I don't understand that's introduced by the function call. -*/ - inline double IA_sqrt_up(double a) { return IA_up(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(a))); } -/* -NOTE: Remove before merge. - -Originally this was: - -FPU_set_cw(CGAL_FE_DOWNWARD); -double i = (d.inf() > 0.0) ? CGAL_IA_SQRT(d.inf()) : 0.0; -FPU_set_cw(CGAL_FE_UPWARD); - -define CGAL_IA_SQRT(a) \ - CGAL_IA_FORCE_TO_DOUBLE(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(a))) - -We pass d.inf() in - -So this should be equivalent to - -double i = (d.inf() > 0.0) ? CGAL_IA_FORCE_TO_DOUBLE(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(d))) : 0.0; - -but we see that the CGAL_IA_FORCE_TO_DOUBLE has been omitted. - -Let's remedy that and see if that addresses the test failure. -*/ - inline double IA_sqrt_toward_zero(double d) { #ifdef CGAL_ALWAYS_ROUND_TO_NEAREST return (d > 0.0) ? nextafter(std::sqrt(d), 0.) : 0.0; From 8094b087084c716e51e34bf3df82191034e96d15 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Thu, 25 Mar 2021 10:37:09 +0100 Subject: [PATCH 114/130] Add missing includes --- .../include/CGAL/internal/Surface_mesh_segmentation/Filters.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h index ae2c7809284..f1733ef2ac4 100644 --- a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h +++ b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h @@ -30,6 +30,8 @@ #include #include +#include +#include namespace CGAL { From b4e98df11789362c49345e1d844e49d4570b4f01 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 25 Mar 2021 11:54:29 +0100 Subject: [PATCH 115/130] cleanup --- Nef_3/include/CGAL/Nef_3/bounded_side_3.h | 102 ---------------------- 1 file changed, 102 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/bounded_side_3.h b/Nef_3/include/CGAL/Nef_3/bounded_side_3.h index 90ff227e88c..9cd7a5eba2e 100644 --- a/Nef_3/include/CGAL/Nef_3/bounded_side_3.h +++ b/Nef_3/include/CGAL/Nef_3/bounded_side_3.h @@ -82,7 +82,6 @@ Bounded_side bounded_side_3(IteratorForward first, typename R::Plane_3 plane = typename R::Plane_3(0,0,0,0)) { typedef typename R::Point_2 Point_2; typedef typename R::Point_3 Point_3; - typedef typename R::Vector_3 Vector_3; typedef typename R::Plane_3 Plane_3; if(plane == Plane_3(0,0,0,0)) { @@ -101,19 +100,7 @@ Bounded_side bounded_side_3(IteratorForward first, typename R::Non_zero_dimension_3 non_zero_dimension_3; int dir = non_zero_dimension_3(plane.orthogonal_vector()); -#if 0 - auto apv = approx(plane.orthogonal_vector()); - int dir = 0; - double max = CGAL::abs(apv.x().sup()); - if(CGAL::abs(apv.y().sup()) > max){ - dir = 1; - max = CGAL::abs(apv.y().sup()); - } - if(CGAL::abs(apv.z().sup()) > max){ - dir = 2; - } -#endif CGAL_assertion(!plane.is_degenerate()); Point_2 (*t)(const Point_3&); @@ -138,94 +125,5 @@ Bounded_side bounded_side_3(IteratorForward first, } //namespace CGAL -#ifdef WRONG_IMPLEMENTATION -/* The following code is wrong since Proyector_.. structures must not return - references to temporal objects */ -template < class Point_2, class Point_3> -struct Project_XY { - typedef Point_3 argument_type; - typedef Point_2 result_type; - Point_2 operator()( Point_3& p) const { - return Point_2(p.hx(), p.hy(), p.hw()); - } - const Point_2 operator()( const Point_3& p) const { - return Point_2(p.hx(), p.hy(), p.hw()); - } -}; - -template < class Point_2, class Point_3> -struct Project_YZ { - typedef Point_3 argument_type; - typedef Point_2 result_type; - Point_2 operator()( Point_3& p) const { - return Point_2(p.hy(), p.hz(), p.hw()); - } - const Point_2 operator()( const Point_3& p) const { - return Point_2(p.hy(), p.hz(), p.hw()); - } -}; - -template < class Point_2, class Point_3> -struct Project_XZ { - typedef Point_3 argument_type; - typedef Point_2 result_type; - Point_2 operator()( Point_3& p) const { - return Point_2(p.hx(), p.hz(), p.hw()); - } - const Point_2 operator()( const Point_3& p) const { - return Point_2(p.hx(), p.hz(), p.hw()); - } -}; - -template -Bounded_side bounded_side_3(IC first, - IC last, - const Point_3& point, - Plane_3 plane = Plane_3(0,0,0,0)) { - - typedef typename R::Point_2 Point_2; - typedef typename R::Point_3 Point_3; - typedef typename R::Vector_3 Vector_3; - typedef typename R::Plane_3 Plane_3; - - CGAL_assertion( !CGAL::is_empty_range( first, last)); - - if(plane == Plane_3(0,0,0,0)) { - Vector_3 hv; - normal_vector_newell_3( first, last, hv); - plane = Plane_3( *first, Vector_3(hv)); - } - CGAL_assertion(!plane.is_degenerate()); - Vector_3 pd(plane.orthogonal_vector()), pyz(1,0,0), pxz(0,1,0); - if(pd == pyz || pd == -pyz) { - /* the plane is parallel to the YZ plane */ - typedef Project_YZ< Point_2, Point_3> Project_YZ; - typedef Iterator_project< IC, Project_YZ> Iterator_YZ; - Project_YZ project; - Point_2 p = project(point); - Iterator_YZ pfirst(first), plast(last); - return bounded_side_2(pfirst, plast, p); - } - else if(pd == pxz || pd ==- pxz) { - /* the plane is parallel to the XZ plane */ - typedef Project_XZ< Point_2, Point_3> Project_XZ; - typedef Iterator_project< IC, Project_XZ> Iterator_XZ; - Project_XZ project; - Point_2 p = project(point); - Iterator_XZ pfirst(first), plast(last); - return bounded_side_2(pfirst, plast, p); - } - else { - CGAL_assertion(cross_product(pd.vector(), Vector_3(0,0,1)) == NULL_VECTOR); - /* the plane is not perpendicular to the XY plane */ - typedef Project_XY< Point_2, Point_3> Project_XY; - typedef Iterator_project< IC, Project_XY> Iterator_XY; - Project_XY project; - Point_2 p = project(point); - Iterator_XY pfirst(first), plast(last); - return bounded_side_2(pfirst, plast, p); - } -} -#endif // WRONG_IMPLEMENTATION #endif // CGAL_BOUNDED_SIDE_3_H From b03920667978d7f7002ead463b39cf5ffd66aac8 Mon Sep 17 00:00:00 2001 From: Doug Roeper Date: Sat, 27 Feb 2021 17:52:20 -0500 Subject: [PATCH 116/130] Separates the `import_from_plane_graph` logic into 2 separate functions so the user can build the graph directly from a list of points and edges instead of a `std::istream`. --- .../CGAL/Linear_cell_complex_constructors.h | 150 +++++++++++------- 1 file changed, 92 insertions(+), 58 deletions(-) diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h index 1505ca79733..0d8808fb7a0 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -28,65 +29,41 @@ namespace CGAL { * CGAL data structures. */ - /** Import an embedded plane graph read into a flux into a - * linear cell complex. - * @param alcc the linear cell complex where the graph will be imported. - * @param ais the istream where read the graph. - * @return A dart created during the convertion. + + /** + * Imports a plane-embedded graph from a list of points and edges represented as pairs of vertex indices */ template< class LCC > typename LCC::Dart_handle import_from_plane_graph(LCC& alcc, - std::istream& ais) + const std::vector& vertices, + const std::vector& edge_indices) { - CGAL_static_assertion( LCC::dimension>=2 && LCC::ambient_dimension==2 ); - + typedef typename LCC::Traits::Construct_direction_2 Construct_direction_2; + typedef typename LCC::Traits::Construct_vector Construct_vector; typedef typename LCC::Dart_handle Dart_handle; typedef typename LCC::Traits::Direction_2 Direction; - typedef typename std::list::iterator List_iterator; typedef typename std::map::iterator LCC_iterator; + typedef typename std::list::iterator List_iterator; + typedef typename LCC::Point Point; + + CGAL_static_assertion( LCC::dimension>=2 && LCC::ambient_dimension==2 ); + CGAL_assertion(edge_indices.size() % 2 == 0); - // Arrays of vertices std::vector< typename LCC::Vertex_attribute_handle > initVertices; - std::vector< std::list > testVertices; + initVertices.reserve(vertices.size()); + std::transform(vertices.begin(), + vertices.end(), + std::back_inserter(initVertices), + [&](const Point& point) { + return alcc.create_vertex_attribute(point); + }); - std::string txt; - typename LCC::FT x, y; - Dart_handle d1=alcc.null_handle; - unsigned int v1, v2; - - unsigned int nbSommets = 0; - unsigned int nbAretes = 0; - - ais >> nbSommets >> nbAretes; - while (nbSommets > 0) - { - if (!ais.good()) - { - std::cout << "Problem: file does not contain enough vertices." - << std::endl; - return alcc.null_handle; - } - - ais >> iformat(x) >> iformat(y); - initVertices.push_back(alcc.create_vertex_attribute - (typename LCC::Point(x, y))); - testVertices.push_back(std::list()); - --nbSommets; - } - - while (nbAretes>0) - { - if (!ais.good()) - { - std::cout << "Problem: file does not contain enough edges." - << std::endl; - return alcc.null_handle; - } - - // We read an egde (given by the number of its two vertices). - ais >> v1 >> v2; - --nbAretes; + std::vector< std::list > testVertices{vertices.size(), std::list()}; + Dart_handle d1 = alcc.null_handle; + for (std::size_t i = 0; (i + 1) < edge_indices.size(); i += 2) { + const auto& v1 = edge_indices[i]; + const auto& v2 = edge_indices[i + 1]; CGAL_assertion(v1 < initVertices.size()); CGAL_assertion(v2 < initVertices.size()); @@ -103,7 +80,6 @@ namespace CGAL { Dart_handle first = alcc.null_handle; Dart_handle prec = alcc.null_handle; - typename LCC::Point sommet1, sommet2; for (unsigned int i=0; i - (typename LCC::Traits::Construct_direction_2() - (typename LCC::Traits::Construct_vector() - (sommet1,sommet2)), *it)); + (Construct_direction_2() + (Construct_vector() + (vertex1,vertex2)), *it)); ++it; while (it!=testVertices[i].end()) { - sommet2 = alcc.point(alcc.other_extremity(*it)); + vertex2 = alcc.point(alcc.other_extremity(*it)); tabDart.insert(std::pair - (typename LCC::Traits::Construct_direction_2() - (typename LCC::Traits::Construct_vector() - (sommet1,sommet2)), *it)); + (Construct_direction_2() + (Construct_vector() + (vertex1,vertex2)), *it)); ++it; } @@ -152,6 +128,64 @@ namespace CGAL { return first; } + /** + * Imports a plane-embedded graph from a file into a LinearCellComplex. + * + * @param alcc the linear cell complex where the graph will be imported. + * @param ais the istream where read the graph. + * @return A dart created during the convertion. + */ + template< class LCC > + typename LCC::Dart_handle import_from_plane_graph(LCC& alcc, + std::istream& ais) + { + using FT = typename LCC::FT; + using Point = typename LCC::Point; + + std::vector vertices; + unsigned int numVertices = 0; + unsigned int numEdges = 0; + ais >> numVertices >> numEdges; + while (numVertices > 0) + { + if (!ais.good()) + { + std::cout << "Problem: file does not contain enough vertices." + << std::endl; + return alcc.null_handle; + } + + FT x, y; + ais >> iformat(x) >> iformat(y); + vertices.push_back(Point{x, y}); + --numVertices; + } + + std::vector edge_indices; + while (numEdges>0) + { + if (!ais.good()) + { + std::cout << "Problem: file does not contain enough edges." + << std::endl; + return alcc.null_handle; + } + + // We read an edge (given by the number of its two vertices). + unsigned int v1, v2; + ais >> v1 >> v2; + --numEdges; + + CGAL_assertion(v1 < vertices.size()); + CGAL_assertion(v2 < vertices.size()); + + edge_indices.push_back(v1); + edge_indices.push_back(v2); + } + + return import_from_plane_graph(alcc, vertices, edge_indices); + } + template < class LCC > typename LCC::Dart_handle import_from_plane_graph(LCC& alcc, const char* filename) From 6ba3a6bae00d7aca1b15dba4f89e15281b1e4d67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 25 Mar 2021 13:26:56 +0100 Subject: [PATCH 117/130] fix deprecated include path --- .../ETHZ/internal/random-forest/common-libraries.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/common-libraries.hpp b/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/common-libraries.hpp index 97e13f532ce..db3a049c47c 100644 --- a/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/common-libraries.hpp +++ b/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/common-libraries.hpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #if BOOST_VERSION >= 104700 From e3b0302b2b8d7a736f0d64d27fd2338f18200209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 26 Mar 2021 09:53:29 +0100 Subject: [PATCH 118/130] inherit from a std exception --- .../internal/Corefinement/intersection_impl.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_impl.h index b95da4e4c2b..eb59cf0357e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_impl.h @@ -30,12 +30,27 @@ #include #include +#include + namespace CGAL{ namespace Polygon_mesh_processing { namespace Corefinement { -struct Self_intersection_exception{}; -struct Triple_intersection_exception{}; +struct Self_intersection_exception : + public std::runtime_error +{ + Self_intersection_exception() + : std::runtime_error("Self-intersection detected in input mesh") + {} +}; + +struct Triple_intersection_exception : + public std::runtime_error +{ + Triple_intersection_exception() + : std::runtime_error("Non-handled triple intersection of input triangles") + {} +}; // This functor computes the pairwise intersection of triangle meshes. // Intersection are given as a set of polylines // The algorithm works as follow: From 48bb925b65342c6e68112041ed3c509c05fe56de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 26 Mar 2021 10:40:53 +0100 Subject: [PATCH 119/130] Fix inconsistency in robust projection code If the triangle/plane is degenerate, the case is handled separately. If we know the plane is not degenerate, the normal should not be recomputed in a different manner, which might lead to a null normal and some issues down the line. --- Kernel_23/include/CGAL/Kernel/function_objects.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index cd335df94fc..9907dbcc455 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -2752,25 +2752,19 @@ namespace CommonKernelFunctors { bool is_inside_triangle_3(const typename K::Point_3& p, const typename K::Triangle_3& t, + const typename K::Vector_3& w, typename K::Point_3& result, const K& k) { typedef typename K::Point_3 Point_3; - typedef typename K::Vector_3 Vector_3; - typename K::Construct_vector_3 vector = - k.construct_vector_3_object(); typename K::Construct_vertex_3 vertex_on = k.construct_vertex_3_object(); - typename K::Construct_cross_product_vector_3 cross_product = - k.construct_cross_product_vector_3_object(); const Point_3& t0 = vertex_on(t,0); const Point_3& t1 = vertex_on(t,1); const Point_3& t2 = vertex_on(t,2); - Vector_3 w = cross_product(vector(t0,t1), vector(t1,t2)); - bool outside = false; if ( is_inside_triangle_3_aux(w, t0, t1, p, result, outside, k) || is_inside_triangle_3_aux(w, t1, t2, p, result, outside, k) @@ -2846,6 +2840,8 @@ namespace CommonKernelFunctors { typename K::Construct_projected_point_3 projection = k.construct_projected_point_3_object(); typename K::Is_degenerate_3 is_degenerate = k.is_degenerate_3_object(); + typename K::Construct_orthogonal_vector_3 normal = + k.construct_orthogonal_vector_3_object(); const typename K::Plane_3 plane = supporting_plane(triangle); if(is_degenerate(plane)) { @@ -2892,9 +2888,8 @@ namespace CommonKernelFunctors { // Project origin on triangle supporting plane const Point_3 proj = projection(plane, origin); - Point_3 moved_point; - bool inside = is_inside_triangle_3(proj,triangle,moved_point,k); + bool inside = is_inside_triangle_3(proj,triangle,normal(plane),moved_point,k); // If proj is inside triangle, return it if ( inside ) From c70c0a511f2c7de5fbf79a8c786a7122464bce37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 29 Mar 2021 09:14:23 +0200 Subject: [PATCH 120/130] use initialized vector --- Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0beec86c962..f6a4a8f6bf5 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 @@ -747,7 +747,7 @@ test_new_3(const R& rep) = rep.oriented_side_3_object(); Oriented_side tmp39 = oriented_side(h2,p2); tmp39 = oriented_side(sp9,p2); - tmp39 = oriented_side(p2,v1,p2); + tmp39 = oriented_side(p2,v3,p2); (void) tmp39; typename R::Bounded_side_3 bounded_side From fe5f6556b9f78bcb1c25cb4d01521b90fc3ad710 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 29 Mar 2021 15:23:24 +0200 Subject: [PATCH 121/130] add a comment --- Cartesian_kernel/include/CGAL/Cartesian/Circle_3.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Circle_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Circle_3.h index 96dac082ad3..ba583f69e7d 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Circle_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Circle_3.h @@ -30,6 +30,7 @@ class CircleC3 { typedef typename R_::Direction_3 Direction_3; typedef typename R_::FT FT; + //using a boost::tuple because std::pair and tuple cannot work with incomplete types. typedef boost::tuple Rep; From 94f969149da57839cccf9de1d051d47a47871ca1 Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Wed, 31 Mar 2021 10:50:05 +0200 Subject: [PATCH 122/130] [cleanup][surface_mesh] Remove unused and duplicate includes The includes became unnecessary after a735e84. --- Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp b/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp index 33ac1ef7dad..034b82b82bb 100644 --- a/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp +++ b/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp @@ -8,14 +8,6 @@ #include #include -#include -#include -#include - -#include -#include -#include - typedef CGAL::Exact_predicates_exact_constructions_kernel K; typedef K::Triangle_3 Triangle_3; From dc854d808836815a3fc5d314f114581a50e8a7ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 31 Mar 2021 11:54:38 +0200 Subject: [PATCH 123/130] Use std::remove_if to speed-up invalid polygon removal --- .../repair_polygon_soup.h | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h index 782ba395cb9..9edd6c93205 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h @@ -316,27 +316,22 @@ template std::size_t remove_invalid_polygons_in_polygon_soup(PointRange& /*points*/, PolygonRange& polygons) { - std::vector to_remove; - const std::size_t ini_polygons_size = polygons.size(); - for(std::size_t polygon_index=0; polygon_index!=ini_polygons_size; ++polygon_index) - { - if(polygons[polygon_index].size() <= 2) - { + const auto rit = std::remove_if(polygons.begin(), polygons.end(), + [](auto& polygon) -> bool + { #ifdef CGAL_PMP_REPAIR_POLYGON_SOUP_VERBOSE_PP - std::cout << "Invalid polygon:"; - print_polygon(std::cout, polygons[polygon_index]); + if(polygon.size() <= 2) + { + std::cout << "Invalid polygon:"; + print_polygon(std::cout, polygon); + } #endif - to_remove.push_back(polygon_index); - } - } + return (polygon.size() <= 2); + }); - while(!to_remove.empty()) - { - polygons.erase(polygons.begin() + to_remove.back()); - to_remove.pop_back(); - } + const std::size_t removed_polygons_n = static_cast(std::distance(rit, polygons.end())); - const std::size_t removed_polygons_n = ini_polygons_size - polygons.size(); + polygons.erase(rit, polygons.end()); #ifdef CGAL_PMP_REPAIR_POLYGON_SOUP_VERBOSE if(removed_polygons_n > 0) From af81a6e1e53e7790780928e44721f4f8fb29697e Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Wed, 31 Mar 2021 12:16:46 +0200 Subject: [PATCH 124/130] [cleanup][surface_mesh] Fix include order from local to global --- Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp b/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp index 034b82b82bb..c6583404588 100644 --- a/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp +++ b/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp @@ -1,13 +1,13 @@ -#include -#include -#include - #include #include #include #include +#include +#include +#include + typedef CGAL::Exact_predicates_exact_constructions_kernel K; typedef K::Triangle_3 Triangle_3; From 590aa1b4a66aa4ade6c616afdec876fa176e771a Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Wed, 31 Mar 2021 11:51:57 +0200 Subject: [PATCH 125/130] Fix out of scope references leading to segfaults --- .../Classification/example_cluster_classification.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Classification/examples/Classification/example_cluster_classification.cpp b/Classification/examples/Classification/example_cluster_classification.cpp index a8b8bdbe714..d9e58780295 100644 --- a/Classification/examples/Classification/example_cluster_classification.cpp +++ b/Classification/examples/Classification/example_cluster_classification.cpp @@ -82,7 +82,12 @@ int main (int argc, char** argv) #endif generator.generate_point_based_features (pointwise_features); - generator.generate_normal_based_features (pointwise_features, pts.normal_map()); + + // Generator should only be used with variables defined at the scope + // of the generator object, thus we instantiate the normal map + // outside of the function + Vmap normal_map = pts.normal_map(); + generator.generate_normal_based_features (pointwise_features, normal_map); #ifdef CGAL_LINKED_WITH_TBB pointwise_features.end_parallel_additions(); @@ -152,8 +157,8 @@ int main (int argc, char** argv) // First, compute means of features. features.begin_parallel_additions(); - for (Feature_handle fh : pointwise_features) - features.add (clusters, fh); + for (std::size_t i = 0; i < pointwise_features.size(); ++ i) + features.add (clusters, pointwise_features[i]); features.end_parallel_additions(); // Then, compute variances of features (and remaining cluster features). From e0ee8aaf426771faf93e469aeebac5b197045f5c Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Wed, 31 Mar 2021 11:52:12 +0200 Subject: [PATCH 126/130] Fix memory leak by resetting unique ptr instead of releasing --- Classification/include/CGAL/Classification/Feature_set.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classification/include/CGAL/Classification/Feature_set.h b/Classification/include/CGAL/Classification/Feature_set.h index 2573c3abde6..16db586b634 100644 --- a/Classification/include/CGAL/Classification/Feature_set.h +++ b/Classification/include/CGAL/Classification/Feature_set.h @@ -228,7 +228,7 @@ public: { #ifdef CGAL_LINKED_WITH_TBB m_tasks->wait(); - m_tasks.release(); + m_tasks.reset(); m_adders.clear(); #endif } From f4a79aebd81bd2a2441685d999d3ddadc4f8bef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 31 Mar 2021 14:12:43 +0200 Subject: [PATCH 127/130] catch const ref --- .../test/Polygon_mesh_processing/test_autorefinement.cpp | 6 +++--- .../Operations_on_polyhedra/Clip_polyhedron_plugin.cpp | 8 ++++---- .../demo/Polyhedron/Plugins/PMP/Corefinement_plugin.cpp | 4 ++-- .../Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp | 4 ++-- .../Plugins/PMP/Surface_intersection_plugin.cpp | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cpp index b6a91b4bd5c..eb8cf3a4654 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cpp @@ -52,7 +52,7 @@ void test(const char* fname, std::size_t nb_polylines, std::size_t total_nb_poin assert(total_nb_points == total_nb_pt); assert( !triple_intersection ); } - catch(PMP::Corefinement::Triple_intersection_exception) + catch(const PMP::Corefinement::Triple_intersection_exception&) { assert( triple_intersection ); } @@ -67,7 +67,7 @@ void test(const char* fname, std::size_t nb_polylines, std::size_t total_nb_poin assert( (nb_vertices_before_autorefine!=nb_vertices_after_autorefine)== (*(visitor.i) != 0) ); assert( !triple_intersection ); } - catch(PMP::Corefinement::Triple_intersection_exception) + catch(const PMP::Corefinement::Triple_intersection_exception&) { assert( triple_intersection ); } @@ -83,7 +83,7 @@ void test(const char* fname, std::size_t nb_polylines, std::size_t total_nb_poin assert( nb_vertices_after_fix==num_vertices(mesh)); assert( !triple_intersection ); } - catch(PMP::Corefinement::Triple_intersection_exception) + catch(const PMP::Corefinement::Triple_intersection_exception&) { assert( triple_intersection ); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Clip_polyhedron_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Clip_polyhedron_plugin.cpp index 7d51372d2bd..b5e059bb108 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Clip_polyhedron_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Clip_polyhedron_plugin.cpp @@ -263,7 +263,7 @@ public Q_SLOTS: .allow_self_intersections(ui_widget.do_not_modify_CheckBox->isChecked())); } } - catch(CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception) + catch(const GAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception&) { CGAL::Three::Three::warning(tr("The requested operation is not possible due to the presence of self-intersections in the region handled.")); } @@ -283,7 +283,7 @@ public Q_SLOTS: .allow_self_intersections(ui_widget.do_not_modify_CheckBox->isChecked())); } } - catch(CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception) + catch(const CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception&) { CGAL::Three::Three::warning(tr("The requested operation is not possible due to the presence of self-intersections in the region handled.")); } @@ -418,7 +418,7 @@ public Q_SLOTS: !ui_widget.coplanarCheckBox->isChecked()), CGAL::Polygon_mesh_processing::parameters::do_not_modify(ui_widget.do_not_modify_CheckBox->isChecked())); } - catch(CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception) + catch(const CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception&) { CGAL::Three::Three::warning(tr("The requested operation is not possible due to the presence of self-intersections in the region handled.")); } @@ -433,7 +433,7 @@ public Q_SLOTS: CGAL::Polygon_mesh_processing::parameters::throw_on_self_intersection(true), CGAL::Polygon_mesh_processing::parameters::do_not_modify(ui_widget.do_not_modify_CheckBox->isChecked())); } - catch(CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception) + catch(const CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception&) { CGAL::Three::Three::warning(tr("The requested operation is not possible due to the presence of self-intersections in the region handled.")); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Corefinement_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Corefinement_plugin.cpp index b3084533368..8228ea5409b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Corefinement_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Corefinement_plugin.cpp @@ -159,7 +159,7 @@ private: scene->itemChanged(item2); scene->itemChanged(item1); } - catch(CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception) + catch(const CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception&) { CGAL::Three::Three::warning(tr("The requested operation is not possible due to the presence of self-intersections in the neighborhood of the intersection.")); } @@ -229,7 +229,7 @@ private: str_op = "Difference"; } } - catch(CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception) + catch(const CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception&) { CGAL::Three::Three::warning(tr("The requested operation is not possible due to the presence of self-intersections in the neighborhood of the intersection.")); QApplication::restoreOverrideCursor(); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp index f16ad282266..0c7e1eba63e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp @@ -257,7 +257,7 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionAutorefine_triggered(Sce try{ CGAL::Polygon_mesh_processing::experimental::autorefine(*poly_item->polyhedron()); } - catch(CGAL::Polygon_mesh_processing::Corefinement::Triple_intersection_exception) + catch(const CGAL::Polygon_mesh_processing::Corefinement::Triple_intersection_exception&) { CGAL::Three::Three::warning(tr("The result of the requested operation is not handled (triple intersection).")); } @@ -288,7 +288,7 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionAutorefineAndRMSelfInter if (!solved) CGAL::Three::Three::information(tr("Self-intersection could not be removed due to non-manifold edges in the output")); } - catch(CGAL::Polygon_mesh_processing::Corefinement::Triple_intersection_exception) + catch(const CGAL::Polygon_mesh_processing::Corefinement::Triple_intersection_exception&) { CGAL::Three::Three::warning(tr("The result of the requested operation is not handled (triple intersection).")); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Surface_intersection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Surface_intersection_plugin.cpp index 88de2f26dab..8134a7494b5 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Surface_intersection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Surface_intersection_plugin.cpp @@ -139,7 +139,7 @@ void Polyhedron_demo_intersection_plugin::intersectionSurfaces() std::back_inserter(new_item->polylines), PMP::parameters::throw_on_self_intersection(true)); } - catch(CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception) + catch(const CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception&) { QMessageBox::warning((QWidget*)NULL, tr("Self-intersections Found"), From 3a409e6ac2b4618c4eeac3825783a265bf6a7159 Mon Sep 17 00:00:00 2001 From: Sebastien Loriot Date: Wed, 31 Mar 2021 14:16:56 +0200 Subject: [PATCH 128/130] Update Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Clip_polyhedron_plugin.cpp Co-authored-by: Laurent Rineau --- .../Plugins/Operations_on_polyhedra/Clip_polyhedron_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Clip_polyhedron_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Clip_polyhedron_plugin.cpp index b5e059bb108..7fca6b934a2 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Clip_polyhedron_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Clip_polyhedron_plugin.cpp @@ -263,7 +263,7 @@ public Q_SLOTS: .allow_self_intersections(ui_widget.do_not_modify_CheckBox->isChecked())); } } - catch(const GAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception&) + catch(const CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception&) { CGAL::Three::Three::warning(tr("The requested operation is not possible due to the presence of self-intersections in the region handled.")); } From b1a537c80c47cf38b1103d678b7b4c527c04364a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 31 Mar 2021 16:35:24 +0200 Subject: [PATCH 129/130] add attention notice in Ceres about libunwind --- Documentation/doc/Documentation/Third_party.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/doc/Documentation/Third_party.txt b/Documentation/doc/Documentation/Third_party.txt index a7232b3b1af..3a26f64255a 100644 --- a/Documentation/doc/Documentation/Third_party.txt +++ b/Documentation/doc/Documentation/Third_party.txt @@ -310,6 +310,10 @@ requires solving complex non-linear least squares problems. Visit the official website of the library at `ceres-solver.org` for more information. +\attention \ceres indicates that `glog` is a recommended dependency. `glog` has `libunwind` as a recommended dependency. +On some platforms, linking with `libunwind` was responsible for an increase of the runtime of the final application. +If you experience such an issue, we recommand to compile \ceres without `glog` support. + \subsection thirdpartyGLPK GLPK \glpk (GNU Linear Programming Kit) is a library for solving linear programming (LP), mixed integer programming (MIP), and other related problems. From 5213cd3bfe50e351d96ccad2daa50e1528d913f5 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 1 Apr 2021 18:11:42 +0100 Subject: [PATCH 130/130] replace include --- Nef_3/include/CGAL/Nef_3/ID_support_handler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nef_3/include/CGAL/Nef_3/ID_support_handler.h b/Nef_3/include/CGAL/Nef_3/ID_support_handler.h index 2d7e28d1674..53a946a0fd6 100644 --- a/Nef_3/include/CGAL/Nef_3/ID_support_handler.h +++ b/Nef_3/include/CGAL/Nef_3/ID_support_handler.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include
Type1
Type1 Type2 `T...`