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..a4627c8592e 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,14 +30,17 @@ 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 decltype( + 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 ); } @@ -57,7 +59,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 e443e08a522..e3ffcacf50c 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 @@ -190,14 +192,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 +366,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()) ); @@ -414,6 +415,27 @@ public: CGAL::SMALLER : CGAL::LARGER; } + 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() + (p, GeomTraits().compute_squared_distance_3_object()(p, bound)), bb,true)? + 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, Boolean_tag::value>()); + } + template CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const FT& sq_distance) const { @@ -423,6 +445,7 @@ public: CGAL::SMALLER : CGAL::LARGER; } + }; Closest_point closest_point_object() const {return Closest_point(*this);} diff --git a/AABB_tree/include/CGAL/AABB_triangle_primitive.h b/AABB_tree/include/CGAL/AABB_triangle_primitive.h index 5c1502d60af..b1b1bd1fe79 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,14 +30,18 @@ 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 decltype( + 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 ); } @@ -57,7 +60,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..4400335e8e3 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,14 +30,18 @@ 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 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; - 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/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/BGL/include/CGAL/boost/graph/Euler_operations.h b/BGL/include/CGAL/boost/graph/Euler_operations.h index 8d5268da6e0..d26d6a4bceb 100644 --- a/BGL/include/CGAL/boost/graph/Euler_operations.h +++ b/BGL/include/CGAL/boost/graph/Euler_operations.h @@ -737,7 +737,7 @@ 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); diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Circle_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Circle_3.h index 4b0bfbd9c47..ba583f69e7d 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,9 @@ 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) { } - }; + //using a boost::tuple because std::pair and tuple cannot work with incomplete types. + typedef boost::tuple Rep; + typedef typename R_::template Handle::type Base; Base base; @@ -125,7 +122,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 +142,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 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 997911312b5..09696e5069c 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 @@ -357,22 +357,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); } @@ -482,21 +468,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 ) { @@ -1014,22 +985,8 @@ 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 typename cpp11::result_of::type type; - }; - - template - struct result { - 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); } @@ -1042,7 +999,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); 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/Circular_kernel_3/function_objects_polynomial_sphere.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h index 30cd1bd3236..48972182b0c 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 @@ -567,15 +567,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, @@ -1019,44 +1010,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/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); 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_cluster_classification.cpp b/Classification/examples/Classification/example_cluster_classification.cpp index bd68016d589..ea11160b881 100644 --- a/Classification/examples/Classification/example_cluster_classification.cpp +++ b/Classification/examples/Classification/example_cluster_classification.cpp @@ -86,7 +86,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(); @@ -156,8 +161,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). 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/ETHZ/internal/random-forest/common-libraries.hpp b/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/common-libraries.hpp index e2fdfd42c87..2815ecbf232 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 @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #if BOOST_VERSION >= 104700 diff --git a/Classification/include/CGAL/Classification/Feature_set.h b/Classification/include/CGAL/Classification/Feature_set.h index 5aebe0b266d..c5930ffb5ec 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 } 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/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/Documentation/doc/Documentation/Third_party.txt b/Documentation/doc/Documentation/Third_party.txt index a7232b3b1af..64d2da2e150 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 \opencv web site is `https://opencv.org/`. -\subsection thirdpartyTensorFlow TensorFlow - -\tensorflow is a library designed for machine learning and deep learning. - -In \cgal, the C++ API of \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 \tensorflow in \cgal programs, the executables -should be linked with the CMake imported target -`CGAL::TensorFlow_support` provided in -`CGAL_TensorFlow_support.cmake`. - -The \tensorflow web site is `https://www.tensorflow.org/`. - \subsection thirdpartyMETIS METIS Version 5.1 or later @@ -310,6 +289,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. diff --git a/Documentation/doc/Documentation/advanced/Configuration_variables.txt b/Documentation/doc/Documentation/advanced/Configuration_variables.txt index 191bb353d59..16a111ca562 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/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 82d6ff20f58..0cdf7b4bd66 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -470,6 +470,7 @@ public: }; // Macro helpers to build the kernel objects +#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 ) @@ -857,7 +858,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 @@ -977,20 +979,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 < \ - typename cpp11::result_of::type >::type >::type > type; \ - }; - - BOOST_PP_REPEAT_FROM_TO(1, 6, CGAL_RESULT_NT, _) - template auto operator()(L const&...l) const -> Lazy_exact_nt>> @@ -1007,8 +995,6 @@ struct Lazy_construction_nt { return new Lazy_rep_0 >(ec( CGAL::exact(l)... )); } } - -#undef CGAL_RESULT_NT }; @@ -1404,7 +1390,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); @@ -1437,7 +1423,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); @@ -1491,7 +1477,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); @@ -1530,7 +1516,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) @@ -1652,20 +1638,23 @@ 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, _) 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; - typedef typename cpp11::result_of::type, - typename Type_mapper::type)>::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; @@ -1706,19 +1695,23 @@ 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; - 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()(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)); @@ -1770,7 +1763,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; @@ -1781,7 +1774,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); \ @@ -1799,7 +1792,7 @@ struct Lazy_construction { BOOST_PP_REPEAT_FROM_TO(1, 9, CGAL_CONSTRUCTION_OPERATOR, _) // nullary - result_type + decltype(auto) operator()() const { typedef Lazy Handle; @@ -1830,27 +1823,18 @@ 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) \ 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()(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 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 { \ @@ -1866,13 +1850,13 @@ 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; - typedef typename cpp11::result_of::type ET; + typedef decltype(std::declval()()) AT; + typedef decltype(std::declval()()) 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/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..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 @@ -168,8 +168,9 @@ 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 { CGAL_BRANCH_PROFILER_3(std::string("semi-static failures/attempts/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); @@ -177,30 +178,47 @@ 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); + 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; - + double double_tmp_result = 0; + double eps = 0; if(scx < bxmin) { double bxmin_scx = bxmin - scx; max1 = bxmin_scx; distance = square(bxmin_scx); + 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(scx > bxmax) { @@ -208,66 +226,136 @@ public: max1 = scx_bxmax; distance = square(scx_bxmax); + 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(scy < bymin) { double bymin_scy = bymin - scy; - if(max1 < bymin_scy) + if(max1 < bymin_scy){ max1 = bymin_scy; + } distance += square(bymin_scy); + 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(scy > bymax) { double scy_bymax = scy - bymax; - if(max1 < scy_bymax) + if(max1 < scy_bymax){ max1 = scy_bymax; - + } 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); + 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); - } + double_tmp_result = (distance - ssr); - double double_tmp_result = (distance - ssr); - double max2 = CGAL::abs(ssr); - - if ((max1 < 3.33558365626356687717e-147) || (max2 < 1.11261183279326254436e-293)){ - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); - } - if ((max1 > 1.67597599124282407923e+153) || (max2 > 2.80889552322236673473e+306)){ - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); - } - - double eps = 1.99986535548615598560e-15 * (std::max) (max2, (max1 * max1)); - - if (double_tmp_result > eps) - return false; - else - { - if (double_tmp_result < -eps) - return true; - else { - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s,b); + 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; + } + } + + // 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); 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 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; 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/Generator/include/CGAL/random_convex_hull_in_disc_2.h b/Generator/include/CGAL/random_convex_hull_in_disc_2.h index 0315a7108e4..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 { @@ -192,7 +193,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/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), 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..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)); } }; @@ -769,11 +766,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 +937,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 +958,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 +1000,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 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..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; @@ -285,6 +289,29 @@ private: return CGAL::sqrt(S*(S-a)*(S-b)*(S-c)); } + // Mollification strategy to avoid degeneracies + void + mollify(const 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 +392,19 @@ 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); } + + if(CGAL::Heat_method_3::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 diff --git a/Heat_method_3/test/Heat_method_3/CMakeLists.txt b/Heat_method_3/test/Heat_method_3/CMakeLists.txt index 6641b2542ba..02b2137a484 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::Eigen3_support) create_single_source_cgal_program("heat_method_surface_mesh_direct_test.cpp") target_link_libraries(heat_method_surface_mesh_direct_test PUBLIC CGAL::Eigen3_support) +create_single_source_cgal_program("heat_method_surface_mesh_intrinsic_test.cpp") +target_link_libraries(heat_method_surface_mesh_intrinsic_test + PUBLIC CGAL::Eigen3_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; +} diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 79a14a29897..42ecb791e06 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -54,6 +54,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) ----------- 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/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/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 diff --git a/Intersections_2/include/CGAL/Intersection_traits.h b/Intersections_2/include/CGAL/Intersection_traits.h index 740fe435f9e..cafd0428ef8 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()(std::declval(), std::declval()))(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()(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 @@ -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/Bbox_3_Sphere_3_do_intersect.h b/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Sphere_3_do_intersect.h index b15270e5294..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 @@ -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(certainly(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(certainly(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(certainly(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(certainly(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 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 2ade2d2fcab..92d6d2e1360 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/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/Kernel_23/doc/Kernel_23/CGAL/Circular_kernel_intersections.h b/Kernel_23/doc/Kernel_23/CGAL/Circular_kernel_intersections.h index 5cc62d8227c..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 -`cpp11::result_of::%type`, 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 3dbd6b566ae..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,20 +57,16 @@ 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 -`cpp11::result_of::%type`, +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. */ /// @{ /*! -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 +86,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 99fab06d311..1b6c85341a3 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/intersections.h +++ b/Kernel_23/doc/Kernel_23/CGAL/intersections.h @@ -101,12 +101,15 @@ 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`. -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.
- + + @@ -197,12 +200,15 @@ 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`. -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...`
- + + @@ -356,9 +362,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 `CGAL::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 @@ -380,7 +386,7 @@ a standard library algorithm. */ template -cpp11::result_of::type +decltype(auto) intersection(Type1 obj1, Type2 obj2); /*! @@ -388,7 +394,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 61033d6d3ab..c1a76efc8aa 100644 --- a/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h +++ b/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h @@ -8409,8 +8409,6 @@ public: \cgalRefines `AdaptableFunctor` (with two arguments) \sa \link intersection_grp `CGAL::intersection()` \endlink - \sa `CGAL::cpp11::result_of` - */ class Intersect_2 { public: @@ -8424,7 +8422,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); /// @} @@ -8438,8 +8436,6 @@ public: \cgalRefines `AdaptableFunctor` (with two or three arguments) \sa intersection_linear_grp - \sa `CGAL::cpp11::result_of` - */ class Intersect_3 { public: @@ -8453,8 +8449,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 0947dbecd5e..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 -`cpp11::result_of` or -`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 */ -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_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 bbe913a36df..0959cd2f474 100644 --- a/Kernel_23/examples/Kernel_23/intersections.cpp +++ b/Kernel_23/examples/Kernel_23/intersections.cpp @@ -13,13 +13,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/Type_mapper.h b/Kernel_23/include/CGAL/Kernel/Type_mapper.h index fe54b5fe96b..683b7fe9255 100644 --- a/Kernel_23/include/CGAL/Kernel/Type_mapper.h +++ b/Kernel_23/include/CGAL/Kernel/Type_mapper.h @@ -87,9 +87,13 @@ 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 > \ + { 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/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index 1d698f65b6e..1a803d094ae 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -37,6 +37,39 @@ namespace CGAL { namespace CommonKernelFunctors { + + + template + class Non_zero_dimension_3 + { + typedef typename K::Vector_3 Vector_3; + + public: + typedef int result_type; + + result_type operator()(const Vector_3& vec) const + { + if(certainly_not(is_zero(vec.x()))){ + return 0; + } else if(certainly_not(is_zero(vec.y()))){ + return 1; + }else if(certainly_not(is_zero(vec.y()))){ + 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 -1; + } + }; + + template class Are_ordered_along_line_2 { @@ -1682,8 +1715,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 +2114,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 +2127,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); @@ -2560,15 +2590,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 @@ -2752,25 +2773,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 +2861,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 +2909,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 ) @@ -3304,11 +3320,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; @@ -3328,8 +3343,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"); @@ -3520,17 +3534,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()); } }; @@ -3540,29 +3547,14 @@ 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 - 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() ); } - 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() ); } }; 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/Kernel_23/include/CGAL/Kernel_checker.h b/Kernel_23/include/CGAL/Kernel_checker.h index b16a3d4806c..bd35c115a08 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,14 @@ 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...); - if (! cmp(res1, res2)) - { - CGAL_kernel_assertion(false); - } - return Pairify()(res1, res2); + auto res1 = p1(a.first...); + auto res2 = p2(a.second...); + + CGAL_kernel_assertion(cmp(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..8143beeb5c0 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,45 +69,53 @@ 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(); } + decltype(auto) + min BOOST_PREVENT_MACRO_SUBSTITUTION() const { + typename R_::Less_xy_2 less_xy; + return less_xy(source(), target()) ? source() : target(); + } - typename cpp11::result_of::type - min BOOST_PREVENT_MACRO_SUBSTITUTION() const; + decltype(auto) + max BOOST_PREVENT_MACRO_SUBSTITUTION() const { + typename R_::Less_xy_2 less_xy; + return less_xy(source(), target()) ? target() : source(); + } - typename cpp11::result_of::type - max BOOST_PREVENT_MACRO_SUBSTITUTION () const; + decltype(auto) + vertex(int i) const + { return (i%2 == 0) ? source() : target(); } - typename cpp11::result_of::type - vertex(int i) const; + decltype(auto) + point(int i) const + { return vertex(i); } - typename cpp11::result_of::type - point(int i) const; - - typename cpp11::result_of::type - operator[](int i) const; + decltype(auto) + operator[](int i) const + { return vertex(i); } bool is_horizontal() const; bool is_vertical() const; @@ -170,47 +177,6 @@ public: } }; -template < class R_ > -CGAL_KERNEL_INLINE -typename cpp11::result_of )>::type -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 -typename cpp11::result_of )>::type -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 -typename cpp11::result_of, int )>::type -Segment_2::vertex(int i) const -{ - return (i%2 == 0) ? source() : target(); -} - -template < class R_ > -inline -typename cpp11::result_of, int )>::type -Segment_2::point(int i) const -{ - return vertex(i); -} - -template < class R_ > -inline -typename cpp11::result_of, int )>::type -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 da8783d67fb..fa0e4e7569d 100644 --- a/Kernel_23/include/CGAL/Segment_3.h +++ b/Kernel_23/include/CGAL/Segment_3.h @@ -68,44 +68,51 @@ 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 - min BOOST_PREVENT_MACRO_SUBSTITUTION () const; + decltype(auto) + min BOOST_PREVENT_MACRO_SUBSTITUTION() const { + typename R_::Less_xyz_3 less_xyz; + return less_xyz(source(), target()) ? source() : target(); + } - typename cpp11::result_of::type - max BOOST_PREVENT_MACRO_SUBSTITUTION () const; + decltype(auto) + max BOOST_PREVENT_MACRO_SUBSTITUTION() const { + typename R_::Less_xyz_3 less_xyz; + return less_xyz(source(), target()) ? target() : source(); + } - typename cpp11::result_of::type - vertex(int i) const; + decltype(auto) + vertex(int i) const + { return (i%2 == 0) ? source() : target(); } - 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); } @@ -161,32 +168,6 @@ public: }; -template < class R_ > -CGAL_KERNEL_INLINE -typename cpp11::result_of ) >::type -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 -typename cpp11::result_of ) >::type -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_ > -CGAL_KERNEL_INLINE -typename cpp11::result_of, int ) >::type -Segment_3::vertex(int i) const -{ - return (i%2 == 0) ? source() : target(); -} - template < class R > std::ostream & 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 d6b05f0fa35..68742e47973 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 fa7e525040c..37aa35f5f4b 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/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; } 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) ); } 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 diff --git a/Kernel_d/doc/Kernel_d/CGAL/intersections_d.h b/Kernel_d/doc/Kernel_d/CGAL/intersections_d.h index f425e157a84..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 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 7d01b176b0c..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 -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 fb1ca9a5b92..30c46dbc277 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 -`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; -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/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); } 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 95ec3e88a2b..40aab7abdd3 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) 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 #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/examples/Mesh_3/CMakeLists.txt b/Mesh_3/examples/Mesh_3/CMakeLists.txt index 9bfe5fd85a0..b993917862d 100644 --- a/Mesh_3/examples/Mesh_3/CMakeLists.txt +++ b/Mesh_3/examples/Mesh_3/CMakeLists.txt @@ -20,8 +20,12 @@ 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(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) 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..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 @@ -261,15 +261,16 @@ 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; + 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); @@ -399,8 +400,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 +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 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 decltype(typename K::Intersect_3()(r, t)) result_type; typedef typename K::Point_3 Point_3; @@ -471,20 +473,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 +487,32 @@ 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; + typedef decltype(typename K_::Intersect_3()(t, s)) 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 +529,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 +543,12 @@ 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; + 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/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 a2a67d32730..1aea65f4fed 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 @@ -385,8 +385,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); @@ -417,8 +415,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/Nef_3/include/CGAL/Nef_3/ID_support_handler.h b/Nef_3/include/CGAL/Nef_3/ID_support_handler.h index ffdd1afec6e..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,8 @@ #include #include -#include +#include +#include #include #undef CGAL_NEF_DEBUG @@ -38,8 +39,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 = 0; + boost::hash_combine(hash,Handle_hash_function()(p.f1)); + boost::hash_combine(hash,Handle_hash_function()(p.f2)); + return hash; + } + }; + std::unordered_map f2m; std::map hash; public: @@ -76,16 +92,17 @@ class ID_support_handler { CGAL_NEF_TRACEN("hash_facet_pair " << sv->point() << std::endl << " " << f1->plane() << &f1 << std::endl << " " << f2->plane() << &f2); + int& idx=f2m[{f1,f2}]; + if(idx==0) { + idx = sv->new_index(); - if(f2m[f1][f2]==0) { - f2m[f1][f2] = sv->new_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); } } 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: 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..46a6dae4962 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: "<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) { + 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); } 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..9cd7a5eba2e 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(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(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(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, @@ -51,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)) { @@ -68,24 +98,19 @@ 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()); 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 */ - 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 */ - t = &point_3_get_x_y_point_2< Point_2, Point_3>; + Point_2 (*t)(const Point_3&); + + if(dir == 0){ + 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, R>; + }else{ + t = &point_3_get_x_y_point_2< Point_2, Point_3, R>; } std::vector< Point_2> points; @@ -95,100 +120,10 @@ 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; } } //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 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 "<& 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; } 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 }*/ diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h index 2064af0b986..3f61fd5ddeb 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h @@ -63,7 +63,7 @@ public: typedef C2E To_exact_converter; typedef C2A To_approximate_converter; - // FIXME: should use result_of, see emails by Nico + // 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/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 e9ed67b5393..92e291e53e7 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::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::type>::type, result_type>::value)); - //CGAL_static_assertion((boost::is_same::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{ 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..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::type>::type Cartesian_const_iterator; + // typedef typename CGAL::decay::type>::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/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index 6d5f02a3075..0a324d451a6 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -114,10 +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) && (defined(__x86_64__) || defined(_M_X64)) +#if defined CGAL_HAS_SSE2 && \ + (defined __x86_64__ || defined _M_X64) && \ + !defined CGAL_ALWAYS_ROUND_TO_NEAREST # define CGAL_USE_SSE2 1 #endif - #ifdef CGAL_CFG_DENORMALS_COMPILE_BUG double& get_static_minimin(); // Defined in Interval_arithmetic_impl.h #endif @@ -347,18 +348,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 ? -#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 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 + // 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) 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_FORCE_TO_DOUBLE(b*b); + return IA_up(b*b); } -#define CGAL_IA_SQRT(a) \ - CGAL_IA_FORCE_TO_DOUBLE(CGAL_BUG_SQRT(CGAL_IA_STOP_CPROP(a))) - - #if defined CGAL_SAFE_SSE2 #define CGAL_IA_SETFPCW(CW) _MM_SET_ROUNDING_MODE(CW) @@ -476,9 +486,15 @@ inline FPU_CW_t FPU_get_cw (void) { +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + 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; CGAL_IA_GETFPCW(cw); return cw; +#endif } // User interface (cont): @@ -487,28 +503,43 @@ 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 } // 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(FPU_CW_t r = CGAL_FE_UPWARD) + Protect_FPU_rounding(FPU_CW_t r = CGAL_FE_PROTECTED) : backup( FPU_get_and_set_cw(r) ) {} ~Protect_FPU_rounding() @@ -524,7 +555,7 @@ template <> struct Protect_FPU_rounding { Protect_FPU_rounding() {} - Protect_FPU_rounding(FPU_CW_t /*= CGAL_FE_UPWARD*/) {} + Protect_FPU_rounding(FPU_CW_t /*= CGAL_FE_PROTECTED */) {} }; @@ -538,13 +569,13 @@ struct Checked_protect_FPU_rounding { Checked_protect_FPU_rounding() { - CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_UPWARD); + CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_PROTECTED); } Checked_protect_FPU_rounding(FPU_CW_t r) : Protect_FPU_rounding(r) { - CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_UPWARD); + CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_PROTECTED); } }; @@ -555,6 +586,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 @@ -579,6 +612,21 @@ inline void force_ieee_double_precision() #endif } +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_IA_FORCE_TO_DOUBLE(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 8a51e7cd860..690f1cc4c74 100644 --- a/Number_types/include/CGAL/Interval_nt.h +++ b/Number_types/include/CGAL/Interval_nt.h @@ -1141,17 +1141,15 @@ 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); - double i = (d.inf() > 0.0) ? CGAL_IA_SQRT(d.inf()) : 0.0; - FPU_set_cw(CGAL_FE_UPWARD); -#endif - return Interval_nt(i, CGAL_IA_SQRT(d.sup())); + double i = IA_sqrt_toward_zero(d.inf()); +#endif // no __AVX512F__ + return Interval_nt(i, IA_sqrt_up(d.sup())); } template diff --git a/Number_types/test/Number_types/CMakeLists.txt b/Number_types/test/Number_types/CMakeLists.txt index 0ac30ad1e78..00459f6ae21 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..7af20f02874 100644 --- a/Number_types/test/Number_types/Interval_nt.cpp +++ b/Number_types/test/Number_types/Interval_nt.cpp @@ -31,12 +31,18 @@ bool spiral_test() break; }; +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + return i == 365; +#else return i == 396; +#endif } // 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() { @@ -92,12 +98,31 @@ bool square_root_test() a = b; }; a -= 1.0; +#ifdef CGAL_ALWAYS_ROUND_TO_NEAREST + DEBUG ( + std::cout << "i = " << i << std::endl; + std::cout << "sup : " << a.sup() << std::endl; + std::cout << "inf : " << a.inf() << std::endl; + ) // DEBUG + if (i != 54) { + return false; + } + // When we round to nearest it doesn't quite converge. + if (a.sup() > 3/(double(1<<30)*(1<<22))) { + return false; + } + if (-3/(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 } @@ -164,9 +189,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(-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()) && c.is_same(IA_nt(0, CGAL_IA_MIN_DOUBLE)); +#endif } @@ -432,10 +463,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..c2ae592c57f --- /dev/null +++ b/Number_types/test/Number_types/Interval_nt_nearest.cpp @@ -0,0 +1,4 @@ +#define CGAL_ALWAYS_ROUND_TO_NEAREST +#define CGAL_DEBUG +#define CGAL_CHECK_EXPENSIVE +#include "Interval_nt.cpp" 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/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..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 @@ -497,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 boost::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/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h index 48002f4a7c3..579dc2edede 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/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h index b15b9dc45e3..65bd536cf71 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 153159fffd8..0a6445492ad 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; @@ -435,7 +435,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 = 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/structure_point_set.h b/Point_set_processing_3/include/CGAL/structure_point_set.h index d032d7a5ecb..8f0bb97dce1 100644 --- a/Point_set_processing_3/include/CGAL/structure_point_set.h +++ b/Point_set_processing_3/include/CGAL/structure_point_set.h @@ -800,9 +800,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 @@ -1029,8 +1027,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)) @@ -1194,16 +1191,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/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 0f30fed84ac..5f2ae9bd610 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/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/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp index c5811a87d2b..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,6 +1,5 @@ #include #include - #include #include #include @@ -9,6 +8,7 @@ #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Surface_mesh Mesh; @@ -42,7 +42,7 @@ int main(int argc, char* argv[]) return 1; } - double target_edge_length = 0.04; + double target_edge_length = (argc > 2) ? std::stod(std::string(argv[2])) : 0.04; unsigned int nb_iter = 3; std::cout << "Split border..."; @@ -52,13 +52,12 @@ int main(int argc, char* argv[]) PMP::split_long_edges(border, target_edge_length, mesh); std::cout << "done." << std::endl; - 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; 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..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 @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef CGAL_PMP_COMPUTE_NORMAL_DEBUG_PP # ifndef CGAL_PMP_COMPUTE_NORMAL_DEBUG @@ -90,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); @@ -106,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); } } @@ -506,6 +513,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()) @@ -669,7 +677,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 #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: 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 aa91b437311..e262e64ea25 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 @@ -263,9 +263,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 = @@ -389,9 +387,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 f0f65b62ee7..279d85b9ad6 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,12 +83,7 @@ bool sorted_around_edge( || coplanar_orientation(o,o_prime,p2,q)==NEGATIVE ); 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 +93,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_processing/internal/Isotropic_remeshing/remesh_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h index 1a0fa1d3b8f..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 @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -43,6 +44,7 @@ #include #include #include +#include #include #include @@ -825,6 +827,19 @@ namespace internal { #ifdef CGAL_PMP_REMESHING_VERBOSE std::cout << "Equalize valences..." << std::endl; #endif + + 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); + } + unsigned int nb_flips = 0; for(edge_descriptor e : edges(mesh_)) { @@ -838,10 +853,11 @@ namespace internal { 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); + 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); + int deviation_pre = CGAL::abs(vva - tvva) + CGAL::abs(vvb - tvvb) + CGAL::abs(vvc - tvvc) @@ -859,6 +875,12 @@ namespace internal { vvb -= 1; vvc += 1; vvd += 1; + + put(degree, va, vva); + put(degree, vb, vvb); + put(degree, vc, vvc); + put(degree, vd, vvd); + ++nb_flips; #ifdef CGAL_PMP_REMESHING_VERBOSE_PROGRESS @@ -894,6 +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_); + + vva += 1; + vvb += 1; + vvc -= 1; + vvd -= 1; + + 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)); @@ -1186,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; @@ -1393,6 +1421,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 +1438,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; @@ -1879,8 +1913,10 @@ 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 initialized(nb_patches,false); + std::vector normal_per_patch(nb_patches); - std::vector< std::vector > normals_per_patch(nb_patches); for(halfedge_descriptor hd : hedges) { Halfedge_status s = status(hd); @@ -1892,18 +1928,18 @@ 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]){ + 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] = n; + initialized[index] = true; } return true; } @@ -1917,19 +1953,6 @@ private: 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_; 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) { 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 8c3ae51e078..937c4a7c549 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) 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/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index 08a65b9ffc4..d124b1cadac 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") @@ -125,14 +126,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/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/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" diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index af1cc39a9f6..e0951e34e38 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/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; } 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." 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..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(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.")); } @@ -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/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( 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/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 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))); 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"), 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() 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/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 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); 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 diff --git a/STL_Extension/include/CGAL/iterator.h b/STL_Extension/include/CGAL/iterator.h index ea2b445b6f5..8395606f4b5 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,8 @@ 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()(std::declval()))> + value_type; typedef typename std::iterator_traits::difference_type difference_type; typedef value_type const* pointer; typedef value_type const& reference; @@ -746,7 +746,8 @@ 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()(std::declval(), std::declval())) + value_type; typedef typename std::iterator_traits::difference_type difference_type; typedef value_type* pointer; typedef value_type& reference; @@ -840,7 +841,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()(std::declval(), std::declval(), std::declval())) 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 337344bc328..863ddb90806 100644 --- a/STL_Extension/include/CGAL/result_of.h +++ b/STL_Extension/include/CGAL/result_of.h @@ -21,42 +21,53 @@ #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_CXX20 || __cpp_lib_is_invocable>=201703L -#include + // C++>=17 -namespace CGAL{ +#elif CGAL_CXX11 -// 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{ + #include -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; +#else // C++<11 + + // 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 -} +#endif // end C++<11 -} +namespace CGAL { +namespace cpp11 { + +#if CGAL_CXX20 || __cpp_lib_is_invocable>=201703L + + template class result_of; + template + class result_of : public std::invoke_result { }; + +#elif CGAL_CXX11 + + using std::result_of; + +#else // C++<11 + + using boost::result_of; + +#endif // end C++<11 + +} // end cpp11 +} // end CGAL #include -#endif //CGAL_RESULT_OF_H +#endif // CGAL_RESULT_OF_H 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 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 b1198b21d43..3536f638ad3 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 @@ -1026,10 +1026,10 @@ private: } 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) - / (FT(num_pts) * FT(octree_depth+1) - * FT(1 << (m_required_samples - 1))), - int(num_candidates)), FT(1)); + 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)); } template 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 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() diff --git a/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp b/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp index 33ac1ef7dad..c6583404588 100644 --- a/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp +++ b/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp @@ -1,17 +1,9 @@ -#include -#include -#include - #include #include #include #include -#include -#include -#include - #include #include #include 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..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 { @@ -92,7 +94,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 +135,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; } 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 dc68794302b..ef841dd6bb3 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)) @@ -1697,8 +1695,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); @@ -1713,7 +1709,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; 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()
Type1
Type1 Type2 `T...`