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/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Arc_2.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Arc_2.h index cb77febb9ce..dcdb6dbbc74 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Arc_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Arc_2.h @@ -37,6 +37,8 @@ #include +#include + namespace CGAL { namespace internal { @@ -1818,8 +1820,7 @@ protected: */ void _check_arc_interior() const { -#if !(defined(CGAL_KERNEL_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || defined(NDEBUG)) +#if !(defined(CGAL_KERNEL_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS)) if(is_vertical()) { Coordinate_1 x0 = _minpoint().x(); 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/Bounding_volumes/include/CGAL/Approximate_min_ellipsoid_d/Approximate_min_ellipsoid_d_configure.h b/Bounding_volumes/include/CGAL/Approximate_min_ellipsoid_d/Approximate_min_ellipsoid_d_configure.h index 79c3b4e66c5..e993f09b580 100644 --- a/Bounding_volumes/include/CGAL/Approximate_min_ellipsoid_d/Approximate_min_ellipsoid_d_configure.h +++ b/Bounding_volumes/include/CGAL/Approximate_min_ellipsoid_d/Approximate_min_ellipsoid_d_configure.h @@ -20,7 +20,7 @@ #include #include -#if (defined(CGAL_NO_ASSERTIONS) || defined(NDEBUG)) +#if defined(CGAL_NO_ASSERTIONS) #undef CGAL_APPEL_ASSERTION_MODE #undef CGAL_APPEL_EXP_ASSERTION_MODE #undef CGAL_APPEL_LOG_MODE diff --git a/CMakeLists.txt b/CMakeLists.txt index 16548a2000f..fc0c013e73b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,14 +12,14 @@ set(CGAL_BRANCH_BUILD ON CACHE INTERNAL "Create CGAL from a Git branch" FORCE) -include(${CMAKE_SOURCE_DIR}/CGALConfigVersion.cmake) -include(${CMAKE_SOURCE_DIR}/Installation/cmake/modules/CGAL_SCM.cmake) -cgal_detect_git(${CMAKE_SOURCE_DIR}) +include(${CMAKE_CURRENT_SOURCE_DIR}/CGALConfigVersion.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/Installation/cmake/modules/CGAL_SCM.cmake) +cgal_detect_git(${CMAKE_CURRENT_SOURCE_DIR}) function(CGAL_error_if_detect_in_source_build) # If in a Git repository, forbid in-source builds - get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH) - get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH) + get_filename_component(srcdir "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH) + get_filename_component(bindir "${CMAKE_CURRENT_BINARY_DIR}" REALPATH) if("${srcdir}" STREQUAL "${bindir}") message( FATAL_ERROR 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/Label_set.h b/Classification/include/CGAL/Classification/Label_set.h index 39deac32537..d95902b9258 100644 --- a/Classification/include/CGAL/Classification/Label_set.h +++ b/Classification/include/CGAL/Classification/Label_set.h @@ -19,6 +19,7 @@ #include #include +#include namespace CGAL { 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_decomposition_3/include/CGAL/Convex_decomposition_3/Ray_hit_generator.h b/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Ray_hit_generator.h index dd400adbfc0..a3b60b73293 100644 --- a/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Ray_hit_generator.h +++ b/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Ray_hit_generator.h @@ -107,8 +107,7 @@ class Ray_hit_generator : public Modifier_base { e->twin() = svb; #ifndef CGAL_NEF_NO_INDEXED_ITEMS svb->set_index(e->get_index()); - svf->set_index(); - svf->twin()->set_index(svf->get_index()); + svf->twin()->set_index(svf->new_index()); #endif } else { svf->twin() = e; @@ -117,8 +116,7 @@ class Ray_hit_generator : public Modifier_base { e->twin() = svf; #ifndef CGAL_NEF_NO_INDEXED_ITEMS svf->set_index(e->get_index()); - svb->set_index(); - svb->twin()->set_index(svb->get_index()); + svb->twin()->set_index(svb->new_index()); #endif } @@ -165,8 +163,7 @@ class Ray_hit_generator : public Modifier_base { SM_walls smw(&*v_new); sv2 = smw.add_ray_svertex(Sphere_point(-dir)); #ifndef CGAL_NEF_NO_INDEXED_ITEMS - sv1->set_index(); - sv2->set_index(sv1->get_index()); + sv2->set_index(sv1->new_index()); #endif } } diff --git a/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Ray_hit_generator2.h b/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Ray_hit_generator2.h index a936a2a47d9..c0e8cdeb858 100644 --- a/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Ray_hit_generator2.h +++ b/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Ray_hit_generator2.h @@ -112,8 +112,7 @@ class Ray_hit_generator2 : public Modifier_base { e->twin() = svb; #ifndef CGAL_NEF_NO_INDEXED_ITEMS svb->set_index(e->get_index()); - svf->set_index(); - svf->twin()->set_index(svf->get_index()); + svf->twin()->set_index(svf->new_index()); #endif } else { svf->twin() = e; @@ -122,8 +121,7 @@ class Ray_hit_generator2 : public Modifier_base { e->twin() = svf; #ifndef CGAL_NEF_NO_INDEXED_ITEMS svf->set_index(e->get_index()); - svb->set_index(); - svb->twin()->set_index(svb->get_index()); + svb->twin()->set_index(svb->new_index()); #endif } @@ -182,8 +180,7 @@ class Ray_hit_generator2 : public Modifier_base { sv1->twin() = sv2; // TODO: why is this necessary? sv2->twin() = sv1; // these edges should not go into the Edge_sorter #ifndef CGAL_NEF_NO_INDEXED_ITEMS - sv1->set_index(); - sv2->set_index(sv1->get_index()); + sv2->set_index(sv1->new_index()); #endif } } diff --git a/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/SM_walls.h b/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/SM_walls.h index 1fac7a8a0af..27a1c4f697a 100644 --- a/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/SM_walls.h +++ b/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/SM_walls.h @@ -529,10 +529,8 @@ class SM_walls : SM_decorator { #ifndef CGAL_NEF_NO_INDEXED_ITEMS CGAL_assertion(index1==0 || index1!=index2); if(index1==0) { - se_new->set_index(); - se_new->twin()->set_index(); - index1 = se_new->get_index(); - index2 = se_new->twin()->get_index(); + index1 = se_new->new_index(); + index2 = se_new->twin()->new_index(); } else { se_new->set_index(index1); se_new->twin()->set_index(index2); diff --git a/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Single_wall_creator.h b/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Single_wall_creator.h index f3878fba24a..d0e8b498a59 100644 --- a/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Single_wall_creator.h +++ b/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Single_wall_creator.h @@ -204,8 +204,7 @@ class Single_wall_creator : public Modifier_base { opp->twin() = lateral_svertex; lateral_svertex->twin() = opp; #ifndef CGAL_NEF_NO_INDEXED_ITEMS - opp->set_index(); - lateral_svertex->set_index(opp->get_index()); + lateral_svertex->set_index(opp->new_index()); #endif pl->add_edge(lateral_svertex); @@ -237,8 +236,7 @@ class Single_wall_creator : public Modifier_base { lateral_svertex->twin() = opp; #ifndef CGAL_NEF_NO_INDEXED_ITEMS - opp->set_index(); - lateral_svertex->set_index(opp->get_index()); + lateral_svertex->set_index(opp->new_index()); #endif pl->add_edge(lateral_svertex); @@ -275,8 +273,7 @@ class Single_wall_creator : public Modifier_base { opp->twin() = lateral_svertex; lateral_svertex->twin() = opp; #ifndef CGAL_NEF_NO_INDEXED_ITEMS - opp->set_index(); - lateral_svertex->set_index(opp->get_index()); + lateral_svertex->set_index(opp->new_index()); #endif pl->add_edge(lateral_svertex); @@ -308,8 +305,7 @@ class Single_wall_creator : public Modifier_base { opp->twin() = lateral_svertex; lateral_svertex->twin() = opp; #ifndef CGAL_NEF_NO_INDEXED_ITEMS - opp->set_index(); - lateral_svertex->set_index(opp->get_index()); + lateral_svertex->set_index(opp->new_index()); #endif pl->add_edge(lateral_svertex); diff --git a/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Single_wall_creator2.h b/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Single_wall_creator2.h index ca32975c940..bd4d22bac38 100644 --- a/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Single_wall_creator2.h +++ b/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Single_wall_creator2.h @@ -163,8 +163,7 @@ class Single_wall_creator2 : public Modifier_base { lateral_sv_tgt[0]->twin() = lateral_sv_tgt[1]; lateral_sv_tgt[1]->twin() = lateral_sv_tgt[0]; #ifndef CGAL_NEF_NO_INDEXED_ITEMS - lateral_sv_tgt[0]->set_index(); - lateral_sv_tgt[1]->set_index(lateral_sv_tgt[0]->get_index()); + lateral_sv_tgt[1]->set_index(lateral_sv_tgt[0]->new_index()); #endif return; } @@ -174,8 +173,7 @@ class Single_wall_creator2 : public Modifier_base { opp->twin() = lateral_sv_tgt[0]; lateral_sv_tgt[0]->twin() = opp; #ifndef CGAL_NEF_NO_INDEXED_ITEMS - opp->set_index(); - lateral_sv_tgt[0]->set_index(opp->get_index()); + lateral_sv_tgt[0]->set_index(opp->new_index()); #endif lateral_sv_tgt[0] = SMW_tgt.add_lateral_svertex(Sphere_segment(lateral_sv_tgt[0]->point().antipode(), diff --git a/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Single_wall_creator3.h b/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Single_wall_creator3.h index a99f84399ac..fc26c54ceb0 100644 --- a/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Single_wall_creator3.h +++ b/Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Single_wall_creator3.h @@ -169,8 +169,7 @@ class Single_wall_creator3 : public Modifier_base { lateral_sv_tgt[0]->twin() = lateral_sv_tgt[1]; lateral_sv_tgt[1]->twin() = lateral_sv_tgt[0]; #ifndef CGAL_NEF_NO_INDEXED_ITEMS - lateral_sv_tgt[0]->set_index(); - lateral_sv_tgt[1]->set_index(lateral_sv_tgt[0]->get_index()); + lateral_sv_tgt[1]->set_index(lateral_sv_tgt[0]->new_index()); #endif pl->add_edge(lateral_sv_tgt[0]); return; @@ -182,8 +181,7 @@ class Single_wall_creator3 : public Modifier_base { lateral_sv_tgt[0]->twin() = opp; pl->add_edge(opp); #ifndef CGAL_NEF_NO_INDEXED_ITEMS - opp->set_index(); - lateral_sv_tgt[0]->set_index(opp->get_index()); + lateral_sv_tgt[0]->set_index(opp->new_index()); #endif lateral_sv_tgt[0] = SMW_tgt.add_lateral_svertex(Sphere_segment(lateral_sv_tgt[0]->point().antipode(), diff --git a/Convex_hull_2/include/CGAL/Convex_hull_2/ch_akl_toussaint_impl.h b/Convex_hull_2/include/CGAL/Convex_hull_2/ch_akl_toussaint_impl.h index 0fdc1a0367b..0ad2835420a 100644 --- a/Convex_hull_2/include/CGAL/Convex_hull_2/ch_akl_toussaint_impl.h +++ b/Convex_hull_2/include/CGAL/Convex_hull_2/ch_akl_toussaint_impl.h @@ -284,8 +284,7 @@ ch_akl_toussaint(ForwardIterator first, ForwardIterator last, internal::ch_akl_toussaint_assign_points_to_regions(std::next(std::get<3>(ranges)),last,left_turn,e,w,n,s,region1,region2,region3,region4,ch_traits); } - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) OutputIterator res(result); #else Tee_for_output_iterator res(result); @@ -337,8 +336,7 @@ ch_akl_toussaint(ForwardIterator first, ForwardIterator last, res.output_so_far_begin(), res.output_so_far_end(), \ ch_traits) ); - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) return res; #else return res.to_output_iterator(); diff --git a/Convex_hull_2/include/CGAL/Convex_hull_2/ch_assertions.h b/Convex_hull_2/include/CGAL/Convex_hull_2/ch_assertions.h index 267f9cf068b..1706f796e9f 100644 --- a/Convex_hull_2/include/CGAL/Convex_hull_2/ch_assertions.h +++ b/Convex_hull_2/include/CGAL/Convex_hull_2/ch_assertions.h @@ -15,7 +15,7 @@ // Note that this header file is intentionnaly not protected with a // macro (as ). Calling it a second time with another value -// for NDEBUG for example must make a difference. +// for CGAL_NO_ASSERTIONS for example must make a difference. #include @@ -28,8 +28,7 @@ #undef CGAL_ch_assertion_msg #undef CGAL_ch_assertion_code -#if defined(CGAL_CH_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG) +#if defined(CGAL_CH_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) # define CGAL_ch_assertion(EX) (static_cast(0)) #include @@ -51,8 +50,7 @@ #undef CGAL_ch_exactness_assertion_code #if defined(CGAL_CH_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_CH_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_CH_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_ch_exactness_assertion(EX) (static_cast(0)) # define CGAL_ch_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_exactness_assertion_code(CODE) @@ -72,8 +70,7 @@ #if defined(CGAL_CH_NO_ASSERTIONS) \ || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_ch_expensive_assertion(EX) (static_cast(0)) # define CGAL_ch_expensive_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_expensive_assertion_code(CODE) @@ -93,8 +90,7 @@ #if defined(CGAL_CH_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ || (!defined(CGAL_CH_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_ch_expensive_exactness_assertion(EX) (static_cast(0)) # define CGAL_ch_expensive_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_expensive_exactness_assertion_code(CODE) @@ -115,8 +111,7 @@ #undef CGAL_ch_precondition_msg #undef CGAL_ch_precondition_code -#if defined(CGAL_CH_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_CH_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) # define CGAL_ch_precondition(EX) (static_cast(0)) # define CGAL_ch_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_precondition_code(CODE) @@ -135,8 +130,7 @@ #undef CGAL_ch_exactness_precondition_code #if defined(CGAL_CH_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_CH_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_CH_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_ch_exactness_precondition(EX) (static_cast(0)) # define CGAL_ch_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_exactness_precondition_code(CODE) @@ -155,8 +149,7 @@ #undef CGAL_ch_expensive_precondition_code #if defined(CGAL_CH_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_ch_expensive_precondition(EX) (static_cast(0)) # define CGAL_ch_expensive_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_expensive_precondition_code(CODE) @@ -176,8 +169,7 @@ #if defined(CGAL_CH_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ || (!defined(CGAL_CH_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_ch_expensive_exactness_precondition(EX) (static_cast(0)) # define CGAL_ch_expensive_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_expensive_exactness_precondition_code(CODE) @@ -198,8 +190,7 @@ #undef CGAL_ch_postcondition_msg #undef CGAL_ch_postcondition_code -#if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) # define CGAL_ch_postcondition(EX) (static_cast(0)) # define CGAL_ch_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_postcondition_code(CODE) @@ -218,8 +209,7 @@ #undef CGAL_ch_exactness_postcondition_code #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_CH_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_CH_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_ch_exactness_postcondition(EX) (static_cast(0)) # define CGAL_ch_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_exactness_postcondition_code(CODE) @@ -238,8 +228,7 @@ #undef CGAL_ch_expensive_postcondition_code #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_ch_expensive_postcondition(EX) (static_cast(0)) # define CGAL_ch_expensive_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_expensive_postcondition_code(CODE) @@ -259,8 +248,7 @@ #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ || (!defined(CGAL_CH_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_ch_expensive_exactness_postcondition(EX) (static_cast(0)) # define CGAL_ch_expensive_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_expensive_exactness_postcondition_code(CODE) @@ -281,8 +269,7 @@ #undef CGAL_ch_warning_msg #undef CGAL_ch_warning_code -#if defined(CGAL_CH_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || defined(NDEBUG) +#if defined(CGAL_CH_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) # define CGAL_ch_warning(EX) (static_cast(0)) # define CGAL_ch_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_warning_code(CODE) @@ -301,8 +288,7 @@ #undef CGAL_ch_exactness_warning_code #if defined(CGAL_CH_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_CH_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_CH_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_ch_exactness_warning(EX) (static_cast(0)) # define CGAL_ch_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_exactness_warning_code(CODE) @@ -321,8 +307,7 @@ #undef CGAL_ch_expensive_warning_code #if defined(CGAL_CH_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_ch_expensive_warning(EX) (static_cast(0)) # define CGAL_ch_expensive_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_expensive_warning_code(CODE) @@ -342,8 +327,7 @@ #if defined(CGAL_CH_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ || (!defined(CGAL_CH_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_CH_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_ch_expensive_exactness_warning(EX) (static_cast(0)) # define CGAL_ch_expensive_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_ch_expensive_exactness_warning_code(CODE) diff --git a/Convex_hull_2/include/CGAL/Convex_hull_2/ch_bykat_impl.h b/Convex_hull_2/include/CGAL/Convex_hull_2/ch_bykat_impl.h index bcd0f1b13c0..2a4f0abe3a9 100644 --- a/Convex_hull_2/include/CGAL/Convex_hull_2/ch_bykat_impl.h +++ b/Convex_hull_2/include/CGAL/Convex_hull_2/ch_bykat_impl.h @@ -66,8 +66,7 @@ ch_bykat(InputIterator first, InputIterator last, *result = a; ++result; return result; } - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) OutputIterator res(result); #else Tee_for_output_iterator res(result); @@ -113,8 +112,7 @@ ch_bykat(InputIterator first, InputIterator last, P.begin(), P.end(), \ res.output_so_far_begin(), res.output_so_far_end(), \ ch_traits)); - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) return res; #else return res.to_output_iterator(); @@ -167,8 +165,7 @@ ch_bykat_with_threshold(InputIterator first, InputIterator last, *result = a; ++result; return result; } - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) OutputIterator res(result); #else Tee_for_output_iterator res(result); @@ -242,8 +239,7 @@ ch_bykat_with_threshold(InputIterator first, InputIterator last, Pbegin, Pend, \ res.output_so_far_begin(), res.output_so_far_end(), \ ch_traits)); - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) return res; #else return res.to_output_iterator(); diff --git a/Convex_hull_2/include/CGAL/Convex_hull_2/ch_graham_andrew_impl.h b/Convex_hull_2/include/CGAL/Convex_hull_2/ch_graham_andrew_impl.h index 798e5d78449..d30fccdc8e3 100644 --- a/Convex_hull_2/include/CGAL/Convex_hull_2/ch_graham_andrew_impl.h +++ b/Convex_hull_2/include/CGAL/Convex_hull_2/ch_graham_andrew_impl.h @@ -90,8 +90,7 @@ ch_graham_andrew_scan( BidirectionalIterator first, typedef typename std::vector< BidirectionalIterator >::iterator std_iterator; std_iterator stack_iter = S.begin(); - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) OutputIterator res(result); #else typedef typename Traits::Point_2 Point_2; @@ -108,8 +107,7 @@ ch_graham_andrew_scan( BidirectionalIterator first, first, last, \ res.output_so_far_begin(), res.output_so_far_end(), \ ch_traits)); - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) return res; #else return res.to_output_iterator(); @@ -208,8 +206,7 @@ ch_graham_andrew( InputIterator first, return result; } - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) OutputIterator res(result); #else Tee_for_output_iterator res(result); @@ -225,8 +222,7 @@ ch_graham_andrew( InputIterator first, V.begin(), V.end(), \ res.output_so_far_begin(), res.output_so_far_end(), \ ch_traits)); - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) return res; #else return res.to_output_iterator(); @@ -254,15 +250,13 @@ ch_lower_hull_scan( InputIterator first, return result; } - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) OutputIterator res(result); #else Tee_for_output_iterator res(result); #endif // no postconditions ... ch_graham_andrew_scan( V.begin(), V.end(), res, ch_traits); - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) return res; #else return res.to_output_iterator(); @@ -285,15 +279,13 @@ ch_upper_hull_scan( InputIterator first, std::sort( V.begin(), V.end(), ch_traits.less_xy_2_object() ); if (equal_points( *(V.begin()), *(V.rbegin())) ) { return result; } - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) OutputIterator res(result); #else Tee_for_output_iterator res(result); #endif // no postconditions ... ch_graham_andrew_scan( V.rbegin(), V.rend(), res, ch_traits); - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) return res; #else return res.to_output_iterator(); diff --git a/Convex_hull_2/include/CGAL/Convex_hull_2/ch_jarvis_impl.h b/Convex_hull_2/include/CGAL/Convex_hull_2/ch_jarvis_impl.h index 65b2d1fc29c..e04da83d4ee 100644 --- a/Convex_hull_2/include/CGAL/Convex_hull_2/ch_jarvis_impl.h +++ b/Convex_hull_2/include/CGAL/Convex_hull_2/ch_jarvis_impl.h @@ -44,8 +44,7 @@ ch_jarvis_march(ForwardIterator first, ForwardIterator last, Equal_2 equal_points = ch_traits.equal_2_object(); - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) OutputIterator res(result); #else typedef typename Traits::Point_2 Point_2; @@ -92,8 +91,7 @@ ch_jarvis_march(ForwardIterator first, ForwardIterator last, first, last, \ res.output_so_far_begin(), res.output_so_far_end(), \ ch_traits)); - #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) + #if defined(CGAL_CH_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) return res; #else return res.to_output_iterator(); 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/Documentation/doc/resources/1.8.20/BaseDoxyfile.in b/Documentation/doc/resources/1.8.20/BaseDoxyfile.in index 93dad8c7100..767fa9f07b2 100644 --- a/Documentation/doc/resources/1.8.20/BaseDoxyfile.in +++ b/Documentation/doc/resources/1.8.20/BaseDoxyfile.in @@ -93,14 +93,6 @@ ALLOW_UNICODE_NAMES = NO OUTPUT_LANGUAGE = English -# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all generated output in the proper direction. -# Possible values are: None, LTR, RTL and Context. -# The default value is: None. - -OUTPUT_TEXT_DIRECTION = None - # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. 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/GraphicsView/demo/Triangulation_2/include/CGAL/Lipschitz_sizing_field_criteria_2.h b/GraphicsView/demo/Triangulation_2/include/CGAL/Lipschitz_sizing_field_criteria_2.h index a1b58514c06..9cf5e923721 100644 --- a/GraphicsView/demo/Triangulation_2/include/CGAL/Lipschitz_sizing_field_criteria_2.h +++ b/GraphicsView/demo/Triangulation_2/include/CGAL/Lipschitz_sizing_field_criteria_2.h @@ -38,7 +38,8 @@ public: : Base(aspect_bound), sizing_field(sf), traits(traits) {} - Lipschitz_sizing_field_criteria_2& operator =(const Lipschitz_sizing_field_criteria_2& c) + Lipschitz_sizing_field_criteria_2(const Lipschitz_sizing_field_criteria_2&) = default; + Lipschitz_sizing_field_criteria_2& operator=(const Lipschitz_sizing_field_criteria_2& c) { if(&c == this) return *this; this->sizing_field = c.sizing_field; diff --git a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h index f306e419ce7..c2c05f90c53 100644 --- a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h +++ b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h @@ -184,16 +184,16 @@ public: // Add custom mouse description setMouseBindingDescription(::Qt::Key_C, ::Qt::ControlModifier, ::Qt::LeftButton, "Rotate the clipping plane when enabled"); setMouseBindingDescription(::Qt::Key_C, ::Qt::ControlModifier, ::Qt::RightButton, "Translate the clipping plane when enabled"); - setMouseBindingDescription(::Qt::Key_C, ::Qt::ControlModifier, ::Qt::MidButton, "Control the clipping plane transparency when enabled"); + setMouseBindingDescription(::Qt::Key_C, ::Qt::ControlModifier, ::Qt::MiddleButton, "Control the clipping plane transparency when enabled"); setMouseBinding(::Qt::ControlModifier, ::Qt::LeftButton, qglviewer::FRAME, qglviewer::NO_MOUSE_ACTION); setMouseBinding(::Qt::ControlModifier, ::Qt::RightButton, qglviewer::FRAME, qglviewer::NO_MOUSE_ACTION); - setMouseBinding(::Qt::ControlModifier, ::Qt::MidButton, qglviewer::FRAME, qglviewer::NO_MOUSE_ACTION); + setMouseBinding(::Qt::ControlModifier, ::Qt::MiddleButton, qglviewer::FRAME, qglviewer::NO_MOUSE_ACTION); setWheelBinding(::Qt::ControlModifier, qglviewer::FRAME, qglviewer::NO_MOUSE_ACTION); setMouseBinding(::Qt::Key_C, ::Qt::ControlModifier, ::Qt::LeftButton, qglviewer::FRAME, qglviewer::ROTATE); setMouseBinding(::Qt::Key_C, ::Qt::ControlModifier, ::Qt::RightButton, qglviewer::FRAME, qglviewer::TRANSLATE); - setMouseBinding(::Qt::Key_C, ::Qt::ControlModifier, ::Qt::MidButton, qglviewer::FRAME, qglviewer::ZOOM); + setMouseBinding(::Qt::Key_C, ::Qt::ControlModifier, ::Qt::MiddleButton, qglviewer::FRAME, qglviewer::ZOOM); setWheelBinding(::Qt::Key_C, ::Qt::ControlModifier, qglviewer::FRAME, qglviewer::ZOOM); if (title[0]==0) 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 5787fc1441b..38b6da75838 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -20,6 +20,7 @@ A comprehensive list of the supported file formats is available in the Stream_su is within a polyhedral envelope around a set of triangles. It is based on the work of Bolun Wang, Teseo Schneider, Yixin Hu, Marco Attene, and Daniele Panozzo. "Exact and efficient polyhedral envelope containment check." (ACM Trans. Graph., 39-4, July 2020). +- Added more functions in the visitor of the corefinement based methods to track all edge creations. ### [Surface Mesh Simplification](https://doc.cgal.org/5.3/Manual/packages.html#PkgSurfaceMeshSimplification) - Added a filtering mechanism so that costly tests get only applied to the next candidate for the edge collapse. @@ -44,6 +45,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/CMakeLists.txt b/Installation/CMakeLists.txt index 3676e52548a..143b6c92cca 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -1,8 +1,8 @@ # Top level CMakeLists.txt for CGAL # The name of our project is "CGAL". CMakeLists files in this project can -# refer to the root source directory of the project as ${CMAKE_SOURCE_DIR} or -# ${CMAKE_SOURCE_DIR} and to the root binary directory of the project as -# ${CMAKE_BINARY_DIR} or ${CMAKE_BINARY_DIR}. +# refer to the root source directory of the project as ${CGAL_SOURCE_DIR} or +# ${CGAL_SOURCE_DIR} and to the root binary directory of the project as +# ${CGAL_BINARY_DIR} or ${CGAL_BINARY_DIR}. if(NOT PROJECT_NAME) cmake_minimum_required(VERSION 3.12...3.18) project(CGAL CXX C) @@ -32,24 +32,24 @@ if(CGAL_BRANCH_BUILD) # list packages file( GLOB CGAL_CONFIGURED_PACKAGES - RELATIVE ${CMAKE_SOURCE_DIR} - "${CMAKE_SOURCE_DIR}/*") + RELATIVE ${CGAL_SOURCE_DIR} + "${CGAL_SOURCE_DIR}/*") list(SORT CGAL_CONFIGURED_PACKAGES) list(REMOVE_ITEM CGAL_CONFIGURED_PACKAGES copyright CMakeLists.txt .svn .git) # detect and remove not existing package-directories foreach(package ${CGAL_CONFIGURED_PACKAGES}) - if(NOT IS_DIRECTORY "${CMAKE_SOURCE_DIR}/${package}") + if(NOT IS_DIRECTORY "${CGAL_SOURCE_DIR}/${package}") list(APPEND CGAL_WRONG_PACKAGES ${package}) elseif(NOT EXISTS - "${CMAKE_SOURCE_DIR}/${package}/package_info/${package}/maintainer") + "${CGAL_SOURCE_DIR}/${package}/package_info/${package}/maintainer") list(APPEND CGAL_WRONG_PACKAGES ${package}) endif() endforeach() find_program( CGAL_CREATE_CMAKE_SCRIPT cgal_create_cmake_script HINT - ${CMAKE_SOURCE_DIR}/Scripts/scripts + ${CGAL_SOURCE_DIR}/Scripts/scripts DOC "Script cgal_create_cmake_script, that creates CMakeLists.txt files" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH) @@ -61,20 +61,20 @@ if(CGAL_BRANCH_BUILD) set(CGAL_CONFIGURED_PACKAGES_NAMES ${CGAL_CONFIGURED_PACKAGES}) set(CGAL_CONFIGURED_PACKAGES) foreach(package ${CGAL_CONFIGURED_PACKAGES_NAMES}) - list(APPEND CGAL_CONFIGURED_PACKAGES "${CMAKE_SOURCE_DIR}/${package}") + list(APPEND CGAL_CONFIGURED_PACKAGES "${CGAL_SOURCE_DIR}/${package}") endforeach() set(CGAL_INSTALLATION_PACKAGE_DIR - "${CMAKE_SOURCE_DIR}/Installation" + "${CGAL_SOURCE_DIR}/Installation" CACHE INTERNAL "Directory containing the Installation package") set(CGAL_MAINTENANCE_PACKAGE_DIR - "${CMAKE_SOURCE_DIR}/Maintenance" + "${CGAL_SOURCE_DIR}/Maintenance" CACHE INTERNAL "Directory containing the Maintenance package") set(CGAL_CORE_PACKAGE_DIR - "${CMAKE_SOURCE_DIR}/Core" + "${CGAL_SOURCE_DIR}/Core" CACHE INTERNAL "Directory containing the Core package") set(CGAL_GRAPHICSVIEW_PACKAGE_DIR - "${CMAKE_SOURCE_DIR}/GraphicsView" + "${CGAL_SOURCE_DIR}/GraphicsView" CACHE INTERNAL "Directory containing the GraphicsView package") message( @@ -86,7 +86,7 @@ if(CGAL_BRANCH_BUILD) else(CGAL_BRANCH_BUILD) # get release name - file(TO_CMAKE_PATH ${CMAKE_SOURCE_DIR} CMAKE_SOURCE_CDIR) + file(TO_CMAKE_PATH ${CGAL_SOURCE_DIR} CMAKE_SOURCE_CDIR) string(REGEX REPLACE "^/" "" CMAKE_SOURCE_DDIR ${CMAKE_SOURCE_CDIR}) string(REPLACE "/" ";" CMAKE_SOURCE_PDIR ${CMAKE_SOURCE_DDIR}) list(GET CMAKE_SOURCE_PDIR -1 CGAL_RELEASE_NAME) @@ -95,19 +95,19 @@ else(CGAL_BRANCH_BUILD) set(CGAL_CONFIGURED_PACKAGES_NAMES ${CGAL_RELEASE_NAME}) # list packages - set(CGAL_CONFIGURED_PACKAGES "${CMAKE_SOURCE_DIR}") + set(CGAL_CONFIGURED_PACKAGES "${CGAL_SOURCE_DIR}") set(CGAL_INSTALLATION_PACKAGE_DIR - "${CMAKE_SOURCE_DIR}" + "${CGAL_SOURCE_DIR}" CACHE INTERNAL "Directory containing the Installation package") set(CGAL_MAINTENANCE_PACKAGE_DIR - "${CMAKE_SOURCE_DIR}" + "${CGAL_SOURCE_DIR}" CACHE INTERNAL "Directory containing the Maintenance package") set(CGAL_CORE_PACKAGE_DIR - "${CMAKE_SOURCE_DIR}" + "${CGAL_SOURCE_DIR}" CACHE INTERNAL "Directory containing the Core package") set(CGAL_GRAPHICSVIEW_PACKAGE_DIR - "${CMAKE_SOURCE_DIR}" + "${CGAL_SOURCE_DIR}" CACHE INTERNAL "Directory containing the GraphicsView package") # Enable testing with BUILD_TESTING @@ -120,7 +120,7 @@ endif(CGAL_BRANCH_BUILD) #message(STATUS "Packages found: ${CGAL_CONFIGURED_PACKAGES}") list(SORT CGAL_CONFIGURED_PACKAGES_NAMES) -if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/Documentation") +if(IS_DIRECTORY "${CGAL_SOURCE_DIR}/Documentation") # Rescope CGAL_CONFIGURED_PACKAGES_NAMES # We need this variable in the Doxygen configuration process. Reset it # and change the scope to the parent scope. @@ -141,7 +141,7 @@ if(CGAL_BRANCH_BUILD) # Create version files # - file(REMOVE ${CMAKE_BINARY_DIR}/VERSION) + file(REMOVE ${CGAL_BINARY_DIR}/VERSION) if(CGAL_BUGFIX_VERSION AND CGAL_BUGFIX_VERSION GREATER 0) set(CGAL_CREATED_VERSION_NUM "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}.${CGAL_BUGFIX_VERSION}") @@ -160,7 +160,7 @@ if(CGAL_BRANCH_BUILD) "${CGAL_CREATED_VERSION_NUM}-I-${CGAL_BUILD_VERSION}") set(CGAL_VERSION "${CGAL_CREATED_VERSION_NUM}-I-${CGAL_BUILD_VERSION}") - file(WRITE "${CMAKE_BINARY_DIR}/VERSION" "${CGAL_CREATED_VERSION_NUM}") + file(WRITE "${CGAL_BINARY_DIR}/VERSION" "${CGAL_CREATED_VERSION_NUM}") message(STATUS "CGAL_VERSION is ${CGAL_CREATED_VERSION}") set(CGAL_FULL_VERSION @@ -196,11 +196,11 @@ if(CGAL_BRANCH_BUILD) message( STATUS "CGAL_CREATED_SVN_REVISION is ${CGAL_CREATED_SVN_REVISION} (dummy)") - file(REMOVE ${CMAKE_BINARY_DIR}/include/CGAL/version.h) + file(REMOVE ${CGAL_BINARY_DIR}/include/CGAL/version.h) string(TIMESTAMP CGAL_CREATED_RELEASE_DATE "%Y%m%d") configure_file( ${CGAL_INSTALLATION_PACKAGE_DIR}/cmake/modules/config/version.h.in - ${CMAKE_BINARY_DIR}/include/CGAL/version.h @ONLY) + ${CGAL_BINARY_DIR}/include/CGAL/version.h @ONLY) # # Duplicate files @@ -265,8 +265,8 @@ if(CGAL_BRANCH_BUILD) else() - if(NOT EXISTS "${CMAKE_SOURCE_DIR}/VERSION" - OR NOT EXISTS "${CMAKE_SOURCE_DIR}/include/CGAL/version.h") + if(NOT EXISTS "${CGAL_SOURCE_DIR}/VERSION" + OR NOT EXISTS "${CGAL_SOURCE_DIR}/include/CGAL/version.h") message( FATAL_ERROR "File VERSION or include/CGAL/version.h are missing, required by release-build." @@ -277,7 +277,7 @@ else() # Read and parse CGAL version number from VERSION file # - file(READ "${CMAKE_SOURCE_DIR}/VERSION" CGAL_VERSION) + file(READ "${CGAL_SOURCE_DIR}/VERSION" CGAL_VERSION) # Comment from Laurent Rineau, 2012/06/28: # file(READ ..) should be replace by file(STRINGS ..), and then we take # the first line. That would avoid parsing errors when the VERSION file @@ -348,60 +348,6 @@ if(CGAL_BUILD_VERSION LESS 1000) message(STATUS "CGAL_BUILD_VERSION=${CGAL_BUILD_VERSION}") endif() -# SONAME, SOVERSION -# -# The rule is that each new release or bug fix release should increse the soversion. -# -# SOVERSION is $(SONAME_VERSION).$(SOVERSION_MINOR).$(SOVERSION_RELEASE) -# -# - If the binary interface of libraries do not change from previous release -# (example: most bug fix releases), increase SOVERSION_RELEASE (this third number). -# - If the binary interface is changed, but remains compatible with -# previous release (example: only addition of new functions), then increase -# SOVERSION_MINOR (second number) and set SOVERSION_RELEASE to 0. -# - If the binary interface is changed in an incompatible way to previous -# release, then increase the SONAME_VERSION, and set the two other -# numbers to 0. -# -# SOVERSION history: -# CGAL<=3.5 : (unversionned) -# CGAL-3.5 : 4.0.0 -# CGAL-3.5.1 : 4.0.1 -# CGAL-3.6 : 5.0.0 -# CGAL-3.6.1 : 5.0.0 (should have been 5.0.1) -# CGAL-3.7 : 6.0.0 (certainly: some types have been turned from int to -# std::size_t, which is different on some platforms) -# CGAL-3.8 : 7.0.0 (At least CGAL::Random has changed its member fields.) -# CGAL-3.9 : 8.0.0 (No way to check the binary compatibility.) -# CGAL-4.0 : 9.0.0 (No way to check the binary compatibility.) -# CGAL-4.1 : 10.0.0 (No way to check the binary compatibility.) -# CGAL-4.2 : 10.0.1 (Nothing different in CGAL compiled libraries¹.) -# CGAL-4.3 : 10.0.2 (Nothing different in CGAL compiled libraries¹.) -# CGAL-4.4 : 10.0.3 (Nothing different in CGAL compiled libraries¹.) -# CGAL-4.5 : 10.0.4 (Nothing different in CGAL compiled libraries¹.) -# CGAL-4.6 : 11.0.0 (int->size_t in CGAL_ImageIO) -# CGAL-4.7 : 11.0.1 (Nothing different in CGAL compiled libraries.) -# CGAL-4.8 : 11.0.2 (Nothing different in CGAL compiled libraries.) -# CGAL-4.9 : 12.0.0 (Change the API/ABI in CGAL_ImageIO, but issue with 4GB images.) -# CGAL-4.10 : 13.0.0 (Change the API/ABI in CGAL_ImageIO.) -# CGAL-4.11 : 13.0.1 (Nothing different in CGAL compiled libraries.) -# CGAL-4.12 : 13.0.2 (Nothing different in CGAL compiled libraries.) -# CGAL-4.14 : 14.0.0 , but only for CGAL_ImageIO (ABI broken in CGAL::Image_3.) -# and for CGAL_Qt5 (ABI broken in DemoMainWindow) -# CGAL-4.14 : 13.0.3 , for other libraries -# ¹) According to http://upstream-tracker.org/versions/cgal.html - -set(CGAL_SONAME_VERSION "13") -set(CGAL_SOVERSION "13.0.3") -set(CGAL_ImageIO_SONAME_VERSION "14") -set(CGAL_ImageIO_SOVERSION "14.0.0") -set(CGAL_Qt5_SONAME_VERSION "14") -set(CGAL_Qt5_SOVERSION "14.0.0") - -message( STATUS "CGAL_SONAME_VERSION=${CGAL_SONAME_VERSION}" ) -message( STATUS "CGAL_SOVERSION =${CGAL_SOVERSION}" ) - - set(CGAL_VERSION_DIR CGAL-${CGAL_VERSION}) set(CGAL_MODULES_REL_DIR cmake/modules) set(CGAL_MODULES_DIR ${CGAL_INSTALLATION_PACKAGE_DIR}/${CGAL_MODULES_REL_DIR}) @@ -595,7 +541,7 @@ if(CGAL_DISABLE_GMP) unset(CGAL_USE_GMP) unset(CGAL_USE_GMP CACHE) # Nasty trick to make sure is not used when CGAL_DISABLE_GMP is TRUE - file(WRITE "${CMAKE_BINARY_DIR}/include/gmp.h" + file(WRITE "${CGAL_BINARY_DIR}/include/gmp.h" "#error GMP is disabled by the CMake option CGAL_DISABLE_GMP") else() list(APPEND CGAL_ESSENTIAL_3RD_PARTY_LIBRARIES GMP MPFR) @@ -603,7 +549,7 @@ else() # When CMake is run several times, to avoid duplicates list(REMOVE_DUPLICATES CGAL_ESSENTIAL_3RD_PARTY_LIBRARIES) - file(REMOVE "${CMAKE_BINARY_DIR}/include/gmp.h") + file(REMOVE "${CGAL_BINARY_DIR}/include/gmp.h") endif() hide_variable(CGAL_ESSENTIAL_3RD_PARTY_LIBRARIES) @@ -698,7 +644,7 @@ set(CGAL_INSTALL_MAN_DIR message("== Generating build files ==") -set(CGAL_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/include) +set(CGAL_INCLUDE_DIRS ${CGAL_BINARY_DIR}/include) foreach(package ${CGAL_CONFIGURED_PACKAGES}) if(EXISTS ${package}/include) @@ -775,9 +721,9 @@ if(CGAL_BRANCH_BUILD AND CGAL_REPORT_DUPLICATE_FILES) endif() configure_file("${CGAL_MODULES_DIR}/CGALConfig_binary_header_only.cmake.in" - "${CMAKE_BINARY_DIR}/CGALConfig.cmake" @ONLY) + "${CGAL_BINARY_DIR}/CGALConfig.cmake" @ONLY) configure_file("${CGAL_MODULES_DIR}/CGALConfigVersion_binary_header_only.cmake.in" - "${CMAKE_BINARY_DIR}/CGALConfigVersion.cmake" @ONLY) + "${CGAL_BINARY_DIR}/CGALConfigVersion.cmake" @ONLY) #-------------------------------------------------------------------------------------------------- # @@ -803,9 +749,9 @@ foreach(dir ${CGAL_CONFIGURED_PACKAGES}) PATTERN "Qt" EXCLUDE) endif() endforeach() -if(EXISTS ${CMAKE_BINARY_DIR}/include/CGAL) +if(EXISTS ${CGAL_BINARY_DIR}/include/CGAL) install( - DIRECTORY ${CMAKE_BINARY_DIR}/include/CGAL + DIRECTORY ${CGAL_BINARY_DIR}/include/CGAL DESTINATION ${CGAL_INSTALL_INC_DIR} PATTERN ".svn" EXCLUDE PATTERN "Qt" EXCLUDE) @@ -840,9 +786,9 @@ install(FILES DESTINATION ${CGAL_INSTALL_CMAKE_DIR}) if(NOT CGAL_INSTALL_CMAKE_DIR STREQUAL "${CGAL_INSTALL_LIB_DIR}/cmake/CGAL") configure_file(${CMAKE_CURRENT_LIST_DIR}/lib/cmake/CGAL/CGALConfig-installation-dirs.cmake.in - ${CMAKE_BINARY_DIR}/config/CGALConfig-installation-dirs.cmake) + ${CGAL_BINARY_DIR}/config/CGALConfig-installation-dirs.cmake) install(FILES - ${CMAKE_BINARY_DIR}/config/CGALConfig-installation-dirs.cmake + ${CGAL_BINARY_DIR}/config/CGALConfig-installation-dirs.cmake DESTINATION ${CGAL_INSTALL_CMAKE_DIR}) endif() @@ -900,7 +846,7 @@ macro(add_programs subdir target ON_OFF) endmacro() # This allows programs to locate CGALConfig.cmake -set(CGAL_DIR ${CMAKE_BINARY_DIR}) +set(CGAL_DIR ${CGAL_BINARY_DIR}) if(NOT RUNNING_CGAL_AUTO_TEST) @@ -1105,13 +1051,13 @@ You must disable CGAL_ENABLE_CHECK_HEADERS.") include_directories(SYSTEM ${CGAL_3RD_PARTY_INCLUDE_DIRS}) # Build the doc - set(DOC_DIR "${CMAKE_BINARY_DIR}/build_doc") + set(DOC_DIR "${CGAL_BINARY_DIR}/build_doc") file(MAKE_DIRECTORY "${DOC_DIR}") execute_process( COMMAND "${CMAKE_COMMAND}" -DCGAL_BUILD_THREE_DOC=TRUE -DDOXYGEN_EXECUTABLE=${DOXYGEN_EXECUTABLE} - "${CMAKE_SOURCE_DIR}/Documentation/doc" + "${CGAL_SOURCE_DIR}/Documentation/doc" WORKING_DIRECTORY "${DOC_DIR}") execute_process( COMMAND @@ -1120,7 +1066,7 @@ You must disable CGAL_ENABLE_CHECK_HEADERS.") #Get the list of the documented headers file(GLOB html_files RELATIVE "${DOC_DIR}/doc_output/" "${DOC_DIR}/doc_output/*/*.html") - file(GLOB example_files RELATIVE "${CMAKE_SOURCE_DIR}/" "${CMAKE_SOURCE_DIR}/*/examples/*/*.cpp") + file(GLOB example_files RELATIVE "${CGAL_SOURCE_DIR}/" "${CGAL_SOURCE_DIR}/*/examples/*/*.cpp") list(SORT example_files) find_program(AWK awk) @@ -1137,7 +1083,7 @@ You must disable CGAL_ENABLE_CHECK_HEADERS.") message("listing headers from examples files") foreach(f ${example_files}) - execute_process(COMMAND "${AWK}" "${awk_arguments}" "${CMAKE_SOURCE_DIR}/${f}" + execute_process(COMMAND "${AWK}" "${awk_arguments}" "${CGAL_SOURCE_DIR}/${f}" OUTPUT_VARIABLE tmp_list) if (NOT "${tmp_list}" STREQUAL "") string(REPLACE "\n" ";" tmp_list ${tmp_list}) @@ -1158,7 +1104,7 @@ You must disable CGAL_ENABLE_CHECK_HEADERS.") ## Loop on package and headers set(check_pkg_target_list) #get build dir for removal from deps - get_filename_component(BUILD_DIR ${CMAKE_BINARY_DIR} NAME) + get_filename_component(BUILD_DIR ${CGAL_BINARY_DIR} NAME) foreach(package ${CGAL_CONFIGURED_PACKAGES_NAMES}) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../${package}/include) set(check_pkg_headers_depends "") 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/include/CGAL/kernel_assertions.h b/Kernel_23/include/CGAL/kernel_assertions.h index 9673575a540..3bd9163f845 100644 --- a/Kernel_23/include/CGAL/kernel_assertions.h +++ b/Kernel_23/include/CGAL/kernel_assertions.h @@ -19,7 +19,7 @@ // Note that this header file is intentionnaly not protected with a // macro (as ). Calling it a second time with another value -// for NDEBUG for example must make a difference. +// for CGAL_NO_ASSERTIONS for example must make a difference. #include @@ -32,8 +32,7 @@ #undef CGAL_kernel_assertion_msg #undef CGAL_kernel_assertion_code -#if defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG) +#if defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) # define CGAL_kernel_assertion(EX) (static_cast(0)) # define CGAL_kernel_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_assertion_code(CODE) @@ -52,8 +51,7 @@ #undef CGAL_kernel_exactness_assertion_code #if defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_KERNEL_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_KERNEL_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_kernel_exactness_assertion(EX) (static_cast(0)) # define CGAL_kernel_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_exactness_assertion_code(CODE) @@ -73,8 +71,7 @@ #if defined(CGAL_KERNEL_NO_ASSERTIONS) \ || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_kernel_expensive_assertion(EX) (static_cast(0)) # define CGAL_kernel_expensive_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_expensive_assertion_code(CODE) @@ -94,8 +91,7 @@ #if defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ || (!defined(CGAL_KERNEL_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_kernel_expensive_exactness_assertion(EX) (static_cast(0)) # define CGAL_kernel_expensive_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_expensive_exactness_assertion_code(CODE) @@ -116,8 +112,7 @@ #undef CGAL_kernel_precondition_msg #undef CGAL_kernel_precondition_code -#if defined(CGAL_KERNEL_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_KERNEL_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) # define CGAL_kernel_precondition(EX) (static_cast(0)) # define CGAL_kernel_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_precondition_code(CODE) @@ -136,8 +131,7 @@ #undef CGAL_kernel_exactness_precondition_code #if defined(CGAL_KERNEL_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_KERNEL_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_KERNEL_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_kernel_exactness_precondition(EX) (static_cast(0)) # define CGAL_kernel_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_exactness_precondition_code(CODE) @@ -156,8 +150,7 @@ #undef CGAL_kernel_expensive_precondition_code #if defined(CGAL_KERNEL_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_kernel_expensive_precondition(EX) (static_cast(0)) # define CGAL_kernel_expensive_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_expensive_precondition_code(CODE) @@ -177,8 +170,7 @@ #if defined(CGAL_KERNEL_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ || (!defined(CGAL_KERNEL_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_kernel_expensive_exactness_precondition(EX) (static_cast(0)) # define CGAL_kernel_expensive_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_expensive_exactness_precondition_code(CODE) @@ -199,8 +191,7 @@ #undef CGAL_kernel_postcondition_msg #undef CGAL_kernel_postcondition_code -#if defined(CGAL_KERNEL_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_KERNEL_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) # define CGAL_kernel_postcondition(EX) (static_cast(0)) # define CGAL_kernel_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_postcondition_code(CODE) @@ -219,8 +210,7 @@ #undef CGAL_kernel_exactness_postcondition_code #if defined(CGAL_KERNEL_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_KERNEL_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_KERNEL_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_kernel_exactness_postcondition(EX) (static_cast(0)) # define CGAL_kernel_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_exactness_postcondition_code(CODE) @@ -239,8 +229,7 @@ #undef CGAL_kernel_expensive_postcondition_code #if defined(CGAL_KERNEL_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_kernel_expensive_postcondition(EX) (static_cast(0)) # define CGAL_kernel_expensive_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_expensive_postcondition_code(CODE) @@ -260,8 +249,7 @@ #if defined(CGAL_KERNEL_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ || (!defined(CGAL_KERNEL_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_kernel_expensive_exactness_postcondition(EX) (static_cast(0)) # define CGAL_kernel_expensive_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_expensive_exactness_postcondition_code(CODE) @@ -282,8 +270,7 @@ #undef CGAL_kernel_warning_msg #undef CGAL_kernel_warning_code -#if defined(CGAL_KERNEL_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || defined(NDEBUG) +#if defined(CGAL_KERNEL_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) # define CGAL_kernel_warning(EX) (static_cast(0)) # define CGAL_kernel_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_warning_code(CODE) @@ -302,8 +289,7 @@ #undef CGAL_kernel_exactness_warning_code #if defined(CGAL_KERNEL_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_KERNEL_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_KERNEL_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_kernel_exactness_warning(EX) (static_cast(0)) # define CGAL_kernel_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_exactness_warning_code(CODE) @@ -322,8 +308,7 @@ #undef CGAL_kernel_expensive_warning_code #if defined(CGAL_KERNEL_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_kernel_expensive_warning(EX) (static_cast(0)) # define CGAL_kernel_expensive_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_expensive_warning_code(CODE) @@ -343,8 +328,7 @@ #if defined(CGAL_KERNEL_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ || (!defined(CGAL_KERNEL_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_kernel_expensive_exactness_warning(EX) (static_cast(0)) # define CGAL_kernel_expensive_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_kernel_expensive_exactness_warning_code(CODE) 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/doc/Mesh_3/Mesh_3.txt b/Mesh_3/doc/Mesh_3/Mesh_3.txt index 86a2dd81e38..45503259386 100644 --- a/Mesh_3/doc/Mesh_3/Mesh_3.txt +++ b/Mesh_3/doc/Mesh_3/Mesh_3.txt @@ -573,13 +573,6 @@ constructor of the `Mesh_criteria` instance. Cut view of a 3D mesh produced from an implicit domain \cgalFigureEnd -\subsubsection Mesh_33DDomainsGrayImageIsosurfaces 3D Domains Bounded by Isosurfaces in 3D Gray-Level Images - -The following example produces a 3D mesh for a domain whose boundary surface -is the isosurface associated to an isovalue inside the input gray-level -3D image. In the distribution you can also find the example \ref Mesh_3/mesh_3D_gray_vtk_image.cpp which can deal with DICOM files as input. - -\cgalExample{Mesh_3/mesh_3D_gray_image.cpp} \subsection Mesh_3MeshingMultipleDomains Meshing Multiple Domains @@ -682,8 +675,18 @@ This allows to remesh a surface, and is equivalent to the function `make_surface View of a remeshed surface. (Left) input mesh (Right) output mesh. Code from subsection \ref Mesh_3RemeshingPolyhedralSurface generates the file. \cgalFigureEnd -\subsection Mesh_3DomainsFromSegmented3DImages Domains From Segmented 3D Images +\subsection Mesh_3DomainsFrom3DImages Domains From 3D Images +\subsubsection Mesh_33DDomainsGrayImageIsosurfaces 3D Domains Bounded by Isosurfaces in 3D Gray-Level Images + +The following example produces a 3D mesh for a domain whose boundary surface +is the isosurface associated to an isovalue inside the input gray-level +3D image. In the distribution you can also find the example \ref Mesh_3/mesh_3D_gray_vtk_image.cpp which can deal with DICOM files as input. + +\cgalExample{Mesh_3/mesh_3D_gray_image.cpp} + + +\subsubsection Mesh_3DomainsFromSegmented3DImages Domains From Segmented 3D Images \anchor Mesh_3_subsection_examples_3d_image The following code produces a 3D mesh from a 3D image. The image is a segmented medical image in which each @@ -703,7 +706,7 @@ The resulting mesh is shown in \cgalFigureRef{figureliver_3d_image_mesh}. Cut view of a 3D mesh produced from a segmented liver image. Code from subsection \ref Mesh_3_subsection_examples_3d_image generates this file. \cgalFigureEnd -\subsubsection Mesh_3DomainsFromSegmented3DImagesWithCustomInitialization Domains From Segmented 3D Images, with a Custom Initialization +\subsubsection Mesh_3DomainsFrom3DImagesWithCustomInitialization Domains From 3D Images, with a Custom Initialization The example \ref Mesh_3/mesh_3D_image_with_custom_initialization.cpp is a modification of \ref Mesh_3/mesh_3D_image.cpp. The goal of that example is to show how @@ -788,6 +791,25 @@ create a 3D image using the undocumented API of CGAL_ImageIO. The code of the function `%random_labeled_image()` is in the header file \ref Mesh_3/random_labeled_image.h\. + +The example \ref Mesh_3/mesh_3D_gray_image_with_custom_initialization.cpp is another +custom initialization example, for meshing of 3D gray-level images. Similarly to +the segmented image example above, the code consists in: + -# the creation of an empty `%c3t3` object, + -# a call to a non-documented function + `initialize_triangulation_from_gray_image()` that inserts points in + the triangulation, + -# then the call to `refine_mesh_3()`. + +\snippet Mesh_3/mesh_3D_gray_image_with_custom_initialization.cpp Meshing + +The code of the function `initialize_triangulation_from_gray_image()` is +in the non-documented header \ref +CGAL/Mesh_3/initialize_triangulation_from_gray_image.h\. As it is +undocumented and may be removed or modified at any time, if you wish to +use it then you should copy-paste it to your user code. + + \subsection Mesh_3UsingVariableSizingField Using Variable Sizing Field \subsubsection Mesh_3SizingFieldasanAnalyticalFunction Sizing Field as an Analytical Function diff --git a/Mesh_3/doc/Mesh_3/examples.txt b/Mesh_3/doc/Mesh_3/examples.txt index eaa86c94551..c1c5e4de1a8 100644 --- a/Mesh_3/doc/Mesh_3/examples.txt +++ b/Mesh_3/doc/Mesh_3/examples.txt @@ -1,9 +1,11 @@ /*! \example Mesh_3/implicit_functions.cpp \example Mesh_3/mesh_3D_image.cpp +\example Mesh_3/mesh_3D_gray_image_with_custom_initialization.cpp \example Mesh_3/mesh_3D_image_with_features.cpp \example Mesh_3/mesh_3D_image_with_custom_initialization.cpp \example Mesh_3/random_labeled_image.h +\example CGAL/Mesh_3/initialize_triangulation_from_gray_image.h \example CGAL/Mesh_3/initialize_triangulation_from_labeled_image.h \example Mesh_3/mesh_3D_image_variable_size.cpp \example Mesh_3/mesh_hybrid_mesh_domain.cpp diff --git a/Mesh_3/examples/Mesh_3/CMakeLists.txt b/Mesh_3/examples/Mesh_3/CMakeLists.txt index 2f9ba7d5b27..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) @@ -149,6 +153,11 @@ if(TARGET CGAL::CGAL_ImageIO) target_link_libraries(mesh_3D_image_with_custom_initialization PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program( + "mesh_3D_gray_image_with_custom_initialization.cpp") + target_link_libraries(mesh_3D_gray_image_with_custom_initialization + PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("mesh_3D_image_variable_size.cpp") target_link_libraries(mesh_3D_image_variable_size PUBLIC CGAL::Eigen3_support) @@ -172,6 +181,7 @@ if(CGAL_ACTIVATE_CONCURRENT_MESH_3 AND TARGET CGAL::TBB_support) mesh_3D_image mesh_3D_image_variable_size mesh_3D_image_with_custom_initialization + mesh_3D_gray_image_with_custom_initialization mesh_3D_image_with_features mesh_implicit_domains mesh_implicit_sphere diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_gray_image_with_custom_initialization.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_gray_image_with_custom_initialization.cpp new file mode 100644 index 00000000000..533637a3f75 --- /dev/null +++ b/Mesh_3/examples/Mesh_3/mesh_3D_gray_image_with_custom_initialization.cpp @@ -0,0 +1,71 @@ + +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + +typedef float Image_word_type; + +// Domain +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Labeled_mesh_domain_3 Mesh_domain; + +// Parallel tag +#ifdef CGAL_CONCURRENT_MESH_3 +typedef CGAL::Parallel_tag Concurrency_tag; +#else +typedef CGAL::Sequential_tag Concurrency_tag; +#endif + +// Triangulation +typedef CGAL::Mesh_triangulation_3::type Tr; +typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; + +// Criteria +typedef CGAL::Mesh_criteria_3 Mesh_criteria; + +// To avoid verbose function and named parameters call +using namespace CGAL::parameters; + +int main(int argc, char* argv[]) +{ + const char* fname = (argc > 1) ? argv[1] : "data/skull_2.9.inr"; + /// [Load image] + CGAL::Image_3 image; + if (!image.read(fname)) { + std::cerr << "Error: Cannot read file " << fname << std::endl; + return EXIT_FAILURE; + } + /// [Domain creation] + Mesh_domain domain = + Mesh_domain::create_gray_image_mesh_domain(image, 2.9f, 0.f); + /// [Domain creation] + + /// [Mesh criteria] + Mesh_criteria criteria(facet_angle = 30, facet_size = 6, facet_distance = 2, + cell_radius_edge_ratio = 3, cell_size = 8); + + /// [Meshing] + C3t3 c3t3; + initialize_triangulation_from_gray_image(c3t3, + domain, + image, + criteria, + 2.9f,//isolevel + Image_word_type(0)); + CGAL::refine_mesh_3(c3t3, domain, criteria); + /// [Meshing] + + /// Output + CGAL::dump_c3t3(c3t3, "out"); + + return 0; +} 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/Mesh_3/initialize_triangulation_from_gray_image.h b/Mesh_3/include/CGAL/Mesh_3/initialize_triangulation_from_gray_image.h new file mode 100644 index 00000000000..1d3a6b7601e --- /dev/null +++ b/Mesh_3/include/CGAL/Mesh_3/initialize_triangulation_from_gray_image.h @@ -0,0 +1,50 @@ +// Copyright (c) 2015,2016 GeometryFactory +// 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) : Laurent Rineau, Jane Tournois + +#ifndef CGAL_MESH_3_INITIALIZE_TRIANGULATION_FROM_GRAY_IMAGE_H +#define CGAL_MESH_3_INITIALIZE_TRIANGULATION_FROM_GRAY_IMAGE_H + +#include + +#include +#include + +#include + +template +void initialize_triangulation_from_gray_image(C3T3& c3t3, + const MeshDomain& domain, + const CGAL::Image_3& image, + const MeshCriteria& criteria, + const FT& iso_value, + Image_word_type, + const Functor image_values_to_subdomain_indices = CGAL::Null_functor(), + bool protect_features = false) +{ + typedef typename CGAL::Default::Get::type Functor_; + + using CGAL::Mesh_3::internal::Create_gray_image_values_to_subdomain_indices; + typedef Create_gray_image_values_to_subdomain_indices C_i_v_t_s_i; + typedef typename C_i_v_t_s_i::type Image_values_to_subdomain_indices; + Image_values_to_subdomain_indices transform_fct = + C_i_v_t_s_i()(image_values_to_subdomain_indices, iso_value); + + initialize_triangulation_from_labeled_image(c3t3, domain, image, criteria, + Image_word_type(), + protect_features, + transform_fct); +} + +#endif // CGAL_MESH_3_INITIALIZE_TRIANGULATION_FROM_GRAY_IMAGE_H diff --git a/Mesh_3/include/CGAL/Mesh_3/initialize_triangulation_from_labeled_image.h b/Mesh_3/include/CGAL/Mesh_3/initialize_triangulation_from_labeled_image.h index 873ae27786a..571a4171e5d 100644 --- a/Mesh_3/include/CGAL/Mesh_3/initialize_triangulation_from_labeled_image.h +++ b/Mesh_3/include/CGAL/Mesh_3/initialize_triangulation_from_labeled_image.h @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -31,17 +32,23 @@ template struct Get_point { const double vx, vy, vz; + const double tx, ty, tz; Get_point(const CGAL::Image_3* image) : vx(image->vx()) , vy(image->vy()) , vz(image->vz()) + , tx(image->tx()) + , ty(image->ty()) + , tz(image->tz()) {} Point operator()(const std::size_t i, const std::size_t j, const std::size_t k) const { - return Point(double(i) * vx, double(j) * vy, double(k) * vz); + return Point(double(i) * vx + tx, + double(j) * vy + ty, + double(k) * vz + tz); } }; template @@ -64,16 +71,16 @@ void init_tr_from_labeled_image_call_init_features(C3T3& c3t3, << " initial points on 1D-features" << std::endl; } - template + typename Image_word_type, + typename TransformOperator = CGAL::Identity > void initialize_triangulation_from_labeled_image(C3T3& c3t3, - const MeshDomain& domain, - const CGAL::Image_3& image, - const MeshCriteria& criteria, - Image_word_type, - bool protect_features = false - ) + const MeshDomain& domain, + const CGAL::Image_3& image, + const MeshCriteria& criteria, + Image_word_type, + bool protect_features = false, + TransformOperator transform = CGAL::Identity()) { typedef typename C3T3::Triangulation Tr; typedef typename Tr::Geom_traits Gt; @@ -111,11 +118,10 @@ void initialize_triangulation_from_labeled_image(C3T3& c3t3, Seeds seeds; Get_point get_point(&image); std::cout << "Searching for connected components..." << std::endl; - CGAL::Identity no_transformation; search_for_connected_components_in_labeled_image(image, std::back_inserter(seeds), CGAL::Emptyset_iterator(), - no_transformation, + transform, get_point, Image_word_type()); std::cout << " " << seeds.size() << " components were found." << std::endl; 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/Halfedge.h b/Nef_3/include/CGAL/Nef_3/Halfedge.h index 3903477b915..21506e7db3b 100644 --- a/Nef_3/include/CGAL/Nef_3/Halfedge.h +++ b/Nef_3/include/CGAL/Nef_3/Halfedge.h @@ -100,6 +100,17 @@ class Halfedge_base return *this; } + Halfedge_base& operator=(Halfedge_base&& e) noexcept + { center_vertex_ = std::move(e.center_vertex_); + point_ = std::move(e.point_); + mark_ = std::move(e.mark_); + twin_ = std::move(e.twin_); + out_sedge_ = std::move(e.out_sedge_); + incident_sface_ = std::move(e.incident_sface_); + info_ = 0; + return *this; + } + Vertex_handle& center_vertex() { return center_vertex_; } Vertex_const_handle center_vertex() const { return center_vertex_; } diff --git a/Nef_3/include/CGAL/Nef_3/ID_support_handler.h b/Nef_3/include/CGAL/Nef_3/ID_support_handler.h index a62e50c78e6..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,17 +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) { - sv->set_index(); - f2m[f1][f2] = sv->get_index(); CGAL_NEF_TRACEN("insert " << sv->point() << &*sv - << ": " << f2m[f1][f2]); + << ": " << idx); CGAL_NEF_TRACEN("not defined, yet"); } else { CGAL_NEF_TRACEN("access " << sv->point() << &*sv); - sv->set_index(f2m[f1][f2]); + sv->set_index(idx); } } 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/SHalfedge.h b/Nef_3/include/CGAL/Nef_3/SHalfedge.h index f390132078f..ddf5b382b1d 100644 --- a/Nef_3/include/CGAL/Nef_3/SHalfedge.h +++ b/Nef_3/include/CGAL/Nef_3/SHalfedge.h @@ -114,6 +114,22 @@ class SHalfedge_base { return *this; } + SHalfedge_base& operator=(SHalfedge_base&& e) noexcept + { + source_ = std::move(e.source_); + sprev_ = std::move(e.sprev_); + snext_ = std::move(e.snext_); + incident_sface_ = std::move(e.incident_sface_); + twin_ = std::move(e.twin_); + prev_ = std::move(e.prev_); + next_ = std::move(e.next_); + facet_ = std::move(e.facet_); + info_ = 0; + mark_ = std::move(e.mark_); + circle_ = std::move(e.circle_); + return *this; + } + Mark& mark() { return mark_; } const Mark& mark() const { return mark_; } diff --git a/Nef_3/include/CGAL/Nef_3/SHalfloop.h b/Nef_3/include/CGAL/Nef_3/SHalfloop.h index c4abb9ebcdc..e6cc98bf944 100644 --- a/Nef_3/include/CGAL/Nef_3/SHalfloop.h +++ b/Nef_3/include/CGAL/Nef_3/SHalfloop.h @@ -75,6 +75,15 @@ class SHalfloop_base { return *this; } + SHalfloop_base& operator=(SHalfloop_base&& l) noexcept + { twin_ = std::move(l.twin_); + incident_sface_ = std::move(l.incident_sface_); + facet_ = std::move(l.facet_); + mark_ = std::move(l.mark_); + circle_ = std::move(l.circle_); + return *this; + } + Mark& mark() { return mark_;} const Mark& mark() const { return mark_; } diff --git a/Nef_3/include/CGAL/Nef_3/SNC_constructor.h b/Nef_3/include/CGAL/Nef_3/SNC_constructor.h index f93e584549d..e5bf90033ff 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_constructor.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_constructor.h @@ -2129,16 +2129,14 @@ class SNC_constructor Halfedge_iterator e; CGAL_forall_edges(e, *this->sncp()) { - e->set_index(); - e->twin()->set_index(e->get_index()); + e->twin()->set_index(e->new_index()); } Halffacet_iterator f; CGAL_forall_halffacets(f, *this->sncp()) { Halffacet_cycle_iterator fci(f->facet_cycles_begin()); SHalfedge_handle se(fci); - se->set_index(); - int index(se->get_index()); + int index(se->new_index()); for(; fci != f->facet_cycles_end(); ++fci) { if(fci.is_shalfedge()) { SHalfedge_around_facet_circulator c1(fci), c2(c1); diff --git a/Nef_3/include/CGAL/Nef_3/SNC_indexed_items.h b/Nef_3/include/CGAL/Nef_3/SNC_indexed_items.h index 786971053d3..2bee2a582e5 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_indexed_items.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_indexed_items.h @@ -116,8 +116,9 @@ class SNC_indexed_items { init_ifacet = sl.init_ifacet; return *this; } - - void set_index(int idx = Index_generator::get_unique_index()) + int new_index() + { index = Index_generator::get_unique_index(); return index; } + void set_index(int idx) { index = idx; } int get_index() const { return index; } Halffacet_const_handle get_index_facet() const { @@ -151,8 +152,9 @@ class SNC_indexed_items { init_ifacet = se.init_ifacet; return *this; } - - void set_index(int idx = Index_generator::get_unique_index()) + int new_index() + { index = index2 = Index_generator::get_unique_index(); return index; } + void set_index(int idx) { index = index2 = idx; } int get_index() const { return index; @@ -186,8 +188,9 @@ class SNC_indexed_items { index = sv.index; return *this; } - - void set_index(int idx = Index_generator::get_unique_index()) + int new_index() + { index = Index_generator::get_unique_index(); return index; } + void set_index(int idx) { index = idx; } int get_index() const { return index; } }; 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_3/include/CGAL/Nef_3/polygon_mesh_to_nef_3.h b/Nef_3/include/CGAL/Nef_3/polygon_mesh_to_nef_3.h index 69a1ad95ebf..dea41f6eb00 100644 --- a/Nef_3/include/CGAL/Nef_3/polygon_mesh_to_nef_3.h +++ b/Nef_3/include/CGAL/Nef_3/polygon_mesh_to_nef_3.h @@ -112,7 +112,7 @@ class Face_graph_index_adder { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; public: Face_graph_index_adder(Polyhedron&, HalfedgeIndexMap ) {} - void set_hash(halfedge_descriptor, + void set_edge(halfedge_descriptor, SHalfedge_handle) {} void resolve_indexes() {} }; @@ -126,21 +126,21 @@ class Face_graph_index_adder Halfedge_around_facet_const_circulator; - typedef std::vector Hash; + typedef std::vector SHalfedges; PolygonMesh& P; HalfedgeIndexMap him; - Hash hash; + SHalfedges shalfedges; public: Face_graph_index_adder(PolygonMesh& P_, HalfedgeIndexMap him) : P(P_), him(him) { - hash.resize(num_halfedges(P)); + shalfedges.resize(num_halfedges(P)); } - void set_hash(halfedge_descriptor evc, + void set_edge(halfedge_descriptor evc, SHalfedge_handle se) { - hash[get(him,evc)] = se; + shalfedges[get(him,evc)] = se; } void resolve_indexes() @@ -148,26 +148,22 @@ public: for(face_descriptor fi : faces(P)) { Halfedge_around_facet_const_circulator fc(halfedge(fi,P),P), end(fc); - typename boost::property_traits::value_type - index = get(him,*fc); - hash[index]->set_index(); - hash[index]->twin()->set_index(); - hash[index]->twin()->source()->set_index(); - int se = hash[index]->get_index(); - int set = hash[index]->twin()->get_index(); - int sv = hash[index]->twin()->source()->get_index(); + SHalfedge_handle s = shalfedges[get(him,*fc)]; + int se = s->new_index(); + int set = s->twin()->new_index(); + int sv = s->twin()->source()->new_index(); ++fc; CGAL_For_all(fc, end) { - index = get(him,*fc); - hash[index]->set_index(se); - hash[index]->twin()->set_index(set); - hash[index]->source()->set_index(sv); - hash[index]->twin()->source()->set_index(); - sv = hash[index]->twin()->source()->get_index(); + SHalfedge_handle n = shalfedges[get(him,*fc)]; + n->set_index(se); + n->twin()->set_index(set); + n->source()->set_index(sv); + sv = n->twin()->source()->new_index(); } - hash[get(him,*fc)]->source()->set_index(sv); + s->source()->set_index(sv); } + } }; @@ -266,7 +262,7 @@ void polygon_mesh_to_nef_3(PolygonMesh& P, SNC_structure& S, FaceIndexMap fimap, e->twin()->circle() = ss_circle.opposite(); e->mark() = e->twin()->mark() = true; - index_adder.set_hash(pe_prev, e); + index_adder.set_edge(pe_prev, e); } sv_prev = sv; @@ -300,7 +296,7 @@ void polygon_mesh_to_nef_3(PolygonMesh& P, SNC_structure& S, FaceIndexMap fimap, e->twin()->circle() = ss_circle.opposite(); e->mark() = e->twin()->mark() = true; - index_adder.set_hash(pe_prev, e); + index_adder.set_edge(pe_prev, e); } // create faces diff --git a/Nef_3/include/CGAL/Nef_3/vertex_cycle_to_nef_3.h b/Nef_3/include/CGAL/Nef_3/vertex_cycle_to_nef_3.h index a291d11bb0a..1b7426fee5a 100644 --- a/Nef_3/include/CGAL/Nef_3/vertex_cycle_to_nef_3.h +++ b/Nef_3/include/CGAL/Nef_3/vertex_cycle_to_nef_3.h @@ -35,37 +35,6 @@ namespace CGAL { -/* -template -class Index_assigner { - Index_assigner() {} - template - void assign_index(Handle& ) const {} - template - void assign_first_index() const {} - template - void assign_new_index() {} -}; - -template<> class Index_assigner { - int first; - int index; - public: - Index_assigner() : - first(Index_generator::get_unique_index()), index(first) {} - - template - void assign_index(Handle& h) const - { h->set_index(index); } - template - void assign_first_index(Handle& h) const - { h->set_index(first); } - template - void assign_new_index(Handle& h) - { h->set_index(); index = h->get_index(); } -}; -*/ - //template class Index_matcher; template @@ -121,11 +90,10 @@ template h->set_index(ei->second); if(plusTwin) h->twin()->set_index(h->get_index()+1); } else { - int new_index = Index_generator::get_unique_index(); + int new_index = h->new_index(); edge2int.insert(std::make_pair(e,new_index)); - h->set_index(new_index); if(plusTwin) - h->twin()->set_index(); + h->twin()->new_index(); } } }; diff --git a/Nef_3/include/CGAL/Nef_polyhedron_3.h b/Nef_3/include/CGAL/Nef_polyhedron_3.h index 525bc7d1d0a..8a2e1e16520 100644 --- a/Nef_3/include/CGAL/Nef_polyhedron_3.h +++ b/Nef_3/include/CGAL/Nef_polyhedron_3.h @@ -375,11 +375,18 @@ protected: } Nef_polyhedron_3& operator=(const Nef_polyhedron_3& N1) { - Base::operator=(N1); + Base::operator=(N1); // copy the handle set_snc(snc()); return (*this); } + Nef_polyhedron_3& operator=(Nef_polyhedron_3&& N1) noexcept { + N1.set_snc(snc()); // N1.set_snc sets N1.sncp_ not N1.snc_ + Base::operator=(std::move(N1)); // swap the handles + set_snc(snc()); // snc() will return N1.snc_ + return (*this); + } + ~Nef_polyhedron_3() { CGAL_NEF_TRACEN("~Nef_polyhedron_3: destructor called for snc "<<&snc()<< ", pl "<new_sface()); SM.link_as_isolated_vertex(sv,sf); if(first) { - sv->set_index(); - index = sv->get_index(); + index = sv->new_index(); first = false; } else sv->set_index(index); @@ -518,8 +524,7 @@ protected: SM.link_as_isolated_vertex(sv1,sf); SM.link_as_isolated_vertex(sv2,sf); sv1->set_index(index); - sv2->set_index(); - index = sv2->get_index(); + index = sv2->new_index(); } }; diff --git a/Nef_S2/include/CGAL/Nef_S2/SM_const_decorator.h b/Nef_S2/include/CGAL/Nef_S2/SM_const_decorator.h index 74b16be98ae..fe38af9ab44 100644 --- a/Nef_S2/include/CGAL/Nef_S2/SM_const_decorator.h +++ b/Nef_S2/include/CGAL/Nef_S2/SM_const_decorator.h @@ -273,36 +273,44 @@ The macros are then |CGAL_forall_svertices(v,M)|, |CGAL_forall_sfaces(f,M)|, |CGAL_forall_sface_cycles_of(fc,F)| where |M| is a sphere map and |F| is a sface.}*/ +private: +std::string get_svertex_index(SVertex_const_handle) const; + }; // SM_const_decorator +template +std::string SM_const_decorator:: +get_svertex_index(SVertex_const_handle v) const +{ + Object_index + VI(svertices_begin(),svertices_end(),'v'); + return VI(v); +} + template void SM_const_decorator:: check_integrity_and_topological_planarity(bool faces) const { CGAL_NEF_TRACEN("check_integrity_and_topological_planarity:"); - using CGAL::Object_index; - Object_index - VI(svertices_begin(),svertices_end(),'v'); +#ifdef CGAL_USE_TRACE Object_index EI(shalfedges_begin(),shalfedges_end(),'e'); - Object_index - FI(sfaces_begin(),sfaces_end(),'f'); +#endif SVertex_const_handle v; int iso_vert_num=0; /* check the source links of out edges and count isolated vertices */ CGAL_forall_svertices(v,*this) { if ( is_isolated(v) ) { if ( faces ) - CGAL_assertion_msg(v->incident_sface() != SFace_const_handle(), VI(v).c_str()); + CGAL_assertion_msg(v->incident_sface() != SFace_const_handle(), get_svertex_index(v).c_str()); ++iso_vert_num; } else { - CGAL_assertion_msg(first_out_edge(v) != SHalfedge_const_handle(), - VI(v).c_str()); - CGAL_NEF_TRACEN(v->point()<<" "<source() == v, - VI(v).c_str()); + CGAL_assertion_code(SHalfedge_const_handle e=first_out_edge(v)); + CGAL_assertion_msg(e != SHalfedge_const_handle(), get_svertex_index(v).c_str()); + CGAL_NEF_TRACEN(v->point()<<" "<source() == v, get_svertex_index(v).c_str()); } } 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/Partition_2/include/CGAL/Partition_2/partition_approx_convex_2.h b/Partition_2/include/CGAL/Partition_2/partition_approx_convex_2.h index 813cc59ab5b..72e81ce0786 100644 --- a/Partition_2/include/CGAL/Partition_2/partition_approx_convex_2.h +++ b/Partition_2/include/CGAL/Partition_2/partition_approx_convex_2.h @@ -230,7 +230,7 @@ OutputIterator partition_approx_convex_2(InputIterator first, } #if defined(CGAL_PARTITION_NO_POSTCONDITIONS) || \ - defined(CGAL_NO_POSTCONDITIONS) || defined(NDEBUG) + defined(CGAL_NO_POSTCONDITIONS) OutputIterator res(result); #else typedef typename Traits::Polygon_2 Polygon_2; @@ -244,7 +244,7 @@ OutputIterator partition_approx_convex_2(InputIterator first, res.output_so_far_end(), traits)); #if defined(CGAL_PARTITION_NO_POSTCONDITIONS) || \ - defined(CGAL_NO_POSTCONDITIONS) || defined(NDEBUG) + defined(CGAL_NO_POSTCONDITIONS) return res; #else return res.to_output_iterator(); diff --git a/Partition_2/include/CGAL/Partition_2/partition_assertions.h b/Partition_2/include/CGAL/Partition_2/partition_assertions.h index 41f5dfe2cf3..6d0f0288b3e 100644 --- a/Partition_2/include/CGAL/Partition_2/partition_assertions.h +++ b/Partition_2/include/CGAL/Partition_2/partition_assertions.h @@ -15,7 +15,7 @@ // Note that this header file is intentionnaly not protected with a // macro (as ). Calling it a second time with another value -// for NDEBUG for example must make a difference. +// for CGAL_NO_ASSERTIONS for example must make a difference. #include @@ -28,8 +28,7 @@ #undef CGAL_partition_assertion_msg #undef CGAL_partition_assertion_code -#if defined(CGAL_PARTITION_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG) +#if defined(CGAL_PARTITION_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) # define CGAL_partition_assertion(EX) (static_cast(0)) #include @@ -51,8 +50,7 @@ #undef CGAL_partition_exactness_assertion_code #if defined(CGAL_PARTITION_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_PARTITION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_PARTITION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_partition_exactness_assertion(EX) (static_cast(0)) # define CGAL_partition_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_exactness_assertion_code(CODE) @@ -72,8 +70,7 @@ #if defined(CGAL_PARTITION_NO_ASSERTIONS) \ || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_partition_expensive_assertion(EX) (static_cast(0)) # define CGAL_partition_expensive_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_expensive_assertion_code(CODE) @@ -93,8 +90,7 @@ #if defined(CGAL_PARTITION_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ || (!defined(CGAL_PARTITION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_partition_expensive_exactness_assertion(EX) (static_cast(0)) # define CGAL_partition_expensive_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_expensive_exactness_assertion_code(CODE) @@ -115,8 +111,7 @@ #undef CGAL_partition_precondition_msg #undef CGAL_partition_precondition_code -#if defined(CGAL_PARTITION_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_PARTITION_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) # define CGAL_partition_precondition(EX) (static_cast(0)) # define CGAL_partition_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_precondition_code(CODE) @@ -135,8 +130,7 @@ #undef CGAL_partition_exactness_precondition_code #if defined(CGAL_PARTITION_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_PARTITION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_PARTITION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_partition_exactness_precondition(EX) (static_cast(0)) # define CGAL_partition_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_exactness_precondition_code(CODE) @@ -155,8 +149,7 @@ #undef CGAL_partition_expensive_precondition_code #if defined(CGAL_PARTITION_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_partition_expensive_precondition(EX) (static_cast(0)) # define CGAL_partition_expensive_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_expensive_precondition_code(CODE) @@ -176,8 +169,7 @@ #if defined(CGAL_PARTITION_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ || (!defined(CGAL_PARTITION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_partition_expensive_exactness_precondition(EX) (static_cast(0)) # define CGAL_partition_expensive_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_expensive_exactness_precondition_code(CODE) @@ -198,8 +190,7 @@ #undef CGAL_partition_postcondition_msg #undef CGAL_partition_postcondition_code -#if defined(CGAL_PARTITION_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_PARTITION_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) # define CGAL_partition_postcondition(EX) (static_cast(0)) # define CGAL_partition_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_postcondition_code(CODE) @@ -218,8 +209,7 @@ #undef CGAL_partition_exactness_postcondition_code #if defined(CGAL_PARTITION_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_PARTITION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_PARTITION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_partition_exactness_postcondition(EX) (static_cast(0)) # define CGAL_partition_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_exactness_postcondition_code(CODE) @@ -238,8 +228,7 @@ #undef CGAL_partition_expensive_postcondition_code #if defined(CGAL_PARTITION_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_partition_expensive_postcondition(EX) (static_cast(0)) # define CGAL_partition_expensive_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_expensive_postcondition_code(CODE) @@ -259,8 +248,7 @@ #if defined(CGAL_PARTITION_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ || (!defined(CGAL_PARTITION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_partition_expensive_exactness_postcondition(EX) (static_cast(0)) # define CGAL_partition_expensive_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_expensive_exactness_postcondition_code(CODE) @@ -281,8 +269,7 @@ #undef CGAL_partition_warning_msg #undef CGAL_partition_warning_code -#if defined(CGAL_PARTITION_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || defined(NDEBUG) +#if defined(CGAL_PARTITION_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) # define CGAL_partition_warning(EX) (static_cast(0)) # define CGAL_partition_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_warning_code(CODE) @@ -301,8 +288,7 @@ #undef CGAL_partition_exactness_warning_code #if defined(CGAL_PARTITION_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_PARTITION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_PARTITION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_partition_exactness_warning(EX) (static_cast(0)) # define CGAL_partition_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_exactness_warning_code(CODE) @@ -321,8 +307,7 @@ #undef CGAL_partition_expensive_warning_code #if defined(CGAL_PARTITION_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_partition_expensive_warning(EX) (static_cast(0)) # define CGAL_partition_expensive_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_expensive_warning_code(CODE) @@ -342,8 +327,7 @@ #if defined(CGAL_PARTITION_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ || (!defined(CGAL_PARTITION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_PARTITION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_partition_expensive_exactness_warning(EX) (static_cast(0)) # define CGAL_partition_expensive_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_partition_expensive_exactness_warning_code(CODE) diff --git a/Partition_2/include/CGAL/Partition_2/partition_greene_approx_convex_2.h b/Partition_2/include/CGAL/Partition_2/partition_greene_approx_convex_2.h index 4e4cbce5334..e2259a19a69 100644 --- a/Partition_2/include/CGAL/Partition_2/partition_greene_approx_convex_2.h +++ b/Partition_2/include/CGAL/Partition_2/partition_greene_approx_convex_2.h @@ -798,7 +798,7 @@ OutputIterator partition_greene_approx_convex_2(InputIterator first, typedef typename Traits::Polygon_2 Polygon_2; #if defined(CGAL_PARTITION_NO_POSTCONDITIONS) || \ - defined(CGAL_NO_POSTCONDITIONS) || defined(NDEBUG) + defined(CGAL_NO_POSTCONDITIONS) OutputIterator res(result); #else @@ -829,7 +829,7 @@ OutputIterator partition_greene_approx_convex_2(InputIterator first, res.output_so_far_end(), traits)); #if defined(CGAL_PARTITION_NO_POSTCONDITIONS) || \ - defined(CGAL_NO_POSTCONDITIONS) || defined(NDEBUG) + defined(CGAL_NO_POSTCONDITIONS) return res; #else return res.to_output_iterator(); diff --git a/Partition_2/include/CGAL/Partition_2/partition_optimal_convex_2.h b/Partition_2/include/CGAL/Partition_2/partition_optimal_convex_2.h index 68baffab98b..0b87e73eb84 100644 --- a/Partition_2/include/CGAL/Partition_2/partition_optimal_convex_2.h +++ b/Partition_2/include/CGAL/Partition_2/partition_optimal_convex_2.h @@ -512,7 +512,7 @@ OutputIterator partition_optimal_convex_2(InputIterator first, #if defined(CGAL_PARTITION_NO_POSTCONDITIONS) || \ - defined(CGAL_NO_POSTCONDITIONS) || defined(NDEBUG) + defined(CGAL_NO_POSTCONDITIONS) OutputIterator res(result); #else typedef typename Traits::Polygon_2 Polygon_2; @@ -567,7 +567,7 @@ OutputIterator partition_optimal_convex_2(InputIterator first, } #if defined(CGAL_PARTITION_NO_POSTCONDITIONS) || \ - defined(CGAL_NO_POSTCONDITIONS) || defined(NDEBUG) + defined(CGAL_NO_POSTCONDITIONS) return res; #else return res.to_output_iterator(); diff --git a/Partition_2/include/CGAL/Partition_2/partition_y_monotone_2.h b/Partition_2/include/CGAL/Partition_2/partition_y_monotone_2.h index d6b1b92857c..a4918e5548f 100644 --- a/Partition_2/include/CGAL/Partition_2/partition_y_monotone_2.h +++ b/Partition_2/include/CGAL/Partition_2/partition_y_monotone_2.h @@ -418,7 +418,7 @@ OutputIterator partition_y_monotone_2(InputIterator first, typedef Circulator_from_iterator Circulator; #if defined(CGAL_PARTITION_NO_POSTCONDITIONS) || \ - defined(CGAL_NO_POSTCONDITIONS) || defined(NDEBUG) + defined(CGAL_NO_POSTCONDITIONS) OutputIterator res(result); #else typedef typename Traits::Polygon_2 Polygon_2; @@ -490,7 +490,7 @@ OutputIterator partition_y_monotone_2(InputIterator first, res.output_so_far_end(), traits)); #if defined(CGAL_PARTITION_NO_POSTCONDITIONS) || \ - defined(CGAL_NO_POSTCONDITIONS) || defined(NDEBUG) + defined(CGAL_NO_POSTCONDITIONS) return res; #else return res.to_output_iterator(); 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/point_set_processing_assertions.h b/Point_set_processing_3/include/CGAL/point_set_processing_assertions.h index 85e5c6012cb..e5b85b5f3ef 100644 --- a/Point_set_processing_3/include/CGAL/point_set_processing_assertions.h +++ b/Point_set_processing_3/include/CGAL/point_set_processing_assertions.h @@ -20,7 +20,7 @@ // Note that this header file is intentionnaly not protected with a // macro (as ). Calling it a second time with another value -// for NDEBUG for example must make a difference. +// for CGAL_NO_ASSERTIONS for example must make a difference. #include @@ -33,8 +33,7 @@ #undef CGAL_point_set_processing_assertion_msg #undef CGAL_point_set_processing_assertion_code -#if defined(CGAL_POINT_SET_PROCESSING_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG) +#if defined(CGAL_POINT_SET_PROCESSING_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) # define CGAL_point_set_processing_assertion(EX) (static_cast(0)) #include @@ -56,8 +55,7 @@ #undef CGAL_point_set_processing_exactness_assertion_code #if defined(CGAL_POINT_SET_PROCESSING_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_point_set_processing_exactness_assertion(EX) (static_cast(0)) # define CGAL_point_set_processing_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_exactness_assertion_code(CODE) @@ -77,8 +75,7 @@ #if defined(CGAL_POINT_SET_PROCESSING_NO_ASSERTIONS) \ || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_point_set_processing_expensive_assertion(EX) (static_cast(0)) # define CGAL_point_set_processing_expensive_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_expensive_assertion_code(CODE) @@ -98,8 +95,7 @@ #if defined(CGAL_POINT_SET_PROCESSING_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_point_set_processing_expensive_exactness_assertion(EX) (static_cast(0)) # define CGAL_point_set_processing_expensive_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_expensive_exactness_assertion_code(CODE) @@ -120,8 +116,7 @@ #undef CGAL_point_set_processing_precondition_msg #undef CGAL_point_set_processing_precondition_code -#if defined(CGAL_POINT_SET_PROCESSING_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_POINT_SET_PROCESSING_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) # define CGAL_point_set_processing_precondition(EX) (static_cast(0)) # define CGAL_point_set_processing_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_precondition_code(CODE) @@ -140,8 +135,7 @@ #undef CGAL_point_set_processing_exactness_precondition_code #if defined(CGAL_POINT_SET_PROCESSING_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_point_set_processing_exactness_precondition(EX) (static_cast(0)) # define CGAL_point_set_processing_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_exactness_precondition_code(CODE) @@ -160,8 +154,7 @@ #undef CGAL_point_set_processing_expensive_precondition_code #if defined(CGAL_POINT_SET_PROCESSING_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_point_set_processing_expensive_precondition(EX) (static_cast(0)) # define CGAL_point_set_processing_expensive_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_expensive_precondition_code(CODE) @@ -181,8 +174,7 @@ #if defined(CGAL_POINT_SET_PROCESSING_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_point_set_processing_expensive_exactness_precondition(EX) (static_cast(0)) # define CGAL_point_set_processing_expensive_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_expensive_exactness_precondition_code(CODE) @@ -203,8 +195,7 @@ #undef CGAL_point_set_processing_postcondition_msg #undef CGAL_point_set_processing_postcondition_code -#if defined(CGAL_POINT_SET_PROCESSING_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_POINT_SET_PROCESSING_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) # define CGAL_point_set_processing_postcondition(EX) (static_cast(0)) # define CGAL_point_set_processing_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_postcondition_code(CODE) @@ -223,8 +214,7 @@ #undef CGAL_point_set_processing_exactness_postcondition_code #if defined(CGAL_POINT_SET_PROCESSING_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_point_set_processing_exactness_postcondition(EX) (static_cast(0)) # define CGAL_point_set_processing_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_exactness_postcondition_code(CODE) @@ -243,8 +233,7 @@ #undef CGAL_point_set_processing_expensive_postcondition_code #if defined(CGAL_POINT_SET_PROCESSING_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_point_set_processing_expensive_postcondition(EX) (static_cast(0)) # define CGAL_point_set_processing_expensive_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_expensive_postcondition_code(CODE) @@ -264,8 +253,7 @@ #if defined(CGAL_POINT_SET_PROCESSING_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_point_set_processing_expensive_exactness_postcondition(EX) (static_cast(0)) # define CGAL_point_set_processing_expensive_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_expensive_exactness_postcondition_code(CODE) @@ -286,8 +274,7 @@ #undef CGAL_point_set_processing_warning_msg #undef CGAL_point_set_processing_warning_code -#if defined(CGAL_POINT_SET_PROCESSING_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || defined(NDEBUG) +#if defined(CGAL_POINT_SET_PROCESSING_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) # define CGAL_point_set_processing_warning(EX) (static_cast(0)) # define CGAL_point_set_processing_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_warning_code(CODE) @@ -306,8 +293,7 @@ #undef CGAL_point_set_processing_exactness_warning_code #if defined(CGAL_POINT_SET_PROCESSING_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_point_set_processing_exactness_warning(EX) (static_cast(0)) # define CGAL_point_set_processing_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_exactness_warning_code(CODE) @@ -326,8 +312,7 @@ #undef CGAL_point_set_processing_expensive_warning_code #if defined(CGAL_POINT_SET_PROCESSING_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_point_set_processing_expensive_warning(EX) (static_cast(0)) # define CGAL_point_set_processing_expensive_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_expensive_warning_code(CODE) @@ -347,8 +332,7 @@ #if defined(CGAL_POINT_SET_PROCESSING_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POINT_SET_PROCESSING_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_point_set_processing_expensive_exactness_warning(EX) (static_cast(0)) # define CGAL_point_set_processing_expensive_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_point_set_processing_expensive_exactness_warning_code(CODE) 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/Poisson_surface_reconstruction_3/include/CGAL/surface_reconstruction_points_assertions.h b/Poisson_surface_reconstruction_3/include/CGAL/surface_reconstruction_points_assertions.h index 48dc293bb88..67bc3df7f1a 100644 --- a/Poisson_surface_reconstruction_3/include/CGAL/surface_reconstruction_points_assertions.h +++ b/Poisson_surface_reconstruction_3/include/CGAL/surface_reconstruction_points_assertions.h @@ -19,7 +19,7 @@ // Note that this header file is intentionnaly not protected with a // macro (as ). Calling it a second time with another value -// for NDEBUG for example must make a difference. +// for CGAL_NO_ASSERTIONS for example must make a difference. #include @@ -32,8 +32,7 @@ #undef CGAL_surface_reconstruction_points_assertion_msg #undef CGAL_surface_reconstruction_points_assertion_code -#if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG) +#if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) # define CGAL_surface_reconstruction_points_assertion(EX) (static_cast(0)) #include @@ -55,8 +54,7 @@ #undef CGAL_surface_reconstruction_points_exactness_assertion_code #if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_surface_reconstruction_points_exactness_assertion(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_exactness_assertion_code(CODE) @@ -76,8 +74,7 @@ #if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_ASSERTIONS) \ || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_surface_reconstruction_points_expensive_assertion(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_assertion_code(CODE) @@ -97,8 +94,7 @@ #if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_surface_reconstruction_points_expensive_exactness_assertion(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_exactness_assertion_code(CODE) @@ -119,8 +115,7 @@ #undef CGAL_surface_reconstruction_points_precondition_msg #undef CGAL_surface_reconstruction_points_precondition_code -#if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) # define CGAL_surface_reconstruction_points_precondition(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_precondition_code(CODE) @@ -139,8 +134,7 @@ #undef CGAL_surface_reconstruction_points_exactness_precondition_code #if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_surface_reconstruction_points_exactness_precondition(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_exactness_precondition_code(CODE) @@ -159,8 +153,7 @@ #undef CGAL_surface_reconstruction_points_expensive_precondition_code #if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_surface_reconstruction_points_expensive_precondition(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_precondition_code(CODE) @@ -180,8 +173,7 @@ #if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_surface_reconstruction_points_expensive_exactness_precondition(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_exactness_precondition_code(CODE) @@ -202,8 +194,7 @@ #undef CGAL_surface_reconstruction_points_postcondition_msg #undef CGAL_surface_reconstruction_points_postcondition_code -#if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) # define CGAL_surface_reconstruction_points_postcondition(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_postcondition_code(CODE) @@ -222,8 +213,7 @@ #undef CGAL_surface_reconstruction_points_exactness_postcondition_code #if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_surface_reconstruction_points_exactness_postcondition(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_exactness_postcondition_code(CODE) @@ -242,8 +232,7 @@ #undef CGAL_surface_reconstruction_points_expensive_postcondition_code #if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_surface_reconstruction_points_expensive_postcondition(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_postcondition_code(CODE) @@ -263,8 +252,7 @@ #if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_surface_reconstruction_points_expensive_exactness_postcondition(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_exactness_postcondition_code(CODE) @@ -285,8 +273,7 @@ #undef CGAL_surface_reconstruction_points_warning_msg #undef CGAL_surface_reconstruction_points_warning_code -#if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || defined(NDEBUG) +#if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) # define CGAL_surface_reconstruction_points_warning(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_warning_code(CODE) @@ -305,8 +292,7 @@ #undef CGAL_surface_reconstruction_points_exactness_warning_code #if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_surface_reconstruction_points_exactness_warning(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_exactness_warning_code(CODE) @@ -325,8 +311,7 @@ #undef CGAL_surface_reconstruction_points_expensive_warning_code #if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_surface_reconstruction_points_expensive_warning(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_warning_code(CODE) @@ -346,8 +331,7 @@ #if defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_SURFACE_RECONSTRUCTION_POINTS_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_surface_reconstruction_points_expensive_exactness_warning(EX) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_surface_reconstruction_points_expensive_exactness_warning_code(CODE) diff --git a/Polygon/include/CGAL/Polygon_2/polygon_assertions.h b/Polygon/include/CGAL/Polygon_2/polygon_assertions.h index 407cf25d25d..47711d72fef 100644 --- a/Polygon/include/CGAL/Polygon_2/polygon_assertions.h +++ b/Polygon/include/CGAL/Polygon_2/polygon_assertions.h @@ -19,7 +19,7 @@ // Note that this header file is intentionnaly not protected with a // macro (as ). Calling it a second time with another value -// for NDEBUG for example must make a difference. +// for CGAL_NO_ASSERTIONS for example must make a difference. #include @@ -35,8 +35,7 @@ #ifndef CGAL_POLYGON_ASSERTIONS_H #define CGAL_POLYGON_ASSERTIONS_H -#if defined(CGAL_POLYGON_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ -|| defined(NDEBUG) +#if defined(CGAL_POLYGON_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) namespace CGAL{ inline void set_use_polygon_assertions(bool){} inline bool get_use_polygon_assertions(){return true;} @@ -57,8 +56,7 @@ inline void set_use_polygon_assertions(bool b) #endif #endif // CGAL_POLYGON_ASSERTIONS_H -#if defined(CGAL_POLYGON_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG) +#if defined(CGAL_POLYGON_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) # define CGAL_polygon_assertion(EX) (static_cast(0)) # define CGAL_polygon_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_assertion_code(CODE) @@ -77,8 +75,7 @@ inline void set_use_polygon_assertions(bool b) #undef CGAL_polygon_exactness_assertion_code #if defined(CGAL_POLYGON_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_POLYGON_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_POLYGON_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_polygon_exactness_assertion(EX) (static_cast(0)) # define CGAL_polygon_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_exactness_assertion_code(CODE) @@ -98,8 +95,7 @@ inline void set_use_polygon_assertions(bool b) #if defined(CGAL_POLYGON_NO_ASSERTIONS) \ || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_polygon_expensive_assertion(EX) (static_cast(0)) # define CGAL_polygon_expensive_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_expensive_assertion_code(CODE) @@ -119,8 +115,7 @@ inline void set_use_polygon_assertions(bool b) #if defined(CGAL_POLYGON_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ || (!defined(CGAL_POLYGON_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_polygon_expensive_exactness_assertion(EX) (static_cast(0)) # define CGAL_polygon_expensive_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_expensive_exactness_assertion_code(CODE) @@ -141,8 +136,7 @@ inline void set_use_polygon_assertions(bool b) #undef CGAL_polygon_precondition_msg #undef CGAL_polygon_precondition_code -#if defined(CGAL_POLYGON_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_POLYGON_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) # define CGAL_polygon_precondition(EX) (static_cast(0)) # define CGAL_polygon_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_precondition_code(CODE) @@ -161,8 +155,7 @@ inline void set_use_polygon_assertions(bool b) #undef CGAL_polygon_exactness_precondition_code #if defined(CGAL_POLYGON_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_POLYGON_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_POLYGON_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_polygon_exactness_precondition(EX) (static_cast(0)) # define CGAL_polygon_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_exactness_precondition_code(CODE) @@ -181,8 +174,7 @@ inline void set_use_polygon_assertions(bool b) #undef CGAL_polygon_expensive_precondition_code #if defined(CGAL_POLYGON_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_polygon_expensive_precondition(EX) (static_cast(0)) # define CGAL_polygon_expensive_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_expensive_precondition_code(CODE) @@ -202,8 +194,7 @@ inline void set_use_polygon_assertions(bool b) #if defined(CGAL_POLYGON_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ || (!defined(CGAL_POLYGON_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_polygon_expensive_exactness_precondition(EX) (static_cast(0)) # define CGAL_polygon_expensive_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_expensive_exactness_precondition_code(CODE) @@ -224,8 +215,7 @@ inline void set_use_polygon_assertions(bool b) #undef CGAL_polygon_postcondition_msg #undef CGAL_polygon_postcondition_code -#if defined(CGAL_POLYGON_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_POLYGON_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) # define CGAL_polygon_postcondition(EX) (static_cast(0)) # define CGAL_polygon_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_postcondition_code(CODE) @@ -244,8 +234,7 @@ inline void set_use_polygon_assertions(bool b) #undef CGAL_polygon_exactness_postcondition_code #if defined(CGAL_POLYGON_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_POLYGON_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_POLYGON_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_polygon_exactness_postcondition(EX) (static_cast(0)) # define CGAL_polygon_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_exactness_postcondition_code(CODE) @@ -264,8 +253,7 @@ inline void set_use_polygon_assertions(bool b) #undef CGAL_polygon_expensive_postcondition_code #if defined(CGAL_POLYGON_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_polygon_expensive_postcondition(EX) (static_cast(0)) # define CGAL_polygon_expensive_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_expensive_postcondition_code(CODE) @@ -285,8 +273,7 @@ inline void set_use_polygon_assertions(bool b) #if defined(CGAL_POLYGON_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ || (!defined(CGAL_POLYGON_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_polygon_expensive_exactness_postcondition(EX) (static_cast(0)) # define CGAL_polygon_expensive_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_expensive_exactness_postcondition_code(CODE) @@ -307,8 +294,7 @@ inline void set_use_polygon_assertions(bool b) #undef CGAL_polygon_warning_msg #undef CGAL_polygon_warning_code -#if defined(CGAL_POLYGON_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || defined(NDEBUG) +#if defined(CGAL_POLYGON_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) # define CGAL_polygon_warning(EX) (static_cast(0)) # define CGAL_polygon_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_warning_code(CODE) @@ -327,8 +313,7 @@ inline void set_use_polygon_assertions(bool b) #undef CGAL_polygon_exactness_warning_code #if defined(CGAL_POLYGON_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_POLYGON_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_POLYGON_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_polygon_exactness_warning(EX) (static_cast(0)) # define CGAL_polygon_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_exactness_warning_code(CODE) @@ -347,8 +332,7 @@ inline void set_use_polygon_assertions(bool b) #undef CGAL_polygon_expensive_warning_code #if defined(CGAL_POLYGON_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_polygon_expensive_warning(EX) (static_cast(0)) # define CGAL_polygon_expensive_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_expensive_warning_code(CODE) @@ -368,8 +352,7 @@ inline void set_use_polygon_assertions(bool b) #if defined(CGAL_POLYGON_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ || (!defined(CGAL_POLYGON_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_POLYGON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_polygon_expensive_exactness_warning(EX) (static_cast(0)) # define CGAL_polygon_expensive_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_polygon_expensive_exactness_warning_code(CODE) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Concepts/PMPCorefinementVisitor.h b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Concepts/PMPCorefinementVisitor.h index cd2e6ebf2eb..450596ed64d 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Concepts/PMPCorefinementVisitor.h +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Concepts/PMPCorefinementVisitor.h @@ -24,37 +24,59 @@ typedef unspecified_type halfedge_descriptor; /// `before_subface_created()`/`after_subface_created()` will correspond to /// the creation of a new face of the triangulation of `f_split`. void before_subface_creations(face_descriptor f_split, Triangle_mesh& tm); - /// called when the triangulation of a face in `tm` is finished + /// called when the triangulation of a face in `tm` is finished. void after_subface_creations(Triangle_mesh& tm); - /// called before creating a new triangle face in `tm` to triangulate the face passed to `before_subface_creations()` + /// called before creating a new triangle face in `tm` to triangulate the face passed to `before_subface_creations()`. void before_subface_created(Triangle_mesh& tm); /// called after creating a new triangle face `f_new` in `tm` to triangulate the face passed to `before_subface_creations()`. /// Note that the call is placed just after a call to `add_face()` so the halfedge pointer is not set yet. void after_subface_created(face_descriptor f_new, Triangle_mesh& tm); /// @} -/// @name Functions used by corefine() when edges are split +/// @name Functions used by corefine() when edges are split or created /// @{ /// called before the edge of `h` in `tm` is split. Each subsequent call to /// `edge_split()` until the call to `after_edge_split()` will correspond to /// the split of that edge. If `edge_split(h_i, tm)` is called for `i=1` to `n`, /// `h_1`, `h_2`, ... ,`h_n`, `h` is the sequence of halfedges representing the - /// edge split (with the same initial orientation) + /// edge split (with the same initial orientation). There is only one call per edge. void before_edge_split(halfedge_descriptor h, TriangleMesh& tm); - /// called when a new split is done. The target of `hnew` is a new split vertex. + /// called when a new split is done. The target of `hnew` is a new split vertex. There is only one call per edge. void edge_split(halfedge_descriptor hnew, TriangleMesh& tm); /// called when the split of the halfedge `h` passed at the later call to `before_edge_split()` is finished. void after_edge_split(); + /// called when a new edge has been added to triangulate a face. The face triangulated is `f_split` + /// in the last call to `before_subface_creations(f_split, tm)`. There is only one call per edge. + void add_retriangulation_edge(halfedge_descriptor h, TriangleMesh& tm); /// @} /// @name Functions used by Boolean operations functions using corefinement. /// These functions are not needed if you only call `corefine()`. /// @{ /// called before importing the face `f_src` of `tm_src` in `tm_tgt` - void before_face_copy(face_descriptor f_src, Triangle_mesh& tm_src, Triangle_mesh& tm_tgt); + void before_face_copy(face_descriptor f_src, const Triangle_mesh& tm_src, Triangle_mesh& tm_tgt); /// called after importing the face `f_src` of `tm_src` in `tm_tgt`. The new face is `f_tgt`. /// Note that the call is placed just after a call to `add_face()` so the halfedge pointer is not set yet. - void after_face_copy(face_descriptor f_src, Triangle_mesh& tm_src, + void after_face_copy(face_descriptor f_src, const Triangle_mesh& tm_src, face_descriptor f_tgt, Triangle_mesh& tm_tgt); + /// called before importing the edge of `h_src` of `tm_src` in `tm_tgt`. There is one call per edge. + void before_edge_copy(halfedge_descriptor h_src/, const TriangleMesh& tm_src, TriangleMesh& tm_tgt){} + /// called after importing the edge of `h_src` of `tm_src` in `tm_tgt`. The corresponding new halfedge is `h_tgt`. + /// There is only one call per edge. + void after_edge_copy(halfedge_descriptor h_src, const TriangleMesh& tm_src, + halfedge_descriptor h_tgt, TriangleMesh& tm_tgt); + /// called before a patch boundary edge is duplicated to disconnect patches of `tm` + /// (When an in-place operation and an out-of-place are both requested). + void before_edge_duplicated(halfedge_descriptor h, TriangleMesh& tm); + /// called when the edge of `h_src` has been duplicated into `h_new` in `tm` + /// (When an in-place operation and an out-of-place are both requested). + void after_edge_duplicated(halfedge_descriptor h_src, + halfedge_descriptor h_new, TriangleMesh& tm); + /// called when an intersection edge (represented in input meshes `tm_src1` and `tm_src2` by `h_src1` and `h_src2`, + /// respectively) is imported in `tm_tgt` as `h_tgt`. There is only one call per edge. + /// (Called only when an out-of-place operation is requested) + void intersection_edge_copy(halfedge_descriptor h_src1, const TriangleMesh& tm_src1, + halfedge_descriptor h_src2, const TriangleMesh& tm_src2, + halfedge_descriptor h_tgt, TriangleMesh& tm_tgt); /// @} }; 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 GT; typedef typename GT::face_descriptor face_descriptor; typedef typename GT::halfedge_descriptor halfedge_descriptor; - +// face visitor functions void before_subface_creations(face_descriptor /*f_old*/,TriangleMesh&){} void after_subface_creations(TriangleMesh&){} void before_subface_created(TriangleMesh&){} void after_subface_created(face_descriptor /*f_new*/,TriangleMesh&){} - void before_face_copy(face_descriptor /*f_old*/, TriangleMesh&, TriangleMesh&){} - void after_face_copy(face_descriptor /*f_old*/, TriangleMesh&, + void before_face_copy(face_descriptor /*f_old*/, const TriangleMesh&, TriangleMesh&){} + void after_face_copy(face_descriptor /*f_old*/, const TriangleMesh&, face_descriptor /* f_new */, TriangleMesh&){} - void before_edge_split(halfedge_descriptor /* h */, const TriangleMesh& /* tm */){} - void edge_split(halfedge_descriptor /* hnew */, const TriangleMesh& /* tm */){} +// edge visitor functions + void before_edge_split(halfedge_descriptor /* h */, TriangleMesh& /* tm */){} + void edge_split(halfedge_descriptor /* hnew */, TriangleMesh& /* tm */){} void after_edge_split(){} + void add_retriangulation_edge(halfedge_descriptor /* h */ , TriangleMesh& /* tm */) {} // edges added during split face retriangulation + + void before_edge_copy(halfedge_descriptor /*h_old*/, const TriangleMesh&, TriangleMesh&){} + void after_edge_copy(halfedge_descriptor /*h_old*/, const TriangleMesh&, + halfedge_descriptor /* f_new */, TriangleMesh&){} + + void before_edge_duplicated(halfedge_descriptor /*h_old*/, TriangleMesh&){} // called before a patch border edge is duplicated + void after_edge_duplicated(halfedge_descriptor /*h_old*/, + halfedge_descriptor /* f_new */, TriangleMesh&){} // called after a patch border edge is duplicated + + void intersection_edge_copy(halfedge_descriptor /* h_old1 */, const TriangleMesh& /* tm1 */, + halfedge_descriptor /* h_old2 */, const TriangleMesh& /* tm2 */, + halfedge_descriptor /* h_new */, TriangleMesh& /* tm_new */){} + + // calls commented in the code and probably incomplete due to the migration // see NODE_VISITOR_TAG /* @@ -512,6 +528,7 @@ triangulate_a_face( !cdt.is_infinite(cdt.mirror_vertex(it->first,it->second)) ) { edge_descriptor e=add_edge(tm); + user_visitor.add_retriangulation_edge(halfedge(e, tm), tm); halfedge_descriptor h=halfedge(e,tm), h_opp=opposite(h,tm); Node_id i0=cdt_v0->info(), i1=cdt_v1->info(); @@ -809,7 +826,8 @@ template + class IntersectionEdgeMap, + class UserVisitor> void import_polyline( PolygonMesh& output, typename boost::graph_traits::halfedge_descriptor h1, @@ -826,7 +844,8 @@ void import_polyline( const VertexPointMap2& /*vpm2*/, const VertexPointMapOut& vpm_out, std::vector - ::edge_descriptor>& output_shared_edges) + ::edge_descriptor>& output_shared_edges, + UserVisitor& user_visitor) { typedef boost::graph_traits GT; typedef typename GT::halfedge_descriptor halfedge_descriptor; @@ -886,6 +905,8 @@ void import_polyline( pm2_to_output_edges.insert( std::make_pair(edge(prev2, pm2), edge(prev_out, output)) ); + user_visitor.intersection_edge_copy(prev1, pm1, prev2, pm2, h_out, output); + src=tgt; for (std::size_t i=1; i(ed, new_edge, @@ -1285,7 +1311,8 @@ void fill_new_triangle_mesh( tm1_to_output_vertices, intersection_edges1, intersection_edges2, vpm1, vpm2, vpm_out, - output_shared_edges); + output_shared_edges, + user_visitor); //import patches of tm1 if (reverse_orientation_of_patches_from_tm1) @@ -1334,13 +1361,15 @@ void fill_new_triangle_mesh( template + class EdgeMap, + class UserVisitor> void disconnect_patches( TriangleMesh& tm1, const boost::dynamic_bitset<>& patches_to_remove, PatchContainer& patches_of_tm1, const EdgeMap& tm1_edge_to_tm2_edge, //map intersection edges of tm1 to the equivalent in tm2 - EdgeMap& new_tm1_edge_to_tm2_edge) //map the new intersection edges of tm1 to the equivalent in tm2 + EdgeMap& new_tm1_edge_to_tm2_edge, //map the new intersection edges of tm1 to the equivalent in tm2 + UserVisitor& user_visitor) { typedef boost::graph_traits GT; typedef typename GT::halfedge_descriptor halfedge_descriptor; @@ -1396,7 +1425,9 @@ void disconnect_patches( for(std::size_t k=0; k #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 0bb7d129c9e..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) @@ -338,23 +335,6 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) PUBLIC CGAL::Eigen3_support) endif() - find_package(LASLIB) - set_package_properties( - LASLIB PROPERTIES - DESCRIPTION "A library for some I/O." - PURPOSE "Requiered for reading or writing LAS files.") - - include(CGAL_LASLIB_support) - if(TARGET CGAL::LASLIB_support) - target_link_libraries(scene_points_with_normal_item - PUBLIC CGAL::LASLIB_support) - if(MSVC) - target_compile_definitions( - scene_points_with_normal_item - PUBLIC "-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS") - endif() - endif() - if(TBB_FOUND) target_link_libraries(scene_points_with_normal_item PUBLIC CGAL::TBB_support) 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/IO/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt index bed7401d8dc..5ac22254a05 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt @@ -1,5 +1,13 @@ include(polyhedron_demo_macros) +find_package(LASLIB) +set_package_properties( + LASLIB PROPERTIES + DESCRIPTION "A library for some I/O." + PURPOSE "Requiered for reading or writing LAS files.") + +include(CGAL_LASLIB_support) + polyhedron_demo_plugin(gocad_plugin GOCAD_io_plugin KEYWORDS Viewer) target_link_libraries(gocad_plugin PUBLIC scene_surface_mesh_item) @@ -96,6 +104,11 @@ else() polyhedron_demo_plugin(las_plugin LAS_io_plugin KEYWORDS Viewer PointSetProcessing Classification) target_link_libraries(las_plugin PUBLIC scene_points_with_normal_item CGAL::LASLIB_support) target_compile_features(las_plugin PRIVATE ${needed_cxx_features}) + if(MSVC) + target_compile_definitions( + las_plugin + PUBLIC "-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS") + endif() else() message( STATUS diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp index d0e616f2108..ee4b373b160 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include using namespace CGAL::Three; class Polyhedron_demo_las_plugin : @@ -35,12 +36,32 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { Scene_points_with_normal_item* item; item = new Scene_points_with_normal_item(); - if(!item->read_las_point_set(in)) + Q_ASSERT(item->point_set() != nullptr); + + item->point_set()->clear(); + + ok = CGAL::read_LAS (in, *(item->point_set())) && !item->isEmpty(); + if(ok) + { + std::cerr << item->point_set()->info(); + + if (!item->point_set()->has_normal_map()) { - delete item; - ok = false; - return QList(); + item->setRenderingMode(Points); } + else{ + item->setRenderingMode(CGAL::Three::Three::defaultPointSetRenderingMode()); + } + if (item->point_set()->check_colors()) + std::cerr << "-> Point set has colors" << std::endl; + + item->invalidateOpenGLBuffers(); + } + if(!ok) + { + delete item; + return QList(); + } item->setName(fileinfo.completeBaseName()); ok = true; @@ -63,14 +84,18 @@ bool Polyhedron_demo_las_plugin::save(QFileInfo fileinfo,QList(item); + Scene_points_with_normal_item* point_set_item = + qobject_cast(item); if(!point_set_item) return false; std::ofstream out(fileinfo.filePath().toUtf8().data()); items.pop_front(); - return point_set_item->write_las_point_set(out); + Q_ASSERT(point_set_item->point_set() != nullptr); + + point_set_item->point_set()->reset_indices(); + + return CGAL::write_LAS(out, *(point_set_item->point_set())); } 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/PCA/Affine_transform_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp index 1772a029a42..d4e638d31b5 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp @@ -571,7 +571,8 @@ void Polyhedron_demo_affine_transform_plugin::end(){ if(transform_item) { CGAL::qglviewer::Vec c = transform_item->center(); - FaceGraph* new_sm = new FaceGraph(*transform_item->getFaceGraph()); + FaceGraph* new_sm = new FaceGraph(); + CGAL::copy_face_graph(*transform_item->getFaceGraph(), *new_sm); typedef boost::property_map::type VPmap; VPmap vpmap = get(CGAL::vertex_point, *new_sm); 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/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp index 17789593d49..a1d7baf7cc9 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp @@ -547,43 +547,6 @@ void Scene_points_with_normal_item::selectDuplicates() Q_EMIT itemChanged(); } -#ifdef CGAL_LINKED_WITH_LASLIB -// Loads point set from .LAS file -bool Scene_points_with_normal_item::read_las_point_set(std::istream& stream) -{ - Q_ASSERT(d->m_points != NULL); - - d->m_points->clear(); - - bool ok = CGAL::read_LAS (stream, *(d->m_points)) && !isEmpty(); - - std::cerr << d->m_points->info(); - - if (!d->m_points->has_normal_map()) - { - setRenderingMode(Points); - } - else{ - setRenderingMode(CGAL::Three::Three::defaultPointSetRenderingMode()); - } - if (d->m_points->check_colors()) - std::cerr << "-> Point set has colors" << std::endl; - - invalidateOpenGLBuffers(); - return ok; -} - -// Write point set to .LAS file -bool Scene_points_with_normal_item::write_las_point_set(std::ostream& stream) const -{ - Q_ASSERT(d->m_points != NULL); - - d->m_points->reset_indices(); - - return CGAL::write_LAS(stream, *(d->m_points)); -} - -#endif // LAS // Loads point set from .PLY file bool Scene_points_with_normal_item::read_ply_point_set(std::istream& stream) diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h index 31e7cfdb324..7594dba0ef4 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h @@ -50,10 +50,6 @@ public: QMenu* contextMenu() Q_DECL_OVERRIDE; // IO -#ifdef CGAL_LINKED_WITH_LASLIB - bool read_las_point_set(std::istream& in); - bool write_las_point_set(std::ostream& out) const; -#endif // LAS bool read_ply_point_set(std::istream& in); bool write_ply_point_set(std::ostream& out, bool binary) const; bool read_off_point_set(std::istream& in); diff --git a/Polytope_distance_d/include/CGAL/Width_3.h b/Polytope_distance_d/include/CGAL/Width_3.h index 314582a5570..b3b055379a2 100644 --- a/Polytope_distance_d/include/CGAL/Width_3.h +++ b/Polytope_distance_d/include/CGAL/Width_3.h @@ -687,8 +687,7 @@ class Width_3 { std::vector apv; #if !(defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE))\ - || defined(NDEBUG)) + || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE))) typename InputDA::Vertex_iterator vtxitass = P.vertices_begin(); while(vtxitass!=P.vertices_end()) { RT px,py,pz,ph; @@ -745,8 +744,7 @@ class Width_3 { DEBUGENDL(INITIAL_VF_PAIR,"Initial Plane E2: ",A<<" "<=0); @@ -1411,14 +1408,12 @@ class Width_3 { DEBUGMSG(WIDTH_3_CONVEX,"All plane equations of all facets computed."); //ensure all flags are false -#if !(defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG)) +#if !(defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS)) int halfedgecount=0; #endif Halfedge_handle esf=P.halfedges_begin(); while(esf!=P.halfedges_end()) { -#if !(defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG)) +#if !(defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS)) ++halfedgecount; #endif DEBUGENDL(EDGE_INITIALIZING,"Edge e: " @@ -1429,8 +1424,7 @@ class Width_3 { ++esf; } -#if !(defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG)) +#if !(defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS)) CGAL_assertion(int(P.size_of_halfedges())==halfedgecount); DEBUGENDL(WIDTH_3_CONVEX,"Visited all ",halfedgecount <<" halfedges. ASSERTION OK."); @@ -1446,8 +1440,7 @@ class Width_3 { initial_VF_pair(dao,f,P,go_on); #if !(defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE))\ - || defined(NDEBUG)) + || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE))) Vertex_iterator vtxass=P.vertices_begin(); while(vtxass!=P.vertices_end()) { RT px,py,pz,ph; @@ -1523,8 +1516,7 @@ class Width_3 { } } #if !(defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE))\ - || defined(NDEBUG)) + || (!defined(CGAL_KERNEL_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE))) Facet_handle fass=P.facets_begin(); while(fass!=P.facets_end()) { std::vector apvass; diff --git a/Polytope_distance_d/include/CGAL/Width_polyhedron_3.h b/Polytope_distance_d/include/CGAL/Width_polyhedron_3.h index 24e0df725e4..4c215e1f282 100644 --- a/Polytope_distance_d/include/CGAL/Width_polyhedron_3.h +++ b/Polytope_distance_d/include/CGAL/Width_polyhedron_3.h @@ -194,8 +194,7 @@ class Data_access { res=it->second; } -#if !(defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG)) +#if !(defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS)) int size_of_impassable() { return(int(impassable_halfedges.size())); } 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/README.md b/README.md index 80336987350..2d51a910d8a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -[![Build Status](https://travis-ci.org/CGAL/cgal.svg?branch=master)](https://travis-ci.org/CGAL/cgal) - ![CGAL](Installation/doc_html/images/cgal_2013_grey.png) The Computational Geometry Algorithms Library (CGAL) is a C++ library that 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.h b/STL_Extension/include/CGAL/Handle.h index 6b02f9b5ecf..e39f538742c 100644 --- a/STL_Extension/include/CGAL/Handle.h +++ b/STL_Extension/include/CGAL/Handle.h @@ -55,6 +55,12 @@ class Handle PTR->count++; } + Handle(Handle&& x) noexcept + : PTR(x.PTR) + { + x.PTR = static_cast(0); + } + ~Handle() { if ( PTR && (--PTR->count == 0)) @@ -72,6 +78,13 @@ class Handle return *this; } + Handle& + operator=(Handle&& x) noexcept + { + swap(*this,x); + return *this; + } + friend void swap(Handle& a, Handle& b) noexcept { std::swap(a.PTR, b.PTR); } void reset() 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/multiset_assertions.h b/STL_Extension/include/CGAL/multiset_assertions.h index 9d001aefa79..894accd47fc 100644 --- a/STL_Extension/include/CGAL/multiset_assertions.h +++ b/STL_Extension/include/CGAL/multiset_assertions.h @@ -14,7 +14,7 @@ // Note that this header file is intentionnaly not protected with a // macro (as ). Calling it a second time with another value -// for NDEBUG for example must make a difference. +// for CGAL_NO_ASSERTIONS for example must make a difference. #include @@ -27,8 +27,7 @@ #undef CGAL_multiset_assertion_msg #undef CGAL_multiset_assertion_code -#if defined(CGAL_MULTISET_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG) +#if defined(CGAL_MULTISET_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) # define CGAL_multiset_assertion(EX) (static_cast(0)) # define CGAL_multiset_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_assertion_code(CODE) @@ -47,8 +46,7 @@ #undef CGAL_multiset_exactness_assertion_code #if defined(CGAL_MULTISET_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_MULTISET_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_MULTISET_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_multiset_exactness_assertion(EX) (static_cast(0)) # define CGAL_multiset_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_exactness_assertion_code(CODE) @@ -68,8 +66,7 @@ #if defined(CGAL_MULTISET_NO_ASSERTIONS) \ || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_multiset_expensive_assertion(EX) (static_cast(0)) # define CGAL_multiset_expensive_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_expensive_assertion_code(CODE) @@ -89,8 +86,7 @@ #if defined(CGAL_MULTISET_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ || (!defined(CGAL_MULTISET_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_multiset_expensive_exactness_assertion(EX) (static_cast(0)) # define CGAL_multiset_expensive_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_expensive_exactness_assertion_code(CODE) @@ -111,8 +107,7 @@ #undef CGAL_multiset_precondition_msg #undef CGAL_multiset_precondition_code -#if defined(CGAL_MULTISET_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_MULTISET_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) # define CGAL_multiset_precondition(EX) (static_cast(0)) # define CGAL_multiset_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_precondition_code(CODE) @@ -131,8 +126,7 @@ #undef CGAL_multiset_exactness_precondition_code #if defined(CGAL_MULTISET_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_MULTISET_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_MULTISET_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_multiset_exactness_precondition(EX) (static_cast(0)) # define CGAL_multiset_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_exactness_precondition_code(CODE) @@ -151,8 +145,7 @@ #undef CGAL_multiset_expensive_precondition_code #if defined(CGAL_MULTISET_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_multiset_expensive_precondition(EX) (static_cast(0)) # define CGAL_multiset_expensive_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_expensive_precondition_code(CODE) @@ -172,8 +165,7 @@ #if defined(CGAL_MULTISET_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ || (!defined(CGAL_MULTISET_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_multiset_expensive_exactness_precondition(EX) (static_cast(0)) # define CGAL_multiset_expensive_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_expensive_exactness_precondition_code(CODE) @@ -194,8 +186,7 @@ #undef CGAL_multiset_postcondition_msg #undef CGAL_multiset_postcondition_code -#if defined(CGAL_MULTISET_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_MULTISET_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) # define CGAL_multiset_postcondition(EX) (static_cast(0)) # define CGAL_multiset_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_postcondition_code(CODE) @@ -214,8 +205,7 @@ #undef CGAL_multiset_exactness_postcondition_code #if defined(CGAL_MULTISET_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_MULTISET_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_MULTISET_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_multiset_exactness_postcondition(EX) (static_cast(0)) # define CGAL_multiset_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_exactness_postcondition_code(CODE) @@ -234,8 +224,7 @@ #undef CGAL_multiset_expensive_postcondition_code #if defined(CGAL_MULTISET_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_multiset_expensive_postcondition(EX) (static_cast(0)) # define CGAL_multiset_expensive_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_expensive_postcondition_code(CODE) @@ -255,8 +244,7 @@ #if defined(CGAL_MULTISET_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ || (!defined(CGAL_MULTISET_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_multiset_expensive_exactness_postcondition(EX) (static_cast(0)) # define CGAL_multiset_expensive_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_expensive_exactness_postcondition_code(CODE) @@ -277,8 +265,7 @@ #undef CGAL_multiset_warning_msg #undef CGAL_multiset_warning_code -#if defined(CGAL_MULTISET_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || defined(NDEBUG) +#if defined(CGAL_MULTISET_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) # define CGAL_multiset_warning(EX) (static_cast(0)) # define CGAL_multiset_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_warning_code(CODE) @@ -297,8 +284,7 @@ #undef CGAL_multiset_exactness_warning_code #if defined(CGAL_MULTISET_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_MULTISET_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_MULTISET_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_multiset_exactness_warning(EX) (static_cast(0)) # define CGAL_multiset_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_exactness_warning_code(CODE) @@ -317,8 +303,7 @@ #undef CGAL_multiset_expensive_warning_code #if defined(CGAL_MULTISET_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_multiset_expensive_warning(EX) (static_cast(0)) # define CGAL_multiset_expensive_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_expensive_warning_code(CODE) @@ -338,8 +323,7 @@ #if defined(CGAL_MULTISET_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ || (!defined(CGAL_MULTISET_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_MULTISET_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_multiset_expensive_exactness_warning(EX) (static_cast(0)) # define CGAL_multiset_expensive_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_multiset_expensive_exactness_warning_code(CODE) 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/STL_Extension/include/CGAL/triangulation_assertions.h b/STL_Extension/include/CGAL/triangulation_assertions.h index c11b20b26db..07c7c80e72f 100644 --- a/STL_Extension/include/CGAL/triangulation_assertions.h +++ b/STL_Extension/include/CGAL/triangulation_assertions.h @@ -14,7 +14,7 @@ // Note that this header file is intentionnaly not protected with a // macro (as ). Calling it a second time with another value -// for NDEBUG for example must make a difference. +// for CGAL_NO_ASSERTIONS for example must make a difference. #include @@ -27,8 +27,7 @@ #undef CGAL_triangulation_assertion_msg #undef CGAL_triangulation_assertion_code -#if defined(CGAL_TRIANGULATION_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG) +#if defined(CGAL_TRIANGULATION_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) # define CGAL_triangulation_assertion(EX) (static_cast(0)) @@ -49,8 +48,7 @@ #undef CGAL_triangulation_exactness_assertion_code #if defined(CGAL_TRIANGULATION_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_TRIANGULATION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_TRIANGULATION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_triangulation_exactness_assertion(EX) (static_cast(0)) # define CGAL_triangulation_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_exactness_assertion_code(CODE) @@ -70,8 +68,7 @@ #if defined(CGAL_TRIANGULATION_NO_ASSERTIONS) \ || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_triangulation_expensive_assertion(EX) (static_cast(0)) # define CGAL_triangulation_expensive_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_expensive_assertion_code(CODE) @@ -91,8 +88,7 @@ #if defined(CGAL_TRIANGULATION_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ || (!defined(CGAL_TRIANGULATION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_triangulation_expensive_exactness_assertion(EX) (static_cast(0)) # define CGAL_triangulation_expensive_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_expensive_exactness_assertion_code(CODE) @@ -113,8 +109,7 @@ #undef CGAL_triangulation_precondition_msg #undef CGAL_triangulation_precondition_code -#if defined(CGAL_TRIANGULATION_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_TRIANGULATION_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) # define CGAL_triangulation_precondition(EX) (static_cast(0)) # define CGAL_triangulation_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_precondition_code(CODE) @@ -133,8 +128,7 @@ #undef CGAL_triangulation_exactness_precondition_code #if defined(CGAL_TRIANGULATION_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_TRIANGULATION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_TRIANGULATION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_triangulation_exactness_precondition(EX) (static_cast(0)) # define CGAL_triangulation_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_exactness_precondition_code(CODE) @@ -153,8 +147,7 @@ #undef CGAL_triangulation_expensive_precondition_code #if defined(CGAL_TRIANGULATION_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_triangulation_expensive_precondition(EX) (static_cast(0)) # define CGAL_triangulation_expensive_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_expensive_precondition_code(CODE) @@ -174,8 +167,7 @@ #if defined(CGAL_TRIANGULATION_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ || (!defined(CGAL_TRIANGULATION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_triangulation_expensive_exactness_precondition(EX) (static_cast(0)) # define CGAL_triangulation_expensive_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_expensive_exactness_precondition_code(CODE) @@ -196,8 +188,7 @@ #undef CGAL_triangulation_postcondition_msg #undef CGAL_triangulation_postcondition_code -#if defined(CGAL_TRIANGULATION_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_TRIANGULATION_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) # define CGAL_triangulation_postcondition(EX) (static_cast(0)) # define CGAL_triangulation_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_postcondition_code(CODE) @@ -216,8 +207,7 @@ #undef CGAL_triangulation_exactness_postcondition_code #if defined(CGAL_TRIANGULATION_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_TRIANGULATION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_TRIANGULATION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_triangulation_exactness_postcondition(EX) (static_cast(0)) # define CGAL_triangulation_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_exactness_postcondition_code(CODE) @@ -236,8 +226,7 @@ #undef CGAL_triangulation_expensive_postcondition_code #if defined(CGAL_TRIANGULATION_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_triangulation_expensive_postcondition(EX) (static_cast(0)) # define CGAL_triangulation_expensive_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_expensive_postcondition_code(CODE) @@ -257,8 +246,7 @@ #if defined(CGAL_TRIANGULATION_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ || (!defined(CGAL_TRIANGULATION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_triangulation_expensive_exactness_postcondition(EX) (static_cast(0)) # define CGAL_triangulation_expensive_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_expensive_exactness_postcondition_code(CODE) @@ -279,8 +267,7 @@ #undef CGAL_triangulation_warning_msg #undef CGAL_triangulation_warning_code -#if defined(CGAL_TRIANGULATION_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || defined(NDEBUG) +#if defined(CGAL_TRIANGULATION_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) # define CGAL_triangulation_warning(EX) (static_cast(0)) # define CGAL_triangulation_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_warning_code(CODE) @@ -299,8 +286,7 @@ #undef CGAL_triangulation_exactness_warning_code #if defined(CGAL_TRIANGULATION_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_TRIANGULATION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_TRIANGULATION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_triangulation_exactness_warning(EX) (static_cast(0)) # define CGAL_triangulation_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_exactness_warning_code(CODE) @@ -319,8 +305,7 @@ #undef CGAL_triangulation_expensive_warning_code #if defined(CGAL_TRIANGULATION_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_triangulation_expensive_warning(EX) (static_cast(0)) # define CGAL_triangulation_expensive_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_expensive_warning_code(CODE) @@ -340,8 +325,7 @@ #if defined(CGAL_TRIANGULATION_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ || (!defined(CGAL_TRIANGULATION_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TRIANGULATION_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_triangulation_expensive_exactness_warning(EX) (static_cast(0)) # define CGAL_triangulation_expensive_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_triangulation_expensive_exactness_warning_code(CODE) diff --git a/Scripts/developer_scripts/autotest_cgal b/Scripts/developer_scripts/autotest_cgal index 70830eb86c9..709a5675e01 100755 --- a/Scripts/developer_scripts/autotest_cgal +++ b/Scripts/developer_scripts/autotest_cgal @@ -60,7 +60,7 @@ WGET="wget" WGET_OPTS="--no-check-certificate --no-verbose" CURL="curl" CURL_OPTS="-k --remote-name --silent --location-trusted" -CGAL_URL="https://cgal.geometryfactory.com/CGAL/Members/Releases" +CGAL_URL="https://cgal.geometryfactory.com/CGAL/Releases" LATEST_LOCATION="${CGAL_URL}/LATEST" TAR="tar" GZIP="gzip" diff --git a/Scripts/developer_scripts/autotest_cgal_with_ctest b/Scripts/developer_scripts/autotest_cgal_with_ctest index 5049e1d0db9..0b250aa618e 100755 --- a/Scripts/developer_scripts/autotest_cgal_with_ctest +++ b/Scripts/developer_scripts/autotest_cgal_with_ctest @@ -16,7 +16,7 @@ export WGET="wget" export WGET_OPTS="--no-check-certificate --no-verbose" export CURL="curl" export CURL_OPTS="-k --remote-name --silent --location-trusted" -export CGAL_URL="https://cgal.geometryfactory.com/CGAL/Members/Releases" +export CGAL_URL="https://cgal.geometryfactory.com/CGAL/Releases" export UPLOAD_RESULT_DESTINATION="cgaltest@cgaltest.geometryfactory.com:incoming" export LATEST_LOCATION="${CGAL_URL}/LATEST" export TAR="tar" @@ -216,7 +216,7 @@ unzip_cgal() # Parse command line arguments for arg in "$@" do - case "$arg" in + case "$arg" in "-c") echo "Using latest unzipped release instead of getting a new one from the server" USE_LATEST_UNZIPPED="y" @@ -263,7 +263,7 @@ LOCK_FILE="${CGAL_HOME}/autotest_cgal_with_cmake.lock" ACTUAL_LOGFILE="${CGAL_HOME}/`basename ${0}`.log" rm -f "${ACTUAL_LOGFILE}" -echo "Running `basename ${0}` "'$Revision$' >> "${ACTUAL_LOGFILE}" +echo "Running `basename ${0}` "'$Revision$' >> "${ACTUAL_LOGFILE}" cd "$CGAL_HOME" diff --git a/Scripts/developer_scripts/run_doxygen_testsuite b/Scripts/developer_scripts/run_doxygen_testsuite index f5cd10a1f12..62e1a5d2eeb 100755 --- a/Scripts/developer_scripts/run_doxygen_testsuite +++ b/Scripts/developer_scripts/run_doxygen_testsuite @@ -22,8 +22,8 @@ function error() { exit 1 } -CGAL_URL="https://cgal.geometryfactory.com/CGAL/Members/Releases" -CURL_OPTS="--remote-name --silent -n" +CGAL_URL="https://cgal.geometryfactory.com/CGAL/Releases" +CURL_OPTS="--remote-name --silent --location --netrc" LATEST_LOCATION="${CGAL_URL}/LATEST" CGAL_DOC_BUILD="/home/cgal-testsuite/cgal_doc_build" diff --git a/Scripts/scripts/cgal_create_assertions.sh b/Scripts/scripts/cgal_create_assertions.sh index f6b391924a2..91268e9b4e9 100755 --- a/Scripts/scripts/cgal_create_assertions.sh +++ b/Scripts/scripts/cgal_create_assertions.sh @@ -48,7 +48,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ // Note that this header file is intentionnaly not protected with a // macro (as ). Calling it a second time with another value -// for NDEBUG for example must make a difference. +// for CGAL_NO_ASSERTIONS for example must make a difference. #include @@ -61,8 +61,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #undef CGAL_xxx_assertion_msg #undef CGAL_xxx_assertion_code -#if defined(CGAL_XXX_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG) +#if defined(CGAL_XXX_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) # define CGAL_xxx_assertion(EX) (static_cast(0)) # define CGAL_xxx_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_assertion_code(CODE) @@ -81,8 +80,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #undef CGAL_xxx_exactness_assertion_code #if defined(CGAL_XXX_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_XXX_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_XXX_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_xxx_exactness_assertion(EX) (static_cast(0)) # define CGAL_xxx_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_exactness_assertion_code(CODE) @@ -102,8 +100,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #if defined(CGAL_XXX_NO_ASSERTIONS) \ || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_xxx_expensive_assertion(EX) (static_cast(0)) # define CGAL_xxx_expensive_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_expensive_assertion_code(CODE) @@ -123,8 +120,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #if defined(CGAL_XXX_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ || (!defined(CGAL_XXX_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_xxx_expensive_exactness_assertion(EX) (static_cast(0)) # define CGAL_xxx_expensive_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_expensive_exactness_assertion_code(CODE) @@ -145,8 +141,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #undef CGAL_xxx_precondition_msg #undef CGAL_xxx_precondition_code -#if defined(CGAL_XXX_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_XXX_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) # define CGAL_xxx_precondition(EX) (static_cast(0)) # define CGAL_xxx_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_precondition_code(CODE) @@ -165,8 +160,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #undef CGAL_xxx_exactness_precondition_code #if defined(CGAL_XXX_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_XXX_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_XXX_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_xxx_exactness_precondition(EX) (static_cast(0)) # define CGAL_xxx_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_exactness_precondition_code(CODE) @@ -185,8 +179,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #undef CGAL_xxx_expensive_precondition_code #if defined(CGAL_XXX_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_xxx_expensive_precondition(EX) (static_cast(0)) # define CGAL_xxx_expensive_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_expensive_precondition_code(CODE) @@ -206,8 +199,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #if defined(CGAL_XXX_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ || (!defined(CGAL_XXX_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_xxx_expensive_exactness_precondition(EX) (static_cast(0)) # define CGAL_xxx_expensive_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_expensive_exactness_precondition_code(CODE) @@ -228,8 +220,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #undef CGAL_xxx_postcondition_msg #undef CGAL_xxx_postcondition_code -#if defined(CGAL_XXX_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_XXX_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) # define CGAL_xxx_postcondition(EX) (static_cast(0)) # define CGAL_xxx_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_postcondition_code(CODE) @@ -248,8 +239,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #undef CGAL_xxx_exactness_postcondition_code #if defined(CGAL_XXX_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_XXX_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_XXX_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_xxx_exactness_postcondition(EX) (static_cast(0)) # define CGAL_xxx_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_exactness_postcondition_code(CODE) @@ -268,8 +258,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #undef CGAL_xxx_expensive_postcondition_code #if defined(CGAL_XXX_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_xxx_expensive_postcondition(EX) (static_cast(0)) # define CGAL_xxx_expensive_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_expensive_postcondition_code(CODE) @@ -289,8 +278,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #if defined(CGAL_XXX_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ || (!defined(CGAL_XXX_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_xxx_expensive_exactness_postcondition(EX) (static_cast(0)) # define CGAL_xxx_expensive_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_expensive_exactness_postcondition_code(CODE) @@ -311,8 +299,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #undef CGAL_xxx_warning_msg #undef CGAL_xxx_warning_code -#if defined(CGAL_XXX_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || defined(NDEBUG) +#if defined(CGAL_XXX_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) # define CGAL_xxx_warning(EX) (static_cast(0)) # define CGAL_xxx_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_warning_code(CODE) @@ -331,8 +318,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #undef CGAL_xxx_exactness_warning_code #if defined(CGAL_XXX_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_XXX_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_XXX_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_xxx_exactness_warning(EX) (static_cast(0)) # define CGAL_xxx_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_exactness_warning_code(CODE) @@ -351,8 +337,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #undef CGAL_xxx_expensive_warning_code #if defined(CGAL_XXX_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_xxx_expensive_warning(EX) (static_cast(0)) # define CGAL_xxx_expensive_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_expensive_warning_code(CODE) @@ -372,8 +357,7 @@ sed -e "s/XXX_/${nameUC}/g" -e "s/xxx_/${nameLC}/g" <<"EOF" \ #if defined(CGAL_XXX_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ || (!defined(CGAL_XXX_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_XXX_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_xxx_expensive_exactness_warning(EX) (static_cast(0)) # define CGAL_xxx_expensive_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_xxx_expensive_exactness_warning_code(CODE) diff --git a/SearchStructures/include/CGAL/Tree_assertions.h b/SearchStructures/include/CGAL/Tree_assertions.h index 1e6db8c676e..091d35fa81b 100644 --- a/SearchStructures/include/CGAL/Tree_assertions.h +++ b/SearchStructures/include/CGAL/Tree_assertions.h @@ -15,7 +15,7 @@ // Note that this header file is intentionnaly not protected with a // macro (as ). Calling it a second time with another value -// for NDEBUG for example must make a difference. +// for CGAL_NO_ASSERTIONS for example must make a difference. #include @@ -28,8 +28,7 @@ #undef CGAL_Tree_assertion_msg #undef CGAL_Tree_assertion_code -#if defined(CGAL_TREE_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG) +#if defined(CGAL_TREE_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) # define CGAL_Tree_assertion(EX) (static_cast(0)) #include @@ -51,8 +50,7 @@ #undef CGAL_Tree_exactness_assertion_code #if defined(CGAL_TREE_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_TREE_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_TREE_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_Tree_exactness_assertion(EX) (static_cast(0)) # define CGAL_Tree_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_exactness_assertion_code(CODE) @@ -72,8 +70,7 @@ #if defined(CGAL_TREE_NO_ASSERTIONS) \ || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_Tree_expensive_assertion(EX) (static_cast(0)) # define CGAL_Tree_expensive_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_expensive_assertion_code(CODE) @@ -93,8 +90,7 @@ #if defined(CGAL_TREE_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ || (!defined(CGAL_TREE_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_Tree_expensive_exactness_assertion(EX) (static_cast(0)) # define CGAL_Tree_expensive_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_expensive_exactness_assertion_code(CODE) @@ -115,8 +111,7 @@ #undef CGAL_Tree_precondition_msg #undef CGAL_Tree_precondition_code -#if defined(CGAL_TREE_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_TREE_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) # define CGAL_Tree_precondition(EX) (static_cast(0)) # define CGAL_Tree_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_precondition_code(CODE) @@ -135,8 +130,7 @@ #undef CGAL_Tree_exactness_precondition_code #if defined(CGAL_TREE_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_TREE_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_TREE_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_Tree_exactness_precondition(EX) (static_cast(0)) # define CGAL_Tree_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_exactness_precondition_code(CODE) @@ -155,8 +149,7 @@ #undef CGAL_Tree_expensive_precondition_code #if defined(CGAL_TREE_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_Tree_expensive_precondition(EX) (static_cast(0)) # define CGAL_Tree_expensive_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_expensive_precondition_code(CODE) @@ -176,8 +169,7 @@ #if defined(CGAL_TREE_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ || (!defined(CGAL_TREE_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_Tree_expensive_exactness_precondition(EX) (static_cast(0)) # define CGAL_Tree_expensive_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_expensive_exactness_precondition_code(CODE) @@ -198,8 +190,7 @@ #undef CGAL_Tree_postcondition_msg #undef CGAL_Tree_postcondition_code -#if defined(CGAL_TREE_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_TREE_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) # define CGAL_Tree_postcondition(EX) (static_cast(0)) # define CGAL_Tree_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_postcondition_code(CODE) @@ -218,8 +209,7 @@ #undef CGAL_Tree_exactness_postcondition_code #if defined(CGAL_TREE_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_TREE_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_TREE_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_Tree_exactness_postcondition(EX) (static_cast(0)) # define CGAL_Tree_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_exactness_postcondition_code(CODE) @@ -238,8 +228,7 @@ #undef CGAL_Tree_expensive_postcondition_code #if defined(CGAL_TREE_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_Tree_expensive_postcondition(EX) (static_cast(0)) # define CGAL_Tree_expensive_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_expensive_postcondition_code(CODE) @@ -259,8 +248,7 @@ #if defined(CGAL_TREE_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ || (!defined(CGAL_TREE_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_Tree_expensive_exactness_postcondition(EX) (static_cast(0)) # define CGAL_Tree_expensive_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_expensive_exactness_postcondition_code(CODE) @@ -281,8 +269,7 @@ #undef CGAL_Tree_warning_msg #undef CGAL_Tree_warning_code -#if defined(CGAL_TREE_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || defined(NDEBUG) +#if defined(CGAL_TREE_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) # define CGAL_Tree_warning(EX) (static_cast(0)) # define CGAL_Tree_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_warning_code(CODE) @@ -301,8 +288,7 @@ #undef CGAL_Tree_exactness_warning_code #if defined(CGAL_TREE_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_TREE_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_TREE_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_Tree_exactness_warning(EX) (static_cast(0)) # define CGAL_Tree_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_exactness_warning_code(CODE) @@ -321,8 +307,7 @@ #undef CGAL_Tree_expensive_warning_code #if defined(CGAL_TREE_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_Tree_expensive_warning(EX) (static_cast(0)) # define CGAL_Tree_expensive_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_expensive_warning_code(CODE) @@ -342,8 +327,7 @@ #if defined(CGAL_TREE_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ || (!defined(CGAL_TREE_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_TREE_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_Tree_expensive_exactness_warning(EX) (static_cast(0)) # define CGAL_Tree_expensive_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_Tree_expensive_exactness_warning_code(CODE) diff --git a/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h b/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h index 820eee71576..e2e7bb38107 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h +++ b/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h @@ -1030,7 +1030,7 @@ namespace CGAL { } inline FT stop_probability(std::size_t largest_candidate, std::size_t num_pts, std::size_t num_candidates, std::size_t octree_depth) const { - return (std::min)(std::pow(FT(1) - FT(largest_candidate) + return (std::min)((FT)std::pow(FT(1) - FT(largest_candidate) / (FT(num_pts) * FT(octree_depth+1) * FT(1 << (m_required_samples - 1))), int(num_candidates)), FT(1)); 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/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/assertions.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/assertions.h index 8b5be6a81c5..3916c7627c5 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/assertions.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/assertions.h @@ -13,11 +13,11 @@ #include +#include #if defined(CGAL_STRAIGHT_SKELETON_NO_POSTCONDITIONS) \ || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_STRAIGHT_SKELETON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_STRAIGHT_SKELETON_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_stskel_expensive_postcondition(EX) (static_cast(0)) # define CGAL_stskel_expensive_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_stskel_expensive_postcondition_code(CODE) diff --git a/Stream_lines_2/include/CGAL/streamlines_assertions.h b/Stream_lines_2/include/CGAL/streamlines_assertions.h index 57a22d3a955..ce5fe41b14b 100644 --- a/Stream_lines_2/include/CGAL/streamlines_assertions.h +++ b/Stream_lines_2/include/CGAL/streamlines_assertions.h @@ -15,7 +15,7 @@ // Note that this header file is intentionnaly not protected with a // macro (as ). Calling it a second time with another value -// for NDEBUG for example must make a difference. +// for CGAL_NO_ASSERTIONS for example must make a difference. #include @@ -28,8 +28,7 @@ #undef CGAL_streamlines_assertion_msg #undef CGAL_streamlines_assertion_code -#if defined(CGAL_STREAMLINES_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || defined(NDEBUG) +#if defined(CGAL_STREAMLINES_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) # define CGAL_streamlines_assertion(EX) (static_cast(0)) #include @@ -51,8 +50,7 @@ #undef CGAL_streamlines_exactness_assertion_code #if defined(CGAL_STREAMLINES_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_STREAMLINES_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_STREAMLINES_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_streamlines_exactness_assertion(EX) (static_cast(0)) # define CGAL_streamlines_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_exactness_assertion_code(CODE) @@ -72,8 +70,7 @@ #if defined(CGAL_STREAMLINES_NO_ASSERTIONS) \ || defined(CGAL_NO_ASSERTIONS) \ - || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_streamlines_expensive_assertion(EX) (static_cast(0)) # define CGAL_streamlines_expensive_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_expensive_assertion_code(CODE) @@ -93,8 +90,7 @@ #if defined(CGAL_STREAMLINES_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \ || (!defined(CGAL_STREAMLINES_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_streamlines_expensive_exactness_assertion(EX) (static_cast(0)) # define CGAL_streamlines_expensive_exactness_assertion_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_expensive_exactness_assertion_code(CODE) @@ -115,8 +111,7 @@ #undef CGAL_streamlines_precondition_msg #undef CGAL_streamlines_precondition_code -#if defined(CGAL_STREAMLINES_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_STREAMLINES_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) # define CGAL_streamlines_precondition(EX) (static_cast(0)) # define CGAL_streamlines_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_precondition_code(CODE) @@ -135,8 +130,7 @@ #undef CGAL_streamlines_exactness_precondition_code #if defined(CGAL_STREAMLINES_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_STREAMLINES_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_STREAMLINES_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_streamlines_exactness_precondition(EX) (static_cast(0)) # define CGAL_streamlines_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_exactness_precondition_code(CODE) @@ -155,8 +149,7 @@ #undef CGAL_streamlines_expensive_precondition_code #if defined(CGAL_STREAMLINES_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ - || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_streamlines_expensive_precondition(EX) (static_cast(0)) # define CGAL_streamlines_expensive_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_expensive_precondition_code(CODE) @@ -176,8 +169,7 @@ #if defined(CGAL_STREAMLINES_NO_PRECONDITIONS) || defined(CGAL_NO_PRECONDITIONS) \ || (!defined(CGAL_STREAMLINES_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_streamlines_expensive_exactness_precondition(EX) (static_cast(0)) # define CGAL_streamlines_expensive_exactness_precondition_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_expensive_exactness_precondition_code(CODE) @@ -198,8 +190,7 @@ #undef CGAL_streamlines_postcondition_msg #undef CGAL_streamlines_postcondition_code -#if defined(CGAL_STREAMLINES_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || defined(NDEBUG) +#if defined(CGAL_STREAMLINES_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) # define CGAL_streamlines_postcondition(EX) (static_cast(0)) # define CGAL_streamlines_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_postcondition_code(CODE) @@ -218,8 +209,7 @@ #undef CGAL_streamlines_exactness_postcondition_code #if defined(CGAL_STREAMLINES_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_STREAMLINES_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_STREAMLINES_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_streamlines_exactness_postcondition(EX) (static_cast(0)) # define CGAL_streamlines_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_exactness_postcondition_code(CODE) @@ -238,8 +228,7 @@ #undef CGAL_streamlines_expensive_postcondition_code #if defined(CGAL_STREAMLINES_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ - || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_streamlines_expensive_postcondition(EX) (static_cast(0)) # define CGAL_streamlines_expensive_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_expensive_postcondition_code(CODE) @@ -259,8 +248,7 @@ #if defined(CGAL_STREAMLINES_NO_POSTCONDITIONS) || defined(CGAL_NO_POSTCONDITIONS) \ || (!defined(CGAL_STREAMLINES_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_streamlines_expensive_exactness_postcondition(EX) (static_cast(0)) # define CGAL_streamlines_expensive_exactness_postcondition_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_expensive_exactness_postcondition_code(CODE) @@ -281,8 +269,7 @@ #undef CGAL_streamlines_warning_msg #undef CGAL_streamlines_warning_code -#if defined(CGAL_STREAMLINES_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || defined(NDEBUG) +#if defined(CGAL_STREAMLINES_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) # define CGAL_streamlines_warning(EX) (static_cast(0)) # define CGAL_streamlines_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_warning_code(CODE) @@ -301,8 +288,7 @@ #undef CGAL_streamlines_exactness_warning_code #if defined(CGAL_STREAMLINES_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_STREAMLINES_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || defined(NDEBUG) + || (!defined(CGAL_STREAMLINES_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS)) # define CGAL_streamlines_exactness_warning(EX) (static_cast(0)) # define CGAL_streamlines_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_exactness_warning_code(CODE) @@ -321,8 +307,7 @@ #undef CGAL_streamlines_expensive_warning_code #if defined(CGAL_STREAMLINES_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ - || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_streamlines_expensive_warning(EX) (static_cast(0)) # define CGAL_streamlines_expensive_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_expensive_warning_code(CODE) @@ -342,8 +327,7 @@ #if defined(CGAL_STREAMLINES_NO_WARNINGS) || defined(CGAL_NO_WARNINGS) \ || (!defined(CGAL_STREAMLINES_CHECK_EXACTNESS) && !defined(CGAL_CHECK_EXACTNESS))\ - || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) \ - || defined(NDEBUG) + || (!defined(CGAL_STREAMLINES_CHECK_EXPENSIVE) && !defined(CGAL_CHECK_EXPENSIVE)) # define CGAL_streamlines_expensive_exactness_warning(EX) (static_cast(0)) # define CGAL_streamlines_expensive_exactness_warning_msg(EX,MSG) (static_cast(0)) # define CGAL_streamlines_expensive_exactness_warning_code(CODE) diff --git a/Stream_support/include/CGAL/IO/OFF/File_header_OFF_impl.h b/Stream_support/include/CGAL/IO/OFF/File_header_OFF_impl.h index 520e6abe76d..4e5d776b261 100644 --- a/Stream_support/include/CGAL/IO/OFF/File_header_OFF_impl.h +++ b/Stream_support/include/CGAL/IO/OFF/File_header_OFF_impl.h @@ -210,7 +210,6 @@ CGAL_INLINE_FUNCTION std::ostream& operator<<( std::ostream& out, const File_header_OFF& h) { if ( h.comments()) { out << "# Output of a CGAL tool\n"; - out << static_cast( h); } if ( h.has_textures()) out << "ST"; @@ -250,12 +249,8 @@ std::istream& operator>>( std::istream& in, File_header_OFF& h) { h.set_off_header( false); char c; while ( (in >> c) && c == '#') { - if ( in.get(c) && c == 'C' && - in.get(c) && c == 'B' && - in.get(c) && c == 'P') { - in >> static_cast( h); - } else if ( c != '\n') - in >> skip_until_EOL; + if ( c != '\n') + in >> skip_until_EOL; } if ( ! in ) return in; diff --git a/Stream_support/include/CGAL/IO/OFF/File_header_extended_OFF_impl.h b/Stream_support/include/CGAL/IO/OFF/File_header_extended_OFF_impl.h index 2405be2d337..5b47cdab293 100644 --- a/Stream_support/include/CGAL/IO/OFF/File_header_extended_OFF_impl.h +++ b/Stream_support/include/CGAL/IO/OFF/File_header_extended_OFF_impl.h @@ -133,72 +133,5 @@ operator+=( const File_header_extended_OFF& header) { return *this; } -#define CGAL_OUT(item) out << "# " #item " " << h.item() << '\n' -#define CGAL_OUTBOOL(item) out << "# " #item " " <<(h.item() ? '1':'0') << '\n' - -// Write extended header incl. CGAL/ENDCBP keywords. -CGAL_INLINE_FUNCTION -std::ostream& operator<<( std::ostream& out, - const File_header_extended_OFF& h) { - out << "#CBP\n"; - CGAL_OUTBOOL( polyhedral_surface); - CGAL_OUT( halfedges); - CGAL_OUTBOOL( triangulated); - CGAL_OUTBOOL( non_empty_facets); - CGAL_OUTBOOL( terrain); - CGAL_OUTBOOL( normalized_to_sphere); - CGAL_OUT( radius); - CGAL_OUTBOOL( rounded); - CGAL_OUT( rounded_bits); - out << "# ENDCBP\n" << std::endl; - return out; -} -#undef CGAL_OUT -#undef OUTBOOL - -#define CGAL_IN(item,type) \ - else if ( std::strcmp( keyword, #item) == 0) { \ - type t; \ - in >> t; \ - h.set_##item( t); \ - } - -#define CGAL_INBOOL(item) \ - else if ( std::strcmp( keyword, #item) == 0) { \ - in >> c; \ - h.set_##item( c == '1'); \ - } - -// Scan extended header. The CBP keyword must be read already. -CGAL_INLINE_FUNCTION -std::istream& operator>>( std::istream& in, File_header_extended_OFF& h) { - const int max_keyword = 42; - char c; - char keyword[max_keyword] = ""; - in >> keyword; - while ( in && std::strcmp( keyword, "ENDCBP") != 0) { - if ( std::strcmp( keyword, "#") == 0) - ; - CGAL_INBOOL( polyhedral_surface) - CGAL_IN( halfedges, int) - CGAL_INBOOL( triangulated) - CGAL_INBOOL( non_empty_facets) - CGAL_INBOOL( terrain) - CGAL_INBOOL( normalized_to_sphere) - CGAL_IN( radius, double) - CGAL_INBOOL( rounded) - CGAL_IN( rounded_bits, int) - else if ( h.verbose()) { - std::cerr << "warning: File_header_extended_OFF: unknown key '" - << keyword << "'." << std::endl; - } - in >> keyword; - } - in >> skip_until_EOL >> skip_comment_OFF; - return in; -} -#undef CGAL_IN -#undef CGAL_INBOOL - } //namespace CGAL // EOF // 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/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index 29d4372c58d..b3927cf03ae 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -55,7 +55,7 @@ # include #endif -#include +#include namespace CGAL { @@ -122,23 +122,27 @@ public: // Cells // N.B.: Concurrent_compact_container requires TBB #ifdef CGAL_LINKED_WITH_TBB - typedef typename boost::mpl::if_c + typedef typename std::conditional < - boost::is_convertible::value, + std::is_convertible::value, Concurrent_compact_container >, Compact_container >::type Cell_range; # else + CGAL_static_assertion_msg + (!(std::is_convertible::value), + "In CGAL triangulations, `Parallel_tag` can only be used with the Intel TBB library. " + "Make TBB available in the build system and then define the macro `CGAL_LINKED_WITH_TBB`."); typedef Compact_container Cell_range; #endif // Vertices // N.B.: Concurrent_compact_container requires TBB #ifdef CGAL_LINKED_WITH_TBB - typedef typename boost::mpl::if_c + typedef typename std::conditional < - boost::is_convertible::value, + std::is_convertible::value, Concurrent_compact_container >, Compact_container >::type Vertex_range; 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...`