diff --git a/AABB_tree/demo/AABB_tree/Scene.cpp b/AABB_tree/demo/AABB_tree/Scene.cpp index 6303fb2140b..a0bc61b75d0 100644 --- a/AABB_tree/demo/AABB_tree/Scene.cpp +++ b/AABB_tree/demo/AABB_tree/Scene.cpp @@ -806,7 +806,6 @@ void Scene::build_facet_tree() timer.start(); std::cout << "Construct Facet AABB tree..."; m_facet_tree.rebuild(faces(*m_pPolyhedron).first, faces(*m_pPolyhedron).second,*m_pPolyhedron); - m_facet_tree.accelerate_distance_queries(); std::cout << "done (" << timer.time() << " s)" << std::endl; } @@ -826,7 +825,6 @@ void Scene::build_edge_tree() timer.start(); std::cout << "Construct Edge AABB tree..."; m_edge_tree.rebuild(edges(*m_pPolyhedron).first,edges(*m_pPolyhedron).second,*m_pPolyhedron); - m_edge_tree.accelerate_distance_queries(); std::cout << "done (" << timer.time() << " s)" << std::endl; } diff --git a/AABB_tree/demo/AABB_tree/benchmarks.cpp b/AABB_tree/demo/AABB_tree/benchmarks.cpp index 1375ecaca7c..364d19bc04e 100644 --- a/AABB_tree/demo/AABB_tree/benchmarks.cpp +++ b/AABB_tree/demo/AABB_tree/benchmarks.cpp @@ -77,7 +77,6 @@ void Scene::benchmark_distances(const double duration) timer.start(); std::cout << "Construct AABB tree and internal KD tree..."; Facet_tree tree(faces(*m_pPolyhedron).first, faces(*m_pPolyhedron).second,*m_pPolyhedron); - tree.accelerate_distance_queries(); std::cout << "done (" << timer.time() << " s)" << std::endl; // benchmark @@ -123,7 +122,7 @@ void Scene::bench_memory() typedef CGAL::Memory_sizer::size_type size_type; size_type before = CGAL::Memory_sizer().virtual_size(); Facet_tree tree(faces(*m_pPolyhedron).first, faces(*m_pPolyhedron).second,*m_pPolyhedron); - // tree.accelerate_distance_queries(); // 150 vs 61 bytes per primitive! + tree.do_not_accelerate_distance_queries(); // 150 vs 61 bytes per primitive! size_type after = CGAL::Memory_sizer().virtual_size(); size_type bytes = after - before; // in Bytes @@ -165,7 +164,6 @@ void Scene::bench_construction() CGAL::Timer time2; time2.start(); Facet_tree tree2(faces(*m_pPolyhedron).first, faces(*m_pPolyhedron).second,*m_pPolyhedron); - tree2.accelerate_distance_queries(); double duration_construction_and_kdtree = time2.time(); std::cout << m_pPolyhedron->size_of_facets() << "\t" @@ -248,7 +246,6 @@ void Scene::bench_distances_vs_nbt() // constructs tree (out of timing) Facet_tree tree(faces(*m_pPolyhedron).first, faces(*m_pPolyhedron).second, *m_pPolyhedron); - tree.accelerate_distance_queries(); // calls queries CGAL::Timer timer; diff --git a/AABB_tree/examples/AABB_tree/AABB_face_graph_triangle_example.cpp b/AABB_tree/examples/AABB_tree/AABB_face_graph_triangle_example.cpp index 54bb75ade1e..244909cb1b1 100644 --- a/AABB_tree/examples/AABB_tree/AABB_face_graph_triangle_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_face_graph_triangle_example.cpp @@ -25,7 +25,6 @@ void run(const FaceGraph& graph){ // constructs the AABB tree and the internal search tree for // efficient distance queries. Tree tree( faces(graph).first, faces(graph).second, graph); - tree.accelerate_distance_queries(); // counts #intersections with a triangle query Segment segment_query(p,q); diff --git a/AABB_tree/examples/AABB_tree/AABB_halfedge_graph_edge_example.cpp b/AABB_tree/examples/AABB_tree/AABB_halfedge_graph_edge_example.cpp index a98753b7a1c..7767ba735c0 100644 --- a/AABB_tree/examples/AABB_tree/AABB_halfedge_graph_edge_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_halfedge_graph_edge_example.cpp @@ -27,7 +27,6 @@ void run(const HalfedgeGraph& graph){ // efficient distance queries. Tree tree( CGAL::edges(graph).first, CGAL::edges(graph).second, graph); - tree.accelerate_distance_queries(); // counts #intersections with a triangle query Triangle triangle_query(p,q,r); diff --git a/AABB_tree/examples/AABB_tree/AABB_insertion_example.cpp b/AABB_tree/examples/AABB_tree/AABB_insertion_example.cpp index ede70be1005..90719fda49f 100644 --- a/AABB_tree/examples/AABB_tree/AABB_insertion_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_insertion_example.cpp @@ -37,8 +37,6 @@ int main() // data structure to accelerate distance queries Tree tree(faces(polyhedron1).first, faces(polyhedron1).second, polyhedron1); - tree.accelerate_distance_queries(); - tree.insert(faces(polyhedron2).first, faces(polyhedron2).second, polyhedron2); // query point diff --git a/AABB_tree/examples/AABB_tree/AABB_polyhedron_edge_example.cpp b/AABB_tree/examples/AABB_tree/AABB_polyhedron_edge_example.cpp index da354a36e72..cac955a5b8f 100644 --- a/AABB_tree/examples/AABB_tree/AABB_polyhedron_edge_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_polyhedron_edge_example.cpp @@ -31,7 +31,6 @@ int main() Tree tree( CGAL::edges(polyhedron).first, CGAL::edges(polyhedron).second, polyhedron); - tree.accelerate_distance_queries(); // counts #intersections with a triangle query Triangle triangle_query(p,q,r); diff --git a/AABB_tree/examples/AABB_tree/AABB_polyhedron_facet_distance_example.cpp b/AABB_tree/examples/AABB_tree/AABB_polyhedron_facet_distance_example.cpp index eb3e3ed806d..bb9ad89e463 100644 --- a/AABB_tree/examples/AABB_tree/AABB_polyhedron_facet_distance_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_polyhedron_facet_distance_example.cpp @@ -31,7 +31,6 @@ int main() // constructs AABB tree and computes internal KD-tree // data structure to accelerate distance queries Tree tree(faces(polyhedron).first, faces(polyhedron).second, polyhedron); - tree.accelerate_distance_queries(); // query point Point query(0.0, 0.0, 3.0); diff --git a/AABB_tree/examples/AABB_tree/AABB_segment_3_example.cpp b/AABB_tree/examples/AABB_tree/AABB_segment_3_example.cpp index 46a0c51118e..95e8c1c7664 100644 --- a/AABB_tree/examples/AABB_tree/AABB_segment_3_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_segment_3_example.cpp @@ -36,7 +36,6 @@ int main() // constructs the AABB tree and the internal search tree for // efficient distance computations. Tree tree(segments.begin(),segments.end()); - tree.accelerate_distance_queries(); // counts #intersections with a plane query Plane plane_query(a,b,d); diff --git a/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h b/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h index 44c2b87cfa2..a8b1cca343a 100644 --- a/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h +++ b/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h @@ -38,7 +38,7 @@ namespace CGAL { *\tparam FaceGraph is a model of the face graph concept. *\tparam VertexPointPMap is a property map with `boost::graph_traits::%vertex_descriptor` * as key type and a \cgal Kernel `Point_3` as value type. - * The default is `typename boost::property_map< FaceGraph,vertex_point_t>::%type`. + * The default is `typename boost::property_map< FaceGraph,vertex_point_t>::%const_type`. *\tparam OneFaceGraphPerTree is either `CGAL::Tag_true` or `CGAL::Tag_false`. * In the former case, we guarantee that all the primitives will be from a * common `FaceGraph` and some data will be factorized so that the size of diff --git a/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h b/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h index b3a161ba521..92596a813f6 100644 --- a/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h +++ b/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h @@ -49,7 +49,7 @@ namespace CGAL { * \tparam HalfedgeGraph is a model of the halfedge graph concept. * as key type and a \cgal Kernel `Point_3` as value type. * \tparam VertexPointPMap is a property map with `boost::graph_traits::%vertex_descriptor`. - * The default is `typename boost::property_map< HalfedgeGraph,vertex_point_t>::%type`. + * The default is `typename boost::property_map< HalfedgeGraph,vertex_point_t>::%const_type`. * \tparam OneHalfedgeGraphPerTree is either `CGAL::Tag_true` or `CGAL::Tag_false`. * In the former case, we guarantee that all the primitives will be from a * common `HalfedgeGraph` and some data will be factorized so that the size of @@ -77,17 +77,17 @@ class AABB_halfedge_graph_segment_primitive HalfedgeGraph, typename Default::Get::type >::type >, + vertex_point_t>::const_type >::type >, Source_point_from_edge_descriptor_map< HalfedgeGraph, typename Default::Get::type >::type >, + vertex_point_t>::const_type >::type >, OneHalfedgeGraphPerTree, CacheDatum > #endif { - typedef typename Default::Get::type >::type VertexPointPMap_; + typedef typename Default::Get::const_type >::type VertexPointPMap_; typedef typename boost::graph_traits::edge_descriptor ED; typedef typename boost::mpl::if_ >::type Id_; @@ -118,7 +118,7 @@ public: /*! The point type. */ - typedef boost::property_traits< boost::property_map< HalfedgeGraph, vertex_point_t>::type >::value_type Point; + typedef boost::property_traits< boost::property_map< HalfedgeGraph, vertex_point_t>::const_type >::value_type Point; /*! Geometric data type. */ diff --git a/AABB_tree/include/CGAL/AABB_tree.h b/AABB_tree/include/CGAL/AABB_tree.h index af9b7e2648a..99dfd89f7f9 100644 --- a/AABB_tree/include/CGAL/AABB_tree.h +++ b/AABB_tree/include/CGAL/AABB_tree.h @@ -176,7 +176,7 @@ namespace CGAL { clear_nodes(); m_primitives.clear(); clear_search_tree(); - m_default_search_tree_constructed = false; + m_default_search_tree_constructed = true; } /// Returns the axis-aligned bounding box of the whole tree. @@ -430,6 +430,8 @@ public: /// a point set taken on the internal primitives /// returns `true` iff successful memory allocation bool accelerate_distance_queries() const; + ///Turns off the lazy construction of the internal search tree. + void do_not_accelerate_distance_queries() const; /// Constructs an internal KD-tree containing the specified point /// set, to be used as the set of potential hints for accelerating @@ -601,7 +603,7 @@ public: , m_p_root_node(nullptr) , m_p_search_tree(nullptr) , m_search_tree_constructed(false) - , m_default_search_tree_constructed(false) + , m_default_search_tree_constructed(true) , m_need_build(false) {} @@ -615,7 +617,7 @@ public: , m_p_root_node(nullptr) , m_p_search_tree(nullptr) , m_search_tree_constructed(false) - , m_default_search_tree_constructed(false) + , m_default_search_tree_constructed(true) , m_need_build(false) { // Insert each primitive into tree @@ -673,7 +675,6 @@ public: void AABB_tree::build() { clear_nodes(); - if(m_primitives.size() > 1) { // allocates tree nodes @@ -695,8 +696,9 @@ public: // In case the users has switched on the accelerated distance query // data structure with the default arguments, then it has to be // /built/rebuilt. - if(m_default_search_tree_constructed) + if(m_default_search_tree_constructed && !empty()){ build_kd_tree(); + } m_need_build = false; } // constructs the search KD tree from given points @@ -741,6 +743,14 @@ public: } } + template + void AABB_tree::do_not_accelerate_distance_queries()const + { + clear_search_tree(); + m_default_search_tree_constructed = false; + } + + // constructs the search KD tree from internal primitives template bool AABB_tree::accelerate_distance_queries() const diff --git a/AABB_tree/package_info/AABB_tree/dependencies b/AABB_tree/package_info/AABB_tree/dependencies index c72f4088b6a..2162029e468 100644 --- a/AABB_tree/package_info/AABB_tree/dependencies +++ b/AABB_tree/package_info/AABB_tree/dependencies @@ -4,6 +4,7 @@ BGL Cartesian_kernel Circulator Distance_2 +Distance_3 Installation Intersections_2 Intersections_3 @@ -16,4 +17,3 @@ Property_map STL_Extension Spatial_searching Stream_support -Distance_3 diff --git a/AABB_tree/test/AABB_tree/aabb_test_empty_tree.cpp b/AABB_tree/test/AABB_tree/aabb_test_empty_tree.cpp index 63b72a7d4e9..3ba40764130 100644 --- a/AABB_tree/test/AABB_tree/aabb_test_empty_tree.cpp +++ b/AABB_tree/test/AABB_tree/aabb_test_empty_tree.cpp @@ -34,7 +34,6 @@ int main() // Test calls to all functions but those who have `!empty()` as // precondition. CGAL::Emptyset_iterator devnull; - tree.accelerate_distance_queries(); tree.all_intersections(triangle_query, devnull); tree.all_intersected_primitives(triangle_query, devnull); assert(!tree.any_intersected_primitive(triangle_query)); diff --git a/AABB_tree/test/AABB_tree/aabb_test_singleton_tree.cpp b/AABB_tree/test/AABB_tree/aabb_test_singleton_tree.cpp index 09c88d37f01..aaf49dbf12b 100644 --- a/AABB_tree/test/AABB_tree/aabb_test_singleton_tree.cpp +++ b/AABB_tree/test/AABB_tree/aabb_test_singleton_tree.cpp @@ -36,7 +36,6 @@ int main() // Test calls to all functions CGAL::Emptyset_iterator devnull; - tree.accelerate_distance_queries(); tree.all_intersections(triangle_query, devnull); tree.all_intersected_primitives(triangle_query, devnull); assert(tree.any_intersected_primitive(triangle_query)); diff --git a/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h b/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h index 0bd401520fd..d39f54faeb2 100644 --- a/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h +++ b/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h @@ -1996,6 +1996,7 @@ namespace CGAL { { // initilisation de la variable globale K: qualite d'echantillonnage requise K = K_init; // valeur d'initialisation de K pour commencer prudemment... + coord_type K_prev = K; Vertex_handle v1, v2; if (_ordered_border.empty()){ @@ -2060,12 +2061,12 @@ namespace CGAL { } while((!_ordered_border.empty())&& (_ordered_border.begin()->first < STANDBY_CANDIDATE_BIS)); - + K_prev = K; K += (std::max)(K_step, min_K - K + eps); // on augmente progressivement le K mais on a deja rempli sans // faire des betises auparavant... } - while((!_ordered_border.empty())&&(K <= K)&&(min_K != infinity())); + while((!_ordered_border.empty())&&(K <= K)&&(min_K != infinity())&&(K!=K_prev)); #ifdef VERBOSE if ((min_K < infinity())&&(!_ordered_border.empty())) { diff --git a/Alpha_shapes_3/doc/Alpha_shapes_3/CGAL/Alpha_shape_3.h b/Alpha_shapes_3/doc/Alpha_shapes_3/CGAL/Alpha_shape_3.h index 7d2bf1f3dd2..b51b927b6dc 100644 --- a/Alpha_shapes_3/doc/Alpha_shapes_3/CGAL/Alpha_shape_3.h +++ b/Alpha_shapes_3/doc/Alpha_shapes_3/CGAL/Alpha_shape_3.h @@ -119,8 +119,8 @@ typedef unspecified_type FT; /*! The point type. -For basic alpha shapes, `Point` will be equal to `Gt::Point_2`. For weighted alpha -shapes, `Point` will be equal to `Gt::Weighted_point_2`. +For basic alpha shapes, `Point` will be equal to `Gt::Point_3`. For weighted alpha +shapes, `Point` will be equal to `Gt::Weighted_point_3`. */ typedef Dt::Point Point; diff --git a/Apollonius_graph_2/include/CGAL/Parabola_segment_2.h b/Apollonius_graph_2/include/CGAL/Parabola_segment_2.h index 6a872d0a35c..52cbc6c72de 100644 --- a/Apollonius_graph_2/include/CGAL/Parabola_segment_2.h +++ b/Apollonius_graph_2/include/CGAL/Parabola_segment_2.h @@ -66,9 +66,9 @@ public: return int(CGAL::sqrt(CGAL::to_double(tt) / 2)); } - void generate_points(std::vector& p) const + void generate_points(std::vector& p, + const FT STEP = FT(2)) const { - const FT STEP(2); FT s0, s1; s0 = t(p1); diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_segment_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_segment_traits_2.h index 9689695b4f8..a9f3506ea29 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_segment_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_segment_traits_2.h @@ -459,7 +459,8 @@ public: if (! cv.is_vertical()) { // Compare p with the segment's supporting line. - return (kernel.compare_y_at_x_2_object()(p, cv.line())); + CGAL_assertion( kernel.compare_x_2_object()(cv.left(), cv.right()) == SMALLER ); + return kernel.orientation_2_object()(cv.left(), cv.right(), p); } else { // Compare with the vertical segment's end-points. diff --git a/BGL/include/CGAL/boost/graph/generators.h b/BGL/include/CGAL/boost/graph/generators.h index b390de5b74b..389f9ba3308 100644 --- a/BGL/include/CGAL/boost/graph/generators.h +++ b/BGL/include/CGAL/boost/graph/generators.h @@ -733,11 +733,12 @@ make_icosahedron(Graph& g, * If `triangulated` is `true`, the diagonal of each cell is oriented from (0,0) to (1,1) * in the cell coordinates. * - *\tparam CoordinateFunctor a function object providing `Point_3 operator()(size_type I, size_type J)` with `Point_3` being - * the value_type of the internal property_map for `CGAL::vertex_point_t`. - * and outputs a `boost::property_traits::%type>::%value_type`. - * It will be called with arguments (`w`, `h`), with `w` in [0..`i`] and `h` in [0..`j`]. - *

%Default: a point with positive integer coordinates (`w`, `h`, 0), with `w` in [0..`i`] and `h` in [0..`j`] + *\tparam CoordinateFunctor a function object providing: + * `%Point_3 operator()(size_type I, size_type J)`, with `%Point_3` being the value_type + * of the internal property_map for `CGAL::vertex_point_t` and outputs an object of type + * `boost::property_traits::%type>::%value_type`. + * It will be called with arguments (`w`, `h`), with `w` in [0..`i`] and `h` in [0..`j`].
+ * %Default: a point with positive integer coordinates (`w`, `h`, 0), with `w` in [0..`i`] and `h` in [0..`j`] * * \returns the non-border non-diagonal halfedge that has the target vertex associated with the first point of the grid (default is (0,0,0) ). */ diff --git a/CGAL_ImageIO/include/CGAL/ImageIO/iris_impl.h b/CGAL_ImageIO/include/CGAL/ImageIO/iris_impl.h index 5fae4452857..acea1c6c3d8 100644 --- a/CGAL_ImageIO/include/CGAL/ImageIO/iris_impl.h +++ b/CGAL_ImageIO/include/CGAL/ImageIO/iris_impl.h @@ -201,7 +201,7 @@ static void addimgtag(byte *dptr, int xsize, int ysize) /*****************************************************/ static unsigned short getshort( const _image *im) { - byte buf[2]; + byte buf[2] = { '\0', '\0' }; ImageIO_read( im, buf, (size_t) 2); return (unsigned short)((buf[0]<<8)+(buf[1]<<0)); } @@ -209,7 +209,7 @@ static unsigned short getshort( const _image *im) /*****************************************************/ static unsigned long getlong( const _image *im ) { - byte buf[4]; + byte buf[4] = { '\0', '\0', '\0', '\0' }; ImageIO_read( im, buf, (size_t) 4); return (((unsigned long) buf[0])<<24) + (((unsigned long) buf[1])<<16) + (((unsigned long) buf[2])<<8) + buf[3]; diff --git a/Classification/include/CGAL/Classification/Feature/Color_channel.h b/Classification/include/CGAL/Classification/Feature/Color_channel.h index 87c4dfa2394..2024c8706e3 100644 --- a/Classification/include/CGAL/Classification/Feature/Color_channel.h +++ b/Classification/include/CGAL/Classification/Feature/Color_channel.h @@ -99,7 +99,7 @@ public: /// \cond SKIP_IN_MANUAL virtual float value (std::size_t pt_index) { - cpp11::array c = get(color_map, *(input.begin()+pt_index)).to_hsv(); + std::array c = get(color_map, *(input.begin()+pt_index)).to_hsv(); return float(c[std::size_t(m_channel)]); } /// \endcond diff --git a/Classification/include/CGAL/Classification/Point_set_neighborhood.h b/Classification/include/CGAL/Classification/Point_set_neighborhood.h index 9b703aedbf4..7ecfecb2492 100644 --- a/Classification/include/CGAL/Classification/Point_set_neighborhood.h +++ b/Classification/include/CGAL/Classification/Point_set_neighborhood.h @@ -81,7 +81,7 @@ class Point_set_neighborhood typedef Search_traits_adapter Search_traits; typedef Sliding_midpoint Splitter; typedef Distance_adapter > Distance; - typedef Kd_tree Tree; + typedef Kd_tree Tree; typedef Fuzzy_sphere Sphere; typedef Orthogonal_k_neighbor_search Knn; diff --git a/Convex_hull_2/package_info/Convex_hull_2/dependencies b/Convex_hull_2/package_info/Convex_hull_2/dependencies index d5197515f41..9d516ba6e29 100644 --- a/Convex_hull_2/package_info/Convex_hull_2/dependencies +++ b/Convex_hull_2/package_info/Convex_hull_2/dependencies @@ -6,7 +6,6 @@ Kernel_23 Modular_arithmetic Number_types Profiling_tools +Property_map STL_Extension Stream_support -Property_map - diff --git a/Convex_hull_d/package_info/Convex_hull_d/dependencies b/Convex_hull_d/package_info/Convex_hull_d/dependencies index 81659211144..1535e6386bf 100644 --- a/Convex_hull_d/package_info/Convex_hull_d/dependencies +++ b/Convex_hull_d/package_info/Convex_hull_d/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Circulator Convex_hull_d Distance_2 +Distance_3 Hash_map Installation Intersections_2 @@ -14,4 +15,3 @@ Number_types Profiling_tools STL_Extension Stream_support -Distance_3 diff --git a/Distance_3/include/CGAL/squared_distance_3_2.h b/Distance_3/include/CGAL/squared_distance_3_2.h index 13dcb55278a..bac711cbbc9 100644 --- a/Distance_3/include/CGAL/squared_distance_3_2.h +++ b/Distance_3/include/CGAL/squared_distance_3_2.h @@ -390,6 +390,20 @@ squared_distance(const Triangle_3 & t, } +template +inline +typename K::FT +squared_distance(const Plane_3 & p1, + const Plane_3 & p2) { + K k; + typename K::Construct_orthogonal_vector_3 ortho_vec = + k.construct_orthogonal_vector_3_object(); + if (!internal::is_null(internal::wcross(ortho_vec(p1), ortho_vec(p2), k), k)) + return typename K::FT(0); + else + return internal::squared_distance(p1.point(), p2, k); +} + } //namespace CGAL diff --git a/Distance_3/test/Distance_3/test_distance_3.cpp b/Distance_3/test/Distance_3/test_distance_3.cpp index 5f73a7eb3cf..1413169832b 100644 --- a/Distance_3/test/Distance_3/test_distance_3.cpp +++ b/Distance_3/test/Distance_3/test_distance_3.cpp @@ -221,6 +221,17 @@ struct Test { check_squared_distance (L(p(2, -4, 3), p( 3,-8, 4)), Pl(0, 1, 0, 0), 0); } + void Pl_Pl() + { + std::cout << "Plane - Plane\n"; + Pl p1(0, 1, 0, 0); + typename K::Vector_3 v = -p1.orthogonal_vector(); + v /= CGAL::sqrt(v.squared_length()); + Pl p2 = Pl(0,-1,0,6); + check_squared_distance (p1,p2, 36); + check_squared_distance (Pl(-2, 1, 1, 0), Pl(2, 1, 3, 0), 0); + } + void run() { std::cout << "3D Distance tests\n"; @@ -239,6 +250,7 @@ struct Test { S_Pl(); R_Pl(); L_Pl(); + Pl_Pl(); } }; diff --git a/Documentation/doc/CMakeLists.txt b/Documentation/doc/CMakeLists.txt index 83b0918e75f..81c78f42f15 100644 --- a/Documentation/doc/CMakeLists.txt +++ b/Documentation/doc/CMakeLists.txt @@ -253,10 +253,15 @@ if (NOT CGAL_CREATED_VERSION_NUM) set(CGAL_CREATED_VERSION_NUM "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}") endif() else() - #read version.h and get the line with CGAL_VERSION - file(STRINGS "${CGAL_ROOT}/include/CGAL/version.h" CGAL_VERSION_LINE REGEX "CGAL_VERSION ") - #extract release id - string(REGEX MATCH "[0-9]+\\.[0-9]+\\.?[0-9]*" CGAL_CREATED_VERSION_NUM "${CGAL_VERSION_LINE}") + if(EXISTS "${CGAL_ROOT}/doc/public_release_name") + file(STRINGS "${CGAL_ROOT}/doc/public_release_name" CGAL_VERSION_LINE) + string(REGEX REPLACE "CGAL-" "" CGAL_CREATED_VERSION_NUM "${CGAL_VERSION_LINE}") + else() + #read version.h and get the line with CGAL_VERSION + file(STRINGS "${CGAL_ROOT}/include/CGAL/version.h" CGAL_VERSION_LINE REGEX "CGAL_VERSION ") + #extract release id + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.?[0-9]*" CGAL_CREATED_VERSION_NUM "${CGAL_VERSION_LINE}") + endif() endif() endif() diff --git a/Documentation/doc/Documentation/Developer_manual/Chapter_code_format.txt b/Documentation/doc/Documentation/Developer_manual/Chapter_code_format.txt index bc975974b27..c3d688e62b0 100644 --- a/Documentation/doc/Documentation/Developer_manual/Chapter_code_format.txt +++ b/Documentation/doc/Documentation/Developer_manual/Chapter_code_format.txt @@ -315,11 +315,8 @@ identification of the file. The file header contains:

  • a copyright notice, specifying all the years during which the file has been written or modified, as well as the owner(s) (typically the institutions -employing the authors) of this work, -
  • the corresponding license (at the moment, only LGPLv3+ and GPLv3+ -are allowed in \cgal), and a pointer to the file containing its text in the +employing the authors) of this work, a pointer to the file containing its text in the \cgal distribution, -
  • a disclaimer notice,
  • then, there are 2 keywords, which are automatically expanded at the creation of a new release:
    • \$URL\$ : canonical path to the file on github, @@ -331,6 +328,9 @@ and `SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial` for L optional affiliation or e-mail address.
    +Note that since \cgal 5.0 the license text is not present in headers anymore, +only SPDX tags are present. + For example and demo programs, the inclusion of the copyright notice is not necessary as this will get in the way if the program is included in the documentation. However, these files should always contain the name of @@ -371,9 +371,6 @@ Here follows what this gives for a file under the LGPL : // Max-Planck-Institute Saarbruecken (Germany), // and Tel-Aviv University (Israel). All rights reserved. // -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// // This file is part of CGAL (www.cgal.org) // // $URL$ diff --git a/Documentation/doc/Documentation/Developer_manual/Chapter_portability.txt b/Documentation/doc/Documentation/Developer_manual/Chapter_portability.txt index 84a7d8078b4..16ef913c408 100644 --- a/Documentation/doc/Documentation/Developer_manual/Chapter_portability.txt +++ b/Documentation/doc/Documentation/Developer_manual/Chapter_portability.txt @@ -236,8 +236,8 @@ operating system and compiler that is defined as follows. quite compiler specific). -Examples are mips_IRIX64-6.5_CC-n32-7.30 or sparc_SunOS-5.6_g++-2.95. For more information, see the \cgal -\link installation installation guide \endlink. +Examples are mips_IRIX64-6.5_CC-n32-7.30 or sparc_SunOS-5.6_g++-2.95. +For more information, see the \cgal \link usage usage guide \endlink. This platform-specific configuration file is created during diff --git a/Documentation/doc/Documentation/Developer_manual/cmakelist_script.txt b/Documentation/doc/Documentation/Developer_manual/cmakelist_script.txt new file mode 100644 index 00000000000..47ca6a404c9 --- /dev/null +++ b/Documentation/doc/Documentation/Developer_manual/cmakelist_script.txt @@ -0,0 +1,40 @@ +/*! + +\page devman_create_cgal_CMakeLists Creating a CMake Script for a Program Using %CGAL + +To compile a program that is not shipped with \cgal, it is recommended to also rely on a CMake-supported +configuration using a `CMakeLists.txt`. The Bourne-shell script `cgal_create_CMakeLists.txt` +can be used to create such `CMakeLists.txt` files. +This script resides in the `scripts` directory of \cgal (e.g. `CGAL-\cgalReleaseNumber``/scripts` +directory if you have downloaded a tarball). +Executing `cgal_create_CMakeLists.txt` in an application directory creates a +`CMakeLists.txt` containing rules to build the contained +application(s). Three command line options determine details of the +configuration. + +
    +
    `-s source`
    If this parameter is given the script will +create a single executable for 'source' linked with +compilations of all other source files +(`*.cc`, `*.cp`, `*.cxx`, `*.cpp`, `*.CPP`, `*.c++`, or `*.C`). +This behaviour is usually needed for (graphical) demos. + +If the parameter is not given, the script creates one executable for each given +source file. +
    `-c com1:com2:...`
    Lists components ("com1", +"com2") of \cgal to which the executable(s) should be linked. Valid components are \cgal's +libraries (i.e.\ "Core", "ImageIO", and "Qt5"). An example is `-c Core`. + +
    `-b boost1:boost2:...`
    Lists components ("boost1", +"boost2") of \sc{Boost} to which the executable(s) should be +linked. Valid options are, for instance, "filesystem" or "program_options". + +
    + +This options should suffice to create `CMakeLists.txt` script +for most directories containing programs. However, in some special +cases, it might still be required to create the script manually, for +instance, if some source files/executables need a different linking than +other source files. + +*/ diff --git a/Documentation/doc/Documentation/Developer_manual/developer_manual.txt b/Documentation/doc/Documentation/Developer_manual/developer_manual.txt index 7d96af6c9e6..b229577bbbc 100644 --- a/Documentation/doc/Documentation/Developer_manual/developer_manual.txt +++ b/Documentation/doc/Documentation/Developer_manual/developer_manual.txt @@ -2,6 +2,8 @@ \page dev_manual Developer Manual +The developer manual is primarly aimed at \cgal developers, but may also be interesting to any \cgal user. + - \subpage devman_intro - \subpage devman_code_format - \subpage devman_kernels @@ -19,6 +21,6 @@ - \subpage devman_testing - \subpage devman_submission - \subpage devman_info +- \subpage devman_create_cgal_CMakeLists - \subpage deprecated - */ diff --git a/Documentation/doc/Documentation/Getting_started.txt b/Documentation/doc/Documentation/Getting_started.txt index d8dcfa659f2..01452b57124 100644 --- a/Documentation/doc/Documentation/Getting_started.txt +++ b/Documentation/doc/Documentation/Getting_started.txt @@ -1,13 +1,30 @@ /*! -\page general_intro Getting Started +\page general_intro Getting Started with %CGAL -- \subpage installation describes how to install %CGAL, and lists the third party libraries on which %CGAL depends, or for which %CGAL provides interfaces. +The following pages describe how to use \cgal on different environments -- \subpage manual gives an idea where you should look for documentation. - The documentation for a class, may be spread over manual pages of - base classes, and reference manual pages of concepts the class is a model of. - +- \subpage usage -- \subpage preliminaries lists the licenses under which the %CGAL datastructures and algorithms are distributed, how to control inlining, thread safety, code deprecation, checking of pre- and postconditions, and how to alter the failure behavior. +- \subpage windows + +- \subpage thirdparty gives information (supported versions, download links) of the required and optional third party libraries. + +The following pages cover advanced installation options + +- \subpage configurationvariables gives information about which CMake variables can be used to help +resolve missing dependencies while using the cmake command line tool. + +- \subpage installation describes the deprecated process of configuring and building \cgal. + +The following pages cover the structure of the manual and general information about \cgal + +- \subpage manual gives an idea of where you should look for documentation. + +- \subpage preliminaries lists how to control inlining, thread safety, code deprecation, checking +of pre- and postconditions, and how to alter the failure behavior. + +Once you are familiar with building your programs with \cgal and how the documentation is structured, +you can head over to the \ref tutorials for a gentle introduction to \cgal, or directly to the package(s) +that interest you the \ref packages. Each package contains simple examples of the various functionalities of the package. */ diff --git a/Documentation/doc/Documentation/Installation.txt b/Documentation/doc/Documentation/Installation.txt deleted file mode 100644 index 541befc0636..00000000000 --- a/Documentation/doc/Documentation/Installation.txt +++ /dev/null @@ -1,1198 +0,0 @@ -/*! -\page installation Installation -\cgalAutoToc -\authors Eric Berberich, Joachim Reichel, and Fernando Cacciola - -\section installation_introduction Introduction - -Since \cgal versionĀ 5.0, \cgal is header-only be default, which means -that there is no need to compile and install anything before it can be -used. The dependencies of \cgal still have to be installed. - -Ideally, compiling an example or a demo shipped with \cgal is -as simple as: - - cd examples/Triangulation_2 # go to an example directory - cmake -DCGAL_DIR=$HOME/CGAL-\cgalReleaseNumber . # configure the examples - make # build the examples - - cd demo/Triangulation_2 # go to a demo directory - cmake -DCGAL_DIR=$HOME/CGAL-\cgalReleaseNumber . # configure the demos - make # build the demos - -Compiling an own non-shipped program is also close: - - cd /path/to/program - cgal_create_CMakeLists -s executable - cmake -DCGAL_DIR=$HOME/CGAL-\cgalReleaseNumber . - make - -where the second line creates a `CMakeLists.txt` file (check -its options in Section \ref seccreate_cgal_CMakeLists for various details). - - -In a less ideal world, you probably have to install required tools, and third party libraries. That is what this manual is about. - -\section secprerequisites Prerequisites - -Using \cgal requires a few components to be installed ahead: a -supported compiler (see Section \ref seccompilers), \sc{Boost}, \sc{Gmp}, and \sc{Mpfr}; see -Section \ref secessential3rdpartysoftware for more details on -essential third party software. - -\section secshippedcgal OS Specific Installation - -Some operating systems with package managers offer \cgal and its -essential third party software through the manager, -for instance, Mac OS X, or some Linux distribution (e.g. Debian). -For Windows, an installer is provided. - -\subsection sseccgalmacosxe CGAL on macOS - -The \cgal project recommends the use of Homebrew, in the following way: - - brew install cgal - -\subsection sseccgaldebian CGAL on Linux - -For instance in Debian/Ubuntu, use apt-get in the following way: - - sudo apt-get install libcgal-dev - -To get the demos use - - sudo apt-get install libcgal-demo - -Check the \cgal-FAQ for source repository of newest releases. - -On other distributions, please consult your package manager documentation. - -\subsection sseccgalwindows CGAL on Windows - -You can download and run `CGAL-\cgalReleaseNumber``-Setup.exe` from https://www.cgal.org/download/windows.html. -It is a self extracting executable that installs the \cgal source, and that allows you -to select and download some precompiled third party libraries. However, you will need to compile -the library using your favorite compiler. - -A tutorial is provided on how to proceed with Microsoft Visual Studio. - - - -\section secgettingcgal Downloading CGAL - -You can obtain the \cgal library from -https://www.cgal.org/download.html -and install it yourself. - -After you have downloaded the file `CGAL-\cgalReleaseNumber``.tar.gz` containing the -\cgal sources, you have to unpack it. Under a Unix-like shell, use the -command: - -
    -tar xzf CGAL-\cgalReleaseNumber.tar.gz
    -
    - -In both cases the directory `CGAL-\cgalReleaseNumber` will be created. This directory -contains the following subdirectories: - - -| Directory | Contents | -| :----------- | :----------| -| `auxiliary` | precompiled \sc{Gmp} and \sc{Mpfr} for Windows | -| `cmake/modules` | modules for finding and using libraries | -| `config` | configuration files for install script | -| `demo` | demo programs (most of them need \sc{Qt}, geomview or other third-party products) | -| `doc_html` | documentation (HTML) | -| `examples` | example programs | -| `include` | header files | -| `scripts` | some useful scripts (e.g. for creating CMakeLists.txt files) | -| `src` | source files | - - -The directories `include/CGAL/CORE` and `src/CGALCore` contain a -distribution of the \sc{Core} library\cgalFootnote{`https://cs.nyu.edu/exact/`} version 1.7 for -dealing with algebraic numbers. \sc{Core} is not part of \cgal and has its -own license. - -The directory `include/CGAL/OpenNL` contains a distribution of the -Open Numerical Library which provides solvers for sparse linear systems, -especially designed for the Computer Graphics community. \sc{OpenNL} is not part -of \cgal and has its own license. - -The only documentation shipped with \cgal sources is the present -installation manual. The \cgal manual must be downloaded separately from -`https://www.cgal.org/download.html`. - -\section seccompilers Supported Compilers - -In order to build a program using \cgal, you need a \cpp compiler -supporting C++14 or later. -\cgal \cgalReleaseNumber is supported, that is continuously tested, for the following compilers/operating systems: - - -| Compiler | Operating System | -| :------- | :--------------- | -|\sc{Gnu} `g++` 6.3 or later\cgalFootnote{`http://gcc.gnu.org/`} | Linux / MacOS X | -| | \sc{MS} Windows | -|\sc{MS} Visual `C++` 14.0, 15.9, 16.0 (\sc{Visual Studio} 2015, 2017, and 2019)\cgalFootnote{`https://visualstudio.microsoft.com/`} | \sc{MS} Windows | -| `Clang` \cgalFootnote{`http://clang.llvm.org/`} compiler version 8.0.0 | Linux | -| Apple `Clang` compiler versions 7.0.2 and 10.0.1 | MacOS X | - -It may work for older versions of the above listed compilers. - -\attention Recent versions of CMake are needed for recent versions of MS Visual C++. Please refer to CMake's documentation for further information. - - -\section secconfigwithcmake Configuring CGAL with CMake - -In order to configure, build, and install the \cgal libraries, examples and -demos, you need CMake, a cross-platform "makefile generator". -If CMake is not installed already you can obtain it from `https://cmake.org/`. -CMake version 3.1 or higher is required. -This manual explains only those features of -CMake which are needed in order to build \cgal. Please refer to the -CMake documentation at `https://cmake.org/` for further details. - -Before building anything using \cgal you have to choose the compiler/linker, -set compiler and linker flags, specify which -third-party libraries you want to use and where they can be found, and -which \cgal libraries you want to build. Gathering -all this information is called configuration. -The end of the process is marked by the generation of a makefile or a -Visual \cpp solution and project file that you can use to build \cgal. - -\subsection installation_configuring_gui Configuring CGAL with the CMake GUI - -The simplest way to start the configuration is to run the graphical -user interface of CMake. We recommend to use `cmake-gui`. You must pass as -argument the root directory of \cgal. For example: - -
    -cd CGAL-\cgalReleaseNumber
    -cmake-gui . # Notice the dot to indicate the current directory.
    -
    - -After `cmake-gui` opens, press 'Configure'. -A dialog will pop up and you will have to choose what shall gets generated. -After you have made your choice and pressed 'Finish', you will see -the output of configuration tests in the lower portion of the application. -When these tests are done, you will see many -red entries in the upper portion of the application. Just ignore them and press 'Configure'. -By now CMake should have found many libraries and have initialized variables. -If you still find red entries, you have to provide the necessary information. -This typically happens if you have installed software at non-standard locations. -Providing information and pressing 'Configure' goes on until -all entries are grayed. You are now ready to press 'Generate'. Once this is -done, you can quit `cmake-gui`. - -\subsection installation_configuring_cmd Configuring CGAL with the cmake Command-Line Tool - -Alternatively, you can run the command-line tool called -`cmake`. You pass as argument the root directory of -\cgal. For example: - -
    -cd CGAL-\cgalReleaseNumber
    -cmake . # Notice the dot to indicate the current directory.
    -
    - -The very first thing CMake does is to detect the compiler to use. This -detection is performed by a special CMake module called a -generator. -A CMake generator understands the build requirements for a -particular compiler/linker and generates the necessary files for that. For -example, the UNIX Makefiles generator understands the GNU chain -of tools (\gcc, ld etc.) and produces makefiles, which can be used to build a -target by a simple call to `make`. Likewise, the Visual Studio -2010 generator produces solution and project files and can be manually -launched in the VS IDE to build the target. - -Each platform has a default generator, so you only need to select one when -the default is not what you want. For example, under Windows, it is -possible to generate NMakefiles instead of Visual Studio project -files in order to build the library with `nmake`. Running -`cmake` with no parameters in a command-line prints the list of -available generators supported by your platform and CMake version. If the -generator you need is not listed there, you can try a newer -CMake version, as generators are hardcoded into CMake, and additional -generators are added with each release. - -Since the choice of the generator determines the type of build files to generate, in some cases -you choose a particular generator as a mean to choose a specific compiler (because they use different -build files). For example, the following generates solution files for -use in Visual \cpp 15.0 on a 64bit machine: - -
    -cd CGAL-\cgalReleaseNumber
    -cmake -G"Visual Studio 15 2017 Win64" . 
    -
    - -In other cases, however, the generator doesn't directly identify a -specific compiler but a chain of tools. -For example, the `UNIX Makefiles` generator produces `makefiles` that call some auto-detected -command-line compiler, like \gcc. If you need the makefiles to use a different compiler, you need to -specify the desired compiler in the call to CMake, as in this example: - -
    -cd CGAL-\cgalReleaseNumber
    -cmake -DCMAKE_CXX_COMPILER:FILEPATH=g++-4.7 . 
    -
    - -CMake maintains configuration parameters in so-called cmake variables, like the `CMAKE_CXX_COMPILER` -in the example above. These variables are not environment variables but CMake variables. Some of the CMake -variables represent user choices, such as `WITH_examples` or `CMAKE_BUILD_TYPE=Release`, while others -indicate the details of a third-party library, such as `Boost_INCLUDE_DIR` or the compiler flags to use, -such as `CMAKE_CXX_FLAGS`. - -The command line tool `cmake` accepts CMake variables as arguments of the form `-D:=`, as -in the example above, but this is only useful if you already know which variables need to be explicitly defined. - -\cgalAdvancedBegin -CMake keeps the variables that a user can manipulate in a -so-called CMake cache, a simple text file named -`CMakeCache.txt`, whose entries are of the form -`VARIABLE:TYPE=VALUE`. Advanced users can manually edit this file, -instead of going through the interactive configuration session. -\cgalAdvancedEnd - -The configuration process not only determines the location of the required dependencies, it also dynamically generates a -`compiler_config.h` file, which encodes the properties of your system and a special file named -`CGALConfig.cmake`, which is used to build programs using \cgal. The -purpose of this file is explained below. - -\section seclibraries CGAL Libraries - -\cgal is split into four libraries. During configuration, you can select the libraries that -you would like to build by setting a CMake variable of the form WITH_. By default all -are switched `ON`. All activated libraries are build after -configuration; see \ref secbuilding - -We next list the libraries and essential 3rd party software -(see \ref secessential3rdpartysoftware) for each library: - -| Library | CMake Variable | Functionality | Dependencies | -| :-------- | :------------- | :------------ | :----------- | -| `%CGAL` | none | Main library | \sc{Gmp}, \sc{Mpfr}, \sc{Boost} (headers) | -| `CGAL_Core` | `WITH_CGAL_Core` | The CORE library for algebraic numbers.\cgalFootnote{CGAL_Core is not part of \cgal, but a custom version of the \sc{Core} library distributed by \cgal for the user convenience and it has it's own license.} | \sc{Gmp} and \sc{Mpfr} | -| `CGAL_ImageIO` | `WITH_CGAL_ImageIO` | Utilities to read and write image files | \sc{zlib}, \sc{Vtk}(optional) | -| `CGAL_Qt5` | `WITH_CGAL_Qt5` | `QGraphicsView` support for \sc{Qt}5-based demos | \sc{Qt}5 | - -\subsection installation_debug Debug vs. Release - -The CMake variable `CMAKE_BUILD_TYPE` indicates how to build -the libraries. It accepts the values `Release` or -`Debug`. The default is `Release` and should be kept, unless you want to debug -your program. - -This is not an issue for solution/project files, as there the user selects the build type from within the IDE. - -\subsection installation_static Static vs. Shared Libraries - -Shared libraries, also called dynamic-link libraries, are built by default -(`.dll` on Windows, `.so` on Linux, `.dylib` on MacOS). You -can choose to produce static libraries instead by setting the CMake -variable `BUILD_SHARED_LIBS` to `FALSE`. If you use -`cmake-gui`, a tick box for that variable is available to set it. - -\subsection subsection_headeronly Header-only Option - -\subsubsection subsection_headeronly_withconfiguration Header-only with CMake Configuration - -Since \cgal 4.9, \cgal can be used in header-only mode, i.e. without compiling the \cgal libraries and linking with these libraries when compiling examples, tests and demos. This possibility can be enabled by setting the value of the CMake variable `CGAL_HEADER_ONLY` to `ON`. - -One advantage of using \cgal in header-only mode is that you do not need to compile and install \cgal libraries before compiling a given example or demo. Note that even in header-only mode we still need to run CMake on \cgal in order to generate different configuration files. So, setting up \cgal becomes now: - -
    -cd CGAL-\cgalReleaseNumber # go to \cgal directory
    -cmake -DCGAL_HEADER_ONLY=ON . # configure \cgal
    -
    - -and we do not need to run `make` anymore. - -\subsubsection subsection_headeronly_without_configuration Header-only without CMake Configuration - -Since \cgal 4.12, \cgal can be used in header-only mode, without even -configuring \cgal\. Programs using \cgal (examples, tests, demos, etc.) -must be directly configured using CMake. In this case, \cgal will be -configured at the same time. The variable `CGAL_DIR` must point to the root -directory of the \cgal source code (either the root of the unpacked release -tarball, or the root of the Git working directory). - -So, using \cgal becomes now: - -
    -cd /path/to/your/code # go to the directory of the code source using \cgal
    -cmake -DCGAL_DIR= .
    -
    - -\subsubsection subsection_headeronly_dependencies CGAL Dependencies - -\cgal can be used as a header-only library, though not all its dependencies -are header-only. The libraries \sc{Gmp} and \sc{Mpfr}, for example, are not -header-only. - -\subsubsection subsection_headeronly_pbonwindows Possible Problem on Windows - -There is one possible problem when using \cgal in header-only mode on a Windows operating system when compiling a program using several modules (executable programs or dynamic-link libraries DLL). If two different modules use the same static variable, this variable is defined independently in each of these modules. If one module modifies the value of this variable, it will not be modified in the other module, which could induce an unexpected behavior. In \cgal, this concerns only a few specific variables: the default random, the failure behavior, `CGAL::IO::Mode`. One example is the following: if you change the default random in one DLL, then if you use the default random in another DLL, you will not obtain the modified default random but the original one. - -\section secessential3rdpartysoftware Essential Third Party Libraries - -The focus of \cgal is on geometry, and we rely on other -highly specialized libraries and software for non-geometric issues, -for instance, for numeric solvers, or visualization. We first list software -that is essential to build (all) libraries of \cgal, that is, -this software must be found during the configuration of \cgal for an -actived library of \cgal (i.e.\ WITH_=ON); -see \ref sec3partysoftwareconfig to specify the location of 3rd -party software. - -The libraries \stl (shipped with any compiler) and \sc{Boost} are essential to all components (i.e.\ libCGAL, -libCGAL_Core, libCGAL_ImageIO, and libCGAL_Qt5). - -\subsection thirdpartystl Standard Template Library (STL) - -\cgal heavily uses the \stl, and in particular adopted -many of its design ideas. You can find online -documentation for the \stl at various web sites, for instance, -`http://www.cplusplus.com/reference/`, -or `https://msdn.microsoft.com/en-us/library/1fe2x6kt(v=vs.140).aspx`. - -The \stl comes with the compiler, so there is nothing to install. - -\subsection thirdpartyBoost Boost - -The \sc{Boost} libraries are a set of portable C++ source libraries. Most of -\sc{Boost} libraries are header-only, but a few of them need to be compiled or -installed as binaries. - -\cgal only requires the headers of the \sc{Boost} libraries, but some demos and examples depend on the binary library `Boost.Program_options`. - -As an exception, because of a bug in the \gcc compiler about the \cpp 11 -keyword `thread_local`, the `CGAL_Core` library always requires -the binary library `Boost.Thread` if the \gcc compiler version 9.0 or -earlier is used. - -In case the \sc{Boost} libraries are not installed on your system already, you -can obtain them from `https://www.boost.org/`. For Visual C++ you can download precompiled libraries -from `https://sourceforge.net/projects/boost/files/boost-binaries/`. - -As on Windows there is no canonical directory for where to find -\sc{Boost}, we recommend that you define the environment variable -`BOOST_ROOT` and set it to where you have installed \sc{Boost}, e.g., -`C:\boost\boost_1_41_0`. - -\subsection thirdpartyMPFR GMP and MPFR - -The components libCGAL, libCGAL_Core, and libCGAL_Qt5 require -\sc{Gmp} and \sc{Mpfr} which are libraries for multi precision integers and rational numbers, -and for multi precision floating point numbers. - -\cgal combines floating point arithmetic with exact arithmetic, -in order to be efficient and reliable. \cgal has a built-in -number type for that, but \sc{Gmp} and \sc{Mpfr} provide a faster -solution, and we recommend to use them. - -Having \sc{Gmp} version 4.2 or higher and \sc{Mpfr} version 2.2.1 or higher -installed is recommended. These libraries can be obtained from -`https://gmplib.org/` and `https://www.mpfr.org/`, respectively. - -As Visual \cpp is not properly -supported by the \sc{Gmp} and \sc{Mpfr} projects, we provide precompiled versions -of \sc{Gmp} and \sc{Mpfr}, which can be downloaded with the installer -`CGAL-\cgalReleaseNumber``-Setup.exe`. - -\subsection thirdpartyzlib zlib - -\sc{zlib} is a data compression library, and is essential for the component libCGAL_ImageIO. - -In \cgal this library is used in the examples of the \ref PkgSurfaceMesher3Ref package. - -If it is not already on your system, -for instance, on Windows, you can download it from `http://www.zlib.net/`. - -\subsection thirdpartyQt Qt5 - -Qt is a cross-platform application and UI framework. - -The component libCGAL_Qt5 requires \sc{Qt}5 installed on your system. -In case \sc{Qt} is not yet installed on your system, you can download -it from `http://www.qt-project.org/`. - - -The exhaustive list of \sc{Qt}5 components used in demos is: -`Core`, `Gui`, `Help`, `OpenGL`, `Script`, `ScriptTools`, `Svg`, `Widgets`, -`qcollectiongenerator` (with `sqlite` driver plugin) and `Xml`. - -\sc{Qt} version 5.9.0 or later is required. - -\section installation_examples CGAL Examples and Demos - -\cgal is distributed with a large collection of examples and demos. By default, these are not configured along with -the \cgal libraries, unless you set the variables `WITH_examples=ON` and/or `WITH_demos=ON`. - -Nevertheless, even when configured with \cgal, they are not automatically built along with the libraries. -You must build the `examples` or `demos` targets (or IDE projects) explicitly. - -If you do not plan to compile any demos, you might skip some of the essential libraries (as \sc{Qt}), -as the corresponding \cgal-libraries are not linked. But for -your own demos you might need these \cgal-libraries. - -\section secoptional3rdpartysoftware Optional Third Party Libraries - -Optional 3rd party software can be used by \cgal for various reasons: -Usually certain optional libraries are required to build examples and -demos shipped with \cgal or to build your own project using \cgal. -Another reason is to speed up basic tasks. - -\subsection thirdpartyLeda LEDA - -\leda is a library of efficient data structures and -algorithms. Like \sc{Core}, \leda offers a real number data type. - -In \cgal this library is optional, and its number types can -be used as an alternative to \sc{Gmp}, \sc{Mpfr}, and \sc{Core}. - -Free and commercial editions of \leda are available from `https://www.algorithmic-solutions.com`. - -\subsection thirdpartyMPFI MPFI - -\sc{Mpfi} provides arbitrary precision interval arithmetic with intervals -represented using \sc{Mpfr} reliable floating-point numbers. -It is based on the libraries \sc{Gmp} and \sc{Mpfr}. -In the setting of \cgal, this library is -optional: it is used by some models of the -\ref PkgAlgebraicKernelDRef "Algebraic Kernel". - -\sc{Mpfi} can be downloaded from `http://mpfi.gforge.inria.fr/`. Version 1.4 or higher is recommended. - -\subsection thirdpartyRS3 RS and RS3 - -\sc{Rs} (Real Solutions) is devoted to the study of the real roots of -polynomial systems with a finite number of complex roots (including -univariate polynomials). In \cgal, \sc{Rs} is used by one model of the -\ref PkgAlgebraicKernelDRef "Algebraic Kernel". - -\sc{Rs} is freely distributable for non-commercial use. You can download it -from `http://vegas.loria.fr/rs/`. Actually, the \sc{Rs} package also includes \sc{Rs3}, the -successor of \sc{Rs}, which is used in conjunction with it. - -The libraries \sc{Rs} and \sc{Rs3} need \sc{Mpfi}, which can be downloaded from -`http://mpfi.gforge.inria.fr/`. - -\subsection thirdpartyNTL NTL - -\sc{Ntl} provides data structures and algorithms for signed, arbitrary -length integers, and for vectors, matrices, and polynomials over the -integers and over finite fields. The optional library \sc{Ntl} is used by \cgal -to speed up operations of the Polynomial package, such as GCDs. It is recommended to install \sc{Ntl} with support from \sc{Gmp}. - -\sc{Ntl} can be downloaded from `http://www.shoup.net/ntl/`. Version 5.1 or higher is recommended. - -\subsection thirdpartyEigen Eigen - -\sc{Eigen} is a `C++` template library for linear algebra. \sc{Eigen} supports all -matrix sizes, various matrix decomposition methods and sparse linear solvers. - -In \cgal, \sc{Eigen} provides sparse linear solvers in the \ref PkgPoissonSurfaceReconstruction3Ref -and the \ref PkgSurfaceMeshParameterizationRef packages. - -In addition, \sc{Eigen} also provides singular value decomposition for the \ref PkgJetFitting3Ref -and the \ref PkgRidges3Ref packages. - -The \sc{Eigen} web site is `http://eigen.tuxfamily.org`. - -\subsection thirdpartyESBTL ESBTL - -The \sc{Esbtl} (Easy Structural Biology Template Library) is a library that allows -the handling of \sc{Pdb} data. - -In \cgal the \sc{Esbtl} is used in an example of the -\ref PkgSkinSurface3Ref package. - -It can be downloaded from `http://esbtl.sourceforge.net/`. - -\subsection thirdpartyTBB Intel TBB - -\sc{Tbb} (Threading Building Blocks) is a library developed by Intel Corporation for writing software -programs that take advantage of multi-core processors. - -In \cgal, \sc{Tbb} is used by the packages that offer parallel code. - -The \sc{Tbb} web site is `https://www.threadingbuildingblocks.org`. - -\subsection thirdpartyLASlib LASlib - -\sc{LASlib} is a `C++` library for handling LIDAR data sets stored in -the LAS format (or the compressed LAZ format). - -In \cgal, \sc{LASlib} is used to provide input and output functions in -the \ref PkgPointSetProcessing3Ref package. - -The \sc{LASlib} web site is `https://rapidlasso.com/lastools/`. \sc{LASlib} -is usually distributed along with LAStools: for simplicity, \cgal -provides a fork with a -CMake based install procedure. - -\subsection thirdpartyOpenCV OpenCV - -\sc{OpenCV} (Open Computer Vision) is a library designed for computer -vision, computer graphics and machine learning. - -In \cgal, \sc{OpenCV} is used by the \ref PkgClassificationRef package. - -The \sc{OpenCV} web site is `https://opencv.org/`. - -\subsection thirdpartyTensorFlow TensorFlow - -\sc{TensorFlow} is a library designed for machine learning and deep learning. - -In \cgal, the C++ API of \sc{TensorFlow} is used by the \ref -PkgClassificationRef 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`. - -The \sc{TensorFlow} web site is `https://www.tensorflow.org/`. - -\subsection thirdpartyMETIS METIS - -\sc{METIS} is a library developed by the Karypis Lab -and designed to partition graphs and produce fill-reducing matrix orderings. - -\cgal offers wrappers around some of the methods of the \sc{METIS} library -to allow the partitioning of graphs that are models of the concepts of the -Boost Graph Library, -and, by extension, of surface meshes (see Section \ref BGLPartitioning of the package \ref PkgBGL). - -More information is available on the METIS library -at `http://glaros.dtc.umn.edu/gkhome/metis/metis/overview`. - -\subsection thirdpartyCeres Ceres Solver - -\sc{Ceres} is an open source C++ library for modeling and solving large, complicated optimization problems. - -In \cgal, \sc{Ceres} is used by the \ref PkgPolygonMeshProcessingRef package for mesh smoothing, which -requires solving complex non-linear least squares problems. - -Visit the official website of the library at `ceres-solver.org` -for more information. - -\subsection thirdpartyGLPK GLPK - -\sc{GLPK} (GNU Linear Programming Kit) is a library for solving linear programming (LP), mixed integer programming (MIP), and other related problems. - -In \cgal, \sc{GLPK} provides an optional linear integer program solver in the \ref PkgPolygonalSurfaceReconstruction package. - -The \sc{GLPK} web site is `https://www.gnu.org/software/glpk/`. - -\subsection thirdpartySCIP SCIP - -\sc{SCIP} (Solving Constraint Integer Programs) is currently one of the fastest open source solvers for mixed integer programming (MIP) and mixed integer nonlinear programming (MINLP). - -In \cgal, \sc{SCIP} provides an optional linear integer program solver in the \ref PkgPolygonalSurfaceReconstruction package. - -The \sc{SCIP} web site is `http://scip.zib.de/`. - -\section secbuilding Building CGAL - -The results of a successful configuration are build files that control the build step. -The nature of the build files depends on the generator used during configuration, but in all cases they -contain several targets, one per library, and a default global target corresponding -to all the libraries. - -For example, in a \sc{Unix}-like environment the default generator produces -makefiles. You can use the `make` command-line tool for the -succeeding build step as follows: - -
    -
    -cd CGAL-\cgalReleaseNumber
    -
    -# build all the selected libraries at once
    -
    -make 
    -
    -
    - -The resulting libraries are placed in the subdirectory `lib` under `` -(which is `CGAL-\cgalReleaseNumber` in case you run an in-source-configuration). - -With generators other than `UNIX Makefiles` the resulting build files -are solution and project files which -should be launched in an \sc{Ide}, such as Visual Studio or KDevelop3. They will contain the targets described -above, which you can manually build as with any other solution/project within your \sc{Ide}. - -Alternatively, you can build it with the command line version of the -\sc{Visual Studio Ide}: - -
    -
    -devenv CGAL.sln /Build Debug
    -
    -
    - -The "Debug" argument is needed because CMake creates solution files for -all four configurations, and you need to explicitly choose one when building -(the other choices are Release, RelWithDebInfo and MinSizeRel). - -\cgalAdvancedBegin -The build files produced by CMake are autoconfigured. That -is, if you change any of the dependencies, the build step -automatically goes all the way back to the configuration step. This -way, once the target has been configured the very first time by -invoking cmake, you don't necessarily need to invoke `cmake` -again. Rebuilding will call itself `cmake` and re-generate the -build file whenever needed. Keep this in mind if you configure \cgal -for the Visual Studio IDE since a build could then change the -solution/project file in-place and VS will prompt you to reload it. -\cgalAdvancedEnd - -If you have turned on the configuration of examples -(`-DWITH_examples=ON`) and/or demos (`-DWITH_demos=ON`), there will be additional -targets named `examples` and `demos`, plus one target for -each example and each demo in the build files. -None of these targets are included by default, so you need to build them explicitly -after the \cgal libraries have been successfully built. -The targets `examples` and `demos` include themselves all the targets -for examples and demos respectively. - -
    -
    -# build all examples at once
    -make examples 
    -
    -# build all demos at once
    -make demos
    -
    -
    - -\cgalAdvancedBegin -When using `UNIX Makefiles` you can find out the -exact name of the example or demo target of a particular package by -typing `make help | grep `. -\cgalAdvancedEnd - -\section secinstalling Installing CGAL - -On many platforms, library pieces such as headers, docs and binaries -are expected to be placed in specific locations. A typical example -being `/usr/include` and `/usr/lib` on \sc{Unix}-like -operating systems or `C:/Program Files/` on Windows. The process -of placing or copying the library elements into its standard location -is sometimes referred to as Installation and it is a -postprocessing step after the build step. - -CMake carries out the installation by producing a build target named install. -The following example shows a typical session from configuration to -installation in a \sc{Unix}-like environment: - -
    -
    -cd CGAL-\cgalReleaseNumber
    -
    -cmake . # configure
    -make # compile
    -make install # install
    -
    -
    - -If you use a generator that produces IDE files (for Visual Studio for instance) there will be an optional -`INSTALL` project, which you will be able to "build" to execute the installation step. - -\cgalAdvancedBegin -The files are copied into a directory tree relative to the installation directory determined by the -CMake variable `CMAKE_INSTALL_PREFIX`. This variable defaults to `/usr/local` under \sc{Unix}-like operating systems -and `C:\Program Files` under Windows. If you want to install to a different location, you must override that CMake -variable explicitly at the configuration time and not when executing the install step. -\cgalAdvancedEnd - -The file `CGALConfig.cmake` is installed by default in -`$CMAKE_INSTALLED_PREFIX/lib/``CGAL-\cgalReleaseNumber`. - -\section seccmakeoutofsource Multiple Variants of Makefiles (out-of-source build) - - -While you can choose between release or debug builds, and shared or static libraries, -it is not possible to generate different variants during a single configuration. You need to run CMake in a -different directory for each variant you are interested in, each with its own selection of configuration parameters. - -CMake stores the resulting makefiles and project files, along with several temporary and auxiliary files such -as the variables cache, in the directory where it is executed, called `CMAKE_BINARY_DIR`, but it -takes the source files and configuration scripts from -`CMAKE_SOURCE_DIR`. - -The binary and source directories do not need to be the same. Thus, you can configure multiple variants by creating a -distinct directory for each configuration and by running CMake from there. This is known in CMake terminology -as out-of-source configuration, as opposite to an in-source -configuration, as showed in the previous sections. - -You can, for example, generate subdirectories `CGAL-\cgalReleaseNumber``/cmake/platforms/debug` and -`CGAL-\cgalReleaseNumber``/cmake/platforms/release` for two configurations, respectively: - -
    -mkdir CGAL-\cgalReleaseNumber/cmake/platforms/debug
    -cd CGAL-\cgalReleaseNumber/cmake/platforms/debug
    -cmake -DCMAKE_BUILD_TYPE=Debug ../../..
    -
    -mkdir CGAL-\cgalReleaseNumber/cmake/platforms/release
    -cd CGAL-\cgalReleaseNumber/cmake/platforms/release
    -cmake -DCMAKE_BUILD_TYPE=Release ../../..
    -
    - -\section installation_configuring_using Configuring and Building Programs Using CGAL - -Ideally, configuring and compiling a demo/example/program amounts to - -
    -
    -cd CGAL-\cgalReleaseNumber/examples/Triangulation_2
    -cmake -DCGAL_DIR=$HOME/CGAL-\cgalReleaseNumber .
    -make
    -
    -
    - -In this ideal world, as for all shipped examples and demos of \cgal, the -required `CMakeLists.txt` is already provided. - -CMake can also be used to configure and build user programs via such -CMake-scripts. In this less ideal world, one has to provide the -`CMakeLists.txt` script either manually, or with the help of a -shell-script that is introduced below. - -For a user program `executable.cpp`, the ideal world looks like this: - -
    -cd /path/to/program 
    -cgal_create_CMakeLists -s executable
    -cmake -DCGAL_DIR=$HOME/CGAL-\cgalReleaseNumber . 
    -make
    -
    - -In both examples we specify the `CGAL_DIR`: -During configuration of the \cgal libraries a file named `CGALConfig.cmake` is generated in \cgal's root directory (in contrast -to \cgal's source directory that has been used for installation). This file -contains the definitions of several CMake variable that summarize the -configuration of \cgal. In order to configure a program, you need -to indicate the location of that config file in the CMake variable -`CGAL_DIR` (as indicated in the example above). -`CGAL_DIR` can also be an environment variable. Setting -`CGAL_DIR` makes particular sense if having multiple -out-of-source builds of \cgal as in Section \ref seccmakeoutofsource. - -If you have installed \cgal, `CGAL_DIR` must afterwards be set to -`$CMAKE_INSTALLED_PREFIX/lib/CGAL`. Note that \cgal is -recommended to be installed in release mode when using it to build programs. - -\subsection installation_creating Creating a CMake Script for a Program Using CGAL - -For compiling a non-shipped program, it is -recommended, to also rely on a CMake-supported configuration using a -`CMakeLists.txt` used for configuration. - -Use the following Bourne-shell script for programs that are relatively -simple to configure: - -\subsection seccreate_cgal_CMakeLists cgal_create_CMakeLists - -The Bourne-shell script `cgal_create_CMakeLists.txt` resides in the -`CGAL-\cgalReleaseNumber``/scripts` directory. It can be used to create -`CMakeLists.txt` files for compiling \cgal applications. Executing -`cgal_create_CMakeLists.txt` in an application directory creates a -`CMakeLists.txt` containing rules to build the contained -application(s). Three command line options determine details of the -configuration. - -
    -
    `-s source`
    If this parameter is given the script will -create a single executable for 'source' linked with -compilations of all other source files -(`*.cc`, `*.cp`, `*.cxx`, `*.cpp`, `*.CPP`, `*.c++`, or `*.C`). -This behaviour is usually needed for (graphical) demos. - -If the parameter is not given, the script creates one executable for each given -source file. -
    `-c com1:com2:...`
    Lists components ("com1", -"com2") of \cgal to which the executable(s) should be linked. Valid components are \cgal's -libraries (i.e.\ "Core", "ImageIO", and "Qt5"). An example is `-c Core`. - -
    `-b boost1:boost2:...`
    Lists components ("boost1", -"boost2") of \sc{Boost} to which the executable(s) should be -linked. Valid options are, for instance, "filesystem" or "program_options". - -
    - -This options should suffice to create `CMakeLists.txt` script -for most directories containing programs. However, in some special -cases, it might still be required to create the script manually, for -instance, if some source files/executables need a different linking than -other source files. - -\subsection seccreate_cgal_cmake_script cgal_create_cmake_script - -\deprecated For backward-compatibility we still provide the -Bourne-shell script `cgal_create_cmake_script` that is -contained in the `CGAL-\cgalReleaseNumber``/scripts` directory. It can be used -to create `CMakeLists.txt` files for compiling \cgal -applications. Executing `cgal_create_cmake_script` in an -application directory creates a `CMakeLists.txt` containing -rules for every C++ source file there. The script is deprecated, -as it only works for applications with a single course file that only -need libCGAL and libCGAL_Core. - -Such a shell-script simply creates a CMake script. Processing it -with CMake, searches for \cgal using `find_package`. If found, -the variable `CGAL_USE_FILE` is set to a compilation environment CMake file. Including -this file within a CMake script sets up include paths and libraries to -link with \cgal and essential third party libraries. Beyond, -`find_package` can demand for `COMPONENTS` of \cgal, -that is, all \cgal libraries `libCGAL_Core` (Core), -libCGAL_ImageIO (ImageIO), and libCGAL_Qt5 -(Qt5) or optional 3rd party software such as MPFI, RS3. -A user is free to create the `CMakeLists.txt` -without calling the script (manual creation). - -\section installation_summary Summary of CGAL's Configuration Variables - -Most configuration variables are not environment variables but -CMake variables. They are given in the command line to CMake -via the `-D` option, or passed from the interactive interface -of `cmake-gui`. Unless indicated differently, all the variables -summarized below are CMake variables. - -\subsection installation_component_selection Component Selection - -The following boolean variables indicate which \cgal components to -configure and build. Their values can be ON or OFF. - - -| Variable | %Default Value | -| :------- | :--------------- | -| `WITH_examples` | OFF | -| `WITH_demos` | OFF | -| `WITH_CGAL_Core` | ON | -| `WITH_CGAL_Qt5` | ON | -| `WITH_CGAL_ImageIO` | ON | - -\subsection installation_flags Compiler and Linker Flags - -The following variables specify compiler and linker flags. Each variable holds a -space-separated list of command-line switches for the compiler and linker and -their default values are automatically defined by CMake based on the target platform. - -Have in mind that these variables specify a list of flags, not just one -single flag. If you provide your own definition for a variable, you will entirely override -the list of flags chosen by CMake for that particular variable. - -The variables that correspond to both debug and release builds are always -used in conjunction with those for the specific build type. - - -| Program | Both Debug and Release | Release Only | Debug Only | -| :------ | :---------------------- | :------------- | :----------- | -| C++ Compiler | `CMAKE_CXX_FLAGS` | `CMAKE_CXX_FLAGS_RELEASE` | `CMAKE_CXX_FLAGS_DEBUG` | -| Linker (shared libs) | `CMAKE_SHARED_LINKER_FLAGS` | `CMAKE_SHARED_LINKER_FLAGS_RELEASE` | `CMAKE_SHARED_LINKER_FLAGS_DEBUG` | -| Linker (static libs) | `CMAKE_MODULE_LINKER_FLAGS` | `CMAKE_MODULE_LINKER_FLAGS_RELEASE` | `CMAKE_MODULE_LINKER_FLAGS_DEBUG` | -| Linker (programs) | `CMAKE_EXE_LINKER_FLAGS` | `CMAKE_EXE_LINKER_FLAGS_RELEASE` | `CMAKE_EXE_LINKER_FLAGS_DEBUG`| - - -\subsection installation_additional_flags Additional Compiler and Linker Flags - -The following variables can be used to add flags without overriding the ones -defined by cmake. - - -| Program | Both Debug and Release | Release Only | Debug Only | -| :------ | :---------------------- | :------------- | :----------- | -| C++ Compiler | `CGAL_CXX_FLAGS` | `CGAL_CXX_FLAGS_RELEASE` | `CGAL_CXX_FLAGS_DEBUG` | -| Linker (shared libs) | `CGAL_SHARED_LINKER_FLAGS` | `CGAL_SHARED_LINKER_FLAGS_RELEASE` | `CGAL_SHARED_LINKER_FLAGS_DEBUG` | -| Linker (static libs) | `CGAL_MODULE_LINKER_FLAGS` | `CGAL_MODULE_LINKER_FLAGS_RELEASE` | `CGAL_MODULE_LINKER_FLAGS_DEBUG` | -| Linker (programs) | `CGAL_EXE_LINKER_FLAGS` | `CGAL_EXE_LINKER_FLAGS_RELEASE` | `CGAL_EXE_LINKER_FLAGS_DEBUG` | - -\subsection installation_misc Miscellaneous Variables - - -| Variable | Description | Type | %Default Value | -| :- | :- | :- | :- | -| `CMAKE_BUILD_TYPE` | Indicates type of build. Possible values are 'Debug' or 'Release' | CMake | Release | -| `CMAKE_CXX_COMPILER` | Full-path to the executable corresponding to the C++ compiler to use. | CMake | platform-dependent | -| `CXX` | Idem | Environment | Idem | - - -\subsection installation_variables_building Variables Used Only When Building Programs (Such as Demos or Examples) - - -| Variable | Description | Type | %Default Value | -| :- | :- | :- | :- | -| `CGAL_DIR` | Full-path to the binary directory where \cgal was configured |Either CMake or Environment | none | - - -\subsection installation_variables_third_party Variables Providing Information About 3rd-Party Libraries -\anchor sec3partysoftwareconfig - -The following variables provide information about the availability and -location of the 3rd party libraries used by \cgal. CMake automatically -searches for dependencies so you need to specify these variables if -CMake was unable to locate something. This is indicated by a value ending in -`NOTFOUND`. - -Since 3rd-party libraries are system wide, many of the CMake variables listed below can alternatively -be given as similarly-named environment variables instead. Keep in mind that you must provide one or the -other but never both. - -\subsection installation_boost Boost Libraries - -In most cases, if \sc{Boost} is not automatically found, setting the `BOOST_ROOT` -variable is enough. If it is not, you can specify the header and library -directories individually. You can also provide the full pathname to a specific compiled library -if it cannot be found in the library directory or its name is non-standard. - -By default, when \sc{Boost} binary libraries are needed, the shared versions -are used if present. You can set the variable -`CGAL_Boost_USE_STATIC_LIBS` to `ON` if you want to link -with static versions explicitly. - -On Windows, if you link with \sc{Boost} shared libraries, you must ensure that -the `.dll` files are found by the dynamic linker, at run time. -For example, you can add the path to the \sc{Boost} `.dll` to the -`PATH` environment variable. - -| Variable | Description | Type | -| :- | :- | :- | -| `BOOST_ROOT`\cgalFootnote{The environment variable can be spelled either `BOOST_ROOT` or `BOOSTROOT`} | Root directory of your \sc{Boost} installation | Either CMake or Environment | -| `Boost_INCLUDE_DIR` | Directory containing the `boost/version.hpp` file | CMake | -| `BOOST_INCLUDEDIR` | Idem | Environment | -| `Boost_LIBRARY_DIRS` | Directory containing the compiled \sc{Boost} libraries | CMake | -| `BOOST_LIBRARYDIR` | Idem | Environment | -| `Boost_(xyz)_LIBRARY_RELEASE` | Full pathname to a release build of the compiled 'xyz' \sc{Boost} library | CMake | -| `Boost_(xyz)_LIBRARY_DEBUG` | Full pathname to a debug build of the compiled 'xyz' \sc{Boost} library | CMake | - - -\subsection installation_gmp GMP and MPFR Libraries - -Under Windows, auto-linking is used, so only the directory -containing the libraries is needed and you would specify `GMP|MPFR_LIBRARY_DIR` rather than -`GMP|MPFR_LIBRARIES`. On the other hand, under Linux the actual library filename is needed. -Thus you would specify `GMP|MPFR_LIBRARIES`. In no case you need to specify both. - -\cgal uses both \sc{Gmp} and \sc{Mpfr} so both need to be supported. If either of them is unavailable the -usage of \sc{Gmp} and of \sc{Mpfr} will be disabled. - - -| Variable | Description | Type | -| :- | :- | :- | -| `CGAL_DISABLE_GMP` | Indicates whether to search and use \sc{Gmp}/\sc{Mpfr} or not | CMake | -| `GMP_DIR` | Directory of \sc{Gmp} default installation | Environment | -| `GMP_INCLUDE_DIR` | Directory containing the `gmp.h` file | CMake | -| `GMP_INC_DIR` | Idem | Environment | -| `GMP_LIBRARIES_DIR` | Directory containing the compiled \sc{Gmp} library | CMake | -| `GMP_LIB_DIR` | Idem | Environment | -| `GMP_LIBRARIES` | Full pathname of the compiled \sc{Gmp} library | CMake | -| `MPFR_INCLUDE_DIR` | Directory containing the `mpfr.h` file | CMake | -| `MPFR_INC_DIR` | Idem | Environment | -| `MPFR_LIBRARIES_DIR` | Directory containing the compiled \sc{Mpfr} library | CMake | -| `MPFR_LIB_DIR` | Idem | Environment | -| `MPFR_LIBRARIES` | Full pathname of the compiled \sc{Mpfr} library | CMake | - - - -Under Linux, the \sc{Gmpxx} is also searched for, and you may specify the following variables: - - -| Variable | Description | Type | -| :- | :- | :- | -| `GMPXX_DIR` | Directory of \sc{gmpxx} default installation | Environment | -| `GMPXX_INCLUDE_DIR` | Directory containing the `gmpxx.h` file | CMake | -| `GMPXX_LIBRARIES` | Full pathname of the compiled \sc{Gmpxx} library | CMake | - - - -\subsection installation_qt5 Qt5 Library - -You must set the cmake or environment variable `Qt5_DIR` to point to the path -to the directory containing the file `Qt5Config.cmake` created by your \sc{Qt}5 installation. If you are -using the open source edition it should be `/qt-everywhere-opensource-src-/qtbase/lib/cmake/Qt5`. - -\subsection installation_leda LEDA Library - -When the \leda libraries are not automatically found, yet they are installed on the system -with base names 'leda' and 'ledaD' (for the release and debug versions resp.), it might -be sufficient to just indicate the library directory via the `LEDA_LIBRARY_DIRS` variable. -If that doesn't work because, for example, the names are different, you can provide the full pathnames of each variant -via `LEDA_LIBRARY_RELEASE` and `LEDA_LIBRARY_DEBUG`. - -The variables specifying definitions and flags can be left undefined if they are not needed by LEDA. - - -| Variable | Description | Type | -| :- | :- | :- | -| `WITH_LEDA` | Indicates whether to search and use \leda or not | CMake | -| `LEDA_DIR` | Directory of \sc{LEDA} default installation | Environment | -| `LEDA_INCLUDE_DIR` | Directory containing the file `LEDA/system/basic.h` | CMake | -| `LEDA_LIBRARIES` | Directory containing the compiled \leda libraries | CMake | -| `LEDA_INC_DIR` | Directory containing the file `LEDA/system/basic.h` | Environment | -| `LEDA_LIB_DIR` | Directory containing the compiled \leda libraries | Environment | -| `LEDA_LIBRARY_RELEASE` | Full pathname to a release build of the \leda library | CMake | -| `LEDA_LIBRARY_DEBUG` | Full pathname to a debug build of the \leda library | CMake | -| `LEDA_DEFINITIONS` | Preprocessor definitions | CMake | -| `LEDA_CXX_FLAGS` | Compiler flags | CMake | -| `LEDA_LINKER_FLAGS` | Linker flags | CMake | - - -\subsection installation_mpfi MPFI Library - -\cgal provides a number type based on this library, but the \cgal library -itself does not depend on \sc{Mpfi}. This means that this library must be -configured when compiling an application that uses the above number type. - -When \sc{Mpfi} files are not on the standard path, the locations of the headers -and library files must be specified by using environment variables. - - -| Variable | Description | Type | -| :- | :- | :- | -| `MPFI_DIR` |Directory of \sc{MPFI} default installation | Environment | -| `MPFI_INCLUDE_DIR` | Directory containing the `mpfi.h` file | CMake | -| `MPFI_INC_DIR` | Idem | Environment | -| `MPFI_LIBRARIES_DIR` | Directory containing the compiled \sc{Mpfi} library | CMake | -| `MPFI_LIB_DIR` | Idem | Environment | -| `MPFI_LIBRARIES` | Full pathname of the compiled \sc{Mpfi} library | CMake | - - - -\subsection installation_rs RS and RS3 Library - -As said before, only the \cgal univariate algebraic kernel depends on the -library Rs. As the algebraic kernel is not compiled as a part of the \cgal -library, this library is not detected nor configured at installation time. - -CMake will try to find Rs in the standard header and library -directories. When it is not automatically detected, the locations of the -headers and library files must be specified using environment variables. - -Rs needs \sc{Gmp} 4.2 or later and \sc{Mpfi} 1.3.4 or later. The variables -related to the latter library may also need to be defined. - - -| Variable | Description | Type | -| :- | :- | :- | -| `RS_DIR` | Directory of \sc{Rs} default installation | Environment | -| `RS_INCLUDE_DIR` | Directory containing the `rs_exports.h` file | CMake | -| `RS_INC_DIR` | Idem | Environment | -| `RS_LIBRARIES_DIR` | Directory containing the compiled \sc{Rs} library | CMake | -| `RS_LIB_DIR` | Idem | Environment | -| `RS_LIBRARIES` | Full pathname of the compiled \sc{Rs} library | CMake | - -Similar variables exist for \sc{Rs3}. - -| Variable | Description | Type | -| :- | :- | :- -| `RS3_DIR` | Directory of \sc{Rs3} default installation | Environment | -| `RS3_INCLUDE_DIR` | Directory containing the file `rs3_fncts.h` file | CMake | -| `RS3_INC_DIR` | Idem | Environment | -| `RS3_LIBRARIES_DIR` | Directory containing the compiled \sc{Rs3} library | CMake | -| `RS3_LIB_DIR` | Idem | Environment | -| `RS3_LIBRARIES` | Full pathname of the compiled \sc{Rs3} library | CMake | - - -\subsection installation_ntl NTL Library - -Some polynomial computations in \cgal's algebraic kernel -are speed up when \sc{Ntl} is available. -As the algebraic kernel is not compiled as a part of the \cgal -library, this library is not detected nor configured at installation time. - -CMake will try to find \sc{Ntl} in the standard header and library -directories. When it is not automatically detected, the locations of the -headers and library files must be specified using environment variables. - -| Variable | Description | Type | -| :- | :- | :- | -| `NTL_DIR` | Directory of \sc{NTL} default installation | Environment | -| `NTL_INCLUDE_DIR` | Directory containing the `NTL/ZZX.h` file | CMake | -| `NTL_INC_DIR` | Idem | Environment | -| `NTL_LIBRARIES_DIR` | Directory containing the compiled \sc{Ntl} library | CMake | -| `NTL_LIB_DIR` | Idem | Environment | -| `NTL_LIBRARIES` | Full pathname of the compiled \sc{Ntl} library | CMake | - -\subsection installation_eigen Eigen Library - -\sc{Eigen} is a header-only template library. -Only the directory containing the header files of \sc{Eigen} 3.1 (or greater) is needed. - - -| Variable | Description | Type | -| :- | :- | :- | -| `EIGEN3_INCLUDE_DIR` | Directory containing the file `signature_of_eigen3_matrix_library` | CMake | -| `EIGEN3_INC_DIR` | Idem | Environment | - -\subsection installation_esbtl ESBTL Library - -One skin surface example requires the \sc{Esbtl} library in order to read \sc{Pdb} files. - -If \sc{Esbtl} is not automatically found, setting the `ESBTL_INC_DIR` -environment variable is sufficient. - - -| Variable | Description | Type | -| :- | :- | :- | -| `ESBTL_DIR` | Directory of \sc{ESBTL} default installation | Environment | -| `ESBTL_INC_DIR` | Directory containing the `ESBTL/default.h` file | Environment | -| `ESBTL_INCLUDE_DIR` | Directory containing the `ESBTL/default.h` file | CMake | - -\subsection installation_tbb TBB Library - -If \sc{Tbb} is not automatically found, the user must set the `TBBROOT` -environment variable. The environment variable `TBB_ARCH_PLATFORM=/` must be set. -`` is `ia32` or `intel64`. `` describes the Linux kernel, gcc version or Visual Studio version -used. It should be set to what is used in `$TBBROOT/lib/`. - -For windows users, the folder `TBBROOT/bin//` should be added to the `PATH` variable. - -Note that the variables in the table below are being used. - -| Variable | Description | Type | -| :- | :- | :- | -| `TBBROOT` | Directory of \sc{Tbb} default installation | Environment | -| `TBB_INCLUDE_DIRS` | Directory containing the `tbb/tbb.h` file | CMake | -| `TBB_LIBRARY_DIRS` | Directory(ies) containing the compiled TBB libraries | CMake | -| `TBB_LIBRARIES` | Full pathnames of the compiled TBB libraries (both release and debug versions, using "optimized" and "debug" CMake keywords). Note that if the debug versions are not found, the release versions will be used instead for the debug mode. | CMake | -| `TBB_RELEASE_LIBRARY` | Full pathname of the compiled TBB release library | CMake | -| `TBB_MALLOC_RELEASE_LIBRARY` | Full pathname of the compiled TBB release malloc library | CMake | -| `TBB_DEBUG_LIBRARY` | Full pathname of the compiled TBB debug library | CMake | -| `TBB_MALLOC_DEBUG_LIBRARY` | Full pathname of the compiled TBB debug malloc library | CMake | -| `TBB_MALLOCPROXY_DEBUG_LIBRARY` | Full pathname of the compiled TBB debug malloc_proxy library (optional) | CMake | -| `TBB_MALLOCPROXY_RELEASE_LIBRARY` | Full pathname of the compiled TBB release malloc_proxy library (optional) | CMake | - -\section installation_compiler_workarounds Compiler Workarounds - -A number of boolean flags are used to workaround compiler bugs and -limitations. They all start with the prefix `CGAL_CFG`. These -flags are used to work around compiler bugs and limitations. For -example, the flag `CGAL_CFG_NO_CPP0X_LONG_LONG` denotes -that the compiler does not know the type `long long`. - -For each installation a file -is defined, with the correct -settings of all flags. This file is generated automatically by CMake, -and it is located in the `include` directory of where you run -CMake. For an in-source configuration this means -`CGAL-\cgalReleaseNumber``/include`. - -The test programs used to generate the `compiler_config.h` -file can be found in `config/testfiles`. -Both -`compiler_config.h` and the test programs contain a short -description of the problem. In case of trouble with one of the -`CGAL_CFG` flags, it is a good idea to take a look at it. - -The file `CGAL/compiler_config.h` is included from -``. -which is included by all \cgal header files. - - -*/ diff --git a/Documentation/doc/Documentation/License.txt b/Documentation/doc/Documentation/License.txt new file mode 100644 index 00000000000..fddf4a1bd8f --- /dev/null +++ b/Documentation/doc/Documentation/License.txt @@ -0,0 +1,104 @@ +/*! +\page license License +\cgalAutoToc + +\cgal is distributed under a dual license scheme, that is under the +\sc{Gpl}/\sc{Lgpl} open source license, as well as under commercial licenses. + +\cgal consists of different parts covered by different open source licenses. +In this section we explain the essence of the different licenses, as well as +the rationale why we have chosen them. + +The fact that \cgal is Open Source software does not mean that users are free +to do whatever they want with the software. Using the software means to accept +the license, which has the status of a contract between the user and the owner +of the \cgal software. + +\section licensesGPL GPL + +The \sc{Gpl} is an Open Source license that, if you distribute your software +based on \sc{Gpl}ed \cgal data structures, obliges you to distribute the +source code of your software under the \sc{Gpl}. + +The exact license terms can be found at the Free Software Foundation +web site: http://www.gnu.org/copyleft/gpl.html. + +\section licensesLGPL LGPL + +The \sc{Lgpl} is an Open Source license that obliges you to distribute +modifications you make on \cgal software accessible to the users. +In contrast to the \sc{Gpl}, there is no obligation to make the source +code of software you build on top of \sc{Lgpl}ed \cgal data structures. + +The exact license terms can be found at the Free Software Foundation web site: +http://www.gnu.org/copyleft/lesser.html. + +\section licensesRationale Rationale of the License Choice + +We have chosen the \sc{Gpl} and the \sc{Lgpl} as they are well-known +and well-understood open source licenses. The former restricts +commercial use, and the latter allows to promote software as de facto standard +so that people can build new higher level data structures on top. + +Therefore, the packages forming a foundation layer are distributed under +the \sc{Lgpl}, and the higher level packages under the \sc{Gpl}. +The package overview states for each package under which license it is distributed. + +\section licensesCommercial Commercial Licenses + +Users who cannot comply with the Open Source license terms can buy individual +data structures under various commercial licenses from GeometryFactory: +http://www.geometryfactory.com/. License fees paid by commercial +customers are reinvested in R\&D performed by the \cgal project partners, +as well as in evolutive maintenance. + +\section licenseCheck License Checking + +Users who have a commercial license for specific packages can check that +they do not accidentally use packages for which they do not have a commercial +license. The same holds for users who want to be sure that they only +use packages of \cgal released under the \sc{Lgpl}. + +To enable checking, users have to define one of the following macros: + +| Macro Name | Effect | +| :--------- | :------ | +| `CGAL_LICENSE_WARNING` | get a warning during the compilation | +| `CGAL_LICENSE_ERROR` | get an error during the compilation | + +The license checking is not a mean to control users as no information +is collected or transmitted. + +\section seccgal_version Identifying the Version of CGAL + +Every release of \cgal defines the following preprocessor macros: + +
    +
    `CGAL_VERSION_STR`
    +
    a textual description of the current release (e.g., or 3.3 or 3.2.1 or 3.2.1-I-15) as a string literal
    +
    `CGAL_VERSION_NR`
    +
    a numerical description of the current release such that more recent +releases have higher number. + +More precisely, it is defined as `1MMmmbiiii`, where `MM` is +the major release number (e.g. 03), `mm` is the minor release +number (e.g. 02), `b` is the bug-fix release number (e.g. 0), +and `iiii` is the internal release number (e.g. 0001). For +public releases, the latter is defined as 1000. Examples: for the +public release 3.2.4 this number is 1030241000; for internal release +3.2-I-1, it is 1030200001. Note that this scheme was modified around +3.2-I-30. +
    +
    `CGAL_VERSION_NUMBER(M,m,b)`
    +
    +a function macro computing the version number macro from the +M.m.b release version. Note that the internal release number is +dropped here. Example: `CGAL_VERSION_NUMBER(3,2,4)` is equal to +1030241000. +
    +
    + +The macro `CGAL_VERSION` is deprecated. It is the same as +`CGAL_VERSION_STR`, but not as a string literal. + +*/ diff --git a/Documentation/doc/Documentation/Preliminaries.txt b/Documentation/doc/Documentation/Preliminaries.txt index 6d03fb0d21d..9f23bbda960 100644 --- a/Documentation/doc/Documentation/Preliminaries.txt +++ b/Documentation/doc/Documentation/Preliminaries.txt @@ -1,130 +1,12 @@ /*! -\page preliminaries Preliminaries +\page preliminaries General Information \cgalAutoToc -\author %CGAL Editorial Board -This chapter lists the licenses -under which the \cgal datastructures and algorithms are distributed. -The chapter further explains how to control inlining, thread safety, -code deprecation, checking of pre- and postconditions, -and how to alter the failure behavior. +The chapter explains some basic features of \cgal such as thread safety, code deprecation, +checking of pre- and postconditions and altering the failure behavior, and how to control inlining. -\section licenseIssues License Issues - -\cgal is distributed under a dual license scheme, that is under the -\sc{Gpl}/\sc{Lgpl} open source license, as well as under commercial licenses. - -\cgal consists of different parts covered by different open source licenses. -In this section we explain the essence of the different licenses, as well as -the rationale why we have chosen them. - -The fact that \cgal is Open Source software does not mean that users are free -to do whatever they want with the software. Using the software means to accept -the license, which has the status of a contract between the user and the owner -of the \cgal software. - -\subsection licensesGPL GPL - -The \sc{Gpl} is an Open Source license that, if you distribute your software -based on \sc{Gpl}ed \cgal data structures,you are obliged to distribute the -source code of your software under the \sc{Gpl}. - -The exact license terms can be found at the Free Software Foundation -web site: http://www.gnu.org/copyleft/gpl.html. - -\subsection licensesLGPL LGPL - -The \sc{Lgpl} is an Open Source license that obliges you to distribute -modifications you make on \cgal software accessible to the users. -In contrast to the \sc{Gpl}, there is no obligation to make the source -code of software you build on top of \sc{Lgpl}ed \cgal data structures - -The exact license terms can be found at the Free Software Foundation web site: -http://www.gnu.org/copyleft/lesser.html. - -\subsection licensesRationale Rationale of the License Choice - -We have chosen the \sc{Gpl} and the \sc{Lgpl} as they are well known -and well understood open source licenses. The former restricts -commercial use, and the latter allows to promote software as de facto standard -so that people can build new higher level data structures on top. - -Therefore, the packages forming a foundation layer are distributed under -the \sc{Lgpl}, and the higher level packages under the \sc{Gpl}. -The package overview states for each package under which license -it is distributed. - -\subsection licensesCommercial Commercial Licenses - -Users who cannot comply with the Open Source license terms can buy individual -data structures under various commercial licenses from GeometryFactory: -http://www.geometryfactory.com/. License fees paid by commercial -customers are reinvested in R\&D performed by the \cgal project partners, -as well as in evolutive maintenance. - -\subsection licenseCheck License Checking - -Users who have a commercial license for specific packages can check that -they do not accidentally use packages for which they do not have a commercial -license. The same holds for users who want to be sure that they only -use packages of \cgal released under the \sc{Lgpl}. - -To enable checking, users have to define one of the following macros: - -| Macro Name | Effect | -| :--------- | :------ | -| `CGAL_LICENSE_WARNING` | get a warning during the compilation | -| `CGAL_LICENSE_ERROR` | get an error during the compilation | - - -The license checking is not a mean to control users as no information -is collected or transmitted. - - - -\section markingSpecialFunctionality Marking of Special Functionality - -In this manual you will encounter sections marked as follows. - - -\subsection advanced_features Advanced Features - -Some functionality is considered more advanced, for example because it is -relatively low-level, or requires special care to be properly used. - -\cgalAdvancedBegin -Such functionality is identified this way in the manual. -\cgalAdvancedEnd - -\subsection debugging_support Debugging Support Features - -Usually related to advanced features that for example may not guarantee -class invariants, some functionality is provided that helps debugging, -for example by performing invariants checks on demand. - -\cgalDebugBegin -Such functionality is identified this way in the manual. -\cgalDebugEnd - -\subsection deprecated_code Deprecated Code - -Sometimes, the \cgal project decides that a feature is deprecated. This means -that it still works in the current release, but it will be removed in the next, -or a subsequent release. This can happen when we have found a better way to do -something, and we would like to reduce the maintenance cost of \cgal at some -point in the future. There is a trade-off between maintaining backward -compatibility and implementing new features more easily. - -In order to help users manage the changes to apply to their code, we attempt -to make \cgal code emit warnings when deprecated code is used. This can be -done using some compiler specific features. Those warnings can be disabled -by defining the macro `CGAL_NO_DEPRECATION_WARNINGS`. On top of this, we -also provide a macro, `CGAL_NO_DEPRECATED_CODE`, which, when defined, -disables all deprecated features. This allows users to easily test if their -code relies on deprecated features. - -\deprecated Such functionality is identified this way in the manual. +These concepts are further developed in the \ref dev_manual. \section Preliminaries_namespace Namespace CGAL @@ -154,19 +36,10 @@ defined, unless `BOOST_HAS_THREADS` or `_OPENMP` is defined. It is possible to force its definition on the command line, and it is possible to prevent its default definition by setting `CGAL_HAS_NO_THREADS` from the command line. +\section Preliminaries_cc0x C++14 Support -\section Preliminaries_cc0x C++11 Support - -\cgal is based on the \CC standard released in 1998 (and later refined in 2003). -A new major version of this standard has been released, and is refered to as \cpp11. -Some compilers and standard library implementations already provide some of the -functionality of this new standard, as a preview. For example, \gcc provides -a command-line switch (`-std=c++0x` or or `-std=c++11` depending on the compiler version) -which enables some of those features. - -\cgal attempts to support this mode progressively, and already makes use of -some of these features if they are available, although no extensive support has -been implemented yet. +After being based on the \CC standard released in 1998 (and later refined in 2003) for a long time, +\cgal is now based on a newer major version of the standard, C++14. \section Preliminaries_functor Functor Return Types @@ -182,43 +55,9 @@ return type of calling the functor with an argument of type Much of the \cgal code contains assert statements for preconditions, and postconditions of functions as well as in the code. These assertions can be switched on and off per package -and the user can change the error behaviour. For details see Section \ref secchecks +and the user can change the error behaviour. For details see Section \ref secchecks of Chapter \ref Chapter_STL_Extensions_for_CGAL. -\section seccgal_version Identifying the Version of CGAL - -`` - -Every release of \cgal defines the following preprocessor macros: - -
    -
    `CGAL_VERSION_STR`
    -
    a textual description of the current release (e.g., or 3.3 or 3.2.1 or 3.2.1-I-15) as a string literal
    -
    `CGAL_VERSION_NR`
    -
    a numerical description of the current release such that more recent -releases have higher number. - -More precisely, it is defined as `1MMmmbiiii`, where `MM` is -the major release number (e.g. 03), `mm` is the minor release -number (e.g. 02), `b` is the bug-fix release number (e.g. 0), -and `iiii` is the internal release number (e.g. 0001). For -public releases, the latter is defined as 1000. Examples: for the -public release 3.2.4 this number is 1030241000; for internal release -3.2-I-1, it is 1030200001. Note that this scheme was modified around -3.2-I-30. -
    -
    `CGAL_VERSION_NUMBER(M,m,b)`
    -
    -a function macro computing the version number macro from the -M.m.b release version. Note that the internal release number is -dropped here. Example: `CGAL_VERSION_NUMBER(3,2,4)` is equal to -1030241000. -
    -
    - -The macro `CGAL_VERSION` is deprecated. It is the same as -`CGAL_VERSION_STR`, but not as a string literal. - \section Preliminaries_flags Compile-time Flags to Control Inlining Making functions inlined can, at times, improve the efficiency of your code. diff --git a/Documentation/doc/Documentation/Third_party.txt b/Documentation/doc/Documentation/Third_party.txt new file mode 100644 index 00000000000..e0220b92691 --- /dev/null +++ b/Documentation/doc/Documentation/Third_party.txt @@ -0,0 +1,289 @@ +/*! + +\page thirdparty Essential and Optional Third Party Dependencies +\cgalAutoToc + +\section seccompilers Supported Compilers + +In order to build a program using \cgal, you need a \cpp compiler +supporting C++14 or later. +\cgal \cgalReleaseNumber is supported (continuously tested) for the following compilers/operating systems: + +| Operating System | Compiler | +| :------- | :--------------- | +| Linux | \sc{Gnu} `g++` 6.3 or later\cgalFootnote{`http://gcc.gnu.org/`} | +| | `Clang` \cgalFootnote{`http://clang.llvm.org/`} compiler version 8.0.0 | +| \sc{MS} Windows | \sc{Gnu} `g++` 6.3 or later\cgalFootnote{`http://gcc.gnu.org/`} | +| | \sc{MS} Visual `C++` 14.0, 15.9, 16.0 (\sc{Visual Studio} 2015, 2017, and 2019)\cgalFootnote{`https://visualstudio.microsoft.com/`} | +| MacOS X | \sc{Gnu} `g++` 6.3 or later\cgalFootnote{`http://gcc.gnu.org/`} | +| | Apple `Clang` compiler versions 7.0.2 and 10.0.1 | + + + +Older versions of the above listed compilers might work, but no guarantee is provided. + +\section seccmake CMake +Version 3.1 or later + +In order to configure and build the \cgal examples, demos, or libraries, +you need CMake, a cross-platform "makefile generator". + +This manual explains only the features of CMake which are needed in order to build \cgal. +Please refer to the CMake documentation +for further details. + +\attention Recent versions of CMake are needed for the most recent versions of MS Visual C++. +Please refer to CMake's documentation for further information, for example +here +for Visual Studio 16 2019. + +\section secessential3rdpartysoftware Essential Third Party Libraries + +The focus of \cgal is on geometry, and we rely on other +highly specialized libraries and software for non-geometric issues, +for instance for numeric solvers or visualization. We first list software +that is essential to most of \cgal, and must therefore be found during the configuration of \cgal. +The page \ref configurationvariables lists CMake and environment variables which can be used to specify +the location of third-party software during configuration. + +\subsection thirdpartystl Standard Template Library (STL) + +\cgal heavily uses the \stl, and in particular adopted many of its design ideas. You can find online +documentation for the \stl at various web sites, for instance, +`https://en.cppreference.com `, +or `https://msdn.microsoft.com`. + +The \stl comes with the compiler, and as such no installation is required. + +\subsection thirdpartyBoost Boost +Version 1.57 or later + +The \sc{Boost} libraries are a set of portable C++ source libraries. +Most of \sc{Boost} libraries are header-only, but a few of them need to be compiled or +installed as binaries. + +\cgal only requires the headers of the \sc{Boost} libraries, but some demos and examples +depend on the binary library `Boost.Program_options`. +As an exception and because of a bug in the \gcc compiler about the \cpp 11 +keyword `thread_local`, the `CGAL_Core` library always requires +the binary library `Boost.Thread` if the \gcc compiler version 9.0 or +earlier is used. + +In case the \sc{Boost} libraries are not installed on your system already, you +can obtain them from `https://www.boost.org/`. +For Visual C++ you can download precompiled libraries +from `https://sourceforge.net/projects/boost/files/boost-binaries/`. + +As there is no canonical directory for where to find \sc{Boost} on Windows, +we recommend that you define the environment variable +`BOOST_ROOT` and set it to where you have installed \sc{Boost}, e.g., `C:\boost\boost_1_69_0`. + +\subsection thirdpartyMPFR GNU Multiple Precision Arithmetic (GMP) and GNU Multiple Precision Floating-Point Reliably (MPFR) Libraries +GMP Version 4.2 or later, MPFR Version 2.2.1 or later + +The components `libCGAL`, `libCGAL_Core`, and `libCGAL_Qt5` require +\sc{Gmp} and \sc{Mpfr} which are libraries for multi precision integers and rational numbers, +and for multi precision floating point numbers. + +\cgal combines floating point arithmetic with exact arithmetic +in order to be efficient and reliable. \cgal has a built-in +number type for that, but \sc{Gmp} and \sc{Mpfr} provide a faster +solution, and we recommend to use them. + +These libraries can be obtained from `https://gmplib.org/` +and `https://www.mpfr.org/`. +Since Visual \cpp is not properly supported by the \sc{Gmp} and \sc{Mpfr} projects, +we provide precompiled versions of \sc{Gmp} and \sc{Mpfr}, which can be downloaded with the installer +`CGAL-\cgalReleaseNumber``-Setup.exe`. + +\section secoptional3rdpartysoftware Optional Third Party Libraries + +Optional 3rd party software can be used by \cgal for various reasons: +certain optional libraries might be required to build examples and +demos shipped with \cgal or to build your own project using \cgal; +another reason is to speed up basic tasks where specialized libraries can be faster than the default +version shipped with \cgal. +The page \ref configurationvariables lists CMake and environment variables which can be used to specify +the location of third-party software during configuration. + +\subsection thirdpartyQt Qt5 +Version 5.9.0 or later + +Qt is a cross-platform application and UI framework. + +The component libCGAL_Qt5 is essential to run the \cgal demos and basic viewers. +It requires \sc{Qt}5 installed on your system. +In case \sc{Qt} is not yet installed on your system, you can download +it from `https://www.qt-project.org/`. + +The exhaustive list of \sc{Qt}5 components used in demos is: +`Core`, `Gui`, `Help`, `OpenGL`, `Script`, `ScriptTools`, `Svg`, `Widgets`, +`qcollectiongenerator` (with `sqlite` driver plugin), and `Xml`. + +\subsection thirdpartyEigen Eigen +Version 3.1 or later + +\sc{Eigen} is a `C++` template library for linear algebra. \sc{Eigen} supports all +matrix sizes, various matrix decomposition methods and sparse linear solvers. + +In \cgal, \sc{Eigen} is used in many packages such as \ref PkgPoissonSurfaceReconstruction3 +or \ref PkgJetFitting3, providing sparse linear solvers and singular value decompositions. +A package dependency over \sc{Eigen} is marked on the +Package Overview page. + +The \sc{Eigen} web site is `http://eigen.tuxfamily.org`. + +\subsection thirdpartyLeda LEDA +Version 6.2 or later + +\leda is a library of efficient data structures and +algorithms. Like \sc{Core}, \leda offers a real number data type. + +In \cgal this library is optional, and its number types can +be used as an alternative to \sc{Gmp}, \sc{Mpfr}, and \sc{Core}. + +Free and commercial editions of \leda are available from `https://www.algorithmic-solutions.com`. + +\subsection thirdpartyMPFI Multiple Precision Floating-point Interval (MPFI) +Version 1.4 or later + +\sc{Mpfi} provides arbitrary precision interval arithmetic with intervals +represented using \sc{Mpfr} reliable floating-point numbers. +It is based on the libraries \sc{Gmp} and \sc{Mpfr}. +In the setting of \cgal, this library is +optional: it is used by some models of the +\ref PkgAlgebraicKernelD "Algebraic Kernel". + +\sc{Mpfi} can be downloaded from `https://mpfi.gforge.inria.fr/`. + +\subsection thirdpartyRS3 RS and RS3 + +\sc{Rs} (Real Solutions) is devoted to the study of the real roots of +polynomial systems with a finite number of complex roots (including +univariate polynomials). In \cgal, \sc{Rs} is used by one model of the +\ref PkgAlgebraicKernelD "Algebraic Kernel". + +\sc{Rs} is freely distributable for non-commercial use. You can download it +from `http://vegas.loria.fr/rs/`. Actually, the \sc{Rs} package also includes \sc{Rs3}, the +successor of \sc{Rs}, which is used in conjunction with it. + +The libraries \sc{Rs} and \sc{Rs3} need \sc{Mpfi}, which can be downloaded from +`https://mpfi.gforge.inria.fr/`. + +\subsection thirdpartyNTL NTL +Version 5.1 or later + +\sc{Ntl} provides data structures and algorithms for signed, arbitrary +length integers, and for vectors, matrices, and polynomials over the +integers and over finite fields. The optional library \sc{Ntl} is used by \cgal +to speed up operations of the Polynomial package, such as GCDs. It is recommended to install \sc{Ntl} with support from \sc{Gmp}. + +\sc{Ntl} can be downloaded from `https://www.shoup.net/ntl/`. + +\subsection thirdpartyESBTL ESBTL + +The \sc{Esbtl} (Easy Structural Biology Template Library) is a library that allows +the handling of \sc{Pdb} data. + +In \cgal, the \sc{Esbtl} is used in an example of the \ref PkgSkinSurface3 package. + +It can be downloaded from `http://esbtl.sourceforge.net/`. + +\subsection thirdpartyTBB Intel TBB + +\sc{Tbb} (Threading Building Blocks) is a library developed by Intel Corporation for writing software +programs that take advantage of multi-core processors. + +In \cgal, \sc{Tbb} is used by the packages that offer parallel code. + +The \sc{Tbb} web site is `https://www.threadingbuildingblocks.org`. + +\subsection thirdpartyLASlib LASlib + +\sc{LASlib} is a `C++` library for handling LIDAR data sets stored in +the LAS format (or the compressed LAZ format). + +In \cgal, \sc{LASlib} is used to provide input and output functions in +the \ref PkgPointSetProcessing3 package. + +The \sc{LASlib} web site is `https://rapidlasso.com/lastools/`. \sc{LASlib} +is usually distributed along with LAStools: for simplicity, \cgal +provides a fork with a +CMake based install procedure. + +\subsection thirdpartyOpenCV OpenCV + +\sc{OpenCV} (Open Computer Vision) is a library designed for computer +vision, computer graphics and machine learning. + +In \cgal, \sc{OpenCV} is used by the \ref PkgClassification package. + +The \sc{OpenCV} web site is `https://opencv.org/`. + +\subsection thirdpartyTensorFlow TensorFlow + +\sc{TensorFlow} is a library designed for machine learning and deep learning. + +In \cgal, the C++ API of \sc{TensorFlow} is used by the \ref +PkgClassification package for neural network. The C++ API can be +compiled using CMake: it is distributed as part of the official +package and is located in `tensorflow/contrib/cmake`. Be sure to +enable and compile the following targets: + +- `tensorflow_BUILD_ALL_KERNELS` +- `tensorflow_BUILD_PYTHON_BINDINGS` +- `tensorflow_BUILD_SHARED_LIB`. + +The \sc{TensorFlow} web site is `https://www.tensorflow.org/`. + +\subsection thirdpartyMETIS METIS +Version 5.1 or later + +\sc{METIS} is a library developed by the Karypis Lab +and designed to partition graphs and produce fill-reducing matrix orderings. + +\cgal offers wrappers around some of the methods of the \sc{METIS} library +to allow the partitioning of graphs that are models of the concepts of the +Boost Graph Library, +and, by extension, of surface meshes (see Section \ref BGLPartitioning of the package \ref PkgBGL). + +More information is available on the METIS library +at `http://glaros.dtc.umn.edu/gkhome/metis/metis/overview`. + +\subsection thirdpartyzlib zlib + +\sc{zlib} is a data compression library, and is essential for the component libCGAL_ImageIO. + +In \cgal, this library is used in the examples of the \ref PkgSurfaceMesher3 package. + +If it is not already on your system, +for instance, on Windows, you can download it from `https://www.zlib.net/`. + +\subsection thirdpartyCeres Ceres Solver + +\sc{Ceres} is an open source C++ library for modeling and solving large, complicated optimization problems. + +In \cgal, \sc{Ceres} is used by the \ref PkgPolygonMeshProcessingRef package for mesh smoothing, which +requires solving complex non-linear least squares problems. + +Visit the official website of the library at `ceres-solver.org` +for more information. + +\subsection thirdpartyGLPK GLPK + +\sc{GLPK} (GNU Linear Programming Kit) is a library for solving linear programming (LP), mixed integer programming (MIP), and other related problems. + +In \cgal, \sc{GLPK} provides an optional linear integer program solver in the \ref PkgPolygonalSurfaceReconstruction package. + +The \sc{GLPK} web site is `https://www.gnu.org/software/glpk/`. + +\subsection thirdpartySCIP SCIP + +\sc{SCIP} (Solving Constraint Integer Programs) is currently one of the fastest open source solvers for mixed integer programming (MIP) and mixed integer nonlinear programming (MINLP). + +In \cgal, \sc{SCIP} provides an optional linear integer program solver in the \ref PkgPolygonalSurfaceReconstruction package. + +The \sc{SCIP} web site is `http://scip.zib.de/`. + +*/ diff --git a/Documentation/doc/Documentation/Tutorials/Tutorial_hello_world.txt b/Documentation/doc/Documentation/Tutorials/Tutorial_hello_world.txt index e90944007da..f90dbe3d5b5 100644 --- a/Documentation/doc/Documentation/Tutorials/Tutorial_hello_world.txt +++ b/Documentation/doc/Documentation/Tutorials/Tutorial_hello_world.txt @@ -15,24 +15,23 @@ namespace CGAL { \cgalAutoToc \author %CGAL Editorial Board -This tutorial is for the %CGAL newbie, who knows C++ and has +This tutorial is for the %CGAL newbie, who knows \CC and has a basic knowledge of geometric algorithms. The first section shows how to define a point and segment class, and how to apply geometric predicates on them. The section further raises the awareness that that there are serious issues when using -floating point numbers for coordinates. In the second section -you see how the 2D convex hull function gets its input -and where it puts the result. The third section shows what -we mean with a \em Traits class, and the fourth section explains -the notion of \em concept and \em model. +floating point numbers for coordinates. In the second section, +you will meet a typical \cgal function, which computes a 2D convex hull. +The third section shows what we mean with a \em Traits class, +and the fourth section explains the notion of \em concept and \em model. \section intro_Three Three Points and One Segment -In this first example we see how to construct some points -and a segment, and we perform some basic operations on them. - -All \cgal header files are in the subdirectory `include/CGAL`. All \cgal -classes and functions are in the namespace `CGAL`. +In this first example, we demonstrate how to construct some points +and a segment, and perform some basic operations on them. + +All \cgal header files are in the subdirectory `include/CGAL`. All \cgal +classes and functions are in the namespace `CGAL`. Classes start with a capital letter, global function with a lowercase letter, and constants are all uppercase. The dimension of an object is expressed with a suffix. @@ -42,24 +41,20 @@ The kernel we have chosen for this first example uses `double` precision floating point numbers for the %Cartesian coordinates of the point. Besides the types we see \em predicates like the orientation test for -three points, and \em constructions like the distance and midpoint +three points, and \em constructions like the distance and midpoint computation. A predicate has a discrete set of possible results, whereas a construction produces either a number, or another geometric entity. - - \cgalExample{Kernel_23/points_and_segment.cpp} - - To do geometry with floating point numbers can be surprising as the next example shows. \cgalExample{Kernel_23/surprising.cpp} -When reading the code, we would assume that it prints three times "collinear". -However we obtain: +Reading the code, we could assume that it would print three times "collinear". +However the actual output is the following: \verbatim not collinear @@ -67,19 +62,18 @@ not collinear collinear \endverbatim - -As the fractions are not representable as double precision number -the collinearity test will internally compute a determinant of a 3x3 matrix +This is because these fractions are not representable as double-precision numbers, +and the collinearity test will internally compute a determinant of a 3x3 matrix which is close but not equal to zero, and hence the non collinearity for the -first two tests. +first two tests. Something similar can happen with points that perform a left turn, but due to rounding errors during the determinant computation, it seems that the points are collinear, or perform a right turn. -If you need that the numbers get interpreted at their full precision -you can use a \cgal kernel that performs exact predicates and -extract constructions. +If you must ensure that your numbers get interpreted at their full precision +you can use a \cgal kernel that performs exact predicates and +extract constructions. \cgalExample{Kernel_23/exact.cpp} @@ -95,7 +89,7 @@ In the first block the points are still not collinear, for the simple reason that the coordinates you see as text get turned into floating point numbers. When they are then turned into arbitrary precision rationals, they exactly -represent the floating point number, but not the text. +represent the floating point number, but not the text! This is different in the second block, which corresponds to reading numbers from a file. The arbitrary precision @@ -106,67 +100,63 @@ In the third block you see that constructions as midpoint constructions are exact, just as the name of the kernel type suggests. - -In many cases you will have floating point numbers that are "exact", +In many cases, you will have floating point numbers that are "exact", in the sense that they were computed by some application or obtained -from a sensor. They are not the string "0.1" or computed on the +from a sensor. They are not the string "0.1" or computed on the fly as "1.0/10.0", but a full precision floating point number. -If they are input to an algorithm that makes no constructions -you can use a kernel that provides exact predicates, but inexact -constructions. An example for that is the convex hull algorithm +If they are input to an algorithm that makes no constructions, +you can use a kernel that provides exact predicates but inexact +constructions. One such example is the convex hull algorithm which we will see in the next section. -The output is a subset of the input, and the algorithm -only compares coordinates and performs orientation tests. +The output is a subset of the input, and the algorithm +only compares coordinates and performs orientation tests. At a first glance the kernel doing exact predicates and constructions seems to be the perfect choice, but performance requirements -or limited memory resources make that it is not. Also for many +or limited memory resources make that it is not. Furthermore, for many algorithms it is irrelevant to do exact constructions. For example a surface mesh simplification algorithm that iteratively contracts -an edge, by collapsing it to the midpoint of the edge. - -Most \cgal packages explain what kind of kernel they need or support. +an edge by collapsing it to the midpoint of the edge. +Most \cgal packages explain which kind of kernel they should use or support. \section intro_convex_hull The Convex Hull of a Sequence of Points All examples in this section compute the 2D convex hull of a set of points. -We show that algorithms get their input as a begin/end iterator pair -denoting a range of points, and that they write the result, in the -example the points on the convex hull, into an output iterator. - +We show that algorithms get their input as a begin/end iterator pair +denoting a range of points, and that they write the result (in the +example the points on the convex hull) into an output iterator. \subsection intro_array The Convex Hull of Points in a Built-in Array -In the first example we have as input an array of five points. -As the convex hull of these points is a subset of the input +In the first example, we have as input an array of five points. +As the convex hull of these points is a subset of the input, it is safe to provide an array for storing the result which has the same size. \cgalExample{Convex_hull_2/array_convex_hull_2.cpp} - We saw in the previous section that \cgal comes -with several kernels. As the convex hull algorithm only makes +We have seen in the previous section that \cgal comes +with several kernels. Since the convex hull algorithm only makes comparisons of coordinates and orientation tests of input points, -we can choose a kernel that provides exact predicates, but no +we can choose a kernel that provides exact predicates, but no exact geometric constructions. The convex hull function takes three arguments, the start -and past-the-end pointer for the input, and the start pointer of the +and past-the-end pointer for the input, and the start pointer of the array for the result. The function returns the pointer into the result array just behind the last convex hull point written, so the pointer difference tells us how -many points are on the convex hull. - +many points are on the convex hull. \subsection intro_vector The Convex Hull of Points in a Vector -In the second example we replace the built-in array -by a `std::vector` of the Standard Template Library. +In the second example, we replace the built-in array +by an `std::vector` of the Standard Template Library. \cgalExample{Convex_hull_2/vector_convex_hull_2.cpp} -We put some points in the vector calling the `push_back()` +We put some points in the vector, calling the `push_back()` method of the `std::vector` class. We then call the convex hull function. The first two arguments, @@ -175,8 +165,8 @@ generalization of pointers: they can be dereferenced and incremented. The convex hull function is *generic* in the sense that it takes as input whatever can be dereferenced and incremented. -The third argument is where the result gets written to. In the -previous example we provided a pointer to allocated memory. The +The third argument is where the result gets written to. In the +previous example we provided a pointer to allocated memory. The generalization of such a pointer is the *output iterator*, which allows to increment and assign a value to the dereferenced iterator. In this example we start with an empty vector which grows as needed. @@ -185,34 +175,32 @@ iterator generated by the helper function `std::back_inserter(result)`. This output iterator does nothing when incremented, and calls `result.push_back(..)` on the assignment. - If you know the \stl, the Standard Template Library, the above makes perfect sense, as this is the way the \stl decouples algorithms from containers. If you don't know the \stl, you maybe better first familiarize yourself with its basic ideas. - \section intro_traits About Kernels and Traits Classes -In this section we show how we express the requirements that must +In this section, we show how we express the requirements that must be fulfilled in order that a function like `convex_hull_2()` can be used with an arbitrary point type. If you look at the manual page of the function `convex_hull_2()` and the other 2D convex hull algorithms, you see that they come in two -versions. In the examples we have seen so far the function that takes two +versions. In the examples we have seen so far, the function that takes two iterators for the range of input points and an output iterator for writing the result to. The second version has an additional template parameter `Traits`, and an additional parameter of this type. \code{.cpp} template -OutputIterator +OutputIterator convex_hull_2(InputIterator first, InputIterator beyond, OutputIterator result, const Traits & ch_traits) -\endcode +\endcode What are the geometric primitives a typical convex hull algorithm uses? Of course, this depends on the algorithm, so let us consider @@ -238,10 +226,8 @@ test, while `Less_xy_2` is used for sorting the points. The requirements these types have to satisfy are documented in full with the concept `ConvexHullTraits_2`. - - The types are regrouped for a simple reason. The alternative would -have been a rather lengthy function template, and an even longer +have been a rather lengthy function template, and an even longer function call. \code{.cpp} @@ -258,7 +244,7 @@ this template parameter? And why do we have template parameters at all? To answer the first question, any model of the %CGAL concept `Kernel` provides what is required by the concept `ConvexHullTraits_2`. -As for the second question, think about an application where we want to +As for the second question, think about an application where we want to compute the convex hull of 3D points projected into the `yz` plane. Using the class `Projection_traits_yz_3` this is a small modification of the previous example. @@ -277,15 +263,14 @@ traits object to store state, for example if the projection plane was given by a direction, which is hardwired in the class `Projection_traits_yz_3`. - \section intro_concept Concepts and Models -In the previous section we wrote that "Any model of the CGAL concept -Kernel provides what is required by the concept ConvexHullTraits_2". +In the previous section, we wrote that "Any model of the CGAL concept +Kernel provides what is required by the concept `ConvexHullTraits_2`. A \em concept is a set of requirements on a type, namely that it has certain nested types, certain member functions, or comes with certain -free functions that take the type as it. A \em model of a concept +free functions that take the type as it. A \em model of a concept is a class that fulfills the requirements of the concept. Let's have a look at the following function. @@ -299,30 +284,30 @@ duplicate(T t) } \endcode -If you want to instantiate this function with a class `C` this -class must at least provide a copy constructor, and we -say that class `C` must be a model of `CopyConstructible`. +If you want to instantiate this function with a class `C`, this +class must at least provide a copy constructor, and we +say that class `C` must be a model of `CopyConstructible`. A singleton class does not fulfill this requirment. -Another example is the function +Another example is the function: \code{.cpp} -template +template T& std::min(const T& a, const T& b) { return (a `std::iterator_traits` must exist (or the generic template must be applicable). @@ -333,11 +318,9 @@ Tutorial and Reference" by Nicolai M. Josuttis from Addison-Wesley, or "Generic Programming and the STL" by Matthew H. Austern for the \stl and its notion of *concepts* and *models*. -Other resources for \cgal are the rest of the \ref tutorials "tutorials" - and the user support page at -https://www.cgal.org/. +Other resources for \cgal are the rest of the \ref tutorials "tutorials" +and the user support page at https://www.cgal.org/. */ } /* namespace CGAL */ - diff --git a/Documentation/doc/Documentation/Tutorials/Tutorials.txt b/Documentation/doc/Documentation/Tutorials/Tutorials.txt index ac3dd2c9197..aab618e954f 100644 --- a/Documentation/doc/Documentation/Tutorials/Tutorials.txt +++ b/Documentation/doc/Documentation/Tutorials/Tutorials.txt @@ -8,9 +8,7 @@ combined to achieve extensive and complex geometric tasks. The tutorials aim at providing help and ideas on how to use CGAL beyond the simple examples of the User Manual. - - -\section tuto_list List of available tutorials +\section tuto_list List of Available Tutorials - \subpage tutorial_hello_world presents you some short example programs to get a first idea for the look and feel of a program that @@ -19,4 +17,9 @@ User Manual. define what primitives are used by a geometric algorithm, the notions of \em concept and \em model. +\section tuto_examples Package Examples + +Each \cgal package comes with a set of commented examples that illustrate basic features of the package. +See for example Section \ref Triangulation3secexamples of the User Manual of the package \ref PkgTriangulation3. + */ diff --git a/Documentation/doc/Documentation/Usage.txt b/Documentation/doc/Documentation/Usage.txt new file mode 100644 index 00000000000..b1a21d4c121 --- /dev/null +++ b/Documentation/doc/Documentation/Usage.txt @@ -0,0 +1,240 @@ +/*! +\page usage Using %CGAL on Unix (Linux, macOS, ...) +\cgalAutoToc + +Since \cgal version 5.0, \cgal is header-only be default, which means +that there is no need to build \cgal before it can be used. +However, some dependencies of \cgal might still need to be installed. + +\section usage_introduction Quick Start: Compiling a Program using CGAL + +Assuming that you have obtained \cgal through one of the package managers offering \cgal on your platform +(see Section \ref secgettingcgal), you can download \cgal examples ( +CGAL-\cgalReleaseNumber-examples.tar.xz) +and the compilation of an example is as simple as: + + cd $HOME/CGAL-\cgalReleaseNumber/examples/Triangulation_2 # go to an example directory + cmake -DCMAKE_BUILD_TYPE=Release . # configure the examples + make # build the examples + +Compiling your own program is similar: + + cd /path/to/your/program + path/to/cgal/Scripts/scripts/cgal_create_CMakeLists -s your_program + cmake -DCMAKE_BUILD_TYPE=Release . + make + +The script `cgal_create_CMakeLists` and its options are detailed in Section \ref devman_create_cgal_CMakeLists. + +In a less ideal world, you might have to install some required tools and third-party libraries. +This is what this page is about. + +\section secprerequisites Prerequisites + +Using \cgal requires a few core components to be previously installed: +
      +
    • a supported compiler (see Section \ref seccompilers),
    • +
    • \ref seccmake,
    • +
    • \ref thirdpartyBoost,
    • +
    • \ref thirdpartyMPFR.
    • +
    + +Optional third-party software might be required to build examples and demos shipped with \cgal, +or to build your own project using \cgal, see Section \ref secoptional3rdpartysoftware. + +\section secgettingcgal Downloading CGAL + +\cgal can be obtained through different channels. We recommend using a package manager as +this will ensure that all essential third party dependencies are present, and with the correct versions. +You may also download the sources of \cgal directly, but it is then your responsability to independently +acquire these dependencies. + +The examples and demos of \cgal are not included when you install \cgal with a package manager, +and must be downloaded +here. + +\subsection secusingpkgman Using a Package Manager + +On most operating systems, package managers offer \cgal and its essential third party dependencies. + +On macOS, we recommend using of Homebrew in the following way: + + brew install cgal + +On Linux distributions such as `Debian`/`Ubuntu`/`Mint`, use `apt-get` in the following way: + + sudo apt-get install libcgal-dev + +For other distributions or package manager, please consult your respective documentation. + +\subsection secusingwebsite Using CGAL Source Archive + +You can also obtain the \cgal library sources directly from +https://www.cgal.org/download.html. + +Once you have downloaded the file `CGAL-\cgalReleaseNumber``.tar.xz` containing the +\cgal sources, you have to unpack it. Under a Unix-like shell, use the +command: + + tar xf CGAL-\cgalReleaseNumber.tar.xz + +The directory `CGAL-\cgalReleaseNumber` will be created. This directory +contains the following subdirectories: + +| Directory | Contents | +| :------------------------- | :----------| +| `auxiliary` (Windows only) | precompiled \sc{Gmp} and \sc{Mpfr} for Windows | +| `cmake/modules` | modules for finding and using libraries | +| `demo` | demo programs (most of them need \sc{Qt}, geomview or other third-party products) | +| `doc_html` | documentation (HTML) | +| `examples` | example programs | +| `include` | header files | +| `scripts` | some useful scripts (e.g. for creating CMakeLists.txt files) | +| `src` | source files | + +The directories `include/CGAL/CORE` and `src/CGALCore` contain a +distribution of the Core library version 1.7 for +dealing with algebraic numbers. Note that \sc{Core} is not part of \cgal and has its +own license. + +The directory `include/CGAL/OpenNL` contains a distribution of the +Open Numerical Library, +which provides solvers for sparse linear systems, especially designed for the Computer Graphics community. +\sc{OpenNL} is not part of \cgal and has its own license. + +The only documentation shipped within \cgal sources is the present manual. +The \cgal manual can also be accessed online at +`https://doc.cgal.org` +or downloaded separately at +`https://github.com/CGAL/cgal/releases`. + +\section section_headeronly Header-only Usage + +\cgal is a header-only library, and as such +there is no need to even configure it before using it. Programs using \cgal (examples, tests, demos, etc.) +are instead configured using CMake and \cgal will be configured at the same time. + +There is one exception to the last paragraph: if you want to install \cgal header files to +a standard location (such as `/usr/local/include`): + + cmake . + make install + +For more advanced installations, we refer to Section \ref installation_configwithcmake. + +Note that even though \cgal is a header-only library, not all its dependencies +are header-only. The libraries \sc{Gmp} and \sc{Mpfr}, for example, are not +header-only. As such, these dependencies must be built or installed independently. + +\section usage_configuring Configuring your Program + +Before building anything using \cgal you have to choose the compiler/linker, set compiler +and linker flags, specify which third-party libraries you want to use and where they can be found. +Gathering all this information is called configuration. The end of the process is marked +by the generation of a makefile or a Visual \cpp solution and project file that you can use +to build your program. + +CMake maintains configuration parameters in so-called Cmake variables, like the `CMAKE_CXX_COMPILER` +in the example above. These variables are not environment variables but CMake variables. +Some of the CMake variables represent user choices, such as `CMAKE_BUILD_TYPE`, +whereas others indicate the details of a third-party library, such as `Boost_INCLUDE_DIR` +or the compiler flags to use, such as `CMAKE_CXX_FLAGS`. + +The most important CMake variable is the variable `CGAL_DIR`, which will serve to configure \cgal +as you configure your program. + +In a typical installation of dependencies, almost all CMake variables will be set automatically. +The variable `CGAL_DIR` is also generally found when \cgal has been obtained via a package manager. +In the rare event that it has not, the variable `CGAL_DIR` should be set manually to: + +
      +
    • something like `/usr/local/Cellar/cgal/CGAL-\cgalReleaseNumber/lib/cmake/CGAL`, for Brew.
    • +
    • something like `/usr/lib/x86_64-linux-gnu/cmake/CGAL`, for Linux distributions.
    • +
    + +If \cgal has been obtained via other means, `CGAL_DIR` must point to the root directory +of the \cgal source code (either the root of the unpacked release tarball or the root +of the Git working directory). + +It is also strongly recommended to set the build type variable to `Release` for performance reasons +if no debugging is intended. Users should thus run: + + cd CGAL-\cgalReleaseNumber/examples/Triangulation_2 + cmake -DCGAL_DIR=$HOME/CGAL-\cgalReleaseNumber -DCMAKE_BUILD_TYPE=Release . # we are here using a release tarball + +\subsection usage_configuring_cmake_gui Specifying Missing Dependencies + +The configuration process launched above might fail if CMake fails to find +all the required dependencies. This typically happens if you have installed dependencies +at non-standard locations. +Although the command line tool `cmake` accepts CMake variables as arguments of the form +`-D:=`, this is only useful if you already know which variables +need to be explicitly defined. or this reason, the simplest way to manually set the missing variables +is to run the graphical user interface of CMake, `cmake-gui`. + + cd CGAL-\cgalReleaseNumber/examples/Triangulation_2 + cmake-gui . + +After the `CMake` window opens, press 'Configure'. A dialog will pop up and you will have to choose +what shall be generated. After you have made your choice and pressed 'Finish', you will see +the output of configuration tests in the lower portion of the application. +Once these tests are done, you will see many red entries in the upper portion of the application. +Just ignore them, and press 'Configure' again. By now, CMake should have found most required +libraries and have initialized variables. +If red entries are still present, you must provide the necessary information (paths/values). +When all entries have been appropriately filled (and automatically filled values have been adjusted, +if desired) and lines are gray, you are now ready to press 'Generate', +and to exit `cmake-gui` afterwards. + +\cgalAdvancedBegin +You may also decide to solve missing dependencies using the command line tool (which is not recommended). +If so, the page \ref configurationvariables lists variables which can be used to specify +the location of third-party software. +\cgalAdvancedEnd + +If you do not need to debug, you should set the variable `CMAKE_BUILD_TYPE` to `Release`. + +\subsection usage_configuring_external Configuring an External Program + +Running `cmake` (or `cmake-gui`) requires a `CMakeLists.txt` file. This file is automatically provided +for all shipped examples and demos of \cgal. For other programs, CMake can also be used to configure +and build user programs, but one has to provide the corresponding `CMakeLists.txt`. +This script can be generated either manually, or with the help of a shell-script, +see Section \ref devman_create_cgal_CMakeLists. Using this shell-script, +the process of configuring a user's program called `your_program.cpp` amounts to: + + cd /path/to/your/program + path/to/cgal/Scripts/scripts/cgal_create_CMakeLists -s your_program + cmake -DCGAL_DIR=$HOME/CGAL-\cgalReleaseNumber -DCMAKE_BUILD_TYPE=Release . + +Note that the script `cgal_create_CMakeLists` creates a very coarse `CMakeLists.txt` file which +might not properly encode the third party dependencies of your program. Users are advised to look +at the `CMakeLists.txt` files in the example folder(s) of the package that they are using to +learn how to specify their dependencies. + +\subsection usage_configuring_advanced_cmake Advanced Configuration Options + +CMake keeps the variables that a user can manipulate in a so-called CMake cache, a simple text file +named `CMakeCache.txt`, whose entries are of the form `VARIABLE:TYPE=VALUE`. Advanced users can manually +edit this file, instead of going through the interactive configuration session. + +\section usage_building_program Building your Program + +The results of a successful configuration are build files that control the build step. +The nature of the build files depends on the generator used during configuration, but in most cases +they contain several targets, such as all the examples of the Triangulation_2 package. + +In a \sc{Unix}-like environment the default generator produces makefiles. +You can use the `make` command-line tool for the succeeding build step as follows: + + cd CGAL-\cgalReleaseNumber/examples/Triangulation_2 + make # build all the examples of the Triangulation_2 package + +\cgalAdvancedBegin +The build files produced by CMake are autoconfigured. That is, if you change any of the dependencies, +the build step automatically goes all the way back to the configuration step. This way, once the target +has been configured the very first time by invoking cmake, you don't necessarily need to invoke `cmake` +again. Rebuilding will call itself `cmake` and re-generate the build file whenever needed. +\cgalAdvancedEnd + +*/ diff --git a/Documentation/doc/Documentation/advanced/Configuration_variables.txt b/Documentation/doc/Documentation/advanced/Configuration_variables.txt new file mode 100644 index 00000000000..1bebdc5ddd7 --- /dev/null +++ b/Documentation/doc/Documentation/advanced/Configuration_variables.txt @@ -0,0 +1,353 @@ +/*! + +\page configurationvariables Summary of %CGAL's Configuration Variables +\cgalAutoToc + +\cgalAdvancedBegin +This page lists CMake variables which you can use to help CMake find missing dependencies +while using the command line. We however recommend using the graphical interface (`cmake-gui`). +\cgalAdvancedEnd + +\section installation_summary Summary of CGAL's Configuration Variables + +Most configuration variables are not environment variables but +CMake variables. They are given in the command line to CMake +via the `-D` option, or passed from the interactive interface +of `cmake-gui`. Unless indicated differently, all the variables +summarized below are CMake variables. + +\subsection installation_component_selection Component Selection + +The following boolean variables indicate which \cgal components to +configure and build. Their values can be ON or OFF. + + +| Variable | %Default Value | +| :------- | :--------------- | +| `WITH_examples` | OFF | +| `WITH_demos` | OFF | +| `WITH_CGAL_Core` | ON | +| `WITH_CGAL_Qt5` | ON | +| `WITH_CGAL_ImageIO` | ON | + +\subsection installation_flags Compiler and Linker Flags + +The following variables specify compiler and linker flags. Each variable holds a +space-separated list of command-line switches for the compiler and linker and +their default values are automatically defined by CMake based on the target platform. + +Have in mind that these variables specify a list of flags, not just one +single flag. If you provide your own definition for a variable, you will entirely override +the list of flags chosen by CMake for that particular variable. + +The variables that correspond to both debug and release builds are always +used in conjunction with those for the specific build type. + + +| Program | Both Debug and Release | Release Only | Debug Only | +| :------ | :---------------------- | :------------- | :----------- | +| C++ Compiler | `CMAKE_CXX_FLAGS` | `CMAKE_CXX_FLAGS_RELEASE` | `CMAKE_CXX_FLAGS_DEBUG` | +| Linker (shared libs) | `CMAKE_SHARED_LINKER_FLAGS` | `CMAKE_SHARED_LINKER_FLAGS_RELEASE` | `CMAKE_SHARED_LINKER_FLAGS_DEBUG` | +| Linker (static libs) | `CMAKE_MODULE_LINKER_FLAGS` | `CMAKE_MODULE_LINKER_FLAGS_RELEASE` | `CMAKE_MODULE_LINKER_FLAGS_DEBUG` | +| Linker (programs) | `CMAKE_EXE_LINKER_FLAGS` | `CMAKE_EXE_LINKER_FLAGS_RELEASE` | `CMAKE_EXE_LINKER_FLAGS_DEBUG`| + + +\subsection installation_additional_flags Additional Compiler and Linker Flags + +The following variables can be used to add flags without overriding the ones +defined by cmake. + + +| Program | Both Debug and Release | Release Only | Debug Only | +| :------ | :---------------------- | :------------- | :----------- | +| C++ Compiler | `CGAL_CXX_FLAGS` | `CGAL_CXX_FLAGS_RELEASE` | `CGAL_CXX_FLAGS_DEBUG` | +| Linker (shared libs) | `CGAL_SHARED_LINKER_FLAGS` | `CGAL_SHARED_LINKER_FLAGS_RELEASE` | `CGAL_SHARED_LINKER_FLAGS_DEBUG` | +| Linker (static libs) | `CGAL_MODULE_LINKER_FLAGS` | `CGAL_MODULE_LINKER_FLAGS_RELEASE` | `CGAL_MODULE_LINKER_FLAGS_DEBUG` | +| Linker (programs) | `CGAL_EXE_LINKER_FLAGS` | `CGAL_EXE_LINKER_FLAGS_RELEASE` | `CGAL_EXE_LINKER_FLAGS_DEBUG` | + +\subsection installation_misc Miscellaneous Variables + +Note that the default build type is `Debug`, which should only be used to debug +and will serverly limit performances. + +| Variable | Description | Type | %Default Value | +| :- | :- | :- | :- | +| `CMAKE_BUILD_TYPE` | Indicates type of build. Possible values are 'Debug' or 'Release' | CMake | | +| `CMAKE_INSTALL_PREFIX`| Installation directory path | CMake | Debug | +| `CMAKE_C_COMPILER` | Full-path to the executable corresponding to the C compiler to use. | CMake | platform-dependent | +| `CMAKE_CXX_COMPILER` | Full-path to the executable corresponding to the C++ compiler to use. | CMake | platform-dependent | +| `CXX` | Idem | Environment | Idem | +| `BUILD_SHARED_LIBS` | Whether to build shared or static libraries. | CMake | TRUE | + +\subsection installation_variables_building Variables Used Only When Building Programs (Such as Demos or Examples) + + +| Variable | Description | Type | %Default Value | +| :- | :- | :- | :- | +| `CGAL_DIR` | Full-path to the binary directory where \cgal was configured |Either CMake or Environment | none | + + +\subsection installation_variables_third_party Variables Providing Information About 3rd-Party Libraries +\anchor sec3partysoftwareconfig + +The following variables provide information about the availability and +location of the 3rd party libraries used by \cgal. CMake automatically +searches for dependencies so you need to specify these variables if +CMake was unable to locate something. This is indicated by a value ending in +`NOTFOUND`. + +Since 3rd-party libraries are system wide, many of the CMake variables listed below can alternatively +be given as similarly-named environment variables instead. Keep in mind that you must provide one or the +other but never both. + +\subsection installation_boost Boost Libraries + +In most cases, if \sc{Boost} is not automatically found, setting the `BOOST_ROOT` +variable is enough. If it is not, you can specify the header and library +directories individually. You can also provide the full pathname to a specific compiled library +if it cannot be found in the library directory or its name is non-standard. + +By default, when \sc{Boost} binary libraries are needed, the shared versions +are used if present. You can set the variable +`CGAL_Boost_USE_STATIC_LIBS` to `ON` if you want to link +with static versions explicitly. + +On Windows, if you link with \sc{Boost} shared libraries, you must ensure that +the `.dll` files are found by the dynamic linker, at run time. +For example, you can add the path to the \sc{Boost} `.dll` to the +`PATH` environment variable. + +| Variable | Description | Type | +| :- | :- | :- | +| `BOOST_ROOT`\cgalFootnote{The environment variable can be spelled either `BOOST_ROOT` or `BOOSTROOT`} | Root directory of your \sc{Boost} installation | Either CMake or Environment | +| `Boost_INCLUDE_DIR` | Directory containing the `boost/version.hpp` file | CMake | +| `BOOST_INCLUDEDIR` | Idem | Environment | +| `Boost_LIBRARY_DIRS` | Directory containing the compiled \sc{Boost} libraries | CMake | +| `BOOST_LIBRARYDIR` | Idem | Environment | +| `Boost_(xyz)_LIBRARY_RELEASE` | Full pathname to a release build of the compiled 'xyz' \sc{Boost} library | CMake | +| `Boost_(xyz)_LIBRARY_DEBUG` | Full pathname to a debug build of the compiled 'xyz' \sc{Boost} library | CMake | + + +\subsection installation_gmp GMP and MPFR Libraries + +Under Windows, auto-linking is used, so only the directory +containing the libraries is needed and you would specify `GMP|MPFR_LIBRARY_DIR` rather than +`GMP|MPFR_LIBRARIES`. On the other hand, under Linux the actual library filename is needed. +Thus you would specify `GMP|MPFR_LIBRARIES`. In no case you need to specify both. + +\cgal uses both \sc{Gmp} and \sc{Mpfr} so both need to be supported. If either of them is unavailable the +usage of \sc{Gmp} and of \sc{Mpfr} will be disabled. + + +| Variable | Description | Type | +| :- | :- | :- | +| `CGAL_DISABLE_GMP` | Indicates whether to search and use \sc{Gmp}/\sc{Mpfr} or not | CMake | +| `GMP_DIR` | Directory of \sc{Gmp} default installation | Environment | +| `GMP_INCLUDE_DIR` | Directory containing the `gmp.h` file | CMake | +| `GMP_INC_DIR` | Idem | Environment | +| `GMP_LIBRARIES_DIR` | Directory containing the compiled \sc{Gmp} library | CMake | +| `GMP_LIB_DIR` | Idem | Environment | +| `GMP_LIBRARIES` | Full pathname of the compiled \sc{Gmp} library | CMake | +| `MPFR_INCLUDE_DIR` | Directory containing the `mpfr.h` file | CMake | +| `MPFR_INC_DIR` | Idem | Environment | +| `MPFR_LIBRARIES_DIR` | Directory containing the compiled \sc{Mpfr} library | CMake | +| `MPFR_LIB_DIR` | Idem | Environment | +| `MPFR_LIBRARIES` | Full pathname of the compiled \sc{Mpfr} library | CMake | + + + +Under Linux, the \sc{Gmpxx} is also searched for, and you may specify the following variables: + + +| Variable | Description | Type | +| :- | :- | :- | +| `GMPXX_DIR` | Directory of \sc{gmpxx} default installation | Environment | +| `GMPXX_INCLUDE_DIR` | Directory containing the `gmpxx.h` file | CMake | +| `GMPXX_LIBRARIES` | Full pathname of the compiled \sc{Gmpxx} library | CMake | + + + +\subsection installation_qt5 Qt5 Library + +You must set the cmake or environment variable `Qt5_DIR` to point to the path +to the directory containing the file `Qt5Config.cmake` created by your \sc{Qt}5 installation. If you are +using the open source edition it should be `/qt-everywhere-opensource-src-/qtbase/lib/cmake/Qt5`. + +\subsection installation_leda LEDA Library + +When the \leda libraries are not automatically found, yet they are installed on the system +with base names 'leda' and 'ledaD' (for the release and debug versions resp.), it might +be sufficient to just indicate the library directory via the `LEDA_LIBRARY_DIRS` variable. +If that doesn't work because, for example, the names are different, you can provide the full pathnames of each variant +via `LEDA_LIBRARY_RELEASE` and `LEDA_LIBRARY_DEBUG`. + +The variables specifying definitions and flags can be left undefined if they are not needed by LEDA. + + +| Variable | Description | Type | +| :- | :- | :- | +| `WITH_LEDA` | Indicates whether to search and use \leda or not | CMake | +| `LEDA_DIR` | Directory of \sc{LEDA} default installation | Environment | +| `LEDA_INCLUDE_DIR` | Directory containing the file `LEDA/system/basic.h` | CMake | +| `LEDA_LIBRARIES` | Directory containing the compiled \leda libraries | CMake | +| `LEDA_INC_DIR` | Directory containing the file `LEDA/system/basic.h` | Environment | +| `LEDA_LIB_DIR` | Directory containing the compiled \leda libraries | Environment | +| `LEDA_LIBRARY_RELEASE` | Full pathname to a release build of the \leda library | CMake | +| `LEDA_LIBRARY_DEBUG` | Full pathname to a debug build of the \leda library | CMake | +| `LEDA_DEFINITIONS` | Preprocessor definitions | CMake | +| `LEDA_CXX_FLAGS` | Compiler flags | CMake | +| `LEDA_LINKER_FLAGS` | Linker flags | CMake | + + +\subsection installation_mpfi MPFI Library + +\cgal provides a number type based on this library, but the \cgal library +itself does not depend on \sc{Mpfi}. This means that this library must be +configured when compiling an application that uses the above number type. + +When \sc{Mpfi} files are not on the standard path, the locations of the headers +and library files must be specified by using environment variables. + + +| Variable | Description | Type | +| :- | :- | :- | +| `MPFI_DIR` |Directory of \sc{MPFI} default installation | Environment | +| `MPFI_INCLUDE_DIR` | Directory containing the `mpfi.h` file | CMake | +| `MPFI_INC_DIR` | Idem | Environment | +| `MPFI_LIBRARIES_DIR` | Directory containing the compiled \sc{Mpfi} library | CMake | +| `MPFI_LIB_DIR` | Idem | Environment | +| `MPFI_LIBRARIES` | Full pathname of the compiled \sc{Mpfi} library | CMake | + + + +\subsection installation_rs RS and RS3 Library + +As said before, only the \cgal univariate algebraic kernel depends on the +library Rs. As the algebraic kernel is not compiled as a part of the \cgal +library, this library is not detected nor configured at installation time. + +CMake will try to find Rs in the standard header and library +directories. When it is not automatically detected, the locations of the +headers and library files must be specified using environment variables. + +Rs needs \sc{Gmp} 4.2 or later and \sc{Mpfi} 1.3.4 or later. The variables +related to the latter library may also need to be defined. + + +| Variable | Description | Type | +| :- | :- | :- | +| `RS_DIR` | Directory of \sc{Rs} default installation | Environment | +| `RS_INCLUDE_DIR` | Directory containing the `rs_exports.h` file | CMake | +| `RS_INC_DIR` | Idem | Environment | +| `RS_LIBRARIES_DIR` | Directory containing the compiled \sc{Rs} library | CMake | +| `RS_LIB_DIR` | Idem | Environment | +| `RS_LIBRARIES` | Full pathname of the compiled \sc{Rs} library | CMake | + +Similar variables exist for \sc{Rs3}. + +| Variable | Description | Type | +| :- | :- | :- +| `RS3_DIR` | Directory of \sc{Rs3} default installation | Environment | +| `RS3_INCLUDE_DIR` | Directory containing the file `rs3_fncts.h` file | CMake | +| `RS3_INC_DIR` | Idem | Environment | +| `RS3_LIBRARIES_DIR` | Directory containing the compiled \sc{Rs3} library | CMake | +| `RS3_LIB_DIR` | Idem | Environment | +| `RS3_LIBRARIES` | Full pathname of the compiled \sc{Rs3} library | CMake | + + +\subsection installation_ntl NTL Library + +Some polynomial computations in \cgal's algebraic kernel +are speed up when \sc{Ntl} is available. +As the algebraic kernel is not compiled as a part of the \cgal +library, this library is not detected nor configured at installation time. + +CMake will try to find \sc{Ntl} in the standard header and library +directories. When it is not automatically detected, the locations of the +headers and library files must be specified using environment variables. + +| Variable | Description | Type | +| :- | :- | :- | +| `NTL_DIR` | Directory of \sc{NTL} default installation | Environment | +| `NTL_INCLUDE_DIR` | Directory containing the `NTL/ZZX.h` file | CMake | +| `NTL_INC_DIR` | Idem | Environment | +| `NTL_LIBRARIES_DIR` | Directory containing the compiled \sc{Ntl} library | CMake | +| `NTL_LIB_DIR` | Idem | Environment | +| `NTL_LIBRARIES` | Full pathname of the compiled \sc{Ntl} library | CMake | + +\subsection installation_eigen Eigen Library + +\sc{Eigen} is a header-only template library. +Only the directory containing the header files of \sc{Eigen} 3.1 (or greater) is needed. + + +| Variable | Description | Type | +| :- | :- | :- | +| `EIGEN3_INCLUDE_DIR` | Directory containing the file `signature_of_eigen3_matrix_library` | CMake | +| `EIGEN3_INC_DIR` | Idem | Environment | + +\subsection installation_esbtl ESBTL Library + +One skin surface example requires the \sc{Esbtl} library in order to read \sc{Pdb} files. + +If \sc{Esbtl} is not automatically found, setting the `ESBTL_INC_DIR` +environment variable is sufficient. + + +| Variable | Description | Type | +| :- | :- | :- | +| `ESBTL_DIR` | Directory of \sc{ESBTL} default installation | Environment | +| `ESBTL_INC_DIR` | Directory containing the `ESBTL/default.h` file | Environment | +| `ESBTL_INCLUDE_DIR` | Directory containing the `ESBTL/default.h` file | CMake | + +\subsection installation_tbb TBB Library + +If \sc{Tbb} is not automatically found, the user must set the `TBB_ROOT` +environment variable. The environment variable `TBB_ARCH_PLATFORM=/` must be set. +`` is `ia32` or `intel64`. `` describes the Linux kernel, gcc version or Visual Studio version +used. It should be set to what is used in `$TBB_ROOT/lib/`. + +For windows users, the folder `TBB_ROOT/bin//` should be added to the `PATH` variable. + +Note that the variables in the table below are being used. + +| Variable | Description | Type | +| :- | :- | :- | +| `TBB_ROOT` | Directory of \sc{Tbb} default installation | Environment | +| `TBB_INCLUDE_DIRS` | Directory containing the `tbb/tbb.h` file | CMake | +| `TBB_LIBRARY_DIRS` | Directory(ies) containing the compiled TBB libraries | CMake | +| `TBB_LIBRARIES` | Full pathnames of the compiled TBB libraries (both release and debug versions, using "optimized" and "debug" CMake keywords). Note that if the debug versions are not found, the release versions will be used instead for the debug mode. | CMake | +| `TBB_RELEASE_LIBRARY` | Full pathname of the compiled TBB release library | CMake | +| `TBB_MALLOC_RELEASE_LIBRARY` | Full pathname of the compiled TBB release malloc library | CMake | +| `TBB_DEBUG_LIBRARY` | Full pathname of the compiled TBB debug library | CMake | +| `TBB_MALLOC_DEBUG_LIBRARY` | Full pathname of the compiled TBB debug malloc library | CMake | +| `TBB_MALLOCPROXY_DEBUG_LIBRARY` | Full pathname of the compiled TBB debug malloc_proxy library (optional) | CMake | +| `TBB_MALLOCPROXY_RELEASE_LIBRARY` | Full pathname of the compiled TBB release malloc_proxy library (optional) | CMake | + +\section installation_compiler_workarounds Compiler Workarounds + +A number of boolean flags are used to workaround compiler bugs and +limitations. They all start with the prefix `CGAL_CFG`. These +flags are used to work around compiler bugs and limitations. For +example, the flag `CGAL_CFG_NO_CPP0X_LONG_LONG` denotes +that the compiler does not know the type `long long`. + +For each installation a file +is defined, with the correct +settings of all flags. This file is generated automatically by CMake, +and it is located in the `include` directory of where you run +CMake. For an in-source configuration this means +`CGAL-\cgalReleaseNumber``/include`. + +The test programs used to generate the `compiler_config.h` +file can be found in `config/testfiles`. +Both +`compiler_config.h` and the test programs contain a short +description of the problem. In case of trouble with one of the +`CGAL_CFG` flags, it is a good idea to take a look at it. + +The file `CGAL/compiler_config.h` is included from +``. +which is included by all \cgal header files. + +*/ diff --git a/Documentation/doc/Documentation/advanced/Installation.txt b/Documentation/doc/Documentation/advanced/Installation.txt new file mode 100644 index 00000000000..314ead765e1 --- /dev/null +++ b/Documentation/doc/Documentation/advanced/Installation.txt @@ -0,0 +1,313 @@ +/*! +\page installation Building %CGAL libraries (non header-only mode) +\cgalAutoToc + +\cgalAdvancedBegin +Since \cgal version 5.0, \cgal is header-only be default, which means +that there is no need to compile \cgal or its libraries before it can be used. + +This page is for advanced users that have a good reason to still use the old way. +If this is not your case, head over back to the page \ref general_intro. +\cgalAdvancedEnd + +This page is a step-by-step description of how to configure, build, and (optionally) install \cgal +in case you do not wish to use the - now enabled by default - header-only mode of \cgal. + +It is assumed that you have downloaded a source archive of \cgal, and are using Linux or macOS. + +\section installation_idealworld Quick Installation + +Ideally, compiling and installing \cgal, as well as compiling some examples shipped by \cgal is as simple as: + + cd $HOME/CGAL-\cgalReleaseNumber + mkdir build + cd build + cmake -DCGAL_HEADER_ONLY=OFF -DCMAKE_BUILD_TYPE=Release .. # configure CGAL + make # build CGAL + make install # install CGAL + cd examples/Triangulation_2 # go to an example directory + cmake -DCGAL_DIR=$CMAKE_INSTALLED_PREFIX/lib/CGAL -DCMAKE_BUILD_TYPE=Release . # configure the examples + make # build the examples + +In a less ideal world, you might have to install some required tools and third-party libraries. +This is what this page is about. + +\section installation_configwithcmake Configuring CGAL with CMake + +Before building \cgal, or anything using \cgal, you have to choose the compiler/linker, +set compiler and linker flags, specify which +third-party libraries you want to use and where they can be found, and +which \cgal libraries you want to build. Gathering +all this information is called configuration. +The end of the process is marked by the generation of a makefile that you can use to build \cgal. + +CMake maintains configuration parameters in so-called cmake variables. Some of the CMake +variables represent user choices, such as `CMAKE_BUILD_TYPE`, while others +indicate the details of a third-party library, such as `Boost_INCLUDE_DIR` or which compiler flags to use, +such as `CMAKE_CXX_FLAGS`. + +The next sections first present the CMake variables related to \cgal, followed by more generic variables, +and finally the configuration and build processes. + +\subsection seclibraries CGAL Libraries + +\cgal is split into four libraries. During configuration, you can select the libraries that +you would like to build by setting a CMake variable of the form WITH_. By default all +are switched `ON`. All activated libraries are to be built after configuration. + +Note that some libraries have specific dependencies in addition to the essential ones. See the page +\ref secessential3rdpartysoftware for more information. + +| Library | CMake Variable | Functionality | Dependencies | +| :-------- | :------------- | :------------ | :----------- | +| `%CGAL` | none | Main library | \sc{Gmp}, \sc{Mpfr}, \sc{Boost} (headers) | +| `CGAL_Core` | `WITH_CGAL_Core` | The %CORE library for algebraic numbers.\cgalFootnote{CGAL_Core is not part of \cgal, but a custom version of the \sc{Core} library distributed by \cgal for the user convenience and it has it's own license.} | \sc{Gmp} and \sc{Mpfr} | +| `CGAL_ImageIO` | `WITH_CGAL_ImageIO` | Utilities to read and write image files | \sc{zlib}, \sc{Vtk} (optional) | +| `CGAL_Qt5` | `WITH_CGAL_Qt5` | `QGraphicsView` support for \sc{Qt}5-based demos | \sc{Qt}5 | + +Shared libraries, also called dynamic-link libraries, are built by default +(`.so` on Linux, `.dylib` on macOS). You +can choose to produce static libraries instead, by setting the CMake +variable `BUILD_SHARED_LIBS` to `FALSE`. + +\subsection installation_examples CGAL Examples and Demos + +\cgal is distributed with a large collection of examples and demos. By default, these are not configured along with +the \cgal libraries, unless you set the variables `WITH_examples=ON` and/or `WITH_demos=ON`. +Additionally, even when configured with \cgal, they are not automatically built along with the libraries. +You must build the `examples` or `demos` targets (or IDE projects) explicitly. + +If you do not plan to compile any demos, you may skip some of the dependencies (such as \sc{Qt}), +as the corresponding \cgal-libraries will not be used. Note, however, that your own demos +might need these \cgal-libraries and thus their dependencies. See the page +\ref secessential3rdpartysoftware for more information. + +\subsection installation_debugrelease Debug vs. Release + +The CMake variable `CMAKE_BUILD_TYPE` indicates how to build the libraries. +It accepts the values `Debug` or `Release`. Note that the default value is `Debug`, since it is +default value in `CMake`. If you do not plan on debugging, it is important to set the variable +to `Release` for performance reasons. + +This is however not an issue for solution/project files, since the user selects the build type +from within the IDE in this environment. + +\subsection installation_miscvariables Other CMake Variables + +There are many more variables that can be used during configuration. The most important ones are: +
      +
    • `CMAKE_INSTALL_PREFIX=` installation directory [/usr/local]
    • +
    • `CMAKE_BUILD_TYPE=` build type [Release]
    • +
    • `BUILD_SHARED_LIBS=` shared or static libraries [TRUE]
    • +
    • `CMAKE_C_COMPILER=` C compiler [gcc]
    • +
    • `CMAKE_CXX_COMPILER=` C++ compiler [g++]
    • +
    + +In case you want to add additional compiler and linker flags, you can use +
      +
    • `CGAL_CXX_FLAGS` additional compiler flags
    • +
    • `CGAL_MODULE_LINKER_FLAGS` add. linker flags (static libraries)
    • +
    • `CGAL_SHARED_LINKER_FLAGS` add. linker flags (shared libraries)
    • +
    • `CGAL_EXE_LINKER_FLAGS` add. linker flags (executables)
    • +
    + +Variants with the additional suffix "_DEBUG" and "_RELEASE" allow to set +separate values for debug and release builds. In case you do not want to add +additional flags, but to override the default flags, replace "CGAL" by +"CMAKE" in the variable names above. + +A comprehensive list of CMake variables can be found on the \ref configurationvariables page. + +Note that CMake maintains a cache name `CMakeCache.txt`. If you change options +(or your environment changes), it is best to remove that file to avoid +problems. + +\subsection installation_configuring_gui Configuring CGAL with the CMake GUI + +The simplest way to start the configuration process is to run the graphical +user interface of CMake, `cmake-gui`. You must pass as +argument the root directory of \cgal. For example: + + cd CGAL-\cgalReleaseNumber/build + cmake-gui .. # The two dots indicate the parent directory + +After `cmake-gui` opens, press *Configure*. +A dialog will pop up and you will have to choose what shall be generated. +After you have made your choice and pressed *Finish*, you will see +the output of configuration tests in the lower portion of the application. +When these tests are done, you will see many +red entries in the upper portion of the application. Just ignore them and press *Configure*. +By now CMake should have found many libraries and have initialized variables. +If you still find red entries, you have to provide the necessary information. +This typically happens if you have installed software at non-standard locations. + +Providing information and pressing *Configure* goes on until +all entries are grayed. You are now ready to press *Generate*. Once this is +done, you can quit `cmake-gui`. + +Since you intend to build CGAL libraries, you should also ensure that the variable +`CGAL_HEADER_ONLY` has not been set. + +If you do not need to debug, you should set the variable `CMAKE_BUILD_TYPE` to `Release`. + +\subsection installation_configuring_cmd Configuring CGAL with the cmake Command-Line Tool + +Alternatively, you can run the command-line tool called `cmake`. +You pass as argument the root directory of \cgal. +The command line tool `cmake` accepts CMake variables as arguments of the form `-D:=`, as +in the example above, but this is only useful if you already know which variables need to be explicitly defined. +For example: + + cd CGAL-\cgalReleaseNumber/build + cmake .. + +The configuration process not only determines the location of the required dependencies, it also dynamically generates a +`compiler_config.h` file, which encodes the properties of your system and a special file named +`CGALConfig.cmake`, which is used to build programs using \cgal. The +purpose of this file is explained below. + +\cgalAdvancedBegin +CMake keeps the variables that a user can manipulate in a +so-called CMake cache, a simple text file named +`CMakeCache.txt`, whose entries are of the form +`VARIABLE:TYPE=VALUE`. Advanced users can manually edit this file, +instead of going through the interactive configuration session. +\cgalAdvancedEnd + +\subsection installation_cgalconfig CGALConfig.cmake + +During configuration of the \cgal libraries a file named `CGALConfig.cmake` is generated +in \cgal's root directory (in contrast to \cgal's source directory that has been used +for installation). This file contains the definitions of several CMake variables +that summarize the configuration of \cgal and will be essential during the configuration and +building of a program using \cgal, see Section \ref installation_buildprogram. + +\section seccmakeoutofsource Multiple Builds + +While you can choose between release or debug builds, and shared or static libraries, +it is not possible to generate different variants during a single configuration. You need to run CMake in a +different directory for each variant you are interested in, each with its own selection of configuration parameters. + +CMake stores the resulting makefiles, along with several temporary and auxiliary files such +as the variables cache, in the directory where it is executed, called `CMAKE_BINARY_DIR`, but it +takes the source files and configuration scripts from +`CMAKE_SOURCE_DIR`. + +The binary and source directories do not need to be the same. Thus, you can configure multiple variants by creating a +distinct directory for each configuration and by running CMake from there. This is known in CMake terminology +as out-of-source configuration, as opposite to an in-source +configuration, as showed in the previous sections. +You can, for example, generate subdirectories `CGAL-\cgalReleaseNumber``/build/debug` and +`CGAL-\cgalReleaseNumber``/build/release` for two configurations, respectively: + + mkdir CGAL-\cgalReleaseNumber/build/debug + cd CGAL-\cgalReleaseNumber/build/debug + cmake -DCMAKE_BUILD_TYPE=Debug ../.. + + mkdir CGAL-\cgalReleaseNumber/build/release + cd CGAL-\cgalReleaseNumber/build/release + cmake -DCMAKE_BUILD_TYPE=Release ../.. + +\section secbuilding Building CGAL + +The results of a successful configuration are build files that control the build step. +The nature of the build files depends on the generator used during configuration, but in all cases they +contain several targets, one per library, and a default global target corresponding +to all the libraries. + +For example, in a \sc{Unix}-like environment the default generator produces makefiles. +You can use the `make` command-line tool for the succeeding build step as follows: + + # build all the selected libraries at once + make + +The resulting libraries are placed in the subdirectory `lib` under `` +(which is `CGAL-\cgalReleaseNumber` in case you run an in-source-configuration). + +\cgalAdvancedBegin +The build files produced by CMake are autoconfigured. That +is, if you change any of the dependencies, the build step +automatically goes all the way back to the configuration step. This +way, once the target has been configured the very first time by +invoking cmake, you don't necessarily need to invoke `cmake` +again. Rebuilding will call itself `cmake` and re-generate the +build file whenever needed. +\cgalAdvancedEnd + +\subsection ssec_installation_build_ex_demos Building Examples and Demos + +If you have turned on the configuration of examples +(`-DWITH_examples=ON`) and/or demos (`-DWITH_demos=ON`), there will be additional +targets named `examples` and `demos`, plus one target for +each example and each demo in the build files. +None of these targets are included by default, so you need to build them explicitly +after the \cgal libraries have been successfully built. +The targets `examples` and `demos` include themselves all the targets +for examples and demos respectively. + + # build all examples at once + make examples + + # build all demos at once + make demos + +If you are interested in the demos or examples of just a particular module, you can build them in the following way: + + make -C demo/Alpha_shapes_2 # equivalent to "cd demo/Alpha_shapes_2; make" + make -C examples/Alpha_shapes_2 # equivalent to "cd examples/Alpha_shapes_2; make" + +When using `UNIX Makefiles`, you can find out the exact name of the example or demo target +of a particular package by typing `make help | grep `. + +\section secinstalling Installing CGAL + +On many platforms, library pieces such as headers, docs and binaries +are expected to be placed in specific locations. A typical example +being `/usr/include` and `/usr/lib`. The process +of placing or copying the library elements into its standard location +is sometimes referred to as Installation and it is a +postprocessing step after the build step. + +CMake carries out the installation by producing a build target named install. +Assuming you have successfully configured and built \cgal as demonstrated in the previous sections, +the installation simply amounts to: + + # install CGAL + make install + +\cgalAdvancedBegin +The files are copied into a directory tree relative to the installation directory determined by the +CMake variable `CMAKE_INSTALL_PREFIX`. This variable defaults to `/usr/local` under \sc{Unix}-like operating systems. +If you want to install to a different location, you must override that CMake +variable explicitly at the configuration time and not when executing the install step. +\cgalAdvancedEnd + +The file `CGALConfig.cmake` is installed by default in +`$CMAKE_INSTALLED_PREFIX/lib/``CGAL-\cgalReleaseNumber`. + +\section installation_buildprogram Building a Program using CGAL + +Similarly to \cgal and its libraries, compiling a program using \cgal is done in the usual +two steps of configuration and building. + +The configuration process is also done using `cmake` (or `cmake-gui`) and requires a `CMakeLists.txt` file. +This file is automatically provided for all shipped examples and demos of \cgal. +For other programs, CMake can also be used to configure +and build user programs, but one has to provide the corresponding `CMakeLists.txt`. +This script can be generated either manually, or with the help of a shell-script, +see Section \ref devman_create_cgal_CMakeLists. Using this shell-script, +the process of configuring a user's program called `your_program.cpp` amounts to: + + cd /path/to/your/program + cgal_create_CMakeLists -s your_program + cmake -DCGAL_DIR=XXXXXX -DCMAKE_BUILD_TYPE=Release . + make + +In order to configure a program, you need to indicate the location of the \cgal configuration file +in the CMake variable `CGAL_DIR` (as shown in the example above). +If you have installed \cgal, `CGAL_DIR` must afterwards be set to `$CMAKE_INSTALLED_PREFIX/lib/CGAL`. + +The variable `CGAL_DIR` can also be an environment variable, but setting it manually makes particular sense +if you have multiple out-of-source builds of \cgal as in Section \ref seccmakeoutofsource. + +*/ diff --git a/Documentation/doc/Documentation/main.txt b/Documentation/doc/Documentation/main.txt index 22a8407f82e..6d9ffe67c1e 100644 --- a/Documentation/doc/Documentation/main.txt +++ b/Documentation/doc/Documentation/main.txt @@ -2,13 +2,17 @@ \mainpage -The goal of the \cgal Open Source Project is to provide easy access to -efficient and reliable geometric algorithms in the form of a C++ -library. +The Computational Geometry Algorithms Library (\cgal) is a software project +that provides easy access to efficient and reliable geometric algorithms +in the form of a C++ library. -The Computational Geometry Algorithms Library offers data structures -and algorithms like \ref PartTriangulationsAndDelaunayTriangulations "triangulations", \ref PartVoronoiDiagrams "Voronoi diagrams", \ref PartPolygons, \ref PartPolyhedra, \ref PartArrangements "arrangements of curves", \ref PartMeshing "mesh generation", \ref PartGeometryProcessing "geometry processing", \ref PartConvexHullAlgorithms "convex hull algorithms", to name just -a few. +

    Package Overview

    + +\cgal offers data structures and algorithms like \ref PartTriangulationsAndDelaunayTriangulations "triangulations", +\ref PartVoronoiDiagrams "Voronoi diagrams", \ref PartPolygons, \ref PartPolyhedra, +\ref PartArrangements "arrangements of curves", \ref PartMeshing "mesh generation", +\ref PartGeometryProcessing "geometry processing", \ref PartConvexHullAlgorithms "convex hull algorithms", +to name just a few. All these data structures and algorithms operate on geometric objects like points and segments, and perform geometric tests on them. These @@ -20,33 +24,32 @@ solver for linear and quadratic programs. It further offers interfaces to third party software such as the GUI libraries Qt, Geomview, and the Boost Graph Library. -Demos and Examples -================== +The complete list of packages is available on the page \ref packages. -In the distribution of the library you find the two directories *demo* -and *examples*. They contain subdirectories for the \cgal packages. -The demos use third party libraries for the graphical user interface. The -examples don't have this dependency and most examples are refered to in the -user manual. +

    Getting Started

    + +Head over to \ref general_intro to learn how to obtain, install, and use \cgal. + +

    License

    -License -======= %CGAL is distributed under a dual-license scheme. %CGAL can be used together with Open Source software free of charge. Using %CGAL in other contexts can be done by obtaining a commercial license from [GeometryFactory](http://www.geometryfactory.com). For more details -see the \ref licenseIssues "License" page. +see the \ref license "License" page. -Manuals for the Previous Releases -================================= +

    Acknowledgement

    + +We provide bibtex entries for each package so that you can cite \cgal correctly in your publications, +see the page \ref how_to_cite_cgal. + +

    Manuals for the Previous Releases

    For releases >= 4.2, visit [https://doc.cgal.org/X.Y](https://doc.cgal.org/4.2) For releases X.Y, with 3.1 <= X.Y <= 4.1 visit [https://doc.cgal.org/Manual/X.Y/doc_html/cgal_manual/packages.html](https://doc.cgal.org/Manual/3.1/doc_html/cgal_manual/packages.html) - - \htmlonly[block]
    \endhtmlonly @@ -55,6 +58,7 @@ For releases X.Y, with 3.1 <= X.Y <= 4.1 visit \subpage tutorials \subpage packages \subpage dev_manual +\subpage license \htmlonly[block]
    diff --git a/Documentation/doc/Documentation/manual.txt b/Documentation/doc/Documentation/manual.txt index dbada72f28d..33354eecf6d 100644 --- a/Documentation/doc/Documentation/manual.txt +++ b/Documentation/doc/Documentation/manual.txt @@ -1,17 +1,14 @@ -namespace CGAL { - /*! \page manual Organization of the Manual \cgalAutoToc \author %CGAL Editorial Board - -Organization of the Manual -========================== +\section secorganization Organization of the Manual This manual is organized in several parts covering the many domains -of computational geometry. Each part consists of several chapters, +of computational geometry. +Each part consists of several chapters, and each chapter is split into a *User Manual* and a *Reference Manual*. The User Manual gives the general idea and comes with examples. The Reference Manual presents the \sc{Api} of the various classes @@ -28,8 +25,7 @@ The scope of the search box is the package you currently look at and the packages it depends on, or it is the whole manual when you are in a top level page such as the package overview. -Organization of the Reference Manual -==================================== +\section secorganizationref Organization of the Reference Manual The \cgal library is a library of class templates. Consequently, we express the requirements on template arguments by specifying \em concepts @@ -70,6 +66,47 @@ As pointed out in Section \ref intro_concept "Concepts and Models" the notion of a \em concept is about requirements, and it can be a required global function or a required traits class. -*/ -} /* namespace CGAL */ +\section markingSpecialFunctionality Marking of Special Functionality + +In this manual, you will encounter sections marked as follows. + +\subsection advanced_features Advanced Features + +Some functionality is considered more advanced, for example because it is +relatively low-level, or requires special care to be properly used. + +\cgalAdvancedBegin +Such functionality is identified this way in the manual. +\cgalAdvancedEnd + +\subsection debugging_support Debugging Support Features + +Usually related to advanced features that for example may not guarantee +class invariants, some functionality is provided that helps debugging, +for example by performing invariants checks on demand. + +\cgalDebugBegin +Such functionality is identified this way in the manual. +\cgalDebugEnd + +\subsection deprecated_code Deprecated Code + +Sometimes, the \cgal project decides that a feature is deprecated. This means +that it still works in the current release, but it will be removed in the next, +or a subsequent release. This can happen when we have found a better way to do +something, and we would like to reduce the maintenance cost of \cgal at some +point in the future. There is a trade-off between maintaining backward +compatibility and implementing new features more easily. + +In order to help users manage the changes to apply to their code, we attempt +to make \cgal code emit warnings when deprecated code is used. This can be +done using some compiler specific features. Those warnings can be disabled +by defining the macro `CGAL_NO_DEPRECATION_WARNINGS`. On top of this, we +also provide a macro, `CGAL_NO_DEPRECATED_CODE`, which, when defined, +disables all deprecated features. This allows users to easily test if their +code relies on deprecated features. + +\deprecated Such functionality is identified this way in the manual. + +*/ diff --git a/Documentation/doc/Documentation/windows.txt b/Documentation/doc/Documentation/windows.txt new file mode 100644 index 00000000000..ca37e021001 --- /dev/null +++ b/Documentation/doc/Documentation/windows.txt @@ -0,0 +1,275 @@ +/*! +\page windows Using %CGAL on Windows (with Visual C++) +\cgalAutoToc + +\cgal \cgalReleaseNumber is supported for the following \sc{MS} Visual `C++` compilers: +14.0, 15.9, 16.0 (\sc{Visual Studio} 2015, 2017, and 2019). + +\cgal is a library that has mandatory dependencies that must be first installed: +\ref thirdpartyBoost and \ref thirdpartyMPFR. + +You have two options to install \cgal and its dependencies: you can either use +the *Vcpkg library manager*, which will automatically install an appropriate version of +these dependencies as you install \cgal, or you can install the dependencies on your own +(making sure that you are using a supported version) by following their respective +installation instructions. + +If you choose to use `vcpkg`, you might have to bootstrap and download +and compile it, but from then on `vcpkg` will make your life easier. +On the other hand, if you need to specify a specific version, or have already installed +a certain version of a dependency and do not wish to potentially have multiple versions installed, +you will want to use the \cgal Installer. + +We explain the two approaches in the next two sections. + +\section sec-installing-with-vcpkg Installing CGAL with the Vcpkg Library Manager + +\subsection ssec-vcpk-install-vcpk Installing Vcpkg + +The first step is to clone or download `vcpkg` from +https://github.com/microsoft/vcpkg. + + C:\dev> git clone https://github.com/microsoft/vcpkg + C:\dev> cd vcpkg + C:\dev\vcpkg> .\bootstrap-vcpkg.bat + +\subsection ssec-vcpk-install-cgal Installing CGAL with Vcpkg + +By default `vcpkg` installs for 32 bit binaries and will use the latest version of Visual C++ +installed on your machine. If you develop 64 bit software you must +set the Windows environment variable `VCPKG_DEFAULT_TRIPLE` to `x64-windows` +or pass the option `--triplet x64-windows` whenever you install a package. +We refer to the +official documentation +of `vcpkg` if you want to compile for an older version of a compiler. + +You are now ready to install \cgal: + + C:\dev\vcpkg> ./vcpkg.exe install cgal + +This will take several minutes as it downloads \mpir (a fork of \gmp), +\mpfr, all boost header files, and it will compile \mpir and \mpfr, as well +as several boost libraries. +Afterwards, you will find the include files, libraries, and dlls in the +subdirectory `C:\dev\vcpkg\installed\x64-windows`. + +Note that \cgal is a header-only library, and there are therefore no `lib` or `dll` files for \cgal. + +\subsection ssec-vcpkg-compile-example Compiling an Example + +In this section we show how to compile a program that uses \cgal. +The examples you find in these User Manual pages are not downloaded when you install \cgal +with the Vcpkg library manager. You must download them separately from the following download page: +CGAL-\cgalReleaseNumber-examples.zip + +Assuming you have unzipped this file in your home directory `C:\Users\Me`, +we will next compile an example from the 2D Triangulation package. + +\subsubsection sssec-vcpkg-configuration-example Configuring of an Example + +Before building anything using \cgal, you have to choose the compiler/linker, set compiler +and linker flags, specify which third-party libraries you want to use and where they can be found. +Gathering all this information is called *configuration* and we use *CMake* as configuration tool +(see Section \ref seccmake for more information on supported versions and where to download it). + +The end of the process is marked by the generation of a Visual \cpp solution +and a project file that you can use to build your program. + + C:\Users\Me\CGAL-\cgalReleaseNumber> cd examples\Triangulation_2 + C:\Users\Me\CGAL-\cgalReleaseNumber\examples\Triangulation_2> mkdir build + C:\Users\Me\CGAL-\cgalReleaseNumber\examples\Triangulation_2> cd build + C:\Users\Me\CGAL-\cgalReleaseNumber\examples\Triangulation_2\build> cmake-gui .. + +The command `cmake-gui` launches the graphical interface for `cmake`. +When you hit the *Configure* button, you must: +
      +
    • specify the *Generator* (e.g., Visual Studio 16 2019),
    • +
    • specify the *Optional Platform* (e.g., `x64` in case you want to create 64 bit binaries),
    • +
    • select *Specify toolchain file for cross compilation* (the file `vcpkg.cmake` within the directory +where you have installed `vcpkg`, e.g. `C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake`).
    • +
    +Once the configuration process is done, tick *Advanced* and *Grouped* in `cmake-gui`. +You will see entries for where header files and libraries are taken from. + +If you do not need to debug, you should set the variable `CMAKE_BUILD_TYPE` to `Release`. + +\subsubsection sssect-vcpkg-additional-dependencies Additional Dependencies + +Some \cgal packages also have additional dependencies. For example, during the configuration process +above, you may have observed the following message: + + NOTICE: The example draw_triangulation_2 requires Qt and will not be compiled + +\cgal is a library of algorithms and data structures and as such does +not depend on `Qt`. However, one of the examples in the Triangulation_2 package does require `Qt` +for visualization purposes. If you already have `Qt` installed, you can simply fill in the requested +CMake variables and paths. Otherwise, you can also install it using `vcpkg`: + + C:\dev\vcpkg> ./vcpkg.exe install qt5 + +Remember to specify `--triplet` or the related environment variable in case you target 64-bit applications. + +As Qt5 is modular and as the \cgal examples and demos use only some of these modules +you can save download and compilation time by specifying an *installation option*: + + C:\dev\vcpkg> ./vcpkg.exe install cgal[qt] + +In both cases, when you start `cmake-gui` again and hit the *Configure* button, +the CMake variables and paths concerning Qt should now be filled. + +Note that not all optional dependencies are available through the Vcpkg library manager. +In this case, you must download and install them independently (see page \ref thirdparty +for information on support versions and download links) as well as fill the missing information +within the `CMake` interface until configuration is successful (no more red lines indicating +missing dependencies). + +\cgalAdvancedBegin +You may also decide to solve missing dependencies using the `CMake` command line tool (which is not recommended). +If so, the page \ref configurationvariables lists variables which can be used to specify +the location of third-party software. +\cgalAdvancedEnd + +\subsubsection sssect-vcpkg-compilation Compilation of an Example + +Once the configuration process is successful, hit the *Generate* button, +and you will find the file `Triangulation_2_examples.sln` +in the directory `C:\Users\Me\CGAL-\cgalReleaseNumber\examples\Triangulation_2\build`. +Double-click it to open it. There is one project per `.cpp` file in the directory. +Compile them all, or just the one you are interested in. + +\subsection subsect-vpckg-my-code Configuring and Compiling Your Code Using CGAL + +Configuring and compiling your own code is practically the same as for \cgal examples +if you use `cmake`. Running `cmake` (or `cmake-gui`) requires a `CMakeLists.txt` file. +This file is automatically provided for all examples and demos of \cgal. For your own programs, +you are advised to look at the `CMakeLists.txt` files in the example +folder of the package(s) that you are using to learn how to specify \cgal and additional third party +dependencies. + +\section install-with-installer Installing with the CGAL Installer + +You can download and run `CGAL-\cgalReleaseNumber``-Setup.exe` from https://www.cgal.org/download/windows.html. +It is a self-extracting executable that downloads the \cgal header files, and optionally the source code of the +examples and demos. Additionally, it can download precompiled versions of \gmp and \mpfr. + +\subsection ssect-installer-boost Installing Boost + +`Boost` is a mandatory dependency of \cgal. Binary versions of `Boost` are available on +SourceForge. +The `Boost` installers install both `Boost` headers and precompiled libraries. +Please note that the \cgal project is not responsible for the files provided on this website. +When \cgal \cgalReleaseNumber was released, the latest version of `Boost` was 1.71. +A typical installation of `Boost` would consist of the following steps: + +
      +
    • Download and run the file boost_1_71_0-msvc-XX.Y-64.exe (where XX.Y = 14.0 for VC 2015, XX.Y = 14.1 for 2017, XX.Y = 14.2 for VC 2019).
    • +
    • Extract the files to a new directory, e.g. `c:\dev\libboost_1_71_0`.
    • +
    • Set the following two environment variables to point respectively to the path of the libraries and the headers +
        +
      • `BOOST_LIBRARYDIR = C:\dev\libboost_1_71_0\lib64-msvc-XX.Y`
      • +
      • `BOOST_INCLUDEDIR = C:\dev\libboost_1_71_0`
      • +
      +as this will help `cmake` to find Boost.
    • +
    • Add the path to the Boost `dlls` (`C:\dev\libboost_1_71_0\lib64-msvc-XX.Y`) files to the `PATH` environment variable.
    • +
    + +\subsection ssect-installer-install-cgal Installing CGAL Itself + +Download and run `CGAL-\cgalReleaseNumber``-Setup.exe` from +https://www.cgal.org/download/windows.html. +It is a self extracting executable that downloads the \cgal header files, and optionally the source code of the +examples and demos. Additionally, it can download the precompiled versions of \gmp and \mpfr. You must +specify if you want the 32 or the 64 bit versions of these two libraries. + +Setting the environment variable `CGAL_DIR` to `C:\dev\CGAL-\cgalReleaseNumber` is a good idea +to help `cmake` to find \cgal during the configuration process, detailed in the next section. + +\subsection ssect-installer-compile-example Compiling an Example + +We assume that you have downloaded the examples with the \cgal Installer. + +Before building anything using \cgal, you have to choose the compiler/linker, set compiler +and linker flags, specify which third-party libraries you want to use and where they can be found. +Gathering all this information is called *configuration* and we use CMake as configuration tool +(see Section \ref seccmake for more information on minimal supported versions and where to +download it). + +The end of the process is marked by the generation of a Visual \cpp solution +and a project file that you can use to build your program. + + C:\dev\CGAL-\cgalReleaseNumber> cd examples\Triangulation_2 + C:\dev\CGAL-\cgalReleaseNumber\examples\Triangulation_2> mkdir build + C:\dev\CGAL-\cgalReleaseNumber\examples\Triangulation_2> cd build + C:\dev\CGAL-\cgalReleaseNumber\examples\Triangulation_2\build> cmake-gui .. + +The command `cmake-gui` launches the graphical interface for `cmake`. +When you hit the *Configure* button, you must: +
      +
    • Specify the *Generator*, e.g., Visual Studio 16 2019), and
    • +
    • specify an *Optional Platform* (`x64` in case you want to create 64 bit binaries).
    • +
    +Once the configuration is done, tick `Advanced` and `Grouped` in `cmake-gui`. +You will see entries for where header files and libraries are taken from. + +If you do not need to debug, you should set the variable `CMAKE_BUILD_TYPE` to `Release`. + +\subsubsection ssect-installer-additional-dependencies Additional Dependencies + +Some \cgal packages also have additional dependencies. For example, during the configuration process +above, you may have observed the following message: + + NOTICE: The example draw_triangulation_2 requires Qt and will not be compiled + +\cgal is a library of algorithms and data structures and as such does +not depend on `Qt`. However, one of the examples does for visualization purposes only. Either you +have Qt installed and you can fill in the requested CMake variables, or you must install it. +A typical `Qt` installation would consist of the following steps: + +
      +
    • +Download and install the Qt library for open source development package for your Visual Studio version at +https://www.qt.io/download/ +(here is the direct link to the offline installers).
    • +
    • Add the environment variable `QTDIR` pointing to the place you installed Qt, e.g., `C:\dev\Qt\Qt5.13.1`, +as this will help `cmake` to find Qt.
    • +
    • Add the bin directory of Qt, e.g. add `C:\dev\Qt\Qt5.13.1\msvcXXXX_YY\bin` to `PATH`, where `XXXX_YY` is something like `vc2017_64`. +To avoid any conflict with another dll with the same name from another folder, add this path as the first in the list.
    • +
    + +Once you have installed `Qt`, the CMake variables concerning `Qt` should now be filled when you +press *Configure* in the \cgal directory. + +You must follow a similar process for other dependencies (see page \ref thirdparty for information +on supported versions of third party libraries as well as download links) and fill the missing information +within the `CMake` interface until configuration is successful (no more red lines indicating +missing dependencies). + +\cgalAdvancedBegin +You may also decide to solve missing dependencies using the `CMake` command line tool (which is not recommended). +If so, the page \ref configurationvariables lists variables which can be used to specify +the location of third-party software. +\cgalAdvancedEnd + +\subsubsection sssect-installer-compilation Compilation of an Example + +Once the configuration process is successful, hit the *Generate* button, +and you will find the file `Triangulation_2_examples.sln` +in the directory `C:\dev\CGAL-\cgalReleaseNumber\examples\Triangulation_2\build`. +Double-click it in order to open it. You will see one project per `.cpp` file. +Compile them all, or just the one you are interested in. + +\subsection subsect-installer-my-code Configuring and Compiling My Code Using CGAL + +Configuring and compiling your own code is practically the same as for \cgal examples +if you use `cmake`. Running `cmake` (or `cmake-gui`) requires a `CMakeLists.txt` file. +This file is automatically provided for all examples and demos of \cgal. For your own programs, +you are advised to look at the `CMakeLists.txt` files in the example +folder of the package(s) that you are using to learn how to specify \cgal and additional third party +dependencies. + +\section install-with-tarball Installing from the Source Archive + +Instead of the installer you can also download release tarballs. The sole difference +is that the installer also downloads precompiled \gmp and \mpfr libraries. + +*/ diff --git a/Documentation/doc/resources/1.8.13/BaseDoxyfile.in b/Documentation/doc/resources/1.8.13/BaseDoxyfile.in index 34d9e359a51..706be1b14ca 100644 --- a/Documentation/doc/resources/1.8.13/BaseDoxyfile.in +++ b/Documentation/doc/resources/1.8.13/BaseDoxyfile.in @@ -233,6 +233,9 @@ ALIASES = "sc{1}=\1\1\1" ALIASES += "cgal=\sc{%CGAL}" ALIASES += "protocgal=\sc{C++gal}" ALIASES += "plageo=\sc{Plageo}" +ALIASES += "gmp=\sc{GMP}" +ALIASES += "mpir=\sc{MPIR}" +ALIASES += "mpfr=\sc{MPFR}" ALIASES += "stl=\sc{STL}" ALIASES += "leda=\sc{LEDA}" ALIASES += "gcc=\sc{GCC}" diff --git a/Documentation/doc/resources/1.8.4/menu_version.js b/Documentation/doc/resources/1.8.4/menu_version.js index 1f8a8eef476..b6eb67f73fc 100644 --- a/Documentation/doc/resources/1.8.4/menu_version.js +++ b/Documentation/doc/resources/1.8.4/menu_version.js @@ -3,12 +3,12 @@ var url_re = /(cgal\.geometryfactory\.com\/CGAL\/doc\/|doc\.cgal\.org\/)(master|latest|(\d\.\d+|\d\.\d+\.\d+))\//; var url_local = /.*\/doc_output\//; - var current_version_local = '5.0-beta2' + var current_version_local = '5.0' var all_versions = [ 'master', 'latest', '5.0', - '4.14.1', + '4.14.2', '4.13.2', '4.12.2', '4.11.3', diff --git a/Generator/doc/Generator/CGAL/point_generators_2.h b/Generator/doc/Generator/CGAL/point_generators_2.h index 654099e0c08..f22f8aa8497 100644 --- a/Generator/doc/Generator/CGAL/point_generators_2.h +++ b/Generator/doc/Generator/CGAL/point_generators_2.h @@ -146,8 +146,6 @@ distributed in an open disc. The default `Creator` is \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Points_on_segment_2` \sa `CGAL::Random_points_in_square_2` \sa `CGAL::Random_points_in_triangle_2` @@ -155,8 +153,6 @@ distributed in an open disc. The default `Creator` is \sa `CGAL::Random_points_on_segment_2` \sa `CGAL::Random_points_on_square_2` \sa `CGAL::Random_points_in_sphere_3` -\sa `std::random_shuffle` - */ template< typename Point_2, typename Creator > class Random_points_in_disc_2 { @@ -214,16 +210,12 @@ distributed in a half-open square. The default `Creator` is \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Points_on_segment_2` \sa `CGAL::Random_points_in_triangle_2` \sa `CGAL::Random_points_in_disc_2` \sa `CGAL::Random_points_on_segment_2` \sa `CGAL::Random_points_on_square_2` \sa `CGAL::Random_points_in_cube_3` -\sa `std::random_shuffle` - */ template< typename Point_2, typename Creator > class Random_points_in_square_2 { @@ -283,8 +275,6 @@ distributed inside a triangle. The default `Creator` is \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Points_on_segment_2` \sa `CGAL::Random_points_in_disc_2` \sa `CGAL::Random_points_on_segment_2` @@ -292,8 +282,6 @@ distributed inside a triangle. The default `Creator` is \sa `CGAL::Random_points_in_cube_3` \sa `CGAL::Random_points_in_triangle_3` \sa `CGAL::Random_points_in_tetrahedron_3` -\sa `std::random_shuffle` - */ template< typename Point_2, typename Creator > class Random_points_in_triangle_2 { @@ -360,8 +348,6 @@ typedef const Point_2& reference; \cgalModels `InputIterator` \cgalModels `PointGenerator` - \sa `std::copy_n()` - \sa `CGAL::Counting_iterator` \sa `CGAL::Points_on_segment_2` \sa `CGAL::Random_points_in_disc_2` \sa `CGAL::Random_points_on_segment_2` @@ -374,8 +360,6 @@ typedef const Point_2& reference; \sa`CGAL::Random_points_in_tetrahedral_mesh_3` \sa `CGAL::Random_points_in_triangles_3` \sa `CGAL::Random_points_in_triangles_2` - \sa `std::random_shuffle` - */ template< typename Point_2, typename Triangulation, @@ -432,8 +416,6 @@ get_default_random() ); \cgalModels `InputIterator` \cgalModels `PointGenerator` - \sa `std::copy_n()` - \sa `CGAL::Counting_iterator` \sa `CGAL::Points_on_segment_2` \sa `CGAL::Random_points_in_disc_2` \sa `CGAL::Random_points_on_segment_2` @@ -445,8 +427,6 @@ get_default_random() ); \sa `CGAL::Random_points_in_tetrahedral_mesh_boundary_3` \sa `CGAL::Random_points_in_tetrahedral_mesh_3` \sa `CGAL::Random_points_in_triangles_3` - \sa `std::random_shuffle` - */ template< typename Point_2, typename Triangle_2 = typename Kernel_traits::Kernel::Triangle_2, @@ -506,8 +486,6 @@ rounding errors. \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Points_on_segment_2` \sa `CGAL::Random_points_in_disc_2` \sa `CGAL::Random_points_in_square_2` @@ -515,8 +493,6 @@ rounding errors. \sa `CGAL::Random_points_on_segment_2` \sa `CGAL::Random_points_on_square_2` \sa `CGAL::Random_points_on_sphere_3` -\sa `std::random_shuffle` - */ template< typename Point_2, typename Creator > class Random_points_on_circle_2 { @@ -577,16 +553,12 @@ distributed on a segment. The default `Creator` is \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Points_on_segment_2` \sa `CGAL::Random_points_in_disc_2` \sa `CGAL::Random_points_in_square_2` \sa `CGAL::Random_points_in_triangle_2` \sa `CGAL::Random_points_on_circle_2` \sa `CGAL::Random_points_on_square_2` -\sa `std::random_shuffle` - */ template< typename Point_2, typename Creator > class Random_points_on_segment_2 { @@ -647,16 +619,12 @@ distributed on the boundary of a square. The default `Creator` is \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Points_on_segment_2` \sa `CGAL::Random_points_in_disc_2` \sa `CGAL::Random_points_in_square_2` \sa `CGAL::Random_points_in_triangle_2` \sa `CGAL::Random_points_on_circle_2` \sa `CGAL::Random_points_on_segment_2` -\sa `std::random_shuffle` - */ template< typename Point_2, typename Creator > class Random_points_on_square_2 { @@ -717,8 +685,6 @@ endpoints are specified upon construction. The points are equally spaced. \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::points_on_segment` \sa `CGAL::Random_points_in_disc_2` \sa `CGAL::Random_points_in_square_2` @@ -727,8 +693,6 @@ endpoints are specified upon construction. The points are equally spaced. \sa `CGAL::Random_points_on_segment_2` \sa `CGAL::Random_points_on_square_2` \sa `CGAL::random_selection()` -\sa `std::random_shuffle` - */ template< typename Point_2 > class Points_on_segment_2 { diff --git a/Generator/doc/Generator/CGAL/point_generators_3.h b/Generator/doc/Generator/CGAL/point_generators_3.h index e8ea46c7060..1eb5c014f0b 100644 --- a/Generator/doc/Generator/CGAL/point_generators_3.h +++ b/Generator/doc/Generator/CGAL/point_generators_3.h @@ -44,15 +44,11 @@ distributed in a half-open cube. The default `Creator` is \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Random_points_in_square_2` \sa `CGAL::Random_points_in_sphere_3` \sa `CGAL::Random_points_in_triangle_3` \sa `CGAL::Random_points_in_tetrahedron_3` \sa `CGAL::Random_points_on_sphere_3` -\sa `std::random_shuffle` - */ template< typename Point_3, typename Creator > class Random_points_in_cube_3 { @@ -113,15 +109,11 @@ distributed strictly inside a sphere. The default `Creator` is \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Random_points_in_disc_2` \sa `CGAL::Random_points_in_cube_3` \sa `CGAL::Random_points_in_triangle_3` \sa `CGAL::Random_points_in_tetrahedron_3` \sa `CGAL::Random_points_on_sphere_3` -\sa `std::random_shuffle` - */ template< typename Point_3, typename Creator > class Random_points_in_sphere_3 { @@ -182,14 +174,10 @@ distributed inside a 3D triangle. The default `Creator` is \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Random_points_in_disc_2` \sa `CGAL::Random_points_in_cube_3` \sa `CGAL::Random_points_in_tetrahedron_3` \sa `CGAL::Random_points_on_sphere_3` -\sa `std::random_shuffle` - */ template< typename Point_3, typename Creator > class Random_points_in_triangle_3 { @@ -260,10 +248,10 @@ distributed on a segment. The default `Creator` is \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` -\sa `std::random_shuffle` - +\sa `CGAL::Random_points_in_cube_3` +\sa `CGAL::Random_points_in_triangle_3` +\sa `CGAL::Random_points_on_sphere_3` +\sa `CGAL::Random_points_in_tetrahedron_3` */ template< typename Point_3, typename Creator > class Random_points_on_segment_3 { @@ -326,13 +314,10 @@ distributed inside a tetrahedron. The default `Creator` is \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` +\sa `CGAL::Random_points_on_segment_3` \sa `CGAL::Random_points_in_cube_3` \sa `CGAL::Random_points_in_triangle_3` \sa `CGAL::Random_points_on_sphere_3` -\sa `std::random_shuffle` - */ template< typename Point_3, typename Creator > class Random_points_in_tetrahedron_3 { @@ -405,8 +390,6 @@ The triangle range must be valid and unchanged while the iterator is used. \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Random_points_in_cube_3` \sa `CGAL::Random_points_in_triangle_3` \sa `CGAL::Random_points_in_tetrahedron_3` @@ -414,8 +397,6 @@ The triangle range must be valid and unchanged while the iterator is used. \sa `CGAL::Random_points_in_tetrahedral_mesh_boundary_3` \sa `CGAL::Random_points_in_tetrahedral_mesh_3` \sa `CGAL::Random_points_in_triangles_2` -\sa `std::random_shuffle` - */ template< typename Point_3, typename Triangle_3=typename Kernel_traits::Kernel::Triangle_3, @@ -476,8 +457,6 @@ The triangle mesh must be valid and unchanged while the iterator is used. \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Random_points_in_disc_2` \sa `CGAL::Random_points_in_cube_3` \sa `CGAL::Random_points_in_triangle_3` @@ -487,7 +466,6 @@ The triangle mesh must be valid and unchanged while the iterator is used. \sa `CGAL::Random_points_in_tetrahedral_mesh_3` \sa `CGAL::Random_points_in_triangles_2` \sa `CGAL::Random_points_in_triangles_3` -\sa `std::random_shuffle` */ template < class TriangleMesh, @@ -559,8 +537,6 @@ The tetrahedral mesh must be valid and unchanged while the iterator is used. \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Random_points_in_disc_2` \sa `CGAL::Random_points_in_cube_3` \sa `CGAL::Random_points_in_triangle_3` @@ -570,8 +546,6 @@ The tetrahedral mesh must be valid and unchanged while the iterator is used. \sa `CGAL::Random_points_in_tetrahedral_mesh_3` \sa `CGAL::Random_points_in_triangles_2` \sa `CGAL::Random_points_in_triangles_3` -\sa `std::random_shuffle` - */ template ` \sa `CGAL::Random_points_in_cube_3` \sa `CGAL::Random_points_in_triangle_3` @@ -648,8 +620,6 @@ The tetrahedral mesh must be valid and unchanged while the iterator is used. \sa `CGAL::Random_points_in_tetrahedral_mesh_boundary_3` \sa `CGAL::Random_points_in_triangles_2` \sa `CGAL::Random_points_in_triangles_3` -\sa `std::random_shuffle` - */ template ` \sa `CGAL::Random_points_in_cube_3` \sa `CGAL::Random_points_in_sphere_3` -\sa `std::random_shuffle` - */ template< typename Point_3, typename Creator > class Random_points_on_sphere_3 { diff --git a/Generator/doc/Generator/CGAL/point_generators_d.h b/Generator/doc/Generator/CGAL/point_generators_d.h index 7a1b71f8c44..a06065a8ac1 100644 --- a/Generator/doc/Generator/CGAL/point_generators_d.h +++ b/Generator/doc/Generator/CGAL/point_generators_d.h @@ -43,13 +43,10 @@ distributed in an open ball in any dimension. \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Random_points_in_disc_2` \sa `CGAL::Random_points_in_sphere_3` \sa `CGAL::Random_points_in_cube_d` \sa `CGAL::Random_points_on_sphere_d` - */ template< typename Point_d > class Random_points_in_ball_d { @@ -112,13 +109,10 @@ distributed in an half-open cube. \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Random_points_in_square_2` \sa `CGAL::Random_points_in_cube_3` \sa `CGAL::Random_points_in_ball_d` \sa `CGAL::Random_points_on_sphere_d` - */ template< typename Point_d > class Random_points_in_cube_d { @@ -187,13 +181,10 @@ rounding errors. \cgalModels `InputIterator` \cgalModels `PointGenerator` -\sa `std::copy_n()` -\sa `CGAL::Counting_iterator` \sa `CGAL::Random_points_on_circle_2` \sa `CGAL::Random_points_on_sphere_3` \sa `CGAL::Random_points_in_cube_d` \sa `CGAL::Random_points_in_ball_d` - */ template< typename Point_d > class Random_points_on_sphere_d { diff --git a/GraphicsView/demo/Apollonius_graph_2/Apollonius_graph_2.cpp b/GraphicsView/demo/Apollonius_graph_2/Apollonius_graph_2.cpp index c41b84b8682..c97a51fe090 100644 --- a/GraphicsView/demo/Apollonius_graph_2/Apollonius_graph_2.cpp +++ b/GraphicsView/demo/Apollonius_graph_2/Apollonius_graph_2.cpp @@ -244,7 +244,7 @@ MainWindow::open(QString fileName) #if BOOST_VERSION >= 105600 && (! defined(BOOST_GCC) || BOOST_GCC >= 40500) std::vector point_3_s; CGAL::read_multi_point_WKT(ifs, point_3_s); - BOOST_FOREACH(const K::Point_3& point_3, point_3_s) + for(const K::Point_3& point_3 : point_3_s) { points.push_back(Apollonius_site_2(K::Point_2(point_3.x(), point_3.y()), point_3.z())); } diff --git a/GraphicsView/demo/Bounding_volumes/Bounding_volumes.cpp b/GraphicsView/demo/Bounding_volumes/Bounding_volumes.cpp index 45e25999ed1..9cd70810ec0 100644 --- a/GraphicsView/demo/Bounding_volumes/Bounding_volumes.cpp +++ b/GraphicsView/demo/Bounding_volumes/Bounding_volumes.cpp @@ -499,7 +499,7 @@ MainWindow::open(QString fileName) { #if BOOST_VERSION >= 105600 && (! defined(BOOST_GCC) || BOOST_GCC >= 40500) CGAL::read_multi_point_WKT(ifs, points); - BOOST_FOREACH(K::Point_2 p, points) + for(K::Point_2 p : points) { mc.insert(p); me.insert(p); diff --git a/GraphicsView/demo/Segment_Delaunay_graph_2/Segment_voronoi_2.cpp b/GraphicsView/demo/Segment_Delaunay_graph_2/Segment_voronoi_2.cpp index 7399174b30a..4694a2a496c 100644 --- a/GraphicsView/demo/Segment_Delaunay_graph_2/Segment_voronoi_2.cpp +++ b/GraphicsView/demo/Segment_Delaunay_graph_2/Segment_voronoi_2.cpp @@ -358,7 +358,7 @@ MainWindow::loadWKTConstraints(QString do{ std::vector polygons; CGAL::read_multi_polygon_WKT(ifs, polygons); - BOOST_FOREACH(const Polygon& poly, polygons) + for(const Polygon& poly : polygons) { if(poly.outer_boundary().is_empty()) continue; @@ -388,7 +388,7 @@ MainWindow::loadWKTConstraints(QString do{ std::vector linestrings; CGAL::read_multi_linestring_WKT(ifs, linestrings); - BOOST_FOREACH(const LineString& ls, linestrings) + for(const LineString& ls : linestrings) { bool first_pass=true; LineString::const_iterator it = ls.begin(); diff --git a/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/Segment_voronoi_linf_2.cpp b/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/Segment_voronoi_linf_2.cpp index ee5ee603726..4b4c74514ff 100644 --- a/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/Segment_voronoi_linf_2.cpp +++ b/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/Segment_voronoi_linf_2.cpp @@ -401,7 +401,7 @@ MainWindow::loadWKT(QString { std::vector mpts; CGAL::read_multi_point_WKT(ifs, mpts); - BOOST_FOREACH(const K::Point_2& p, mpts) + for(const K::Point_2& p : mpts) svd.insert(p); }while(ifs.good() && !ifs.eof()); //Lines @@ -412,7 +412,7 @@ MainWindow::loadWKT(QString typedef std::vector LineString; std::vector mls; CGAL::read_multi_linestring_WKT(ifs, mls); - BOOST_FOREACH(const LineString& ls, mls) + for(const LineString& ls : mls) { if(ls.empty()) continue; @@ -450,7 +450,7 @@ MainWindow::loadWKT(QString typedef CGAL::Polygon_with_holes_2 Polygon; std::vector mps; CGAL::read_multi_polygon_WKT(ifs, mps); - BOOST_FOREACH(const Polygon& poly, mps) + for(const Polygon& poly : mps) { if(poly.outer_boundary().is_empty()) continue; diff --git a/GraphicsView/demo/Snap_rounding_2/Snap_rounding_2.cpp b/GraphicsView/demo/Snap_rounding_2/Snap_rounding_2.cpp index 4be765f84c8..cd337a2b470 100644 --- a/GraphicsView/demo/Snap_rounding_2/Snap_rounding_2.cpp +++ b/GraphicsView/demo/Snap_rounding_2/Snap_rounding_2.cpp @@ -273,7 +273,7 @@ MainWindow::open(QString fileName) #if BOOST_VERSION >= 105600 && (! defined(BOOST_GCC) || BOOST_GCC >= 40500) std::vector > mls; CGAL::read_multi_linestring_WKT(ifs, mls); - BOOST_FOREACH(const std::vector& ls, mls) + for(const std::vector& ls : mls) { if(ls.size() > 2) continue; @@ -315,7 +315,7 @@ MainWindow::on_actionSaveSegments_triggered() { #if BOOST_VERSION >= 105600 && (! defined(BOOST_GCC) || BOOST_GCC >= 40500) std::vector >mls; - BOOST_FOREACH(const Segment_2& seg, input) + for(const Segment_2& seg : input) { std::vector ls(2); ls[0] = seg.source(); diff --git a/GraphicsView/demo/Triangulation_2/Constrained_Delaunay_triangulation_2.cpp b/GraphicsView/demo/Triangulation_2/Constrained_Delaunay_triangulation_2.cpp index 008e227d28c..697b6ca1e00 100644 --- a/GraphicsView/demo/Triangulation_2/Constrained_Delaunay_triangulation_2.cpp +++ b/GraphicsView/demo/Triangulation_2/Constrained_Delaunay_triangulation_2.cpp @@ -572,12 +572,12 @@ MainWindow::loadWKT(QString typedef CGAL::Point_2 Point; std::vector mps; CGAL::read_multi_polygon_WKT(ifs, mps); - BOOST_FOREACH(const Polygon& p, mps) + for(const Polygon& p : mps) { if(p.outer_boundary().is_empty()) continue; - BOOST_FOREACH(Point point, p.outer_boundary().container()) + for(Point point : p.outer_boundary().container()) cdt.insert(point); for(Polygon::General_polygon_2::Edge_const_iterator e_it=p.outer_boundary().edges_begin(); e_it != p.outer_boundary().edges_end(); ++e_it) @@ -586,7 +586,7 @@ MainWindow::loadWKT(QString for(Polygon::Hole_const_iterator h_it = p.holes_begin(); h_it != p.holes_end(); ++h_it) { - BOOST_FOREACH(Point point, h_it->container()) + for(Point point : h_it->container()) cdt.insert(point); for(Polygon::General_polygon_2::Edge_const_iterator e_it=h_it->edges_begin(); e_it != h_it->edges_end(); ++e_it) @@ -604,7 +604,7 @@ MainWindow::loadWKT(QString typedef std::vector LineString; std::vector mls; CGAL::read_multi_linestring_WKT(ifs, mls); - BOOST_FOREACH(const LineString& ls, mls) + for(const LineString& ls : mls) { if(ls.empty()) continue; @@ -642,7 +642,7 @@ MainWindow::loadWKT(QString { std::vector mpts; CGAL::read_multi_point_WKT(ifs, mpts); - BOOST_FOREACH(const K::Point_2& p, mpts) + for(const K::Point_2& p : mpts) { cdt.insert(p); } diff --git a/GraphicsView/demo/Triangulation_2/Regular_triangulation_2.cpp b/GraphicsView/demo/Triangulation_2/Regular_triangulation_2.cpp index ca1023d4b1d..002050f4952 100644 --- a/GraphicsView/demo/Triangulation_2/Regular_triangulation_2.cpp +++ b/GraphicsView/demo/Triangulation_2/Regular_triangulation_2.cpp @@ -260,7 +260,7 @@ MainWindow::on_actionLoadPoints_triggered() #if BOOST_VERSION >= 105600 && (! defined(BOOST_GCC) || BOOST_GCC >= 40500) std::vector points_3; CGAL::read_multi_point_WKT(ifs, points_3); - BOOST_FOREACH(const K::Point_3& p, points_3) + for(const K::Point_3& p : points_3) { points.push_back(Weighted_point_2(K::Point_2(p.x(), p.y()), p.z())); } diff --git a/GraphicsView/demo/icons/license.txt b/GraphicsView/demo/icons/license.txt index ff11c043161..b9de5ecd798 100644 --- a/GraphicsView/demo/icons/license.txt +++ b/GraphicsView/demo/icons/license.txt @@ -3,3 +3,5 @@ The following files have been copied from Qt Free Edition version 4.4: fileOpen.png fileSave.png, fit-page-32.png + +This Qt version was released under GPL-2 and GPL-3. diff --git a/GraphicsView/include/CGAL/Buffer_for_vao.h b/GraphicsView/include/CGAL/Buffer_for_vao.h index 6cb6bfa5b86..e6f7cb8e341 100644 --- a/GraphicsView/include/CGAL/Buffer_for_vao.h +++ b/GraphicsView/include/CGAL/Buffer_for_vao.h @@ -71,7 +71,7 @@ namespace internal static typename Local_kernel::Point_3 get_local_point(const typename K::Point_2& p) { CGAL::Cartesian_converter converter; - return Local_point(converter(p.x()), 0, converter(p.y())); + return typename Local_kernel::Point_3(converter(p.x()), 0, converter(p.y())); } static typename Local_kernel::Point_3 get_local_point(const typename K::Weighted_point_2& p) { @@ -91,13 +91,18 @@ namespace internal static typename Local_kernel::Vector_3 get_local_vector(const typename K::Vector_2& v) { CGAL::Cartesian_converter converter; - return Local_vector(converter(v.x()), 0, converter(v.y())); + return typename Local_kernel::Vector_3(converter(v.x()), 0, converter(v.y())); } static typename Local_kernel::Vector_3 get_local_vector(const typename K::Vector_3& v) { CGAL::Cartesian_converter converter; return converter(v); } + static typename Local_kernel::Ray_2 get_local_ray(const typename K::Ray_2& r) + { + CGAL::Cartesian_converter converter; + return converter(r); + } }; // Specialization when K==Local_kernel, because there is no need of convertion here. @@ -116,6 +121,8 @@ namespace internal { return typename Local_kernel::Vector_3(v.x(), 0, v.y()); } static const typename Local_kernel::Vector_3& get_local_vector(const typename Local_kernel::Vector_3& v) { return v; } + static const typename Local_kernel::Ray_2& get_local_ray(const typename Local_kernel::Ray_2& r) + { return r; } }; } // End namespace internal @@ -127,6 +134,7 @@ public: typedef CGAL::Exact_predicates_inexact_constructions_kernel Local_kernel; typedef Local_kernel::Point_3 Local_point; typedef Local_kernel::Vector_3 Local_vector; + typedef Local_kernel::Ray_2 Local_ray; Buffer_for_vao(std::vector* pos=nullptr, std::vector* indices=nullptr, @@ -143,6 +151,7 @@ public: m_zero_x(true), m_zero_y(true), m_zero_z(true), + m_inverse_normal(false), m_face_started(false) {} @@ -193,6 +202,17 @@ public: bool has_zero_z() const { return m_zero_z; } + void negate_normals() + { + m_inverse_normal=!m_inverse_normal; + for (std::vector*array=m_flat_normal_buffer; array!=nullptr; + array=(array==m_gouraud_normal_buffer?nullptr:m_gouraud_normal_buffer)) + { + for (std::size_t i=0; isize(); ++i) + { (*array)[i]=-(*array)[i]; } + } + } + // 1.1) Add a point, without color. Return the index of the added point. template std::size_t add_point(const KPoint& kp) @@ -212,6 +232,16 @@ public: return m_pos_buffer->size()-3; } + template + std::size_t add_point_infinity(const KPoint& kp) + { + if (!has_position()) return (std::size_t)-1; + + Local_point p=get_local_point(kp); + add_point_in_buffer(p, *m_pos_buffer); + return m_pos_buffer->size()-3; + } + // 1.2) Add a point, with color. template void add_point(const KPoint& kp, const CGAL::Color& c) @@ -243,7 +273,7 @@ public: add_segment(kp1, kp2); add_color(c); add_color(c); - } + } // 2.3) Add an indexed segment, without color. template @@ -253,6 +283,44 @@ public: add_indexed_point(index2); } + // 3.1) Add a ray segment, without color + template + void add_ray_segment(const KPoint& kp1, const KVector& kp2) + { + add_point(kp1); + add_point_infinity(kp2); + } + + //3.2) Add a ray segment, with color + template + void add_ray_segment(const KPoint& kp1, const KVector& kp2, + const CGAL::Color& c) + { + add_point(kp1); + add_point_infinity(kp2); + add_color(c); + add_color(c); + } + + // 4.1) Add a line, without color + template + void add_line_segment(const KPoint& kp1, const KPoint& kp2) + { + add_point_infinity(kp1); + add_point_infinity(kp2); + } + + // 4.1) Add a line, with color + template + void add_line_segment(const KPoint& kp1, const KPoint& kp2, + const CGAL::Color& c) + { + add_point_infinity(kp1); + add_point_infinity(kp2); + add_color(c); + add_color(c); + } + /// @return true iff a face has begun. bool is_a_face_started() const { return m_face_started; } @@ -399,9 +467,10 @@ public: /// adds `kv` coordinates to `buffer` template - static void add_normal_in_buffer(const KVector& kv, std::vector& buffer) + static void add_normal_in_buffer(const KVector& kv, std::vector& buffer, + bool inverse_normal=false) { - Local_vector n=get_local_vector(kv); + Local_vector n=(inverse_normal?-get_local_vector(kv):get_local_vector(kv)); buffer.push_back(n.x()); buffer.push_back(n.y()); buffer.push_back(n.z()); @@ -457,8 +526,9 @@ public: } return true; } + CGAL::Bbox_3 *bb() const { return m_bb; } -protected: + protected: void face_begin_internal(bool has_color, bool has_normal) { if (is_a_face_started()) @@ -484,23 +554,23 @@ protected: if (m_indices_of_points_of_face.size()>0) { add_indexed_point(m_indices_of_points_of_face[i]); - } + } else { add_point(m_points_of_face[i]); // Add the position of the point - if (m_started_face_is_colored) - { add_color(m_color_of_face); } // Add the color - add_flat_normal(normal); // Add the flat normal - // Its smooth normal (if given by the user) - if (m_vertex_normals_for_face.size()>0) - { // Here we have 3 vertex normals; we can use Gouraud - add_gouraud_normal(m_vertex_normals_for_face[i]); - } - else - { // Here user does not provide all vertex normals: we use face normal istead - // and thus we will not be able to use Gouraud - add_gouraud_normal(normal); - } + if (m_started_face_is_colored) + { add_color(m_color_of_face); } // Add the color + add_flat_normal(normal); // Add the flat normal + // Its smooth normal (if given by the user) + if (m_vertex_normals_for_face.size()>0) + { // Here we have 3 vertex normals; we can use Gouraud + add_gouraud_normal(m_vertex_normals_for_face[i]); + } + else + { // Here user does not provide all vertex normals: we use face normal istead + // and thus we will not be able to use Gouraud + add_gouraud_normal(normal); + } } } } @@ -766,14 +836,14 @@ protected: void add_flat_normal(const KVector& kv) { if(m_flat_normal_buffer != nullptr) - { add_normal_in_buffer(kv, *m_flat_normal_buffer); } + { add_normal_in_buffer(kv, *m_flat_normal_buffer, m_inverse_normal); } } template void add_gouraud_normal(const KVector& kv) { if(m_gouraud_normal_buffer != nullptr) - { add_normal_in_buffer(kv, *m_gouraud_normal_buffer); } + { add_normal_in_buffer(kv, *m_gouraud_normal_buffer, m_inverse_normal); } } protected: @@ -826,8 +896,10 @@ protected: bool m_zero_x; /// True iff all points have x==0 bool m_zero_y; /// True iff all points have y==0 bool m_zero_z; /// True iff all points have z==0 + + bool m_inverse_normal;; - // Local variables, used when we started a new face. + // Local variables, used when we started a new face.g bool m_face_started; bool m_started_face_is_colored; bool m_started_face_has_normal; diff --git a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h index ae92bca0cf4..ddb4c99fa57 100644 --- a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h +++ b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h @@ -15,10 +15,12 @@ #include #include +#include +#include #ifdef CGAL_USE_BASIC_VIEWER -#ifdef __GNUC__ +#ifdef __GNUC__ #if __GNUC__ >= 9 # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wdeprecated-copy" @@ -35,7 +37,7 @@ #include #include -#ifdef __GNUC__ +#ifdef __GNUC__ #if __GNUC__ >= 9 # pragma GCC diagnostic pop #endif @@ -43,6 +45,7 @@ #include #include +#include #include #include @@ -59,14 +62,14 @@ const char vertex_source_color[] = "attribute highp vec4 vertex;\n" "attribute highp vec3 normal;\n" "attribute highp vec3 color;\n" - + "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - + "varying highp vec4 fP; \n" "varying highp vec3 fN; \n" "varying highp vec4 fColor; \n" - + "uniform highp float point_size; \n" "void main(void)\n" "{\n" @@ -89,9 +92,8 @@ const char fragment_source_color[] = "uniform highp vec4 light_spec; \n" "uniform highp vec4 light_amb; \n" "uniform float spec_power ; \n" - + "void main(void) { \n" - " highp vec3 L = light_pos.xyz - fP.xyz; \n" " highp vec3 V = -fP.xyz; \n" @@ -102,7 +104,6 @@ const char fragment_source_color[] = " highp vec3 R = reflect(-L, N); \n" " highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * fColor; \n" " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" - "gl_FragColor = light_amb*fColor + diffuse ; \n" "} \n" "\n" @@ -235,7 +236,7 @@ inline CGAL::Color get_random_color(CGAL::Random& random) } //------------------------------------------------------------------------------ class Basic_viewer_qt : public CGAL::QGLViewer -{ +{ public: typedef CGAL::Exact_predicates_inexact_constructions_kernel Local_kernel; typedef Local_kernel::Point_3 Local_point; @@ -248,18 +249,28 @@ public: bool draw_edges=true, bool draw_faces=true, bool use_mono_color=false, - bool inverse_normal=false) : + bool inverse_normal=false, + bool draw_rays=true, + bool draw_lines=true, + bool draw_text=true) : CGAL::QGLViewer(parent), m_draw_vertices(draw_vertices), m_draw_edges(draw_edges), + m_draw_rays(draw_rays), + m_draw_lines(draw_lines), m_draw_faces(draw_faces), m_flatShading(true), m_use_mono_color(use_mono_color), m_inverse_normal(inverse_normal), + m_draw_text(draw_text), m_size_points(7.), - m_size_edges(3.1), + m_size_edges(3.1), + m_size_rays(3.1), + m_size_lines(3.1), m_vertices_mono_color(200, 60, 60), m_edges_mono_color(0, 0, 0), + m_rays_mono_color(0, 0, 0), + m_lines_mono_color(0, 0, 0), m_faces_mono_color(60, 60, 200), m_ambient_color(0.6f, 0.5f, 0.5f, 0.5f), m_are_buffers_initialized(false), @@ -281,6 +292,24 @@ public: &m_bounding_box, &arrays[COLOR_SEGMENTS], nullptr, nullptr), + m_buffer_for_mono_rays(&arrays[POS_MONO_RAYS], + nullptr, + &m_bounding_box, + nullptr, nullptr), + m_buffer_for_colored_rays(&arrays[POS_COLORED_RAYS], + nullptr, + &m_bounding_box, + &arrays[COLOR_RAYS], + nullptr, nullptr), + m_buffer_for_mono_lines(&arrays[POS_MONO_RAYS], + nullptr, + &m_bounding_box, + nullptr, nullptr), + m_buffer_for_colored_lines(&arrays[POS_COLORED_LINES], + nullptr, + &m_bounding_box, + &arrays[COLOR_LINES], + nullptr, nullptr), m_buffer_for_mono_faces(&arrays[POS_MONO_FACES], nullptr, &m_bounding_box, @@ -290,7 +319,7 @@ public: m_buffer_for_colored_faces(&arrays[POS_COLORED_FACES], nullptr, &m_bounding_box, - &arrays[COLOR_FACES], + &arrays[COLOR_FACES], &arrays[FLAT_NORMAL_COLORED_FACES], &arrays[SMOOTH_NORMAL_COLORED_FACES]) { @@ -300,6 +329,9 @@ public: setWindowTitle(title); resize(500, 450); + + if (inverse_normal) + { negate_all_normals(); } } ~Basic_viewer_qt() @@ -307,7 +339,7 @@ public: for (unsigned int i=0; i @@ -371,23 +420,89 @@ public: template void add_point(const KPoint& p, const CGAL::Color& acolor) - { m_buffer_for_colored_points.add_point(p, acolor); } - + { m_buffer_for_colored_points.add_point(p, acolor); } + template void add_segment(const KPoint& p1, const KPoint& p2) { m_buffer_for_mono_segments.add_segment(p1, p2); } - + template void add_segment(const KPoint& p1, const KPoint& p2, const CGAL::Color& acolor) - { m_buffer_for_colored_segments.add_segment(p1, p2, acolor); } + { m_buffer_for_colored_segments.add_segment(p1, p2, acolor); } + + template + void update_bounding_box_for_ray(const KPoint &p, const KVector &v) + { + Local_point lp = get_local_point(p); + Local_vector lv = get_local_vector(v); + CGAL::Bbox_3 b = (lp + lv).bbox(); + m_bounding_box += b; + } + + template + void update_bounding_box_for_line(const KPoint &p, const KVector &v, + const KVector &pv) + { + Local_point lp = get_local_point(p); + Local_vector lv = get_local_vector(v); + Local_vector lpv = get_local_vector(pv); + + CGAL::Bbox_3 b = lp.bbox() + (lp + lv).bbox() + (lp + lpv).bbox(); + m_bounding_box += b; + } + + template + void add_ray(const KPoint &p, const KVector &v) + { + double bigNumber = 1e30; + m_buffer_for_mono_rays.add_ray_segment(p, (p + (bigNumber)*v)); + } + + template + void add_ray(const KPoint &p, const KVector &v, const CGAL::Color &acolor) + { + double bigNumber = 1e30; + m_buffer_for_colored_rays.add_ray_segment(p, (p + (bigNumber)*v), acolor); + } + + template + void add_line(const KPoint &p, const KVector &v) + { + double bigNumber = 1e30; + m_buffer_for_mono_lines.add_line_segment((p - (bigNumber)*v), + (p + (bigNumber)*v)); + } + + template + void add_line(const KPoint &p, const KVector &v, const CGAL::Color &acolor) + { + double bigNumber = 1e30; + m_buffer_for_colored_lines.add_line_segment((p - (bigNumber)*v), + (p + (bigNumber)*v), acolor); + } + + template + void add_text(const KPoint& kp, const QString& txt) + { + Local_point p=get_local_point(kp); + m_texts.push_back(std::make_tuple(p, txt)); + } + + template + void add_text(const KPoint& kp, const char* txt) + { add_text(kp, QString(txt)); } + + template + void add_text(const KPoint& kp, const std::string& txt) + { add_text(kp, txt.c_str()); } bool is_a_face_started() const { return m_buffer_for_mono_faces.is_a_face_started() || m_buffer_for_colored_faces.is_a_face_started(); } - + void face_begin() { if (is_a_face_started()) @@ -396,7 +511,7 @@ public: } else { m_buffer_for_mono_faces.face_begin(); } - } + } void face_begin(const CGAL::Color& acolor) { @@ -417,7 +532,7 @@ public: { return m_buffer_for_colored_faces.add_point_in_face(kp); } return false; } - + template bool add_point_in_face(const KPoint& kp, const KVector& p_normal) { @@ -455,20 +570,20 @@ protected: { rendering_program_face.removeAllShaders(); rendering_program_p_l.removeAllShaders(); - + // Create the buffers for (unsigned int i=0; i(arrays[POS_MONO_RAYS].size()*sizeof(float))); + rendering_program_p_l.enableAttributeArray("vertex"); + rendering_program_p_l.setAttributeArray("vertex",GL_FLOAT,0,3); + + buffers[bufn].release(); + + rendering_program_p_l.disableAttributeArray("color"); + + vao[VAO_MONO_RAYS].release(); + + // 3.2) Color rays + + vao[VAO_COLORED_RAYS].bind(); + + ++bufn; + assert(bufn(arrays[POS_COLORED_RAYS].size()*sizeof(float))); + rendering_program_p_l.enableAttributeArray("vertex"); + rendering_program_p_l.setAttributeBuffer("vertex",GL_FLOAT,0,3); + + buffers[bufn].release(); + + ++bufn; + assert(bufn(arrays[COLOR_RAYS].size()*sizeof(float))); + rendering_program_p_l.enableAttributeArray("color"); + rendering_program_p_l.setAttributeBuffer("color",GL_FLOAT,0,3); + buffers[bufn].release(); + + vao[VAO_COLORED_RAYS].release(); + + rendering_program_p_l.release(); + + // 4) LINES SHADER + // 4.1) Mono lines + vao[VAO_MONO_LINES].bind(); + + ++bufn; + assert(bufn(arrays[POS_MONO_LINES].size()*sizeof(float))); + rendering_program_p_l.enableAttributeArray("vertex"); + rendering_program_p_l.setAttributeArray("vertex",GL_FLOAT,0,3); + + buffers[bufn].release(); + + rendering_program_p_l.disableAttributeArray("color"); + + vao[VAO_MONO_LINES].release(); + + // 4.2 Color lines + + vao[VAO_COLORED_LINES].bind(); + + ++bufn; + assert(bufn(arrays[POS_COLORED_LINES].size()*sizeof(float))); + rendering_program_p_l.enableAttributeArray("vertex"); + rendering_program_p_l.setAttributeBuffer("vertex",GL_FLOAT,0,3); + + buffers[bufn].release(); + + ++bufn; + assert(bufn(arrays[COLOR_LINES].size()*sizeof(float))); + rendering_program_p_l.enableAttributeArray("color"); + rendering_program_p_l.setAttributeBuffer("color",GL_FLOAT,0,3); + buffers[bufn].release(); + + vao[VAO_COLORED_LINES].release(); + + rendering_program_p_l.release(); + + // 5) FACE SHADER rendering_program_face.bind(); - // 3.1) Mono faces + // 5.1) Mono faces vao[VAO_MONO_FACES].bind(); - // 3.1.1) points of the mono faces + // 5.1.1) points of the mono faces ++bufn; assert(bufn(arrays[POS_COLORED_FACES].size()*sizeof(float))); rendering_program_face.enableAttributeArray("vertex"); rendering_program_face.setAttributeBuffer("vertex",GL_FLOAT,0,3); - + buffers[bufn].release(); - - // 3.2.2) normals of the color faces + + // 5.2.2) normals of the color faces ++bufn; assert(bufn(arrays[COLOR_FACES].size()*sizeof(float))); rendering_program_face.enableAttributeArray("color"); rendering_program_face.setAttributeBuffer("color",GL_FLOAT,0,3); - + buffers[bufn].release(); - + vao[VAO_COLORED_FACES].release(); - + rendering_program_face.release(); - + m_are_buffers_initialized = true; } @@ -712,12 +918,12 @@ protected: QMatrix4x4 mvMatrix; double mat[16]; viewer->camera()->getModelViewProjectionMatrix(mat); - for(int i=0; i < 16; i++) + for(unsigned int i=0; i < 16; i++) { mvpMatrix.data()[i] = (float)mat[i]; } viewer->camera()->getModelViewMatrix(mat); - for(int i=0; i < 16; i++) + for(unsigned int i=0; i < 16; i++) { mvMatrix.data()[i] = (float)mat[i]; } @@ -734,13 +940,13 @@ protected: CGAL::Bbox_3 bb; if (bb==bounding_box()) // Case of "empty" bounding box - { + { bb=Local_point(CGAL::ORIGIN).bbox(); bb=bb + Local_point(1,1,1).bbox(); // To avoid a warning from Qglviewer } else { bb=bounding_box(); } - + QVector4D position((bb.xmax()-bb.xmin())/2, (bb.ymax()-bb.ymin())/2, bb.zmax(), 0.0); @@ -764,13 +970,18 @@ protected: rendering_program_face.setUniformValue(mvpLocation, mvpMatrix); rendering_program_face.setUniformValue(mvLocation, mvMatrix); rendering_program_face.release(); - + rendering_program_p_l.bind(); int mvpLocation2 = rendering_program_p_l.uniformLocation("mvp_matrix"); rendering_program_p_l.setUniformValue(mvpLocation2, mvpMatrix); rendering_program_p_l.release(); } + // Returns true if the data structure lies on a plane + bool is_two_dimensional() { + return (!is_empty() && (has_zero_x() || has_zero_y() || has_zero_z())); + } + virtual void draw() { glEnable(GL_DEPTH_TEST); @@ -792,7 +1003,7 @@ protected: rendering_program_p_l.setUniformValue("point_size", GLfloat(m_size_points)); glDrawArrays(GL_POINTS, 0, static_cast(arrays[POS_MONO_POINTS].size()/3)); vao[VAO_MONO_POINTS].release(); - + vao[VAO_COLORED_POINTS].bind(); if (m_use_mono_color) { @@ -846,6 +1057,83 @@ protected: rendering_program_p_l.release(); } + if(m_draw_rays) + { + rendering_program_p_l.bind(); + + vao[VAO_MONO_RAYS].bind(); + color.setRgbF((double)m_rays_mono_color.red()/(double)255, + (double)m_rays_mono_color.green()/(double)255, + (double)m_rays_mono_color.blue()/(double)255); + rendering_program_p_l.setAttributeValue("color",color); + glLineWidth(m_size_rays); + glDrawArrays(GL_LINES, 0, static_cast(arrays[POS_MONO_RAYS].size()/3)); + vao[VAO_MONO_RAYS].release(); + + vao[VAO_COLORED_RAYS].bind(); + if (m_use_mono_color) + { + color.setRgbF((double)m_rays_mono_color.red()/(double)255, + (double)m_rays_mono_color.green()/(double)255, + (double)m_rays_mono_color.blue()/(double)255); + rendering_program_p_l.disableAttributeArray("color"); + rendering_program_p_l.setAttributeValue("color",color); + } + else + { + rendering_program_p_l.enableAttributeArray("color"); + } + glLineWidth(m_size_rays); + glDrawArrays(GL_LINES, 0, static_cast(arrays[POS_COLORED_RAYS].size()/3)); + vao[VAO_COLORED_RAYS].release(); + + rendering_program_p_l.release(); + } + + if(m_draw_lines) + { + rendering_program_p_l.bind(); + + vao[VAO_MONO_LINES].bind(); + color.setRgbF((double)m_lines_mono_color.red()/(double)255, + (double)m_lines_mono_color.green()/(double)255, + (double)m_lines_mono_color.blue()/(double)255); + rendering_program_p_l.setAttributeValue("color",color); + glLineWidth(m_size_lines); + glDrawArrays(GL_LINES, 0, static_cast(arrays[POS_MONO_LINES].size()/3)); + vao[VAO_MONO_LINES].release(); + + rendering_program_p_l.release(); + + vao[VAO_COLORED_LINES].bind(); + if (m_use_mono_color) + { + color.setRgbF((double)m_rays_mono_color.red()/(double)255, + (double)m_rays_mono_color.green()/(double)255, + (double)m_rays_mono_color.blue()/(double)255); + rendering_program_p_l.disableAttributeArray("color"); + rendering_program_p_l.setAttributeValue("color",color); + } + else + { + rendering_program_p_l.enableAttributeArray("color"); + } + glLineWidth(m_size_lines); + glDrawArrays(GL_LINES, 0, static_cast(arrays[POS_COLORED_LINES].size()/3)); + vao[VAO_COLORED_LINES].release(); + + rendering_program_p_l.release(); + } + + // Fix Z-fighting by drawing faces at a depth + GLfloat offset_factor; + GLfloat offset_units; + if (is_two_dimensional()) { + glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &offset_factor); + glGetFloatv(GL_POLYGON_OFFSET_UNITS, &offset_units); + glPolygonOffset(0.1f, 0.9f); + } + if (m_draw_faces) { rendering_program_face.bind(); @@ -874,10 +1162,13 @@ protected: glDrawArrays(GL_TRIANGLES, 0, static_cast(arrays[POS_COLORED_FACES].size()/3)); vao[VAO_COLORED_FACES].release(); + if (is_two_dimensional()) + glPolygonOffset(offset_factor, offset_units); + rendering_program_face.release(); } - if (!is_empty() && (has_zero_x() || has_zero_y() || has_zero_z())) + if (is_two_dimensional()) { camera()->setType(CGAL::qglviewer::Camera::ORTHOGRAPHIC); // Camera Constraint: @@ -893,6 +1184,21 @@ protected: constraint.setRotationConstraintDirection(CGAL::qglviewer::Vec(cx, cy, cz)); camera()->frame()->setConstraint(&constraint); } + + if (m_draw_text) + { + glDisable(GL_LIGHTING); + for (std::size_t i=0; iprojectedCoordinatesOf + (CGAL::qglviewer::Vec(std::get<0>(m_texts[i]).x(), + std::get<0>(m_texts[i]).y(), + std::get<0>(m_texts[i]).z())); + + drawText((int)screenPos[0], (int)screenPos[1], std::get<1>(m_texts[i])); + } + glEnable(GL_LIGHTING); + } } virtual void redraw() @@ -900,7 +1206,7 @@ protected: initialize_buffers(); update(); } - + virtual void init() { // Restore previous viewer state. @@ -916,6 +1222,7 @@ protected: setKeyDescription(::Qt::Key_G, "Switch between flat/Gouraud shading display"); setKeyDescription(::Qt::Key_M, "Toggles mono color"); setKeyDescription(::Qt::Key_N, "Inverse direction of normals"); + setKeyDescription(::Qt::Key_T, "Toggles text display"); setKeyDescription(::Qt::Key_V, "Toggles vertices display"); setKeyDescription(::Qt::Key_Plus, "Increase size of edges"); setKeyDescription(::Qt::Key_Minus, "Decrease size of edges"); @@ -939,7 +1246,7 @@ protected: CGAL::Bbox_3 bb; if (bb==bounding_box()) // Case of "empty" bounding box - { + { bb=Local_point(CGAL::ORIGIN).bbox(); bb=bb + Local_point(1,1,1).bbox(); // To avoid a warning from Qglviewer } @@ -957,13 +1264,10 @@ protected: void negate_all_normals() { - for (unsigned int k=BEGIN_NORMAL; kmodifiers(); @@ -973,8 +1277,7 @@ protected: m_draw_edges=!m_draw_edges; displayMessage(QString("Draw edges=%1.").arg(m_draw_edges?"true":"false")); update(); - } - else if ((e->key()==::Qt::Key_F) && (modifiers==::Qt::NoButton)) + }else if ((e->key()==::Qt::Key_F) && (modifiers==::Qt::NoButton)) { m_draw_faces=!m_draw_faces; displayMessage(QString("Draw faces=%1.").arg(m_draw_faces?"true":"false")); @@ -1002,6 +1305,12 @@ protected: negate_all_normals(); redraw(); } + else if ((e->key()==::Qt::Key_T) && (modifiers==::Qt::NoButton)) + { + m_draw_text=!m_draw_text; + displayMessage(QString("Draw text=%1.").arg(m_draw_text?"true":"false")); + update(); + } else if ((e->key()==::Qt::Key_V) && (modifiers==::Qt::NoButton)) { m_draw_vertices=!m_draw_vertices; @@ -1146,16 +1455,23 @@ protected: protected: bool m_draw_vertices; bool m_draw_edges; + bool m_draw_rays; + bool m_draw_lines; bool m_draw_faces; bool m_flatShading; bool m_use_mono_color; bool m_inverse_normal; + bool m_draw_text; double m_size_points; double m_size_edges; + double m_size_rays; + double m_size_lines; CGAL::Color m_vertices_mono_color; CGAL::Color m_edges_mono_color; + CGAL::Color m_rays_mono_color; + CGAL::Color m_lines_mono_color; CGAL::Color m_faces_mono_color; QVector4D m_ambient_color; @@ -1173,12 +1489,18 @@ protected: POS_COLORED_POINTS, POS_MONO_SEGMENTS, POS_COLORED_SEGMENTS, + POS_MONO_RAYS, + POS_COLORED_RAYS, + POS_MONO_LINES, + POS_COLORED_LINES, POS_MONO_FACES, POS_COLORED_FACES, END_POS, BEGIN_COLOR=END_POS, COLOR_POINTS=BEGIN_COLOR, COLOR_SEGMENTS, + COLOR_RAYS, + COLOR_LINES, COLOR_FACES, END_COLOR, BEGIN_NORMAL=END_COLOR, @@ -1195,20 +1517,28 @@ protected: Buffer_for_vao m_buffer_for_colored_points; Buffer_for_vao m_buffer_for_mono_segments; Buffer_for_vao m_buffer_for_colored_segments; + Buffer_for_vao m_buffer_for_mono_rays; + Buffer_for_vao m_buffer_for_colored_rays; + Buffer_for_vao m_buffer_for_mono_lines; + Buffer_for_vao m_buffer_for_colored_lines; Buffer_for_vao m_buffer_for_mono_faces; Buffer_for_vao m_buffer_for_colored_faces; - + static const unsigned int NB_VBO_BUFFERS=(END_POS-BEGIN_POS)+ (END_COLOR-BEGIN_COLOR)+2; // +2 for 2 vectors of normals QGLBuffer buffers[NB_VBO_BUFFERS]; // The following enum gives the indices of the differents vao. - enum + enum { VAO_MONO_POINTS=0, VAO_COLORED_POINTS, VAO_MONO_SEGMENTS, VAO_COLORED_SEGMENTS, + VAO_MONO_RAYS, + VAO_COLORED_RAYS, + VAO_MONO_LINES, + VAO_COLORED_LINES, VAO_MONO_FACES, VAO_COLORED_FACES, NB_VAO_BUFFERS @@ -1217,6 +1547,8 @@ protected: QOpenGLShaderProgram rendering_program_face; QOpenGLShaderProgram rendering_program_p_l; + + std::vector > m_texts; }; } // End namespace CGAL diff --git a/INSTALL.md b/INSTALL.md index ca09f887112..8913be934e0 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,71 +1,55 @@ -Building CGAL Libraries From a Branch -===================================== +NOTICE +====== -Building CGAL using the *branch build* presented here keeps the -build-sources attached to the Git repository. +Since Version 5.0, CGAL is a header-only library it is not needed +to build and install it. Usage of CGAL should thus simply amount to: -Note that we do not document here what are the dependancies and cmake options that -are needed to configure CGAL as they are already documented in the -[installation manual](https://doc.cgal.org/latest/Manual/installation.html). - -Branch Build of CGAL -==================== -The cmake script at the root of the repository is the one to use to -build the CGAL library from a branch. It will collect the list of packages -of the branch and will append their include folder to the include path. -This is main noticeable difference with a build using a regular *flat* release. - -Here is an example of how to build the library in Debug: ``` {.bash} git clone https://github.com/CGAL/cgal.git /path/to/cgal.git -cd /path/to/cgal.git +cd /path/to/cgal.git/Triangulation_2/examples/Triangulation_2 mkdir -p build/debug cd build/debug -cmake -DCMAKE_BUILD_TYPE=Debug ../.. +cmake -DCMAKE_BUILD_TYPE=Debug -DCGAL_DIR=/path/to/cgal.git make ``` -Here is an example of how to build the library in Release: -``` {.bash} -git clone https://github.com/CGAL/cgal.git /path/to/cgal.git -cd /path/to/cgal.git -mkdir -p build/release -cd build/release -cmake -DCMAKE_BUILD_TYPE=Release ../.. -make -``` -Note that *no installation is required* to use that version of CGAL once it has been compiled. +in the case of the building of an example in debug mode. + +For more information head over to the [CGAL manual](https://doc.cgal.org/latest/Manual/general_intro.html). +Note that this page describes the setting of CGAL as a sources release and, as such, +files are organized in a slightly different way, see the [Layout of the CGAL Git Repository](README.md). + Building a Program Using CGAL ============================= To compile a program using CGAL, simply set `CGAL_DIR` to the location -of where you built the library (environment or cmake variable). +of the directory containing `CGALConfig.cmake` (for example the root +of the extracted source archive or the root of a git checkout). Here is an example of how to build in debug the examples from the 3D Triangulations package: ``` {.bash} - cmake -DCGAL_DIR:PATH=/path/to/cgal.git/build/debug /path/to/cgal.git/Triangulation_3/examples/Triangulation_3 + cd /path/to/cgal.git/Triangulation_3/examples/Triangulation_3 + mkdir -p build/debug + cd build/debug + cmake -DCGAL_DIR:PATH=/path/to/cgal.git ../.. make ``` -If you're trying to build examples or tests that does not already have a `CMakeLists.txt`, you can trigger its creation by calling the script [`cgal_create_cmake_script`](Scripts/scripts/cgal_create_cmake_script) found in `/path/to/cgal.git/Scripts/scripts/` at the root of the example/test directory. Here is an example for the examples of the 2D Triangulation package: +If you are trying to build examples or tests that do not already have a `CMakeLists.txt`, +you can trigger its creation by calling the script [`cgal_create_cmake_script`](Scripts/scripts/cgal_create_cmake_script) +found in `/path/to/cgal.git/Scripts/scripts/` at the root of the example/test directory. +Here is an example for the examples of the 2D Triangulation package: ``` {.bash} cd /path/to/cgal.git/Triangulation_2/examples/Triangulation_2 /path/to/cgal.git/Scripts/scripts/cgal_create_cmake_script - cd - - cmake -DCGAL_DIR:PATH=/path/to/cgal.git/build/debug /path/to/cgal.git/Triangulation_2/examples/Triangulation_2 + cd /path/to/cgal.git/Triangulation_2/examples/Triangulation_2 + mkdir -p build/debug + cd build/debug + cmake -DCGAL_DIR:PATH=/path/to/cgal.git ../.. make ``` -Note If You Switch Between Branches -=================================== -A build may be outdated after an include/dir has been deleted, -switched or even updated. This might lead to compile problems (link -with outdated version). Thus, it is recommended to build CGAL after -each update, switch, merge of a branch (in particular if directories -have been added/deleted, or cpp files have been added, deleted or -altered). - - +For more information head over to the [CGAL manual](https://doc.cgal.org/latest/Manual/general_intro.html). diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 51e45d1c998..d3cc2cd26e5 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -1,10 +1,65 @@ Release History =============== +Release 5.1 +----------- + +Release date: June 2020 + +### 3D Fast Intersection and Distance Computation +- **Breaking change**: the internal search tree is now lazily constructed. To disable it, one must call + the new function `do_not_accelerate_distance_queries()` before the first distance query. + +### Polygon Mesh Processing + +- The function `CGAL::Polygon_mesh_processing::stitch_borders()` now returns the number + of halfedge pairs that were stitched. + +### 2D Triangulations +- To fix an inconsistency between code and documentation and to clarify which types of intersections + are truly allowed in constrained Delaunay triangulations, the tag `CGAL::No_intersection_tag` + has been deprecated in favor of two new tags `CGAL::No_constraint_intersection_tag` + and `CGAL::No_constraint_intersection_requiring_constructions_tag`. + The latter is equivalent to the now-deprecated `CGAL::No_intersection_tag`, and allows constraints + to intersect as long as no new point has to be created to represent that intersection (for example, + the intersection of two constraint segments in a 'T'-like junction is an existing point + and does not require any new construction). The former tag, `CGAL::No_constraint_intersection_tag`, + does not allow any intersection, except for the configuration of two constraints having a single + common endpoints, for convience. + +### dD Spatial Searching + +- Improved the performance of the kd-tree in some cases: + - Not storing the points coordinates inside the tree usually + generates a lot of cache misses, leading to non-optimal + performance. This is the case for example + when indices are stored inside the tree, or to a lesser extent when the points + coordinates are stored in a dynamically allocated array (e.g., `Epick_d` + with dynamic dimension) — we says "to a lesser extent" because the points + are re-created by the kd-tree in a cache-friendly order after its construction, + so the coordinates are more likely to be stored in a near-optimal order + on the heap. + In these cases, the new `EnablePointsCache` template parameter of the + `CGAL::Kd_tree` class can be set to `CGAL::Tag_true`. The points coordinates + will then be cached in an optimal way. This will increase memory + consumption but provides better search performance. See the updated + `GeneralDistance` and `FuzzyQueryItem` + concepts for additional requirements when using such a cache. + - In most cases (e.g., Euclidean distance), the distance computation + algorithm knows before its end that the distance will be greater + than or equal to some given value. This is used in the (orthogonal) + k-NN search to interrupt some distance computations before its end, + saving precious milliseconds, in particular in medium-to-high dimension. + +### dD Geometry Kernel +- Epick\_d and Epeck\_d gain 2 new functors: `Power_side_of_bounded_power_sphere_d` and + `Compute_squared_radius_smallest_orthogonal_sphere_d`. Those are + essential for the computation of weighted alpha-complexes. + [Release 5.0](https://github.com/CGAL/cgal/releases/tag/releases%2FCGAL-5.0) ----------- -Release date: October 2019 +Release date: November 2019 ### General changes @@ -18,6 +73,9 @@ Release date: October 2019 - Since CGAL 4.9, CGAL can be used as a header-only library, with dependencies. Since CGALĀ 5.0, that is now the default, unless specified differently in the (optional) CMake configuration. +- The section "Getting Started with CGAL" of the documentation has + been updated and reorganized. +- The minimal version of Boost is now 1.57.0. ### [Polygonal Surface Reconstruction](https://doc.cgal.org/5.0/Manual/packages.html#PkgPolygonalSurfaceReconstruction) (new package) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index c149c941c4e..db6e3120e77 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -1191,7 +1191,7 @@ You must disable CGAL_ENABLE_CHECK_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") find_program(AWK awk) - set(awk_arguments [=[{ match($0, /# *include *(<|[<"])(CGAL\/[^>&"]*)([>"]|>)/,arr); if(arr[2]!="") print arr[2] }]=]) + set(awk_arguments [=[{ match($0, /# *include *(<|[<"])(CGAL\/[^>&"]*)([>"]|>)| (CGAL\/[^>&"]*\.h)/,arr); if(arr[2]!="") print arr[2]; if(arr[4]!="") print arr[4] }]=]) message("listing headers from html files") foreach(f ${html_files}) execute_process(COMMAND "${AWK}" "${awk_arguments}" "${DOC_DIR}/doc_output/${f}" diff --git a/Installation/INSTALL.md b/Installation/INSTALL.md index eeefd10cf37..54d011ef408 100644 --- a/Installation/INSTALL.md +++ b/Installation/INSTALL.md @@ -1,199 +1,15 @@ -INTRODUCTION -============ +NOTICE +====== -This file describes how to install CGAL. The instructions in this file -are for the most common use cases, and cover the command line tools. +Since Version 5.0, CGAL is now header-only by default, meaning that you do not need to build and install CGAL. Usage of CGAL as a header-only library +simply amounts to, for example: -For further information, or in case of problems, please see the -detailed installation instructions, which can be found in this -distribution in the file ./doc_html/index.html or on the CGAL website -https://doc.cgal.org/latest/Manual/installation.html - -The documentation of CGAL is available in PDF and HTML formats. -It is not bundled with the software but can be downloaded separately -at . - -For more information about CGAL, see the . - -In the current file, x.y is an implicit replacement for the current version -of CGAL (3.5.1, 3.6, and so on). - - -PREREQUISITES -============= - -To install CGAL, you need 'cmake' and several third-party libraries. -Some are essential for entire CGAL, some are mandatory for particular -CGAL packages, some are only needed for demos. - - * CMake (>= 3.1), the build system used by CGAL - Required for building CGAL - - * Boost (>= 1.48) - Required for building CGAL and for applications using CGAL - Optional compiled Boost library: Boost.Program_options - http://www.boost.org/ or http://www.boostpro.com/products/free/ - You need the former if you plan to compile the boost libraries yourself, - for example because you target 64 bit applications for XP64 - - * Exact Arithmetic - CGAL combines floating point arithmetic with exact arithmetic, in order - to be fast and reliable. CGAL offers support for GMP and MPFR, for LEDA - exact number types, as well as a built-in exact number type used when - none of the other two is installed. - Required by several examples which have hard coded the number type. - - - GMP (>= 4.1.4) - http://gmplib.org/ - or precompiled version that can be downloaded with CGAL-x.y-Setup.exe - based on http://fp.gladman.plus.com/computing/gmp4win.htm - - - MPFR (>= 2.2.1) - https://www.mpfr.org/ - or precompiled version that can be downloaded with CGAL-x.y-Setup.exe - based on http://fp.gladman.plus.com/computing/gmp4win.htm - - - LEDA (>= 6.2) - http://www.algorithmic-solutions.com/leda/index.htm - - * Visualization - Required for most demos - - - Qt5 (>= 5.9) - http://qt-project.org/ - - - Geomview - http://www.geomview.org/ - Not supported with Visual C++ - - * Numerical Libraries - - EIGEN (>=3.1) - Required by the packages: - * Estimation of Local Differential Properties of Point-Sampled Surfaces - * Approximation of Ridges and Umbilics on Triangulated Surface Meshes - * Planar Parameterization of Triangulated Surface Meshes - * Surface Reconstruction from Point Sets - http://eigen.tuxfamily.org/index.php?title=Main_Page - - - MPFI - Required by the package: - * Algebraic Kernel - https://gforge.inria.fr/projects/mpfi/ - (or shipped with RS http://vegas.loria.fr/rs/) - - - RS (root isolation) - Required by the package: - * Algebraic Kernel - http://vegas.loria.fr/rs/ - - - NTL (Number Type Theory) - Optional for the packages: - * Polynomial - * Algebraic Kernel - http://www.shoup.net/ntl/ - - * Miscellaneous - - - zlib - Optional for the package: - * Surface Mesh Generator can read compressed images directly - http://www.zlib.net/ - - - ESBTL - Optional to read PDB files: - * Import data from a PDB file as CGAL points or weighted points. - An example is given in package Skin_surface (see example skin_surface_pdb_reader.cpp) - http://esbtl.sourceforge.net/ - -CONFIGURATION -============= - -To configure CGAL, type -``` - cmake . -``` -in the directory that contains this INSTALL file. You can add several options -to this command. The most important ones are - -* `-DCMAKE_INSTALL_PREFIX=` installation directory [/usr/local] -* `-DCMAKE_BUILD_TYPE=` build type [Release] -* `-DBUILD_SHARED_LIBS=` shared or static libraries [TRUE] -* `-DCMAKE_C_COMPILER=` C compiler [gcc] -* `-DCMAKE_CXX_COMPILER=` C++ compiler [g++] - -In case you want to add additional compiler and linker flags, you can use - -* `-DCGAL_CXX_FLAGS` additional compiler flags -* `-DCGAL_MODULE_LINKER_FLAGS` add. linker flags (static libraries) -* `-DCGAL_SHARED_LINKER_FLAGS` add. linker flags (shared libraries) -* `-DCGAL_EXE_LINKER_FLAGS` add. linker flags (executables) - -Variants with the additional suffix "_DEBUG" and "_RELEASE" allow to set -separate values for debug and release builds. In case you do not want to add -additional flags, but to override the default flags, replace "CGAL" by -"CMAKE" in the variable names above. - -By default demos and examples are not configured. If you want to configure -them at the same time as the CGAL library, you can use - -* `-DWITH_examples=true` -* `-DWITH_demos=true` - -Note that CMake maintains a cache name `CMakeCache.txt`. If you change options -(or your environment changes), it is best to remove that file to avoid -problems. - - -BUILDING -======== - -To build the CGAL libraries, type -``` - make -``` -(or nmake in a Windows command prompt). -If you want, you can install the CGAL header and libraries. To do so, type -``` - make install -``` -You can build all demos or examples by typing -``` - make demos - make examples -``` -If you are interested in the demos or examples of just a particular module, -you can build them in the following way: -``` - make -C demo/Alpha_shapes_2 (or: cd demo/Alpha_shapes_2; make) - make -C examples/Alpha_shapes_2 (or: cd examples/Alpha_shapes_2; make) -``` -A list of all available make targets can be obtained by -``` - make help +``` {.bash} +cd /path/to/cgal/examples/Triangulation_2 +mkdir -p build/debug +cd build/debug +cmake -DCMAKE_BUILD_TYPE=Debug -DCGAL_DIR=/path/to/cgal +make ``` -OUT-OF-SOURCE BUILDS -==================== - -The above instructions build the CGAL library in the same directory tree as -the CGAL sources. Sometimes it is advisable to place all the generated files -somewhere else. For example, if you want to build the library in several -configurations (debug and release, different compilers, and so on). Using -different build directories keeps all the generated files separated for each -configuration. - -In the following, `$CGAL_SRC` denotes the directory with the CGAL sources; -`$CGAL_BUILD` is an arbitrary directory where the generated files will be -placed. You can perform an out-of-source build as follows: -``` - mkdir $CGAL_BUILD - cd $CGAL_BUILD - cmake [options] $CGAL_SRC - make - make install (if desired) - make demos (if desired) - make examples (if desired) -``` -Basically, the only difference is the last parameter of the `cmake` command: -`$CGAL_SRC` instead of `.` . - +For more information head over to the [CGAL manual](https://doc.cgal.org/latest/Manual/general_intro.html). diff --git a/Installation/LICENSE b/Installation/LICENSE index 677312c96e7..4a393c57241 100644 --- a/Installation/LICENSE +++ b/Installation/LICENSE @@ -33,6 +33,8 @@ licenses: (see LICENSE.LGPL). - OpenNL, in the directory "include/CGAL/OpenNL", is licensed under the LGPL (see LICENSE.LGPL). +- ETH Zurich random forest algorithm, in the directory "CGAL/Classification/ETHZ", + is licensed under a MIT like license (see LICENSE.RFL). All other files that do not have an explicit copyright notice (e.g., all examples and some demos) are licensed under a very permissive license. The diff --git a/Installation/cmake/modules/CGAL_SetupCGAL_Qt5Dependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGAL_Qt5Dependencies.cmake index dae96c444e6..2cdc190f75a 100644 --- a/Installation/cmake/modules/CGAL_SetupCGAL_Qt5Dependencies.cmake +++ b/Installation/cmake/modules/CGAL_SetupCGAL_Qt5Dependencies.cmake @@ -36,7 +36,9 @@ endif() if(NOT Qt5_FOUND) set(CGAL_Qt5_MISSING_DEPS "${CGAL_Qt5_MISSING_DEPS} Qt5") endif() - +if(NOT EXISTS ${CGAL_GRAPHICSVIEW_PACKAGE_DIR}/include/CGAL/Qt/GraphicsItem.h) + set(CGAL_Qt5_MISSING_DEPS "${CGAL_Qt5_MISSING_DEPS} headers") +endif() #.rst: # Result Variables diff --git a/Installation/doc_html/index.html b/Installation/doc_html/index.html index 0c67b663e5e..1c7c7682d48 100644 --- a/Installation/doc_html/index.html +++ b/Installation/doc_html/index.html @@ -25,13 +25,9 @@ in the form of a C++ library.

    Manuals

    - - + @@ -39,7 +35,7 @@ in the form of a C++ library. diff --git a/Installation/include/CGAL/auto_link/auto_link.h b/Installation/include/CGAL/auto_link/auto_link.h index c02515b95d9..3f9a015f1bb 100644 --- a/Installation/include/CGAL/auto_link/auto_link.h +++ b/Installation/include/CGAL/auto_link/auto_link.h @@ -1,15 +1,13 @@ // This header file is a copy of "boost/config/auto_link.hpp" // from boost version 1.44.0 // but slightly modified to accommodate CGAL libraries. - +// // Before CGAL-4.7-beta1, it has been synchronized with // libs/config/ version boost-1.58.0-39-g15d56c9, file // include/boost/config/auto_link.hpp - +// // (C) Copyright John Maddock 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) +// // // $URL$ // $Id$ diff --git a/Installation/include/CGAL/version.h b/Installation/include/CGAL/version.h index f3edd55ba82..5277243907f 100644 --- a/Installation/include/CGAL/version.h +++ b/Installation/include/CGAL/version.h @@ -16,11 +16,11 @@ #ifndef CGAL_VERSION_H #define CGAL_VERSION_H -#define CGAL_VERSION 5.0-beta2 -#define CGAL_VERSION_NR 1050000920 +#define CGAL_VERSION 5.1 +#define CGAL_VERSION_NR 1050100000 #define CGAL_SVN_REVISION 99999 #define CGAL_GIT_HASH abcdef -#define CGAL_RELEASE_DATE 20190930 +#define CGAL_RELEASE_DATE 20191108 #include diff --git a/Intersections_3/include/CGAL/Intersection_traits_3.h b/Intersections_3/include/CGAL/Intersection_traits_3.h index c17c6e7716a..f95b3718ad0 100644 --- a/Intersections_3/include/CGAL/Intersection_traits_3.h +++ b/Intersections_3/include/CGAL/Intersection_traits_3.h @@ -155,6 +155,25 @@ struct Intersection_traits { typedef typename boost::optional< variant_type > result_type; }; +// Iso_cuboid_3 Triangle_3, variant of 4 +template +struct Intersection_traits { + typedef typename + boost::variant< typename K::Point_3, typename K::Segment_3, + typename K::Triangle_3, std::vector > variant_type; + + typedef typename boost::optional< variant_type > result_type; +}; + +template +struct Intersection_traits { + typedef typename + boost::variant< typename K::Point_3, typename K::Segment_3, + typename K::Triangle_3, std::vector > variant_type; + + typedef typename boost::optional< variant_type > result_type; +}; + // Point_3 Line_3, variant of one template struct Intersection_traits { diff --git a/Intersections_3/include/CGAL/Intersections_3/Iso_cuboid_3_Triangle_3.h b/Intersections_3/include/CGAL/Intersections_3/Iso_cuboid_3_Triangle_3.h index 56ff1b737a8..af6ae4e0dbb 100644 --- a/Intersections_3/include/CGAL/Intersections_3/Iso_cuboid_3_Triangle_3.h +++ b/Intersections_3/include/CGAL/Intersections_3/Iso_cuboid_3_Triangle_3.h @@ -18,9 +18,11 @@ #include #include +#include namespace CGAL { - CGAL_DO_INTERSECT_FUNCTION(Iso_cuboid_3,Triangle_3, 3) + CGAL_DO_INTERSECT_FUNCTION(Iso_cuboid_3, Triangle_3, 3) + CGAL_INTERSECTION_FUNCTION(Iso_cuboid_3, Triangle_3, 3) } #endif // CGAL_INTERSECTIONS_3_BBOX_3_TRIANGLE_3_H diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Triangle_3_intersection.h b/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Triangle_3_intersection.h new file mode 100644 index 00000000000..ea8155daf58 --- /dev/null +++ b/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Triangle_3_intersection.h @@ -0,0 +1,217 @@ +// Copyright (c) 2019 GeometryFactory(France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Maxime Gimeno +// + +#ifndef CGAL_INTERSECTIONS_3_INTERNAL_ISO_CUBOID_3_TRIANGLE_3_INTERSECTION_H +#define CGAL_INTERSECTIONS_3_INTERNAL_ISO_CUBOID_3_TRIANGLE_3_INTERSECTION_H + +#include +#include + +#include +#include +#include + +namespace CGAL { + +namespace Intersections { + +namespace internal { + +//only work for convex polygons, but in here that's always the case +template +void clip_poly_halfspace( + std::vector& polygon, + const typename K::Plane_3& pl, + const K& k) +{ + if(polygon.empty()) + return; + + typedef typename K::Point_3 Point; + typedef typename K::Plane_3 Plane; + typedef typename K::Segment_3 Segment; + + typedef typename Intersection_traits >::result_type SP_type; + + // Keep in memory which points we are going to delete later (newer intersection points + // by construction will not be deleted) + std::list > p_list; + for(const Point& p : polygon) + p_list.emplace_back(p, pl.has_on_positive_side(p)); + + //corefine with plane. + auto it = p_list.begin(); + while(it != p_list.end()) + { + const Point& p1 = (it++)->first; + if(it == p_list.end()) + break; + + const Point& p2 = it->first; + const Segment seg = k.construct_segment_3_object()(p1, p2); + + if(do_intersect(seg, pl)) + { + SP_type inter = k.intersect_3_object()(seg, pl); + if(inter) + { + Point* p_inter = boost::get(&*inter); + if(p_inter + && !(k.equal_3_object()(*p_inter, p1)) + && !(k.equal_3_object()(*p_inter, p2))) + { + // 'false' because we know the intersection is by construction not on the positive side of the plane + p_list.insert(it, std::make_pair(*p_inter, false)); + } + } + } + } + + if(polygon.size() > 2) + { + const Point& p2 = p_list.front().first; + const Point& p1 = p_list.back().first; + const Segment seg(p1, p2); + + if(do_intersect(seg, pl)) + { + SP_type inter = typename K::Intersect_3()(seg, pl); + if(inter) + { + Point* p_inter = boost::get(&*inter); + if(p_inter + && !(k.equal_3_object()(*p_inter, p1)) + && !(k.equal_3_object()(*p_inter, p2))) + { + // 'false' because we know the intersection is by construction not on the positive side of the plane + p_list.emplace_back(*p_inter, false); + } + } + } + } + + //remove all points on positive side + for(auto it = p_list.begin(); it != p_list.end();) + { + if(it->second) + it = p_list.erase(it); + else + ++it; + } + + // Update the polygon + polygon.clear(); + for(const auto& pr : p_list) + polygon.push_back(pr.first); +} + +template +typename Intersection_traits::result_type +intersection( + const typename K::Iso_cuboid_3 &cub, + const typename K::Triangle_3 &tr, + const K& k) +{ + typedef typename K::Point_3 Point; + typedef typename K::Segment_3 Segment; + typedef typename K::Triangle_3 Triangle; + typedef typename K::Plane_3 Plane; + typedef std::vector Poly; + + typedef typename Intersection_traits, + CGAL::Triangle_3 >::result_type Res_type; + + //Lazy implem: clip 6 times the input triangle. + Plane planes[6]; + planes[0] = Plane(cub.vertex(0), + cub.vertex(1), + cub.vertex(5)); + + planes[1] = Plane(cub.vertex(0), + cub.vertex(4), + cub.vertex(3)); + + planes[2] = Plane(cub.vertex(0), + cub.vertex(3), + cub.vertex(1)); + + planes[3] = Plane(cub.vertex(7), + cub.vertex(6), + cub.vertex(1)); + + planes[4] = Plane(cub.vertex(7), + cub.vertex(3), + cub.vertex(4)); + + planes[5] = Plane(cub.vertex(7), + cub.vertex(4), + cub.vertex(6)); + + std::vector poly; + poly.push_back(tr.vertex(0)); + poly.push_back(tr.vertex(1)); + poly.push_back(tr.vertex(2)); + + for (int i = 0; i < 6; ++i) + clip_poly_halfspace(poly, planes[i], k); + + switch(poly.size()) + { + case 0: + return Res_type(); + break; + case 1: + { + Point res = poly.front(); + return Res_type(std::forward(res)); + } + break; + case 2: + { + Segment res = Segment(poly.front(), poly.back()); + return Res_type(std::forward(res)); + } + break; + case 3: + { + + Triangle res = Triangle(poly[0], poly[1], poly[2]); + return Res_type(std::forward(res)); + } + break; + default: + { + return Res_type(std::forward(poly)); + } + break; + } +} + +template +typename Intersection_traits::result_type +intersection( + const typename K::Triangle_3 &tr, + const typename K::Iso_cuboid_3 &cub, + const K& k) +{ + return intersection(cub, tr, k); +} + +} // namespace internal +} // namespace Intersections +} // namespace CGAL + +#endif // CGAL_INTERSECTIONS_3_INTERNAL_ISO_CUBOID_3_TRIANGLE_3_INTERSECTION_H diff --git a/Intersections_3/test/Intersections_3/test_intersections_3.cpp b/Intersections_3/test/Intersections_3/test_intersections_3.cpp index b8c20156922..d2851243da8 100644 --- a/Intersections_3/test/Intersections_3/test_intersections_3.cpp +++ b/Intersections_3/test/Intersections_3/test_intersections_3.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -61,6 +62,7 @@ struct Test { typedef CGAL::Iso_cuboid_3< K > Cub; typedef CGAL::Sphere_3< K > Sph; typedef CGAL::Bbox_3 Bbox; + typedef std::vector

    Pol; template < typename Type > @@ -94,20 +96,20 @@ struct Test { bool approx_equal(const S & p, const S & q) { - return approx_equal(p.source(), q.source()) && approx_equal(p.target(), q.target()); + return approx_equal(p.source(), q.source()) && approx_equal(p.target(), q.target()); } - /* bool approx_equal(const Pol & p, const Pol & q) { - if (p.size() != q.size()) - return false; - for(typename Pol::const_iterator itp = p.begin(), itq = q.begin(); itp != p.end(); ++itp, ++itq) - if (!approx_equal(*itp, *itq)) - return false; - return true; + if(p.size() != q.size()) + return false; + + for(typename Pol::const_iterator itp = p.begin(), itq = q.begin(); itp != p.end(); ++itp, ++itq) + if(!approx_equal(*itp, *itq)) + return false; + + return true; } - */ template < typename O1, typename O2> void check_no_intersection(const O1& o1, const O2& o2) @@ -563,11 +565,114 @@ struct Test { << do_intersect_counter << "\n"; } // end function Bbox_Tr - void run() + void Cub_Tr(bool is_exact) + { + typedef typename CGAL::Intersection_traits::result_type Res; + + std::cout << "Triangle_3 - Cuboid_3\n"; + + // tr outside + Cub cub(P(1,1,1), P(2,2,2)); + check_no_intersection(cub, Tr(P(1.1, 2, 0), P(2, 3, 1), P(4, 5, 6))); + + // tr in a face + check_intersection(cub, Tr(P(1, 1.1, 1), P(1, 1.5, 1), P(1, 1, 1.1)), + Tr(P(1, 1.1, 1), P(1, 1.5, 1), P(1, 1, 1.1))); + + //face in a tr + Tr tr(P(-3, -3, 1), P(3, -3, 1), P(1.5, 6, 1)); + Res res = CGAL::intersection(cub, tr); + Pol* poly = boost::get >(&*res); + assert(poly != nullptr); + assert(poly->size() == 4); + if(is_exact) + { + for(auto& p : *poly) + assert(tr.has_on(p) && cub.has_on_boundary(p)); + } + + //tr adj to a cuboid vertex + check_intersection(cub, Tr(P(1, 0.5, 0.5), P(3, 2, 1), P(3, 1, 2)), P(2,1,1)); + + //tr adj to a point on a cuboid edge + check_intersection(cub, Tr(P(1, 0.5, 0.5), P(3, 2, 1), P(3, 1, 2)), P(2,1,1)); + + //tr adj to a point on a cuboid face + check_intersection(cub, Tr(P(1, 1.5, 1.5), P(0, 0, 0), P(-4, 3, 1)), P(1, 1.5, 1.5)); + + //tr adj to an edge + check_intersection(cub, Tr(P(2, 1.5, 2), P(5, 6, 7), P(4, 7, 6)), P(2, 1.5, 2)); + + //tr sharing an edge + check_intersection(cub, Tr(P(2, 1.5, 2), P(2, 2.5, 2), P(4, 7, 6)), + S(P(2, 1.5, 2), P(2, 2, 2))); + + //tr sharing part of an edge + check_intersection(cub, Tr(P(2, 1.5, 2), P(5, 6, 7), P(4, 7, 6)), P(2, 1.5, 2)); + + //tr inside + check_intersection(cub, Tr(P(1.1,1.1,1.1), P(1.8,1.8,1.8), P(1.5,1.8,1.1)), + Tr(P(1.1,1.1,1.1), P(1.8,1.8,1.8), P(1.5,1.8,1.1))); + + //tr through + tr = Tr(P(2, 4, 2), P(1, 3.5, -0.5), P(1, -1, 1)); + res = CGAL::intersection(cub, tr); + poly = boost::get >(&*res); + assert(poly != nullptr); + assert(poly->size() == 4); + if(is_exact) + { + for(const P& p : *poly) + assert(tr.has_on(p) && cub.has_on_boundary(p)); + } + + //cutting in half along diagonal (intersection == triangle) + check_intersection(cub, Tr(P(1, 1, 1), P(2, 2, 2), P(2, 2, 1)), + Tr(P(1, 1, 1), P(2, 2, 2), P(2, 2, 1))); + + //cutting in half along diagonal (intersection included in triangle) + tr = Tr(P(1, 1, 10), P(10, 10, 1), P(1, 1, 1)); + res = CGAL::intersection(cub, tr); + poly = boost::get >(&*res); + assert(poly != nullptr); + assert(poly->size() == 4); + if(is_exact) + { + for(const P& p : *poly) + assert(tr.has_on(p) && cub.has_on_boundary(p)); + } + + //6 points intersection + tr = Tr(P(18.66, -5.4, -11.33), P(-2.41, -7.33, 19.75), P(-10.29, 20.15, -10.33)); + res = CGAL::intersection(cub, tr); + poly = boost::get >(&*res); + assert(poly != nullptr); + assert(poly->size() == 6); + if(is_exact) + { + for(const P& p : *poly) + assert(tr.has_on(p) && cub.has_on_boundary(p)); + } + + //triangle clipping a cuboid corner + tr = Tr(P(1.02, 1.33, 0.62), P(1.95, 2.54, 0.95), P(0.79, 2.36, 1.92)); + res = CGAL::intersection(cub, tr); + Tr* tr_res = boost::get(&*res); + assert(tr_res != nullptr); + if(is_exact) + { + assert(cub.has_on_boundary((*tr_res)[0])); + assert(cub.has_on_boundary((*tr_res)[1])); + assert(cub.has_on_boundary((*tr_res)[2])); + } + } + + void run(bool is_exact = false) { std::cout << "3D Intersection tests\n"; P_do_intersect(); Cub_Cub(); + Cub_Tr(is_exact); L_Cub(); Pl_L(); Pl_Pl(); @@ -590,8 +695,16 @@ struct Test { int main() { - Test< CGAL::Simple_cartesian >().run(); - Test< CGAL::Homogeneous >().run(); - // TODO : test more kernels. + std::cout << " |||||||| Test Simple_cartesian ||||||||" << std::endl; + Test< CGAL::Simple_cartesian >().run(); + + std::cout << " |||||||| Test CGAL::Homogeneous ||||||||" << std::endl; + Test< CGAL::Homogeneous >().run(); + + std::cout << " |||||||| Test EPECK ||||||||" << std::endl; + Test< CGAL::Epeck >().run(true); + + std::cout << " |||||||| Test CGAL::Homogeneous ||||||||" << std::endl; + Test< CGAL::Homogeneous >().run(true); } diff --git a/Kernel_23/include/CGAL/internal/Projection_traits_3.h b/Kernel_23/include/CGAL/internal/Projection_traits_3.h index 24c5a4988dd..95c12d97e8f 100644 --- a/Kernel_23/include/CGAL/internal/Projection_traits_3.h +++ b/Kernel_23/include/CGAL/internal/Projection_traits_3.h @@ -43,6 +43,7 @@ struct Projector static typename R::FT y(const typename R::Point_3& p) {return p.z();} static typename R::FT x(const typename R::Vector_3& p) {return p.y();} static typename R::FT y(const typename R::Vector_3& p) {return p.z();} + static Bbox_2 bbox(const Bbox_3& bb) { return Bbox_2(bb.ymin(),bb.zmin(),bb.ymax(),bb.zmax()); } static const int x_index=1; static const int y_index=2; }; @@ -60,6 +61,7 @@ struct Projector static typename R::FT y(const typename R::Point_3& p) {return p.z();} static typename R::FT x(const typename R::Vector_3& p) {return p.x();} static typename R::FT y(const typename R::Vector_3& p) {return p.z();} + static Bbox_2 bbox(const Bbox_3& bb) { return Bbox_2(bb.xmin(),bb.zmin(),bb.xmax(),bb.zmax()); } static const int x_index=0; static const int y_index=2; }; @@ -78,11 +80,18 @@ struct Projector static typename R::FT y(const typename R::Point_3& p) {return p.y();} static typename R::FT x(const typename R::Vector_3& p) {return p.x();} static typename R::FT y(const typename R::Vector_3& p) {return p.y();} + static Bbox_2 bbox(const Bbox_3& bb) { return Bbox_2(bb.xmin(),bb.ymin(),bb.xmax(),bb.ymax()); } static const int x_index=0; static const int y_index=1; }; - +template +class Construct_bbox_projected_2 { +public: + typedef typename R::Point_3 Point; + + Bbox_2 operator()(const Point& p) const { typename R::Construct_bbox_3 bb; return Projector::bbox(bb(p)); } +}; template class Orientation_projected_3 @@ -795,7 +804,8 @@ public: typedef Construct_weighted_circumcenter_projected_3 Construct_weighted_circumcenter_2; typedef Power_side_of_bounded_power_circle_projected_3 Power_side_of_bounded_power_circle_2; typedef Power_side_of_oriented_power_circle_projected_3 Power_side_of_oriented_power_circle_2; - + typedef Construct_bbox_projected_2 Construct_bbox_2; + typedef typename Rp::Construct_point_3 Construct_point_2; typedef typename Rp::Construct_weighted_point_3 Construct_weighted_point_2; typedef typename Rp::Construct_segment_3 Construct_segment_2; @@ -805,7 +815,7 @@ public: typedef typename Rp::Construct_scaled_vector_3 Construct_scaled_vector_2; typedef typename Rp::Construct_triangle_3 Construct_triangle_2; typedef typename Rp::Construct_line_3 Construct_line_2; - typedef typename Rp::Construct_bbox_3 Construct_bbox_2; + struct Less_xy_2 { typedef bool result_type; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_ray_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_ray_3.h index 83b88ac7254..22e200263fb 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_ray_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_ray_3.h @@ -27,9 +27,6 @@ _test_cls_ray_3(const R& ) typedef typename R::RT RT; typedef typename R::FT FT; - typename R::Ray_3 ir; - CGAL::Ray_3 r1(ir); - RT n1 = 8; RT n2 = 20; RT n3 = 4; @@ -42,10 +39,18 @@ _test_cls_ray_3(const R& ) CGAL::Point_3 p2( n4, n5, n6, n5); CGAL::Point_3 p3( n7, n2, n4, n7); + typename R::Ray_3 ir ( p2, p1 ); + + CGAL::Ray_3 r1( ir ); CGAL::Ray_3 r2( p1, p2 ); CGAL::Ray_3 r3( p2, p1 ); CGAL::Ray_3 r4( r2 ); r1 = r4; + + typename R::Ray_3 ir2 ( r4 ); + ir = r1; + r4 = ir2; + CGAL::Direction_3 dir( p2 - p1 ); CGAL::Vector_3 vec( p2 - p1 ); CGAL::Line_3 l( p1, p2 ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_segment_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_segment_3.h index 025cfb9a13b..a020f307028 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_segment_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_segment_3.h @@ -27,9 +27,6 @@ _test_cls_segment_3(const R& ) typedef typename R::RT RT; typedef typename R::FT FT; - typename R::Segment_3 is; - CGAL::Segment_3 s1(is); - RT n1 = 7; RT n2 = 21; RT n3 = 14; @@ -42,11 +39,19 @@ _test_cls_segment_3(const R& ) CGAL::Point_3 p2( n4, n5, n6, n5); CGAL::Point_3 p3( n2, n8, n2, n8); + typename R::Segment_3 is ( p2, p1 ); + + CGAL::Segment_3 s1( is ); CGAL::Segment_3 s2( p1, p2 ); CGAL::Segment_3 s3( p2, p1 ); CGAL::Segment_3 s4( s2 ); + s1 = s4; + typename R::Segment_3 is2 ( s4 ); + is = s1; + s4 = is2; + assert( CGAL::parallel(s2, s3) ); CGAL::Vector_3 v0(p1, p2); diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index 5e3013b880c..eb43e4c69e9 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -120,6 +120,15 @@ public: template FT operator()(ForwardIterator first, ForwardIterator last); }; +class Compute_squared_radius_smallest_orthogonal_sphere_d { +public: +/*! returns the radius of the sphere defined by `A=tuple[first,last)`. The sphere is centered in the affine hull of A and orthogonal to all the spheres of A. The order of the points of A does not matter. + \pre A is affinely independent. + \tparam ForwardIterator has `Epeck_d::Weighted_point_d` as value type. + */ +template +FT operator()(ForwardIterator first, ForwardIterator last); +}; /*! \cgalModels `Kernel_d::Side_of_bounded_sphere_d` */ class Side_of_bounded_sphere_d { @@ -131,7 +140,18 @@ public: template Bounded_side operator()(ForwardIterator first, ForwardIterator last, const Point_d&p); }; +class Power_side_of_bounded_power_sphere_d { +public: +/*! returns the relative position of weighted point p to the sphere defined by `A=tuple[first,last)`. The sphere is centered in the affine hull of A and orthogonal to all the spheres of A. The order of the points of A does not matter. + \pre A is affinely independent. + \tparam ForwardIterator has `Epeck_d::Weighted_point_d` as value type. + */ +template +Bounded_side operator()(ForwardIterator first, ForwardIterator last, const Weighted_point_d&p); +}; Construct_circumcenter_d construct_circumcenter_d_object(); Compute_squared_radius_d compute_squared_radius_d_object(); +Compute_squared_radius_smallest_orthogonal_sphere_d compute_squared_radius_smallest_orthogonal_sphere_d_object(); +Power_side_of_bounded_power_sphere_d power_side_of_bounded_power_sphere_d_object(); }; /* end Epeck_d */ } /* end namespace CGAL */ diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index 1999d676423..50295d58d96 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -109,6 +109,15 @@ public: template FT operator()(ForwardIterator first, ForwardIterator last); }; +class Compute_squared_radius_smallest_orthogonal_sphere_d { +public: +/*! returns the radius of the sphere defined by `A=tuple[first,last)`. The sphere is centered in the affine hull of A and orthogonal to all the spheres of A. The order of the points of A does not matter. + \pre A is affinely independent. + \tparam ForwardIterator has `Epick_d::Weighted_point_d` as value type. + */ +template +FT operator()(ForwardIterator first, ForwardIterator last); +}; /*! \cgalModels `Kernel_d::Side_of_bounded_sphere_d` */ class Side_of_bounded_sphere_d { @@ -120,7 +129,18 @@ public: template Bounded_side operator()(ForwardIterator first, ForwardIterator last, const Point_d&p); }; +class Power_side_of_bounded_power_sphere_d { +public: +/*! returns the relative position of weighted point p to the sphere defined by `A=tuple[first,last)`. The sphere is centered in the affine hull of A and orthogonal to all the spheres of A. The order of the points of A does not matter. + \pre A is affinely independent. + \tparam ForwardIterator has `Epick_d::Weighted_point_d` as value type. + */ +template +Bounded_side operator()(ForwardIterator first, ForwardIterator last, const Weighted_point_d&p); +}; Construct_circumcenter_d construct_circumcenter_d_object(); Compute_squared_radius_d compute_squared_radius_d_object(); +Compute_squared_radius_smallest_orthogonal_sphere_d compute_squared_radius_smallest_orthogonal_sphere_d_object(); +Power_side_of_bounded_power_sphere_d power_side_of_bounded_power_sphere_d_object(); }; /* end Epick_d */ } /* end namespace CGAL */ diff --git a/Linear_cell_complex/demo/Linear_cell_complex/typedefs.h b/Linear_cell_complex/demo/Linear_cell_complex/typedefs.h index 1ac77e34b5b..17924ecca8d 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/typedefs.h +++ b/Linear_cell_complex/demo/Linear_cell_complex/typedefs.h @@ -185,8 +185,7 @@ typedef CGAL::Triangulation_face_base_with_info_2 Fb1; typedef CGAL::Constrained_triangulation_face_base_2 Fb; typedef CGAL::Triangulation_data_structure_2 TDS; -// typedef CGAL::No_intersection_tag Itag; - typedef CGAL::Exact_predicates_tag Itag; +typedef CGAL::Exact_predicates_tag Itag; typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; diff --git a/Linear_cell_complex/examples/Linear_cell_complex/basic_viewer.h b/Linear_cell_complex/examples/Linear_cell_complex/basic_viewer.h index 9ce687ecf9a..1abc71c12cc 100644 --- a/Linear_cell_complex/examples/Linear_cell_complex/basic_viewer.h +++ b/Linear_cell_complex/examples/Linear_cell_complex/basic_viewer.h @@ -215,7 +215,6 @@ class Basic_viewer : public CGAL::QGLViewer, public QOpenGLFunctions_2_1 typedef CGAL::Constrained_triangulation_face_base_2 Fb; typedef CGAL::Triangulation_data_structure_2 TDS; - // typedef CGAL::No_intersection_tag Itag; typedef CGAL::Exact_predicates_tag Itag; typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; diff --git a/Maintenance/infrastructure/cgal.geometryfactory.com/crontab b/Maintenance/infrastructure/cgal.geometryfactory.com/crontab index 13e489c8854..6d4757ab8f2 100644 --- a/Maintenance/infrastructure/cgal.geometryfactory.com/crontab +++ b/Maintenance/infrastructure/cgal.geometryfactory.com/crontab @@ -23,11 +23,15 @@ LC_CTYPE=en_US.UTF-8 # The script also updates the manual tools. # "master" alone -0 21 * * Sun cd $HOME/CGAL/create_internal_release && /usr/bin/time scl enable rh-git29 -- $HOME/bin/create_release $HOME/CGAL/branches/master.git --public --do-it --beta 2 || echo ERROR +0 21 * * Sun cd $HOME/CGAL/create_internal_release && /usr/bin/time scl enable rh-git29 -- $HOME/bin/create_release $HOME/CGAL/branches/master.git --do-it || echo ERROR # "integration" -0 21 * * Mon,Tue,Wed,Thu,Fri cd $HOME/CGAL/create_internal_release && /usr/bin/time scl enable rh-git29 -- $HOME/bin/create_release $HOME/CGAL/branches/integration.git $HOME/CGAL/branches/empty-dir --do-it --public --beta 2 || echo ERROR +0 21 * * Mon,Tue,Wed,Thu cd $HOME/CGAL/create_internal_release && /usr/bin/time scl enable rh-git29 -- $HOME/bin/create_release $HOME/CGAL/branches/integration.git $HOME/CGAL/branches/empty-dir --do-it --public || echo ERROR +# from branch 5.0 +0 21 * * fri cd $HOME/CGAL/create_internal_release-5.0-branch && /usr/bin/time scl enable rh-git29 -- $HOME/bin/create_release $HOME/CGAL/branches/CGAL-4.14-branch.git --public --do-it || echo ERROR # from branch 4.14 0 21 * * Sat cd $HOME/CGAL/create_internal_release-4.14-branch && /usr/bin/time scl enable rh-git29 -- $HOME/bin/create_release $HOME/CGAL/branches/CGAL-4.14-branch.git --public --do-it || echo ERROR + +## Older stuff # from branch 4.13 #0 21 * * Fri cd $HOME/CGAL/create_internal_release-4.13-branch && /usr/bin/time scl enable rh-git29 -- $HOME/bin/create_release $HOME/CGAL/branches/CGAL-4.13-branch.git --public --do-it || echo ERROR # from branch 4.12 @@ -49,7 +53,7 @@ LC_CTYPE=en_US.UTF-8 # Launch our Docker testsuite , at 21:36, # after a pull of all new images at 20:23. -06 20 * * * /usr/bin/time docker pull -a docker.io/cgal/testsuite-docker; docker rmi $(docker images | awk '// {print $3}') +06 20 * * * for i in $(cat /home/lrineau/.config/CGAL/test_cgal_docker_images); do docker pull $i; done; docker rmi $(docker images | awk '// {print $3}') 36 21 * * * cd /home/lrineau/Git/cgal-testsuite-dockerfiles && /usr/bin/time ./test_cgal.py --use-fedora-selinux-policy --force-rm --max-cpus 12 --container-cpus 4 --jobs 5 --upload-results --images $($HOME/bin/docker_images_to_test_today) diff --git a/Maintenance/public_release/announcement/announcement-beta.md b/Maintenance/public_release/announcement/announcement-beta.md new file mode 100644 index 00000000000..c7029907fed --- /dev/null +++ b/Maintenance/public_release/announcement/announcement-beta.md @@ -0,0 +1,76 @@ +The CGAL Open Source Project is pleased to announce the release 5.0 BetaĀ 2 +of CGAL, the Computational Geometry Algorithms Library. + +CGAL version 5.0 Beta 2 is a public testing release. It should provide +a solid ground to report bugs that need to be tackled before the +release of the final version of CGAL 5.0 in November. + +### General changes + +- CGAL 5.0 is the first release of CGAL that requires a C++ compiler + with the support of C++14 or later. The new list of supported + compilers is: + - Visual C++ 14.0 (from Visual Studio 2015 Update 3) or later, + - Gnu g++ 6.3 or later (on Linux or MacOS), + - LLVM Clang version 8.0 or later (on Linux or MacOS), and + - Apple Clang compiler versions 7.0.2 and 10.0.1 (on MacOS). +- Since CGAL 4.9, CGAL can be used as a header-only library, with + dependencies. Since CGAL 5.0, that is now the default, unless + specified differently in the (optional) CMake configuration. +- The section "Getting Started with CGAL" of the documentation has + been updated and reorganized. +- The minimal version of Boost is now 1.57.0. + + +### [Polygonal Surface Reconstruction](https://doc.cgal.org/5.0/Manual/packages.html#PkgPolygonalSurfaceReconstruction) (new package) + + - This package provides a method for piecewise planar object reconstruction from point clouds. + The method takes as input an unordered point set sampled from a piecewise planar object + and outputs a compact and watertight surface mesh interpolating the input point set. + The method assumes that all necessary major planes are provided (or can be extracted from + the input point set using the shape detection method described in Point Set Shape Detection, + or any other alternative methods).The method can handle arbitrary piecewise planar objects + and is capable of recovering sharp features and is robust to noise and outliers. See also + the associated [blog entry](https://www.cgal.org/2019/08/05/Polygonal_surface_reconstruction/). + +### [Shape Detection](https://doc.cgal.org/5.0/Manual/packages.html#PkgShapeDetection) (major changes) + - **Breaking change:** The concept `ShapeDetectionTraits` has been renamed to [`EfficientRANSACTraits`](https://doc.cgal.org/5.0/Shape_detection/classEfficientRANSACTraits.html). + - **Breaking change:** The `Shape_detection_3` namespace has been renamed to [`Shape_detection`](https://doc.cgal.org/5.0/Shape_detection/annotated.html). + - Added a new, generic implementation of region growing. This enables for example applying region growing to inputs such as 2D and 3D point sets, + or models of the [`FaceGraph`](https://doc.cgal.org/5.0/BGL/classFaceGraph.html) concept. Learn more about this new algorithm with this [blog entry](https://www.cgal.org/2019/07/30/Shape_detection/). + +### [dD Geometry Kernel](https://doc.cgal.org/5.0/Manual/packages.html#PkgKernelD) + - A new exact kernel, [`Epeck_d`](https://doc.cgal.org/5.0/Kernel_d/structCGAL_1_1Epeck__d.html), is now available. + +### 2D and 3D Triangulations + +- **Breaking change:** Several deprecated functions and classes have been + removed. See the full list of breaking changes in the release + notes. + +- **Breaking change:** The constructor and the `insert()` function of + `CGAL::Triangulation_2` or `CGAL::Triangulation_3` which take a range + of points as argument are now guaranteed to insert the points + following the order of `InputIterator`. Note that this change only + affects the base class `CGAL::Triangulation_[23]` and not any + derived class, such as `CGAL::Delaunay_triangulation_[23]`. + + +### [Polygon Mesh Processing](https://doc.cgal.org/latest/Manual/packages.html#PkgPolygonMeshProcessing) + - Introduced a [wide range of new functions](https://doc.cgal.org/5.0/Polygon_mesh_processing/index.html#title36) + related to location of queries on a triangle mesh, + such as [`CGAL::Polygon_mesh_processing::locate(Point, Mesh)`](https://doc.cgal.org/5.0/Polygon_mesh_processing/group__PMP__locate__grp.html#gada09bd8740ba69ead9deca597d53cf15). + The location of a point on a triangle mesh is expressed as the pair of a face and the barycentric + coordinates of the point in this face, enabling robust manipulation of locations + (for example, intersections of two 3D segments living within the same face). + - Added the mesh smoothing function [`smooth_mesh()`](https://doc.cgal.org/5.0/Polygon_mesh_processing/group__PMP__meshing__grp.html#gaa0551d546f6ab2cd9402bea12d8332a3), + which can be used to improve the quality of triangle elements based on various geometric characteristics. + - Added the shape smoothing function [`smooth_shape()`](https://doc.cgal.org/5.0/Polygon_mesh_processing/group__PMP__meshing__grp.html#gaaa083ec78bcecf351e04d1bbf460b4a2), + which can be used to smooth the surface of a triangle mesh, using the mean curvature flow to perform noise removal. + (See also the new entry in the [User Manual](https://doc.cgal.org/5.0/Polygon_mesh_processing/index.html#title8)) + +### [Point Set Processing](https://doc.cgal.org/latest/Manual/packages.html#PkgPointSetProcessing3) + - **Breaking change**: the API using iterators and overloads for optional parameters (deprecated since + CGAL 4.12) has been removed. The current (and now only) API uses ranges and Named Parameters. + +See https://www.cgal.org/2019/10/31/cgal50-beta2/ for a complete list of changes. diff --git a/Maintenance/public_release/announcement/announcement.md b/Maintenance/public_release/announcement/announcement.md new file mode 100644 index 00000000000..3f2ce921f63 --- /dev/null +++ b/Maintenance/public_release/announcement/announcement.md @@ -0,0 +1,75 @@ +The CGAL Open Source Project is pleased to announce the release 5.0 +of CGAL, the Computational Geometry Algorithms Library. + +Besides fixes and general enhancement to existing packages, the +following has changed since CGALĀ 4.14.2: + +### General changes + +- CGAL 5.0 is the first release of CGAL that requires a C++ compiler + with the support of C++14 or later. The new list of supported + compilers is: + - Visual C++ 14.0 (from Visual Studio 2015 Update 3) or later, + - Gnu g++ 6.3 or later (on Linux or MacOS), + - LLVM Clang version 8.0 or later (on Linux or MacOS), and + - Apple Clang compiler versions 7.0.2 and 10.0.1 (on MacOS). +- Since CGAL 4.9, CGAL can be used as a header-only library, with + dependencies. Since CGAL 5.0, that is now the default, unless + specified differently in the (optional) CMake configuration. +- The section "Getting Started with CGAL" of the documentation has + been updated and reorganized. +- The minimal version of Boost is now 1.57.0. + + +### [Polygonal Surface Reconstruction](https://doc.cgal.org/5.0/Manual/packages.html#PkgPolygonalSurfaceReconstruction) (new package) + + - This package provides a method for piecewise planar object reconstruction from point clouds. + The method takes as input an unordered point set sampled from a piecewise planar object + and outputs a compact and watertight surface mesh interpolating the input point set. + The method assumes that all necessary major planes are provided (or can be extracted from + the input point set using the shape detection method described in Point Set Shape Detection, + or any other alternative methods).The method can handle arbitrary piecewise planar objects + and is capable of recovering sharp features and is robust to noise and outliers. See also + the associated [blog entry](https://www.cgal.org/2019/08/05/Polygonal_surface_reconstruction/). + +### [Shape Detection](https://doc.cgal.org/5.0/Manual/packages.html#PkgShapeDetection) (major changes) + - **Breaking change:** The concept `ShapeDetectionTraits` has been renamed to [`EfficientRANSACTraits`](https://doc.cgal.org/5.0/Shape_detection/classEfficientRANSACTraits.html). + - **Breaking change:** The `Shape_detection_3` namespace has been renamed to [`Shape_detection`](https://doc.cgal.org/5.0/Shape_detection/annotated.html). + - Added a new, generic implementation of region growing. This enables for example applying region growing to inputs such as 2D and 3D point sets, + or models of the [`FaceGraph`](https://doc.cgal.org/5.0/BGL/classFaceGraph.html) concept. Learn more about this new algorithm with this [blog entry](https://www.cgal.org/2019/07/30/Shape_detection/). + +### [dD Geometry Kernel](https://doc.cgal.org/5.0/Manual/packages.html#PkgKernelD) + - A new exact kernel, [`Epeck_d`](https://doc.cgal.org/5.0/Kernel_d/structCGAL_1_1Epeck__d.html), is now available. + +### 2D and 3D Triangulations + +- **Breaking change:** Several deprecated functions and classes have been + removed. See the full list of breaking changes in the release + notes. + +- **Breaking change:** The constructor and the `insert()` function of + `CGAL::Triangulation_2` or `CGAL::Triangulation_3` which take a range + of points as argument are now guaranteed to insert the points + following the order of `InputIterator`. Note that this change only + affects the base class `CGAL::Triangulation_[23]` and not any + derived class, such as `CGAL::Delaunay_triangulation_[23]`. + + +### [Polygon Mesh Processing](https://doc.cgal.org/latest/Manual/packages.html#PkgPolygonMeshProcessing) + - Introduced a [wide range of new functions](https://doc.cgal.org/5.0/Polygon_mesh_processing/index.html#title36) + related to location of queries on a triangle mesh, + such as [`CGAL::Polygon_mesh_processing::locate(Point, Mesh)`](https://doc.cgal.org/5.0/Polygon_mesh_processing/group__PMP__locate__grp.html#gada09bd8740ba69ead9deca597d53cf15). + The location of a point on a triangle mesh is expressed as the pair of a face and the barycentric + coordinates of the point in this face, enabling robust manipulation of locations + (for example, intersections of two 3D segments living within the same face). + - Added the mesh smoothing function [`smooth_mesh()`](https://doc.cgal.org/5.0/Polygon_mesh_processing/group__PMP__meshing__grp.html#gaa0551d546f6ab2cd9402bea12d8332a3), + which can be used to improve the quality of triangle elements based on various geometric characteristics. + - Added the shape smoothing function [`smooth_shape()`](https://doc.cgal.org/5.0/Polygon_mesh_processing/group__PMP__meshing__grp.html#gaaa083ec78bcecf351e04d1bbf460b4a2), + which can be used to smooth the surface of a triangle mesh, using the mean curvature flow to perform noise removal. + (See also the new entry in the [User Manual](https://doc.cgal.org/5.0/Polygon_mesh_processing/index.html#title8)) + +### [Point Set Processing](https://doc.cgal.org/latest/Manual/packages.html#PkgPointSetProcessing3) + - **Breaking change**: the API using iterators and overloads for optional parameters (deprecated since + CGAL 4.12) has been removed. The current (and now only) API uses ranges and Named Parameters. + +See https://www.cgal.org/2019/11/08/cgal50/ for a complete list of changes. diff --git a/Maintenance/public_release/announcement/mailing-beta.eml b/Maintenance/public_release/announcement/mailing-beta.eml index 262f7185e04..11251b7563a 100644 --- a/Maintenance/public_release/announcement/mailing-beta.eml +++ b/Maintenance/public_release/announcement/mailing-beta.eml @@ -1,33 +1,38 @@ -Subject: CGAL 5.0 Beta 1 Released, Computational Geometry Algorithms Library +Subject: CGAL 5.0 Beta 2 Released, Computational Geometry Algorithms Library Content-Type: text/plain; charset="utf-8" Body: -The CGAL Open Source Project is pleased to announce the release 5.0Ā BetaĀ 1 +The CGAL Open Source Project is pleased to announce the release 5.0Ā BetaĀ 2 of CGAL, the Computational Geometry Algorithms Library. -CGAL version 5.0 Beta 1 is a public testing release. It should provide -a solid ground to report bugs that need to be tackled before the -release of the final version of CGAL 5.0 in October. +CGAL version 5.0 Beta 2 is a public testing release. It should provide a +solid ground to report bugs that need to be tackled before the release +of the final version of CGAL 5.0 in November. - -CGAL 5.0 is the first release of CGAL that requires a C++ compiler -with the support of C++14 or later. The new list of supported -compilers is: - - - Visual C++ 14.0 (from Visual Studio 2015 Update 3) or later, - - Gnu g++ 6.3 or later (on Linux or MacOS), - - LLVM Clang version 8.0 or later (on Linux or MacOS), and - - Apple Clang compiler versions 7.0.2 and 10.0.1 (on MacOS). - -Since CGAL 4.9, CGAL can be used as a header-only library, with -dependencies. Since CGALĀ 5.0, that is now the default, unless -specified differently in the (optional) CMake configuration. +The important changes since CGAL 5.0Ā BetaĀ 1 are the fix of CMake +issues, with header-only installations, and the update of the section +ā€œGetting Started with CGALā€ of the documentation. Besides fixes and general enhancement to existing packages, the following has changed since CGALĀ 4.14: +General changes + +- CGAL 5.0 is the first release of CGAL that requires a C++ compiler + with the support of C++14 or later. The new list of supported + compilers is: + - Visual C++ 14.0 (from Visual Studio 2015 Update 3) or later, + - Gnu g++ 6.3 or later (on Linux or MacOS), + - LLVM Clang version 8.0 or later (on Linux or MacOS), and + - Apple Clang compiler versions 7.0.2 and 10.0.1 (on MacOS). +- Since CGAL 4.9, CGAL can be used as a header-only library, with + dependencies. Since CGAL 5.0, that is now the default, unless + specified differently in the (optional) CMake configuration. +- The section ā€œGetting Started with CGALā€ of the documentation has + been updated and reorganized. +- The minimal version of Boost is now 1.57.0. Polygonal Surface Reconstruction (new package) @@ -68,16 +73,14 @@ dD Geometry Kernel 2D and 3D Triangulations - BREAKING CHANGE: Several deprecated functions and classes have been - removed. See the full list of breaking changes in the release - notes. + removed. See the full list of breaking changes in the release notes. - BREAKING CHANGE: The constructor and the insert() function of - CGAL::Triangulation_2 or CGAL::Triangulation_3 which take a range - of points as argument are now guaranteed to insert the points - following the order of InputIterator. Note that this change only - affects the base class CGAL::Triangulation_[23] and not any - derived class, such as CGAL::Delaunay_triangulation_[23]. - + CGAL::Triangulation_2 or CGAL::Triangulation_3 which take a range of + points as argument are now guaranteed to insert the points following + the order of InputIterator. Note that this change only affects the + base class CGAL::Triangulation_[23] and not any derived class, such + as CGAL::Delaunay_triangulation_[23]. Polygon Mesh Processing @@ -102,8 +105,7 @@ Point Set Processing parameters (deprecated since CGAL 4.12) has been removed. The current (and now only) API uses ranges and Named Parameters. - -See https://www.cgal.org/2019/09/30/cgal50-beta1/ for a complete list of +See https://www.cgal.org/2019/10/31/cgal50-beta2/ for a complete list of changes. diff --git a/Maintenance/public_release/scripts/prepare_release b/Maintenance/public_release/scripts/prepare_release index 2e3f23db0f0..5768f1fe733 100755 --- a/Maintenance/public_release/scripts/prepare_release +++ b/Maintenance/public_release/scripts/prepare_release @@ -17,7 +17,11 @@ PUBLIC_RELEASE_DIR="$1" INTERNAL_RELEASE=`basename ${PUBLIC_RELEASE_DIR/-public/}` -PUBLIC_RELEASE_NAME=`basename ${~${ZIP_TARBALL::="$PUBLIC_RELEASE_DIR"/*.zip}}` +ZIP_TARBALL=("$PUBLIC_RELEASE_DIR"/*-library.zip(N)) +[ -z "$ZIP_TARBALL" ] && ZIP_TARBALL=("$PUBLIC_RELEASE_DIR"/*.zip(N)) + +PUBLIC_RELEASE_NAME=`basename "$ZIP_TARBALL"` +PUBLIC_RELEASE_NAME=${PUBLIC_RELEASE_NAME/-library.zip/} PUBLIC_RELEASE_NAME=${PUBLIC_RELEASE_NAME/.zip/} DEST_DIR="${RELEASE_CANDIDATES_DIR}/$PUBLIC_RELEASE_NAME" @@ -55,12 +59,6 @@ pushd "$DEST_DIR" zip -q -r "$DEST_DIR/${PUBLIC_RELEASE_NAME}-doc_html.zip" doc_html popd -printf "bzip2 doc_html tarball...\n" -bzip2 --best < "$DEST_DIR/${PUBLIC_RELEASE_NAME}-doc_html.tar" > "$DEST_DIR/${PUBLIC_RELEASE_NAME}-doc_html.tar.bz2" - -printf "bzip2 source tarball...\n" -zcat "$DEST_DIR/${PUBLIC_RELEASE_NAME}.tar.gz" | bzip2 --best > "$DEST_DIR/${PUBLIC_RELEASE_NAME}.tar.bz2" - printf "xz doc_html tarball...\n" xz --best < "$DEST_DIR/${PUBLIC_RELEASE_NAME}-doc_html.tar" > "$DEST_DIR/${PUBLIC_RELEASE_NAME}-doc_html.tar.xz" diff --git a/Maintenance/release_building/MINOR_NUMBER b/Maintenance/release_building/MINOR_NUMBER index 573541ac970..d00491fd7e5 100644 --- a/Maintenance/release_building/MINOR_NUMBER +++ b/Maintenance/release_building/MINOR_NUMBER @@ -1 +1 @@ -0 +1 diff --git a/Maintenance/release_building/public_release_name b/Maintenance/release_building/public_release_name index 35f0924c662..0c48f1e0ed2 100644 --- a/Maintenance/release_building/public_release_name +++ b/Maintenance/release_building/public_release_name @@ -1 +1 @@ -CGAL-5.0-beta2 +CGAL-5.1-dev diff --git a/Maintenance/test_handling/create_testresult_page b/Maintenance/test_handling/create_testresult_page index 2fc447b2eba..ce38de030a9 100755 --- a/Maintenance/test_handling/create_testresult_page +++ b/Maintenance/test_handling/create_testresult_page @@ -48,9 +48,10 @@ sub sort_releases($$) my $b = $_[0]; my $a = $_[1]; - #take only the numbers from release id, skipping I and Ic - my @A = ($a =~ /\d+/g); - my @B = ($b =~ /\d+/g); + #take only the numbers from release id, skipping the bug-fix + #number, and I and Ic + my @A = ($a =~ /(\d+)\.(\d+)\.?(:?\d+)?(:?-Ic?-)?(\d+)?/a); + my @B = ($b =~ /(\d+)\.(\d+)\.?(:?\d+)?(:?-Ic?-)?(\d+)?/a); while(@A and @B) { my $av = shift(@A); @@ -67,8 +68,8 @@ sub write_selects() print OUTPUTV "

    You can browse the test results of a different version :

    "; my %releases; foreach $_ (glob("results-*.shtml")) { - $_ =~ /results-([^I]*)((-Ic?)-([^I].*))\.shtml/; - $releases{"$1$3"}=1; + $_ =~ /results-(\d+.\d+)([^I]*)((-Ic?)-([^I].*))\.shtml/a; + $releases{"$1"}=1; } print OUTPUTV "\n"; print OUTPUTV " \n"; @@ -79,7 +80,7 @@ sub write_selects() } print OUTPUTV "\n"; print OUTPUTV "\n"; - write_select("sel", ".*"); + write_select("sel"); $count = 0; foreach $_ (sort sort_releases (keys %releases)) { write_select("sel" . $count, $_); @@ -91,19 +92,27 @@ sub write_selects() sub write_select() { my $id = shift(@_); - my $pattern = shift(@_); + my $pattern = ".*"; + if (@_ != 0) { + $pattern = quotemeta(shift(@_)); + } my($filename, @result); print OUTPUTV " "; @@ -282,7 +291,7 @@ EOF print_result_table(); if ($PLATFORMS_BESIDE_RESULTS) { - print OUTPUT "
    All releases (last one)
    \n\n"; + print OUTPUT "
    \n\n"; if ($platform_count > 0) { my $repeat_count = (1 + 1.1/16.5)*scalar(keys %test_directories)/($platform_count+0.25); while ($repeat_count >= 1) { diff --git a/Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h b/Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h index 787bf3c7640..c18be2bc370 100644 --- a/Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h +++ b/Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h @@ -15,7 +15,7 @@ #include -#include +#include #include #include diff --git a/Mesh_3/include/CGAL/IO/File_maya.h b/Mesh_3/include/CGAL/IO/File_maya.h index 0eb232d0544..dfb7398d498 100644 --- a/Mesh_3/include/CGAL/IO/File_maya.h +++ b/Mesh_3/include/CGAL/IO/File_maya.h @@ -14,7 +14,7 @@ #include -#include +#include #include #include diff --git a/Mesh_3/include/CGAL/IO/File_tetgen.h b/Mesh_3/include/CGAL/IO/File_tetgen.h index ef00fad211b..9feaa354ef9 100644 --- a/Mesh_3/include/CGAL/IO/File_tetgen.h +++ b/Mesh_3/include/CGAL/IO/File_tetgen.h @@ -15,7 +15,7 @@ #include -#include +#include #include #include diff --git a/Mesh_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h b/Mesh_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h index 718e7baab0c..132df01c693 100644 --- a/Mesh_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h +++ b/Mesh_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h @@ -18,9 +18,9 @@ #include #include -#include #include #include +#include #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 3f4421ed3e9..a27c9556cb0 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/Detect_polylines_in_polyhedra.h b/Mesh_3/include/CGAL/Mesh_3/Detect_polylines_in_polyhedra.h deleted file mode 100644 index d71d60c1195..00000000000 --- a/Mesh_3/include/CGAL/Mesh_3/Detect_polylines_in_polyhedra.h +++ /dev/null @@ -1,384 +0,0 @@ -// Copyright (c) 2010, 2012 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) : Laurent Rineau -// - -#ifndef CGAL_MESH_3_DETECT_POLYLINES_IN_POLYHEDRA_H -#define CGAL_MESH_3_DETECT_POLYLINES_IN_POLYHEDRA_H - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -namespace CGAL { namespace Mesh_3 { - -template -struct Detect_polylines -{ - typedef typename Polyhedron::Traits Geom_traits; - typedef typename Geom_traits::Point_3 Point_3; - typedef typename Polyhedron::Halfedge_const_handle Halfedge_const_handle; - typedef typename Polyhedron::Halfedge_handle Halfedge_handle; - typedef typename Polyhedron::Vertex_const_handle Vertex_const_handle; - typedef typename Polyhedron::Vertex_handle Vertex_handle; - typedef typename Polyhedron::size_type size_type; - typedef CGAL::Compare_handles_with_or_without_timestamps Compare_handles; - - typedef CGAL::Hash_handles_with_or_without_timestamps Hash_fct; - typedef boost::unordered_set Vertices_set; - typedef boost::unordered_map Vertices_counter; - - typedef boost::unordered_set Feature_edges_set; - - Feature_edges_set edges_to_consider; - Vertices_set corner_vertices; - - // typedef std::vector Polyline_and_context; - - typedef typename Polyhedron::Vertex Polyhedron_vertex; - typedef typename Polyhedron_vertex::Set_of_indices Set_of_indices; - - template - static - void display_index(std::ostream& stream, const T& x) - { - stream << x; - } - - template - static - void display_index(std::ostream& stream, const std::pair& p) - { - stream << p.first << "+" << p.second; - } - - static - void display_set(std::ostream& stream, Set_of_indices set) { - stream << "( "; - for(typename Set_of_indices::value_type i : set) { - display_index(stream, i); - stream << " "; - } - stream << ")"; - } - - static Set_of_indices - edge_indices(const Halfedge_handle he) { - Set_of_indices set_of_indices; - const Set_of_indices& source_set = - he->opposite()->vertex()->incident_patches_ids_set(); - const Set_of_indices& target_set = - he->vertex()->incident_patches_ids_set(); - std::set_intersection(source_set.begin(), source_set.end(), - target_set.begin(), target_set.end(), - std::inserter(set_of_indices, - set_of_indices.begin())); - if(set_of_indices.empty()) { - std::cerr << "Indices set of following edge is empty:\n"; - std::cerr << " " << he->opposite()->vertex()->point() - << " "; - display_set(std::cerr, source_set); - std::cerr << "\n"; - std::cerr << " " << he->vertex()->point() - << " "; - display_set(std::cerr, target_set); - std::cerr << "\n"; - } - return set_of_indices; - } - - static Halfedge_handle canonical(Halfedge_handle he) - { - const Halfedge_handle& op = he->opposite(); - if(Compare_handles()(he, op)) - return he; - else - return op; - } - - static bool is_feature(const Halfedge_handle he) { - return - he->is_feature_edge() || he->opposite()->is_feature_edge(); - } - - /** Follow a polyline or a polygon, from the halfedge he. */ - template - Polylines_output_iterator - follow_half_edge(const Halfedge_handle he, - Polylines_output_iterator polylines_out, - Polyline_and_context = Polyline_and_context()) - { - typename Feature_edges_set::iterator it = - edges_to_consider.find(canonical(he)); - if(it == edges_to_consider.end()) { - return polylines_out; - } - - Polyline_and_context polyline; - polyline.polyline_content.push_back(he->opposite()->vertex()->point()); - - Halfedge_handle current_he = he; - - Set_of_indices set_of_indices_of_current_edge - = edge_indices(current_he); - - do { - CGAL_assertion(!set_of_indices_of_current_edge.empty()); - CGAL_assertion(is_feature(current_he)); - CGAL_assertion_code(const size_type n = ) - edges_to_consider.erase(canonical(current_he)); - CGAL_assertion(n > 0); - Vertex_handle v = current_he->vertex(); - polyline.polyline_content.push_back(v->point()); - // std::cerr << v->point() << std::endl; - if(corner_vertices.count(v) > 0) break; - typename Polyhedron::Halfedge_around_vertex_circulator - loop_he = v->vertex_begin(); - ++loop_he; - // CGAL_assertion((&*loop_he) != (&*current_he) ); - while((&*loop_he) == (&*current_he) || - (!is_feature(loop_he)) ) { - ++loop_he; - // CGAL_assertion((&*loop_he) != (&*current_he) ); - } - - Set_of_indices set_of_indices_of_next_edge = - edge_indices(loop_he); - - if(! (set_of_indices_of_next_edge.size() == - set_of_indices_of_current_edge.size() - && - std::equal(set_of_indices_of_next_edge.begin(), - set_of_indices_of_next_edge.end(), - set_of_indices_of_current_edge.begin())) ) - { - // the vertex is a special vertex, a new corner -#ifdef CGAL_MESH_3_PROTECTION_DEBUG - std::cerr << "New corner vertex " << v->point() << std::endl; - std::cerr << " indices were: "; - for(typename Set_of_indices::value_type i : - set_of_indices_of_current_edge) { - std::cerr << i << " "; - } - std::cerr << "\n now: "; - for(typename Set_of_indices::value_type i : - set_of_indices_of_next_edge) { - std::cerr << i << " "; - } - std::cerr << "\n"; -#endif - ++v->nb_of_feature_edges; - corner_vertices.insert(v); - polyline.context.adjacent_patches_ids=set_of_indices_of_current_edge; - *polylines_out++ = polyline; - polyline.polyline_content.clear(); - polyline.polyline_content.push_back(loop_he->vertex()->point()); - set_of_indices_of_current_edge = set_of_indices_of_next_edge; - } - - current_he = loop_he->opposite(); - } while(current_he != he ); - - polyline.context.adjacent_patches_ids=set_of_indices_of_current_edge; - *polylines_out++ = polyline; - return polylines_out; - } - - /** Loop around a corner vertex, and try to follow a polyline of feature - edges, from each incident edge. */ - template - Polylines_output_iterator - loop_around_corner(const Vertex_handle v, - Polylines_output_iterator polylines_out, - Polyline_and_context empty_polyline = - Polyline_and_context() ) - { - typename Polyhedron::Halfedge_around_vertex_circulator - he = v->vertex_begin(), end(he); - do { - CGAL_assertion(he->vertex() == v); - polylines_out = follow_half_edge(he->opposite(), - polylines_out, - empty_polyline); - ++he; - } while(he != end); - return polylines_out; - } - - /** For a non-corner vertex v (that is incident to two feature edges), - measure the angle between the two edges, and mark the vertex as corner - edge, if the angle is < 120°. **/ - static bool measure_angle(const Vertex_handle v) - { - Halfedge_handle e1; - Halfedge_handle e2; - typename Polyhedron::Halfedge_around_vertex_circulator he = - v->vertex_begin(), end(he); - // std::cerr << "measure_handle(" << (void*)(&*v) - // << " = " << v->point() << ")"; - bool first = true; - bool done = false; - do { - CGAL_assertion(he->vertex() == v); - // std::cerr << he->opposite()->vertex()->point() << std::endl; - if(is_feature(he)) { - if(first) { - e1 = he; - first = false; - } - else { - if(done) { - std::cerr << v->point() << " should be a corner!\n" - << " Too many adjacent feature edges!\n"; - return false; - } - e2 = he; - done = true; - } - // std::cerr << "x"; - } - // else - // std::cerr << "."; - ++he; - } while(he != end); - if(!done) { - std::cerr << v->point() << " should be a corner!\n" - << " Not enough adjacent feature edge!\n"; - return false; - } - // std::cerr << "\n"; - const Point_3 pv = v->point(); - const Point_3 pa = e1->opposite()->vertex()->point(); - const Point_3 pb = e2->opposite()->vertex()->point(); - const typename Geom_traits::Vector_3 av = pv - pa; - const typename Geom_traits::Vector_3 bv = pv - pb; - const typename Geom_traits::FT sc_prod = av * bv; - if( sc_prod >= 0 || - (sc_prod < 0 && - CGAL::square(sc_prod) < (av * av) * (bv * bv) / 4 ) ) - { - // std::cerr << "Corner (" << pa << ", " << pv - // << ", " << pb << ")\n"; - return true; - } - else { - return false; - } - } - - template - Polylines_output_iterator - operator()(Polyhedron* pMesh, - Polylines_output_iterator out_it, - Polyline_and_context empty_polyline) - { - // That call orders the set of edges of the polyhedron, so that the - // feature edges are at the end of the sequence of edges. - // pMesh->normalize_border(); - Vertices_counter feature_vertices; - - // Iterate over all edges, and find out which vertices are corner - // vertices (more than two incident feature edges). - for(typename Polyhedron::Edge_iterator - eit = pMesh->edges_begin (), - end = pMesh->edges_end(); - eit != end; ++eit) - { - if(!eit->is_feature_edge()) continue; - edges_to_consider.insert(canonical(eit)); - typename Polyhedron::Vertex_handle v = eit->vertex(); - for(unsigned i = 0; i < 2; ++i) { - if(++feature_vertices[v] == 3) - corner_vertices.insert(v); - v = eit->opposite()->vertex(); - } - } - - for(typename Polyhedron::Vertex_iterator - vit = pMesh->vertices_begin (), - end = pMesh->vertices_end(); - vit != end; ++vit) - { - if(feature_vertices.count(vit) !=0 && - feature_vertices[vit] == 1) { - corner_vertices.insert(vit); - } - } - -#ifdef CGAL_MESH_3_PROTECTION_DEBUG - std::cerr << "Corner vertices: " << corner_vertices.size() << std::endl; - std::cerr << "Feature vertices: " << feature_vertices.size() << std::endl; -#endif - - // // Iterate over non-corner feature vertices, and measure the angle. - for(typename Vertices_counter::iterator it = feature_vertices.begin(), - end = feature_vertices.end(); it != end; ++it) - { - const Vertex_handle v = it->first; - if(corner_vertices.count(v) == 0) { - CGAL_assertion(it->second == 2); - if(measure_angle(v)) { - corner_vertices.insert(v); - } - } - } -#ifdef CGAL_MESH_3_PROTECTION_DEBUG - std::cerr << "New corner vertices: " - << corner_vertices.size() << std::endl; -#endif - - // Follow the polylines... - for(typename Vertices_set::iterator it = corner_vertices.begin(), - end = corner_vertices.end(); it != end; ++it) - { - out_it = loop_around_corner(*it, out_it, empty_polyline); - } - - // ... and the cycles. - while(! edges_to_consider.empty() ) { - out_it = follow_half_edge(*edges_to_consider.begin(), - out_it, - empty_polyline); - } - - return out_it; - } -}; - -template -Polylines_output_iterator -detect_polylines(Polyhedron* pMesh, - Polylines_output_iterator out_it) { - - Detect_polylines go; - Polyline_and_context empty_polyline; - return go(pMesh, out_it, empty_polyline); -} - -} // end namespace CGAL::Mesh_3 -} // end namespace CGAL - - -#endif // CGAL_MESH_3_DETECT_POLYLINES_IN_POLYHEDRA_H diff --git a/Mesh_3/include/CGAL/Mesh_3/Detect_polylines_in_polyhedra_fwd.h b/Mesh_3/include/CGAL/Mesh_3/Detect_polylines_in_polyhedra_fwd.h deleted file mode 100644 index 184c4cf4ed9..00000000000 --- a/Mesh_3/include/CGAL/Mesh_3/Detect_polylines_in_polyhedra_fwd.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2010 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) : Laurent Rineau -// - -#ifndef CGAL_DETECT_POLYLINES_IN_POLYHEDRA_FWD_H -#define CGAL_DETECT_POLYLINES_IN_POLYHEDRA_FWD_H - -#include - - -namespace CGAL { namespace Mesh_3 { - -template -struct Detect_polylines; - -template -Polylines_output_iterator -detect_polylines(Polyhedron* pMesh, - Polylines_output_iterator out_it); - -} // end namespace CGAL::Mesh_3 -} // end namespace CGAL - - -#endif // CGAL_DETECT_POLYLINES_IN_POLYHEDRA_FWD_H diff --git a/Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h b/Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h index 1bed83025b7..387f1e9c1f1 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h +++ b/Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_base.h b/Mesh_3/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_base.h index e621c87d4b1..b2cd9715ee5 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_base.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_base.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h b/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h index 0e4145b26f7..cd4310bf5fb 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h @@ -29,8 +29,8 @@ #include #include #include +#include -#include #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h b/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h index 20e360c5a39..e58a21ff397 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h @@ -288,6 +288,24 @@ private: CGAL::cpp11::atomic* const stop_ptr; #endif +#ifdef CGAL_LINKED_WITH_TBB + std::size_t approximate_number_of_vertices(CGAL::Parallel_tag) const { +# if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + return r_c3t3_.triangulation().tds().vertices().approximate_size(); +# else // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + CGAL_error_msg( + "If you want to use the Mesh_3 feature \"maximal_number_of_vertices\"\n" + "with CGAL::Parallel_tag then you need to recompile the code with the\n" + "preprocessor macro CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE\n" + "set to 1. That will induce a performance loss of 3%.\n"); +# endif // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + } +#endif // CGAL_LINKED_WITH_TBB + + std::size_t approximate_number_of_vertices(CGAL::Sequential_tag) const { + return r_c3t3_.triangulation().number_of_vertices(); + } + bool forced_stop() const { #ifndef CGAL_NO_ATOMIC if(stop_ptr != 0 && @@ -298,8 +316,7 @@ private: } #endif // not defined CGAL_NO_ATOMIC if(maximal_number_of_vertices_ != 0 && - r_c3t3_.triangulation().number_of_vertices() >= - maximal_number_of_vertices_) + approximate_number_of_vertices(Concurrency_tag()) >= maximal_number_of_vertices_) { if(error_code_ != 0) { *error_code_ = CGAL_MESH_3_MAXIMAL_NUMBER_OF_VERTICES_REACHED; @@ -502,15 +519,15 @@ refine_mesh(std::string dump_after_refine_surface_prefix) % r_tr.number_of_vertices() % nbsteps % cells_mesher_.debug_info() % (nbsteps / timer.time()); - if(! forced_stop() && - refinement_stage == REFINE_FACETS && + if(refinement_stage == REFINE_FACETS && + ! forced_stop() && facets_mesher_.is_algorithm_done()) { facets_mesher_.scan_edges(); refinement_stage = REFINE_FACETS_AND_EDGES; } - if(! forced_stop() && - refinement_stage == REFINE_FACETS_AND_EDGES && + if(refinement_stage == REFINE_FACETS_AND_EDGES && + ! forced_stop() && facets_mesher_.is_algorithm_done()) { facets_mesher_.scan_vertices(); @@ -800,7 +817,7 @@ status() const if(boost::is_convertible::value) { const WorksharingDataStructureType* ws_ds = this->get_worksharing_data_structure(); - return Mesher_status(r_c3t3_.triangulation().number_of_vertices(), + return Mesher_status(approximate_number_of_vertices(Concurrency_tag()), 0, ws_ds->approximate_number_of_enqueued_element()); } diff --git a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h index 7516d6e6656..3fdc4cf0b0b 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h +++ b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h @@ -41,8 +41,7 @@ #endif #include -#include -#include +#include #include #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h index 8939cbce2a3..1568ea059aa 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h @@ -19,9 +19,9 @@ #include -#include -#include #include +#include +#include #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h b/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h index 9d5a69d4c2b..ac6e886e4a3 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h +++ b/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h @@ -42,8 +42,7 @@ #include #include #include -#include -#include +#include #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/Triangulation_helpers.h b/Mesh_3/include/CGAL/Mesh_3/Triangulation_helpers.h index 8ac0c8e2340..5eafdc611a1 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Triangulation_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/Triangulation_helpers.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_experimental.h b/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_experimental.h index b0edd480e67..f010b11bc38 100644 --- a/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_experimental.h +++ b/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_experimental.h @@ -310,7 +310,6 @@ public: m_own_ptree.reset(new Tree(triangles.begin(), triangles.end())); m_own_ptree->build(); - m_own_ptree->accelerate_distance_queries(); } private: diff --git a/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_polyhedron.h b/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_polyhedron.h index e23ff69545d..c60ce33db5c 100644 --- a/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_polyhedron.h +++ b/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_polyhedron.h @@ -131,7 +131,6 @@ public: m_own_ptree.reset(new Tree(triangles.begin(), triangles.end())); m_own_ptree->build(); - m_own_ptree->accelerate_distance_queries(); } private: diff --git a/Mesh_3/include/CGAL/Mesh_3/polyhedral_to_labeled_function_wrapper.h b/Mesh_3/include/CGAL/Mesh_3/polyhedral_to_labeled_function_wrapper.h index 7528d874fe1..940a08eb03c 100644 --- a/Mesh_3/include/CGAL/Mesh_3/polyhedral_to_labeled_function_wrapper.h +++ b/Mesh_3/include/CGAL/Mesh_3/polyhedral_to_labeled_function_wrapper.h @@ -90,7 +90,7 @@ public: , step_size_(step_size) , first_level_(first_level) { - tree_->accelerate_distance_queries(); + } // Default copy constructor and assignment operator are ok @@ -207,7 +207,6 @@ public: , sq_tolerance_size_(tolerance_size*tolerance_size) , hint_(p.facets_begin()->halfedge()->vertex()->point()) { - tree_->accelerate_distance_queries(); } // Default copy constructor and assignment operator are ok @@ -283,7 +282,6 @@ public: , sq_tolerance_size_(tolerance_size*tolerance_size) , hint_(p.facets_begin()->halfedge()->vertex()->point()) { - tree_->accelerate_distance_queries(); } // Default copy constructor and assignment operator are ok diff --git a/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h b/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h index 82bafa3f43b..07ceaabc6d0 100644 --- a/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h +++ b/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h @@ -24,6 +24,7 @@ #include #include +#include #ifdef CGAL_MESH_3_PERTURBER_VERBOSE #include diff --git a/Mesh_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/Mesh_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 9ab9148c55f..954478ccee7 100644 --- a/Mesh_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/Mesh_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -22,10 +22,10 @@ #include #include -#include #include #include #include +#include #include #include diff --git a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h index f10e243d999..f9a7a0d5cf4 100644 --- a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h +++ b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h @@ -206,7 +206,7 @@ public: struct Primitive_type { //setting OneFaceGraphPerTree to false transforms the id type into //std::pair. - typedef AABB_face_graph_triangle_primitive::type, CGAL::Tag_false> type; + typedef AABB_face_graph_triangle_primitive::const_type, CGAL::Tag_false> type; static typename IGT_::Triangle_3 datum(const typename type::Id primitive_id) { diff --git a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h index e6c1a99fba2..d5f9979bc9b 100644 --- a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h +++ b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h @@ -28,7 +28,6 @@ #include #include #include -#include #include #include diff --git a/Mesh_3/test/Mesh_3/data/c3t3_io-hetero.binary.cgal b/Mesh_3/test/Mesh_3/data/c3t3_io-hetero.binary.cgal index 9de545a229b..f4c958d9239 100644 Binary files a/Mesh_3/test/Mesh_3/data/c3t3_io-hetero.binary.cgal and b/Mesh_3/test/Mesh_3/data/c3t3_io-hetero.binary.cgal differ diff --git a/Mesh_3/test/Mesh_3/data/c3t3_io-hetero.cgal b/Mesh_3/test/Mesh_3/data/c3t3_io-hetero.cgal index 9d9667f2c8c..f0c10161e35 100644 --- a/Mesh_3/test/Mesh_3/data/c3t3_io-hetero.cgal +++ b/Mesh_3/test/Mesh_3/data/c3t3_io-hetero.cgal @@ -9,38 +9,38 @@ CGAL c3t3 Triangulation_3(Weighted_point,Vb(Tvb_3+i+boost::variant,Vb(Tvb_3+i+i),Cb(i+RTcb_3+(i)[ 3 9 13 0 3 1 12 0 1 3 4 -6 5 3 4 -5 6 0 4 -1 6 3 4 +4 0 1 6 +4 3 5 6 +5 0 4 6 3 2 1 0 -2 0 3 5 -5 0 3 4 -6 1 0 4 -2 1 0 6 -2 6 0 5 -6 2 3 5 -1 2 3 6 -3 6 7 4 -6 3 2 10 -7 6 1 9 -1 0 7 11 -8 0 5 11 -6 10 9 4 -0 1 2 5 -0 2 3 8 -7 9 11 4 -2 5 10 8 -5 1 9 11 -10 3 8 4 +3 0 4 5 +0 3 2 5 +4 1 3 6 +5 3 2 6 +2 3 1 6 +2 0 5 6 +0 2 1 6 +7 5 1 4 +11 7 3 0 +8 3 7 5 +1 2 10 5 +11 0 6 9 +3 2 6 0 +8 10 5 4 +9 2 1 0 +9 10 2 6 +7 11 8 4 +3 8 11 6 +9 1 10 4 0 3 0 0 0 -1 4 0 0 0 -0 0 0 0 0 -2 0 3 0 0 -0 0 0 0 0 -0 0 0 0 0 0 0 4 0 0 +1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +2 0 0 4 3 +0 0 0 0 0 +0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 diff --git a/Mesh_3/test/Mesh_3/test_c3t3_io.cpp b/Mesh_3/test/Mesh_3/test_c3t3_io.cpp index d6cd39136df..bda2c383f8e 100644 --- a/Mesh_3/test/Mesh_3/test_c3t3_io.cpp +++ b/Mesh_3/test/Mesh_3/test_c3t3_io.cpp @@ -384,6 +384,17 @@ struct Test_c3t3_io { return true; } + { + std::string filename(prefix); + filename += "_new"; + if(binary) filename += ".binary"; + filename += ".cgal"; + std::ofstream output(filename.c_str(), + binary ? (std::ios_base::out | std::ios_base::binary) + : std::ios_base::out); + CGAL::Mesh_3::save_binary_file(output, c3t3_bis, binary); + } + c3t3_bis.clear(); { std::ifstream input(filename.c_str(), diff --git a/Nef_3/doc/Nef_3/CGAL/draw_nef_3.h b/Nef_3/doc/Nef_3/CGAL/draw_nef_3.h new file mode 100644 index 00000000000..3ec9c0b2a8c --- /dev/null +++ b/Nef_3/doc/Nef_3/CGAL/draw_nef_3.h @@ -0,0 +1,15 @@ +namespace CGAL { + +/*! +\ingroup PkgDrawNef3 + +Open a new window and draws `anef3`, the `Nef_polyhedron_3`. A call to this function is blocking, that is the program continues as soon as the user closes the window. + This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time. +\tparam Nef3 a model of the `Nef_polyhedron_3` concept. +\param anef3 the nef polyhedron to draw. + +*/ +template +void draw(const Nef3& anef3); + +} /* namespace CGAL */ \ No newline at end of file diff --git a/Nef_3/doc/Nef_3/Nef_3.txt b/Nef_3/doc/Nef_3/Nef_3.txt index b1bd50533b8..c4d45087f12 100644 --- a/Nef_3/doc/Nef_3/Nef_3.txt +++ b/Nef_3/doc/Nef_3/Nef_3.txt @@ -425,6 +425,18 @@ the symbolical value, large but finite, for the size of the infimaximal box. \cgalExample{Nef_3/extended_kernel.cpp} +\subsection Nef_3DrawNefPolyhedron Draw a Nef Polyhedron + +A nef polyhedron can be visualised by calling the \link PkgDrawNef3 CGAL::draw() \endlink function as shown in the following example. This function opens a new window showing the given Nef Polyhedron. + +\cgalExample{Nef_3/draw_nef_3.cpp} + +This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time. + +\cgalFigureBegin{fig_draw_nef_polyhedron, draw_nef_3.png} +Result of the run of the draw_nef_3 program. A window shows the nef polyhedron and allows to navigate through the 3D scene. +\cgalFigureEnd + \section Nef_3File File I/O \anchor sectionNef_3IO diff --git a/Nef_3/doc/Nef_3/PackageDescription.txt b/Nef_3/doc/Nef_3/PackageDescription.txt index b8a0ab9c5e1..91de0089d8d 100644 --- a/Nef_3/doc/Nef_3/PackageDescription.txt +++ b/Nef_3/doc/Nef_3/PackageDescription.txt @@ -3,6 +3,13 @@ /// \defgroup PkgNef3IOFunctions I/O Functions /// \ingroup PkgNef3Ref +/*! Draw. + \code + #include + \endcode +*/ +/// \defgroup PkgDrawNef3 Draw a Nef Polyhedron +/// \ingroup PkgNef3Ref /*! \addtogroup PkgNef3Ref @@ -64,5 +71,8 @@ a simple OpenGL visualization for debugging and illustrations. - \link PkgNef3IOFunctions `CGAL::operator<<()` \endlink - \link PkgNef3IOFunctions `CGAL::operator>>()` \endlink +\cgalCRPSection{Draw a Nef Polyhedron} +- \link PkgDrawNef3 CGAL::draw() \endlink + */ diff --git a/Nef_3/doc/Nef_3/dependencies b/Nef_3/doc/Nef_3/dependencies index 92b8ee474e4..467cacb769e 100644 --- a/Nef_3/doc/Nef_3/dependencies +++ b/Nef_3/doc/Nef_3/dependencies @@ -11,3 +11,4 @@ Number_types BGL Surface_mesh Polygon_mesh_processing +GraphicsView diff --git a/Nef_3/doc/Nef_3/examples.txt b/Nef_3/doc/Nef_3/examples.txt index 3c394cfd017..4a790f646bc 100644 --- a/Nef_3/doc/Nef_3/examples.txt +++ b/Nef_3/doc/Nef_3/examples.txt @@ -17,4 +17,5 @@ \example Nef_3/topological_operations.cpp \example Nef_3/transformation.cpp \example Nef_3/nef_3_to_surface_mesh.cpp +\example Nef_3/draw_nef_3.cpp */ diff --git a/Nef_3/doc/Nef_3/fig/draw_nef_3.png b/Nef_3/doc/Nef_3/fig/draw_nef_3.png new file mode 100644 index 00000000000..03d51641277 Binary files /dev/null and b/Nef_3/doc/Nef_3/fig/draw_nef_3.png differ diff --git a/Nef_3/examples/Nef_3/CMakeLists.txt b/Nef_3/examples/Nef_3/CMakeLists.txt index ec12fc129f2..3ae02207f06 100644 --- a/Nef_3/examples/Nef_3/CMakeLists.txt +++ b/Nef_3/examples/Nef_3/CMakeLists.txt @@ -6,7 +6,11 @@ cmake_minimum_required(VERSION 3.1...3.15) project( Nef_3_Examples ) -find_package(CGAL QUIET) +find_package(CGAL COMPONENTS Qt5) + +if(CGAL_Qt5_FOUND) + add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS) +endif() if ( CGAL_FOUND ) @@ -16,6 +20,10 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "${cppfile}" ) endforeach() + if(CGAL_Qt5_FOUND) + target_link_libraries(draw_nef_3 PUBLIC CGAL::CGAL_Qt5) + endif() + else() message(STATUS "This program requires the CGAL library, and will not be compiled.") diff --git a/Nef_3/examples/Nef_3/data/cross.off b/Nef_3/examples/Nef_3/data/cross.off new file mode 100644 index 00000000000..0f08a5b0f18 --- /dev/null +++ b/Nef_3/examples/Nef_3/data/cross.off @@ -0,0 +1,85 @@ +OFF +40 38 0 + +0 3 0 +1 3 0 +2 3 0 +2 4 0 +2 5 0 +3 5 0 +3 4 0 +3 3 0 +4 3 0 +5 3 0 +5 2 0 +4 2 0 +3 2 0 +3 1 0 +3 0 0 +2 0 0 +2 1 0 +2 2 0 +1 2 0 +0 2 0 + +0 3 1 +1 3 1 +2 3 1 +2 4 1 +2 5 1 +3 5 1 +3 4 1 +3 3 1 +4 3 1 +5 3 1 +5 2 1 +4 2 1 +3 2 1 +3 1 1 +3 0 1 +2 0 1 +2 1 1 +2 2 1 +1 2 1 +0 2 1 + +4 0 1 18 19 +4 1 2 17 18 +4 2 7 12 17 +4 2 3 6 7 +4 3 4 5 6 +4 7 8 11 12 +4 8 9 10 11 +4 12 13 16 17 +4 13 14 15 16 + +4 1 0 20 21 +4 2 1 21 22 +4 3 2 22 23 +4 4 3 23 24 +4 5 4 24 25 +4 6 5 25 26 +4 7 6 26 27 +4 8 7 27 28 +4 9 8 28 29 +4 10 9 29 30 +4 11 10 30 31 +4 12 11 31 32 +4 13 12 32 33 +4 14 13 33 34 +4 15 14 34 35 +4 16 15 35 36 +4 17 16 36 37 +4 18 17 37 38 +4 19 18 38 39 +4 0 19 39 20 + +4 39 38 21 20 +4 38 37 22 21 +4 37 32 27 22 +4 27 26 23 22 +4 26 25 24 23 +4 32 31 28 27 +4 31 30 29 28 +4 37 36 33 32 +4 36 35 34 33 diff --git a/Nef_3/examples/Nef_3/draw_nef_3.cpp b/Nef_3/examples/Nef_3/draw_nef_3.cpp new file mode 100644 index 00000000000..06727eac187 --- /dev/null +++ b/Nef_3/examples/Nef_3/draw_nef_3.cpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include + +#include +#include + +typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; +typedef CGAL::Polyhedron_3 Polyhedron; +typedef CGAL::Nef_polyhedron_3 Nef_polyhedron; + +int main(int argc, char *argv[]) +{ + // read OFF file into a polyhedron + Polyhedron P; + std::ifstream ifs((argc > 1) ? argv[1] : "data/cross.off"); + ifs >> P; + + // initialize nef from polyhedron + Nef_polyhedron N(P); + + // draw Nef Polyhedron + CGAL::draw(N); + + return EXIT_SUCCESS; +} diff --git a/Nef_3/include/CGAL/Nef_3/K3_tree.h b/Nef_3/include/CGAL/Nef_3/K3_tree.h index f51f29c18b6..765ab11aa71 100644 --- a/Nef_3/include/CGAL/Nef_3/K3_tree.h +++ b/Nef_3/include/CGAL/Nef_3/K3_tree.h @@ -162,11 +162,11 @@ private: template class Triangulation_handler { - typedef typename CGAL::Triangulation_vertex_base_2 Vb; - typedef typename CGAL::Constrained_triangulation_face_base_2 Fb; - typedef typename CGAL::Triangulation_data_structure_2 TDS; - typedef typename CGAL::No_intersection_tag Itag; - typedef typename CGAL::Constrained_triangulation_2 CT; + typedef typename CGAL::Triangulation_vertex_base_2 Vb; + typedef typename CGAL::Constrained_triangulation_face_base_2 Fb; + typedef typename CGAL::Triangulation_data_structure_2 TDS; + typedef typename CGAL::No_constraint_intersection_requiring_constructions_tag Itag; + typedef typename CGAL::Constrained_triangulation_2 CT; typedef typename CT::Face_handle Face_handle; typedef typename CT::Finite_faces_iterator Finite_face_iterator; 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 e72f7f59200..3aafa4e5cbf 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h @@ -212,11 +212,11 @@ public: template class Triangulation_handler { - typedef typename CGAL::Triangulation_vertex_base_2 Vb; - typedef typename CGAL::Constrained_triangulation_face_base_2 Fb; - typedef typename CGAL::Triangulation_data_structure_2 TDS; - typedef typename CGAL::No_intersection_tag Itag; - typedef typename CGAL::Constrained_triangulation_2 CT; + typedef typename CGAL::Triangulation_vertex_base_2 Vb; + typedef typename CGAL::Constrained_triangulation_face_base_2 Fb; + typedef typename CGAL::Triangulation_data_structure_2 TDS; + typedef typename CGAL::No_constraint_intersection_requiring_constructions_tag Itag; + typedef typename CGAL::Constrained_triangulation_2 CT; typedef typename CT::Face_handle Face_handle; typedef typename CT::Finite_faces_iterator Finite_face_iterator; diff --git a/Nef_3/include/CGAL/draw_nef_3.h b/Nef_3/include/CGAL/draw_nef_3.h new file mode 100644 index 00000000000..da8e01bacc8 --- /dev/null +++ b/Nef_3/include/CGAL/draw_nef_3.h @@ -0,0 +1,272 @@ +// Copyright (c) 2019 Max-Planck-Institute Saarbruecken (Germany). +// 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) : Jasmeet Singh + +#ifndef DRAW_NEF_3_H +#define DRAW_NEF_3_H + +#include +#include + +#ifdef CGAL_USE_BASIC_VIEWER + +#include +#include +#include +#include + +namespace CGAL { + +// Default color functor; user can change it to have its own face color +struct DefaultColorFunctorNefPolyhedron +{ + template + static CGAL::Color run(const NefPolyhedron&, + typename NefPolyhedron::Halffacet_const_handle fh) + { + if (fh == nullptr) // use to get the mono color + return CGAL::Color(100, 125, 200); // R G B between 0-255 + + CGAL::Random random((unsigned int)(std::size_t)(&(*fh))); + return get_random_color(random); + } +}; + +// Viewer class for Nef Polyhedron +template +class SimpleNefPolyhedronViewerQt : public Basic_viewer_qt +{ + typedef Basic_viewer_qt Base; + typedef typename Nef_Polyhedron::Kernel Kernel; + + typedef typename Nef_Polyhedron::Halffacet_cycle_const_iterator Halffacet_cycle_const_iterator; + typedef typename Nef_Polyhedron::SHalfedge_around_facet_const_circulator SHalfedge_around_facet_const_circulator; + + typedef typename Nef_Polyhedron::Shell_entry_const_iterator Shell_entry_const_iterator; + typedef typename Nef_Polyhedron::SHalfedge_const_iterator SHalfedge_const_iterator; + typedef typename Nef_Polyhedron::Volume_const_iterator Volume_const_iterator; + + typedef typename Nef_Polyhedron::Vertex_const_handle Vertex_const_handle; + typedef typename Nef_Polyhedron::SFace_const_handle SFace_const_handle; + typedef typename Nef_Polyhedron::Halfedge_const_handle Halfedge_const_handle; + typedef typename Nef_Polyhedron::Halffacet_const_handle Halffacet_const_handle; + typedef typename Nef_Polyhedron::SHalfedge_const_handle SHalfedge_const_handle; + typedef typename Nef_Polyhedron::SHalfloop_const_handle SHalfloop_const_handle; + +public: + /// Construct the viewer + /// @param anef the nef polyhedron to view + /// @param title the title of the window + /// @param anofaces if true, do not draw faces (faces are not + /// computed: this can be useful for big objects) + SimpleNefPolyhedronViewerQt(QWidget* parent, + const Nef_Polyhedron& anef, + const char* title="Basic Nef Polyhedron Viewer", + bool anofaces=false, + const ColorFunctor& fcolor=ColorFunctor()) : + //First draw: vertex; edges, faces; mon-color; inverse normal + Base(parent, title, false, true, true, true, false), + nef(anef), + m_nofaces(anofaces), + m_fcolor(fcolor) + { + compute_elements(); + } +protected: + // Visitor class to iterate through shell objects + class Nef_Visitor { + public: + Nef_Visitor(SimpleNefPolyhedronViewerQt &v) + : n_faces(0), n_edges(0), viewer(v) {} + + void visit(Vertex_const_handle vh) { + viewer.add_point(vh->point()); + } + + void visit(Halffacet_const_handle opposite_facet) + { + Halffacet_const_handle f = opposite_facet->twin(); + + if (facets_done.find(f) != facets_done.end() || + facets_done.find(opposite_facet) != facets_done.end()) { + return; + } + + SHalfedge_const_handle se; + Halffacet_cycle_const_iterator fc; + fc = f->facet_cycles_begin(); + + se = SHalfedge_const_handle(fc); // non-zero if shalfedge is returned + if(se == 0) + { //return if not-shalfedge + return; + } + + CGAL::Color c = viewer.run_color(f); + viewer.face_begin(c); + + SHalfedge_around_facet_const_circulator hc_start(se); + SHalfedge_around_facet_const_circulator hc_end(hc_start); + CGAL_For_all(hc_start, hc_end) { + Vertex_const_handle vh = hc_start->source()->center_vertex(); + viewer.add_point_in_face(vh->point(), + viewer.get_vertex_normal(vh)); + } + viewer.face_end(); + facets_done[f] = true; + n_faces++; + } + + void visit(Halfedge_const_handle he) + { + Halfedge_const_handle twin = he->twin(); + if (edges_done.find(he) != edges_done.end() || + edges_done.find(twin) != edges_done.end()) + { + // Edge already added + return; + } + + viewer.add_segment(he->source()->point(), he->target()->point()); + edges_done[he] = true; + n_edges++; + } + + void visit(SHalfedge_const_handle ) {} + void visit(SHalfloop_const_handle ) {} + void visit(SFace_const_handle ) {} + int n_faces; + int n_edges; + protected: + std::unordered_map facets_done; + std::unordered_map edges_done; + SimpleNefPolyhedronViewerQt& viewer; + }; + + void compute_elements() + { + clear(); + + Volume_const_iterator c; + + Nef_Visitor V(*this); + CGAL_forall_volumes(c, nef) + { + Shell_entry_const_iterator it; + CGAL_forall_shells_of(it, c) + { + nef.visit_shell_objects(SFace_const_handle(it), V); + } + } + + negate_all_normals(); + } + + CGAL::Color run_color(Halffacet_const_handle fh) + { + return m_fcolor.run(nef, fh); + } + + virtual void keyPressEvent(QKeyEvent *e) + { + // Test key pressed: + // const ::Qt::KeyboardModifiers modifiers = e->modifiers(); + // if ((e->key()==Qt::Key_PageUp) && (modifiers==Qt::NoButton)) { ... } + + // Call: * compute_elements() if the model changed, followed by + // * redraw() if some viewing parameters changed that implies some + // modifications of the buffers + // (eg. type of normal, color/mono) + // * update() just to update the drawing + + // Call the base method to process others/classicals key + Base::keyPressEvent(e); + } + +protected: + Local_vector get_face_normal(SHalfedge_const_handle she) + { + SHalfedge_around_facet_const_circulator he(she); + Local_vector normal = CGAL::NULL_VECTOR; + SHalfedge_around_facet_const_circulator end = he; + unsigned int nb = 0; + + CGAL_For_all(he, end) + { + internal::newell_single_step_3(this->get_local_point + (he->next()->source()->center_vertex()->point()), + this->get_local_point(he->source()->center_vertex()-> + point()), normal); + ++nb; + } + + assert(nb > 0); + return (typename Local_kernel::Construct_scaled_vector_3()(normal, 1.0 / nb)); + } + + Local_vector get_vertex_normal(Vertex_const_handle vh) + { + Local_vector normal = CGAL::NULL_VECTOR; + + SHalfedge_const_iterator it = vh->shalfedges_begin(); + SHalfedge_const_handle end = it; + do { + Local_vector n = get_face_normal(it); + normal = typename Local_kernel::Construct_sum_of_vectors_3()(normal, n); + it = it->snext(); + } while( it != end ); + + if (!typename Local_kernel::Equal_3()(normal, CGAL::NULL_VECTOR)) + { + normal = (typename Local_kernel::Construct_scaled_vector_3()( + normal, 1.0 / CGAL::sqrt(normal.squared_length()))); + } + + return normal; + } + +protected: + const Nef_Polyhedron &nef; + bool m_nofaces; + const ColorFunctor &m_fcolor; +}; + +#define CGAL_NEF3_TYPE Nef_polyhedron_3 + +template +void draw(const CGAL_NEF3_TYPE &anef, + const char *title = "Nef Polyhedron Viewer", + bool nofill = false) { +#if defined(CGAL_TEST_SUITE) + bool cgal_test_suite = true; +#else + bool cgal_test_suite = qEnvironmentVariableIsSet("CGAL_TEST_SUITE"); +#endif + + if (!cgal_test_suite) + { + int argc = 1; + const char *argv[2] = {"nef_polyhedron_viewer", "\0"}; + QApplication app(argc, const_cast(argv)); + DefaultColorFunctorNefPolyhedron fcolor; + SimpleNefPolyhedronViewerQt + mainwindow(app.activeWindow(), anef, title, nofill, fcolor); + mainwindow.show(); + app.exec(); + } +} + +} // End namespace CGAL + +#endif // CGAL_USE_BASIC_VIEWER + +#endif // DRAW_NEF_3_H diff --git a/Nef_3/package_info/Nef_3/dependencies b/Nef_3/package_info/Nef_3/dependencies index 71b69c66df6..9723ec4e097 100644 --- a/Nef_3/package_info/Nef_3/dependencies +++ b/Nef_3/package_info/Nef_3/dependencies @@ -7,6 +7,7 @@ Circulator Distance_2 Distance_3 Filtered_kernel +GraphicsView HalfedgeDS Hash_map Homogeneous_kernel diff --git a/Nef_S2/package_info/Nef_S2/dependencies b/Nef_S2/package_info/Nef_S2/dependencies index 75135011028..fcc8ed45ff2 100644 --- a/Nef_S2/package_info/Nef_S2/dependencies +++ b/Nef_S2/package_info/Nef_S2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Circulator Distance_2 +Distance_3 Hash_map Installation Intersections_2 @@ -16,4 +17,3 @@ Profiling_tools STL_Extension Stream_support Union_find -Distance_3 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 78841b43848..01008336965 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h @@ -58,6 +58,7 @@ template struct Kernel_d_interface : public Base_ { typedef typename Get_functor::type Point_dimension_d; typedef typename Get_functor::type Side_of_oriented_sphere_d; typedef typename Get_functor::type Power_side_of_power_sphere_d; + typedef typename Get_functor::type Power_side_of_bounded_power_sphere_d; typedef typename Get_functor::type Power_center_d; typedef typename Get_functor::type Power_distance_d; typedef typename Get_functor::type Contained_in_affine_hull_d; @@ -166,6 +167,16 @@ template struct Kernel_d_interface : public Base_ { return typename Get_functor::type(this->kernel())(b,e); } }; + struct Compute_squared_radius_smallest_orthogonal_sphere_d : private Store_kernel { + typedef Kernel R_; // for the macro + CGAL_FUNCTOR_INIT_STORE(Compute_squared_radius_smallest_orthogonal_sphere_d) + typedef FT result_type; + template FT operator()(I b, I e)const{ + typename Get_functor::type pw(this->kernel()); + typename Get_functor::type pc(this->kernel()); + return pw(pc(b,e)); + } + }; typedef typename Construct_cartesian_const_iterator_d::result_type Cartesian_const_iterator_d; typedef typename Get_functor::type Squared_distance_d; typedef typename Get_functor::type Squared_length_d; @@ -210,6 +221,7 @@ template struct Kernel_d_interface : public Base_ { Point_of_sphere_d point_of_sphere_d_object()const{ return Point_of_sphere_d(*this); } Side_of_oriented_sphere_d side_of_oriented_sphere_d_object()const{ return Side_of_oriented_sphere_d(*this); } Power_side_of_power_sphere_d power_side_of_power_sphere_d_object()const{ return Power_side_of_power_sphere_d(*this); } + Power_side_of_bounded_power_sphere_d power_side_of_bounded_power_sphere_d_object()const{ return Power_side_of_bounded_power_sphere_d(*this); } Power_center_d power_center_d_object()const{ return Power_center_d(*this); } Power_distance_d power_distance_d_object()const{ return Power_distance_d(*this); } Side_of_bounded_sphere_d side_of_bounded_sphere_d_object()const{ return Side_of_bounded_sphere_d(*this); } @@ -243,6 +255,7 @@ template struct Kernel_d_interface : public Base_ { Construct_sphere_d construct_sphere_d_object()const{ return Construct_sphere_d(*this); } Construct_hyperplane_d construct_hyperplane_d_object()const{ return Construct_hyperplane_d(*this); } Compute_squared_radius_d compute_squared_radius_d_object()const{ return Compute_squared_radius_d(*this); } + Compute_squared_radius_smallest_orthogonal_sphere_d compute_squared_radius_smallest_orthogonal_sphere_d_object()const{ return Compute_squared_radius_smallest_orthogonal_sphere_d(*this); } Squared_distance_d squared_distance_d_object()const{ return Squared_distance_d(*this); } Squared_length_d squared_length_d_object()const{ return Squared_length_d(*this); } Scalar_product_d scalar_product_d_object()const{ return Scalar_product_d(*this); } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index e49ba75d9d1..5e0e24254fe 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -30,7 +30,7 @@ struct Nth_iterator_element : private Store_kernel { typedef typename Get_type::value_tag>::type result_type; template result_type operator()(U&& u, int i) const { typename Get_functor >::type ci(this->kernel()); - return *cpp0x::next(ci(std::forward(u),Begin_tag()),i); + return *std::next(ci(std::forward(u),Begin_tag()),i); } }; //typedef typename Functor::nth_element>::type nth_elem; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h index aa975accbf0..e1ca315a997 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h @@ -169,29 +169,107 @@ template struct Power_center : Store_kernel { WPoint const& wp0 = *f; Point const& p0 = pdw(wp0); int d = pd(p0); - FT const& n0 = sdo(p0) - pw(wp0); - Matrix m(d,d); - Vec b = typename CVec::Dimension()(d); - // Write the point coordinates in lines. - int i; - for(i=0; ++f!=e; ++i) { - WPoint const& wp=*f; - Point const& p=pdw(wp); - for(int j=0;j(std::distance(f,e)); + if (d+1 == k) + { + FT const& n0 = sdo(p0) - pw(wp0); + Matrix m(d,d); + Vec b = typename CVec::Dimension()(d); + // Write the point coordinates in lines. + int i; + for(i=0; ++f!=e; ++i) { + WPoint const& wp=*f; + Point const& p=pdw(wp); + for(int j=0;j::Other LAd; + typedef typename LAd::Square_matrix Matrix; + typedef typename LAd::Vector Vec; + typename Get_functor::type sp(this->kernel()); + Matrix m(k,k); + Vec b(k); + Vec l(k); + int j,i=0; + for(Iter f2=f; f2!=e; ++f2,++i){ + WPoint const& wp = *f2; + Point const& p = pdw(wp); + b(i) = m(i,i) = sdo(p) - pw(wp); + j=0; + for(Iter f3=f; f3!=e; ++f3,++j){ + // FIXME: scalar product of points ??? + m(j,i) = m(i,j) = sp(p,pdw(*f3)); + } + } + for(i=1;i struct Power_side_of_bounded_power_circumsphere : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Power_side_of_bounded_power_circumsphere) + typedef typename Get_type::type result_type; + + template + result_type operator()(Iter f, Iter const& e, P const& p0) const { + // TODO: Special case when the dimension is full. + typename Get_functor::type pc(this->kernel()); + typename Get_functor::type pd(this->kernel()); + + // ON_UNBOUNDED_SIDE = -1 + return enum_cast(-CGAL::sign(pd(pc(f, e), p0))); + } +}; + } CGAL_KD_DEFAULT_TYPE(Weighted_point_tag,(CGAL::KerD::Weighted_point),(Point_tag),()); CGAL_KD_DEFAULT_FUNCTOR(Construct_ttag,(CartesianDKernelFunctors::Construct_weighted_point),(Weighted_point_tag,Point_tag),()); @@ -202,5 +280,6 @@ CGAL_KD_DEFAULT_FUNCTOR(In_flat_power_side_of_power_sphere_tag,(CartesianDKernel CGAL_KD_DEFAULT_FUNCTOR(Power_distance_tag,(CartesianDKernelFunctors::Power_distance),(Weighted_point_tag,Point_tag),(Squared_distance_tag,Point_drop_weight_tag,Point_weight_tag)); CGAL_KD_DEFAULT_FUNCTOR(Power_distance_to_point_tag,(CartesianDKernelFunctors::Power_distance_to_point),(Weighted_point_tag,Point_tag),(Squared_distance_tag,Point_drop_weight_tag,Point_weight_tag)); CGAL_KD_DEFAULT_FUNCTOR(Power_center_tag,(CartesianDKernelFunctors::Power_center),(Weighted_point_tag,Point_tag),(Compute_point_cartesian_coordinate_tag,Construct_ttag,Construct_ttag,Point_dimension_tag,Squared_distance_to_origin_tag,Point_drop_weight_tag,Point_weight_tag,Power_distance_to_point_tag)); +CGAL_KD_DEFAULT_FUNCTOR(Power_side_of_bounded_power_circumsphere_tag,(CartesianDKernelFunctors::Power_side_of_bounded_power_circumsphere),(Weighted_point_tag),(Power_distance_tag,Power_center_tag)); } // namespace CGAL #endif diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index bede1fa2fa3..8cfabbb5518 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -665,11 +665,13 @@ template struct Construct_circumcenter : Store_kernel { Vec b(k); Vec l(k); int j,i=0; + // We are doing a quadratic number of *f, which can be costly with transforming_iterator. for(Iter f2=f;f2!=e;++f2,++i){ - b(i)=m(i,i)=sdo(*f2); + Point const& p2=*f2; + b(i)=m(i,i)=sdo(p2); j=0; for(Iter f3=f;f3!=e;++f3,++j){ - m(j,i)=m(i,j)=sp(*f2,*f3); + m(j,i)=m(i,j)=sp(p2,*f3); } } for(i=1;i2.5); assert(pw(xw)<2.95); assert(pw(xw)>2.5); - + assert(psbps(tw+0,tw+3,cwp(cp(5,0),1.499)) == CGAL::ON_UNBOUNDED_SIDE); + assert(psbps(tw+0,tw+3,cwp(cp(5,0),1.500)) == CGAL::ON_BOUNDARY); + assert(psbps(tw+0,tw+3,cwp(cp(5,0),1.501)) == CGAL::ON_BOUNDED_SIDE); + WP tw2[]={cwp(cp(-3,2),1),cwp(cp(5,2),2),cwp(cp(1,6),1)}; + assert(psbps(tw2+0,tw2+2,tw2[2]) == CGAL::ON_UNBOUNDED_SIDE); + assert(abs(csrsos(tw2+0,tw2+2)-14.5039)<.0001); + assert(abs(csrsos(tw2+0,tw2+1)+1)<.0001); P tl=cp(2,5); P br=cp(4,-1); diff --git a/Number_types/include/CGAL/Interval_nt.h b/Number_types/include/CGAL/Interval_nt.h index fe8bc784310..a312ea72aa6 100644 --- a/Number_types/include/CGAL/Interval_nt.h +++ b/Number_types/include/CGAL/Interval_nt.h @@ -530,9 +530,9 @@ private: #endif Internal_protector P; #ifdef CGAL_USE_SSE2 -# if 1 +# if !defined __SSE4_1__ && !defined __AVX__ // Brutal, compute all products in all directions. - // The actual winner (by a hair) on recent hardware + // The actual winner (by a hair) on recent hardware before removing NaNs. __m128d aa = IA_opacify128_weak(a.simd()); // {-ai,as} __m128d bb = b.simd(); // {-bi,bs} __m128d m = _mm_set_sd(-0.); // {-0,+0} @@ -542,21 +542,34 @@ private: __m128d bz = _mm_xor_pd(bb, m); // {bi,bs} bz = IA_opacify128(bz); __m128d c = swap_m128d (bz); // {bs,bi} + + // The multiplications could produce some NaN, with 0 * inf. Replacing it with inf is safe. + // min(x,y) (the order is essential) returns its second argument when the first is NaN. + // An IEEE 754-2019 maximum could help. + __m128d big = IA::largest().simd(); __m128d x1 = _mm_mul_pd(aa,bz); // {-ai*bi,as*bs} + //x1 = _mm_min_pd(x1,big); // no NaN __m128d x2 = _mm_mul_pd(aa,c); // {-ai*bs,as*bi} + x2 = _mm_min_pd(x2,big); // no NaN __m128d x3 = _mm_mul_pd(ap,bz); // {-as*bi,ai*bs} + //x3 = _mm_min_pd(x3,big); // no NaN __m128d x4 = _mm_mul_pd(ap,c); // {-as*bs,ai*bi} + x4 = _mm_min_pd(x4,big); // no NaN + __m128d y1 = _mm_max_pd(x1,x2); __m128d y2 = _mm_max_pd(x3,x4); __m128d r = _mm_max_pd (y1, y2); + // Alternative with fewer instructions but more dependency + // __m128d r = _mm_max_pd(x1,_mm_max_pd(x2,_mm_max_pd(x3,_mm_min_pd(x4,big)))); return IA (IA_opacify128(r)); -# elif 0 +# elif 1 // we want to multiply ai,as with {ai<0?-bs:-bi,as<0?bi:bs} // we want to multiply as,ai with {as<0?-bs:-bi,ai<0?bi:bs} // requires SSE4 (otherwise use _mm_cmplt_pd, _mm_and_pd, _mm_andnot_pd and _mm_or_pd to avoid blendv) // probably faster on older hardware __m128d m = _mm_set_sd(-0.); // {-0,+0} __m128d m1 = _mm_set1_pd(-0.); // {-0,-0} + __m128d big = IA::largest().simd(); __m128d aa = a.simd(); // {-ai,as} __m128d az = _mm_xor_pd(aa, m); // {ai,as} az = IA_opacify128_weak(az); @@ -567,7 +580,9 @@ private: __m128d x = _mm_blendv_pd (bb, bp, az); // {ai<0?-bs:-bi,as<0?bi:bs} __m128d y = _mm_blendv_pd (bb, bp, azp); // {as<0?-bs:-bi,ai<0?bi:bs} __m128d p1 = _mm_mul_pd (az, x); + //p1 = _mm_min_pd(p1,big); // no NaN __m128d p2 = _mm_mul_pd (azp, y); + p2 = _mm_min_pd(p2,big); // no NaN __m128d r = _mm_max_pd (p1, p2); return IA (IA_opacify128(r)); # elif 0 @@ -575,6 +590,7 @@ private: // we want to multiply -as,ai with {as<0?bs:bi,ai>0?bs:bi} // slightly worse than the previous one __m128d m1 = _mm_set1_pd(-0.); // {-0,-0} + __m128d big = IA::largest().simd(); __m128d aa = IA_opacify128_weak(a.simd()); // {-ai,as} __m128d ax = swap_m128d (aa); // {as,-ai} __m128d ap = _mm_xor_pd (ax, m1); // {-as,ai} @@ -586,13 +602,16 @@ private: __m128d x = _mm_blendv_pd (bbs, bbi, aa); // {ai>0?bi:bs,as<0?bi:bs} __m128d y = _mm_blendv_pd (bbi, bbs, ax); // {as<0?bs:bi,ai>0?bs:bi} __m128d p1 = _mm_mul_pd (aa, x); + //p1 = _mm_min_pd(p1,big); // no NaN __m128d p2 = _mm_mul_pd (ap, y); + p2 = _mm_min_pd(p2,big); // no NaN __m128d r = _mm_max_pd (p1, p2); return IA (IA_opacify128(r)); # else // AVX version of the brutal method, same running time or slower __m128d aa = IA_opacify128_weak(a.simd()); // {-ai,as} __m128d bb = b.simd(); // {-bi,bs} + __m256d big = _mm256_set1_pd(std::numeric_limits::infinity()); __m128d m = _mm_set_sd(-0.); // {-0,+0} __m128d m1 = _mm_set1_pd(-0.); // {-0,-0} __m128d ax = swap_m128d (aa); // {as,-ai} @@ -603,7 +622,9 @@ private: __m256d Y1 = _mm256_set_m128d(bz,bz); // {bi,bs,bi,bs} __m256d Y2 = _mm256_permute_pd(Y1,5); // {bs,bi,bs,bi} __m256d Z1 = _mm256_mul_pd(X,Y1); + //Z1 = _mm256_min_pd(Z1,big); // no NaN __m256d Z2 = _mm256_mul_pd(X,Y2); + Z2 = _mm256_min_pd(Z2,big); // no NaN __m256d Z = _mm256_max_pd(Z1,Z2); __m128d z1 = _mm256_castpd256_pd128(Z); __m128d z2 = _mm256_extractf128_pd(Z,1); @@ -611,19 +632,22 @@ private: return IA (IA_opacify128(r)); # endif #else + // TODO: try to move some NaN tests out of the hot path (test a.inf()>0 instead of >=0?). if (a.inf() >= 0.0) // a>=0 { // b>=0 [a.inf()*b.inf(); a.sup()*b.sup()] // b<=0 [a.sup()*b.inf(); a.inf()*b.sup()] // b~=0 [a.sup()*b.inf(); a.sup()*b.sup()] double aa = a.inf(), bb = a.sup(); + if (bb <= 0.) return 0.; // In case b has an infinite bound, avoid NaN. if (b.inf() < 0.0) { aa = bb; if (b.sup() < 0.0) bb = a.inf(); } - return IA(-CGAL_IA_MUL(aa, -b.inf()), CGAL_IA_MUL(bb, b.sup())); + double r = (b.sup() == 0) ? 0. : CGAL_IA_MUL(bb, b.sup()); // In case bb is infinite, avoid NaN. + return IA(-CGAL_IA_MUL(aa, -b.inf()), r); } else if (a.sup()<=0.0) // a<=0 { @@ -634,19 +658,25 @@ private: if (b.inf() < 0.0) { aa=bb; - if (b.sup() < 0.0) + if (b.sup() <= 0.0) bb=a.sup(); } + else if (b.sup() <= 0) return 0.; // In case a has an infinite bound, avoid NaN. return IA(-CGAL_IA_MUL(-bb, b.sup()), CGAL_IA_MUL(-aa, -b.inf())); } else // 0 \in a { - if (b.inf()>=0.0) // b>=0 - return IA(-CGAL_IA_MUL(-a.inf(), b.sup()), - CGAL_IA_MUL( a.sup(), b.sup())); - if (b.sup()<=0.0) // b<=0 + if (b.inf()>=0.0) { // b>=0 + if (b.sup()<=0.0) + return 0.; // In case a has an infinite bound, avoid NaN. + else + return IA(-CGAL_IA_MUL(-a.inf(), b.sup()), + CGAL_IA_MUL( a.sup(), b.sup())); + } + if (b.sup()<=0.0) { // b<=0 return IA(-CGAL_IA_MUL( a.sup(), -b.inf()), CGAL_IA_MUL(-a.inf(), -b.inf())); + } // 0 \in b double tmp1 = CGAL_IA_MUL(-a.inf(), b.sup()); double tmp2 = CGAL_IA_MUL( a.sup(), -b.inf()); @@ -661,6 +691,7 @@ private: Interval_nt operator* (double a, Interval_nt b) { + CGAL_assertion(is_finite(a)); // return Interval_nt(a)*b; Internal_protector P; if (a < 0) { a = -a; b = -b; } @@ -670,8 +701,12 @@ private: __m128d bb = IA_opacify128_weak(b.simd()); __m128d aa = _mm_set1_pd(IA_opacify(a)); __m128d r = _mm_mul_pd(aa, bb); + // In case a is 0 and b has an infinite bound. This returns an interval + // larger than necessary, but is likely faster to produce. + r = _mm_min_pd(r,largest().simd()); return IA(IA_opacify128(r)); #else + else if (!(a > 0)) return 0.; // We could test this before the SSE block and remove the minpd line. return IA(-CGAL_IA_MUL(a, -b.inf()), CGAL_IA_MUL(a, b.sup())); #endif } diff --git a/Number_types/include/CGAL/Mpzf.h b/Number_types/include/CGAL/Mpzf.h index 360e31d7034..031e242ca90 100644 --- a/Number_types/include/CGAL/Mpzf.h +++ b/Number_types/include/CGAL/Mpzf.h @@ -655,7 +655,7 @@ struct Mpzf { rdata=Mpzf_impl::fill_n_ptr(rdata,xexp-absysize,-1); mpn_sub_1(rdata, xdata, absxsize, 1); res.size=absxsize+xexp; - if(res.data()[res.size-1]==0) --res.size; + while(/*res.size>0&&*/res.data()[res.size-1]==0) --res.size; if(xsize<0) res.size=-res.size; return res; } else { diff --git a/Number_types/test/Number_types/Interval_nt_new.cpp b/Number_types/test/Number_types/Interval_nt_new.cpp index eee594ce126..95d4f5521fe 100644 --- a/Number_types/test/Number_types/Interval_nt_new.cpp +++ b/Number_types/test/Number_types/Interval_nt_new.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #define CGAL_catch_error(expr, error) \ { \ @@ -159,6 +160,42 @@ int main() { CGAL_catch_error((bool)(I>=J),CGAL::Uncertain_conversion_exception&); CGAL_catch_error((bool)(I<=J),CGAL::Uncertain_conversion_exception&); } + { // Multiplication + const double inf = std::numeric_limits::infinity(); + Interval all = Interval::largest(); + Interval zero = 0; + Interval a(0,1); + Interval b(1,inf); + Interval c(-1,inf); + Interval d(0,inf); + // For CGAL's purposes, [0,0]*anything is 0, but we tolerate larger intervals if they can be produced faster. + for (Interval I : { all*zero, zero*all, all*0., 0.*all, b*zero, zero*b, -b*zero, zero*-b, c*zero, zero*c, -c*zero, zero*-c }) + { + //std::cout << I << '\n'; + assert(I.inf()<=0 && I.sup()>=0); + } + // This should be [0,inf], but again we tolerate more. + for (Interval I : { a*b, b*a, -a*-b, -b*-a, d*d, -d*-d }) + { + //std::cout << I << '\n'; + assert(I.inf()<=0 && I.sup()==inf); + } + for (Interval I : { -a*b, -b*a, a*-b, b*-a, -d*d, d*-d }) + { + //std::cout << I << '\n'; + assert(I.inf()==-inf && I.sup()>=0); + } + for (Interval I : { all*a, a*all, all*-a, -a*all }) + { + //std::cout << I << '\n'; + assert(I.inf()==-inf && I.sup()==inf); + } + for (Interval I : { all*d, d*all, all*-d, -d*all }) + { + //std::cout << I << '\n'; + assert(I.inf()==-inf && I.sup()==inf); + } + } {// external functions on Intervals // functions (abs, square, sqrt, pow) {//abs diff --git a/Optimal_transportation_reconstruction_2/package_info/Optimal_transportation_reconstruction_2/dependencies b/Optimal_transportation_reconstruction_2/package_info/Optimal_transportation_reconstruction_2/dependencies index 9b809650984..7fb921a03fa 100644 --- a/Optimal_transportation_reconstruction_2/package_info/Optimal_transportation_reconstruction_2/dependencies +++ b/Optimal_transportation_reconstruction_2/package_info/Optimal_transportation_reconstruction_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Circulator Distance_2 +Distance_3 Filtered_kernel Hash_map Installation @@ -20,4 +21,3 @@ Spatial_sorting Stream_support TDS_2 Triangulation_2 -Distance_3 diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/draw_periodic_2_triangulation_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/draw_periodic_2_triangulation_2.h new file mode 100644 index 00000000000..6365c1c51c8 --- /dev/null +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/draw_periodic_2_triangulation_2.h @@ -0,0 +1,15 @@ +namespace CGAL { + +/*! +\ingroup PkgDrawPeriodic2Triangulation2 + +opens a new window and draws `ap2t2`, the `Periodic_2_Triangulation_2`. A call to this function is blocking, that is the program continues as soon as the user closes the window. + This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time. +\tparam P2T2 a model of the `Periodic_2TriangulationTraits_2` concept. +\param ap2t2 the 2D periodic trinagulation to draw. + +*/ +template +void draw(const P2T2& ap2t2); + +} /* namespace CGAL */ diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/PackageDescription.txt b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/PackageDescription.txt index 91e32e18995..4f3a46a85b1 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/PackageDescription.txt +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/PackageDescription.txt @@ -15,6 +15,14 @@ /// \defgroup PkgPeriodic2Triangulation2Enums Enums /// \ingroup PkgPeriodic2Triangulation2Ref +/*! Draw. + \code + #include + \endcode +*/ +/// \defgroup PkgDrawPeriodic2Triangulation2 Draw a 2D Periodic Triangulation +/// \ingroup PkgPeriodic2Triangulation2Ref + /*! \addtogroup PkgPeriodic2Triangulation2Ref @@ -103,5 +111,8 @@ of the concept `Periodic_2Offset_2`. - `CGAL::Periodic_2_triangulation_2::Iterator_type` - `CGAL::Periodic_2_triangulation_2::Locate_type` +\cgalCRPSection{Draw 2D Periodic Triangulation} + - \link PkgDrawPeriodic2Triangulation2 CGAL::draw() \endlink + */ diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Periodic_2_triangulation_2.txt b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Periodic_2_triangulation_2.txt index ac02381048b..26a3cce21d1 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Periodic_2_triangulation_2.txt +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Periodic_2_triangulation_2.txt @@ -394,6 +394,26 @@ in the unit rectangle. The tests were done on an Intel i7 @ 2.67GHz. \image html p2dt2_performance.png \image latex p2dt2_performance.png +\section P2T2_Draw_Periodic_Triangulation Draw a 2D Periodic Triangulation + +A 2D periodic triangulation can be visualized by calling the \link PkgDrawPeriodic2Triangulation2 CGAL::draw() \endlink function as shown in the following example. This function opens a new window showing the given Periodic Triangulation. Elements of the periodic triangulation can be viewed in four different modes: + +\cgalExample{Periodic_2_triangulation_2/draw_periodic_2_triangulation_2.cpp} + +- STORED Display all geometric primitives as they are stored in Triangulation_data_structure_2; +- UNIQUE Display only one representative of each geometric primitive even if the triangulation is computed in multiply sheeted covering space; +- STORED_COVER_DOMAIN Same as STORED but also display all primitives whose intersection with the original domain of the current covering space is non-empty; +- UNIQUE_COVER_DOMAIN Same as UNIQUE but also display all primitives whose intersection with the original domain of the current covering space is non-empty. + +The domain can also be visualized by a key press. To see how to visualize the Periodic Triangulation in various modes, press key H when the viewer window is active and go to Keyboard tab. See \cgalFigureRef{P2Triangulation2figdraw1} and \cgalFigureRef{P2Triangulation2figdraw2}. + +\cgalFigureBegin{P2Triangulation2figdraw1, unique.png, unique-cover.png} +Result of the run of the draw_periodic_2_triangulation_2 program for display modes Unique(left) and Unique Cover Domain(right). The window allows to navigate through the 2D scene. +\cgalFigureEnd +\cgalFigureBegin{P2Triangulation2figdraw2, stored.png, stored-cover.png} +Result of the run of the draw_periodic_2_triangulation_2 program for display modes Stored(left) and Stored Cover Domain(right). +\cgalFigureEnd + \section P2T2_Design Design and Implementation History The periodic 2D-triangulation is based on the 2D triangulation package diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/dependencies b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/dependencies index 32fa6fbdf73..b0b47131d59 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/dependencies +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/dependencies @@ -7,3 +7,4 @@ Stream_support TDS_2 Triangulation_2 Spatial_sorting +GraphicsView diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/examples.txt b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/examples.txt index 9be1a7e1709..37a43d200ff 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/examples.txt +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/examples.txt @@ -9,4 +9,5 @@ \example Periodic_2_triangulation_2/p2t2_info_insert_with_transform_iterator_2.cpp \example Periodic_2_triangulation_2/p2t2_info_insert_with_zip_iterator_2.cpp \example Periodic_2_triangulation_2/p2t2_large_point_set.cpp +\example Periodic_2_triangulation_2/draw_periodic_2_triangulation_2.cpp */ diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/fig/stored-cover.png b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/fig/stored-cover.png new file mode 100644 index 00000000000..ead02c3044c Binary files /dev/null and b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/fig/stored-cover.png differ diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/fig/stored.png b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/fig/stored.png new file mode 100644 index 00000000000..cc14f2a0de1 Binary files /dev/null and b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/fig/stored.png differ diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/fig/unique-cover.png b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/fig/unique-cover.png new file mode 100644 index 00000000000..77fddcc5c6a Binary files /dev/null and b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/fig/unique-cover.png differ diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/fig/unique.png b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/fig/unique.png new file mode 100644 index 00000000000..66008914fe5 Binary files /dev/null and b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/fig/unique.png differ diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/CMakeLists.txt b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/CMakeLists.txt index 71e272f464c..849f222a5df 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/CMakeLists.txt +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/CMakeLists.txt @@ -6,7 +6,11 @@ cmake_minimum_required(VERSION 3.1...3.15) project( Periodic_2_triangulation_2_Examples ) -find_package(CGAL QUIET) +find_package(CGAL COMPONENTS Qt5) + +if(CGAL_Qt5_FOUND) + add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS) +endif() if ( CGAL_FOUND ) @@ -16,6 +20,9 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "${cppfile}" ) endforeach() + if(CGAL_Qt5_FOUND) + target_link_libraries(draw_periodic_2_triangulation_2 PUBLIC CGAL::CGAL_Qt5) + endif() else() message(STATUS "This program requires the CGAL library, and will not be compiled.") diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/data/data1.dt.cin b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/data/data1.dt.cin new file mode 100644 index 00000000000..30765637fa5 --- /dev/null +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/data/data1.dt.cin @@ -0,0 +1,20 @@ +0.192592592592593 0.037037037037037 +0.17037037037037 0.177777777777778 +0.451851851851852 0.111111111111111 +0.274074074074074 0.37037037037037 +0.133333333333333 0.592592592592593 +0.037037037037037 0.688888888888889 +0.177777777777778 0.844444444444444 +0.288888888888889 0.674074074074074 +0.318518518518519 0.925925925925926 +0.540740740740741 0.844444444444444 +0.637037037037037 0.703703703703704 +0.511111111111111 0.496296296296296 +0.725925925925926 0.237037037037037 +0.933333333333333 0.22962962962963 +0.733333333333333 0.511111111111111 +0.925925925925926 0.459259259259259 +0.866666666666667 0.777777777777778 +0.77037037037037 0.925925925925926 +0.881481481481482 0.977777777777778 +0.990000000000000 0.911111111111111 diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/draw_periodic_2_triangulation_2.cpp b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/draw_periodic_2_triangulation_2.cpp new file mode 100644 index 00000000000..28a49c76731 --- /dev/null +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/draw_periodic_2_triangulation_2.cpp @@ -0,0 +1,36 @@ +#include +#include +#include +#include + +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Periodic_2_Delaunay_triangulation_traits_2 GT; +typedef CGAL::Periodic_2_Delaunay_triangulation_2 PDT; + +typedef PDT::Point Point; + +int main(int argc, char* argv[]) +{ + // Declare periodic triangulation 2D + PDT T; + + // Read points and insert in T + Point p; + std::ifstream ifs((argc > 1) ? argv[1] : "data/data1.dt.cin"); + if (ifs) + { + while (ifs >> p) + { T.insert(p); } + CGAL_assertion(T.is_valid()); + + if( T.is_triangulation_in_1_sheet()) + { T.convert_to_9_sheeted_covering(); } + + // Draw the periodic triangulation + CGAL::draw(T); + } + + return EXIT_SUCCESS; +} diff --git a/Periodic_2_triangulation_2/include/CGAL/draw_periodic_2_triangulation_2.h b/Periodic_2_triangulation_2/include/CGAL/draw_periodic_2_triangulation_2.h new file mode 100644 index 00000000000..42970bfa8e9 --- /dev/null +++ b/Periodic_2_triangulation_2/include/CGAL/draw_periodic_2_triangulation_2.h @@ -0,0 +1,279 @@ +// Copyright (c) 2019 INRIA Sophia-Antipolis (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) : Jasmeet Singh + +#ifndef DRAW_PERIODIC_2_TRIANGULATION_2_H +#define DRAW_PERIODIC_2_TRIANGULATION_2_H + +#include +#include + +#ifdef CGAL_USE_BASIC_VIEWER + +#include +#include + +namespace CGAL { + +// Default color functor; user can change it to have its own face color +struct DefaultColorFunctorP2T2 { + template + static CGAL::Color run(const P2T2 &, + const typename P2T2::Periodic_triangle_iterator /*ti*/) { + //CGAL::Random random((unsigned int)(std::size_t)(&*ti)); + //return get_random_color(random); + return CGAL::Color(73, 250, 117); + } +}; + +// Viewer class for P2T2 +template +class SimplePeriodic2Triangulation2ViewerQt : public Basic_viewer_qt +{ + typedef Basic_viewer_qt Base; + + typedef typename P2T2::Iterator_type Iterator_type; + + // Vertex iterators + typedef typename P2T2::Periodic_point_iterator Periodic_point_iterator; + + // Edge iterators + typedef typename P2T2::Periodic_segment_iterator Periodic_segment_iterator; + typedef typename P2T2::Segment Segment; + + // Face iterators + typedef typename P2T2::Periodic_triangle_iterator Periodic_triangle_iterator; + typedef typename P2T2::Triangle Triangle; + + typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; + +public: + /// Construct the viewer. + /// @param ap2t2 the p2t2 to view + /// @param title the title of the window + /// @param anofaces if true, do not draw faces (faces are not computed; this can be + /// usefull for very big object where this time could be long) + SimplePeriodic2Triangulation2ViewerQt(QWidget* parent, const P2T2& ap2t2, + const char* title="Basic P2T2 Viewer", + bool anofaces=false, + const ColorFunctor& fcolor=ColorFunctor()) : + // First draw: vertices; edges, faces; multi-color; no inverse normal + Base(parent, title, true, true, true, false, false), + p2t2(ap2t2), + m_nofaces(anofaces), + m_fcolor(fcolor), + m_display_type(STORED_COVER_DOMAIN), + m_domain(true) + { + // Add custom key description (see keyPressEvent). + setKeyDescription(::Qt::Key_1, "STORED: Display all geometric primitives as they are stored in " + "Triangulation_data_structure_2"); + setKeyDescription(::Qt::Key_2, "UNIQUE: Display only one representative of each geometric primitive even " + "if the triangulation is computed in multiply sheeted covering space."); + setKeyDescription(::Qt::Key_3, "STORED_COVER_DOMAIN: Same as STORED but also display " + "all primitives whose intersection with the original " + "domain of the current covering space is non-empty"); + setKeyDescription(::Qt::Key_4, "UNIQUE_COVER_DOMAIN: Same as UNIQUE but also display " + "all primitives whose intersection with the original " + "domain of the current covering space is non-empty"); + setKeyDescription(::Qt::Key_D, "Toggle 9-sheeted domain display"); + + compute_elements(); + } +protected: + void compute_vertex(Periodic_point_iterator pi) + { + // Construct the point in 9-sheeted covering space and add to viewer + add_point(p2t2.point(*pi)); + } + + void compute_edge(Periodic_segment_iterator si) + { + // Construct the segment in 9-sheeted covering space and add to viewer + Segment s(p2t2.segment(*si)); + add_segment(s[0], s[1]); + } + + void compute_face(Periodic_triangle_iterator ti) + { + // Construct the triangle in 9-sheeted covering space and add to viewer + Triangle t(p2t2.triangle(*ti)); + + CGAL::Color c=m_fcolor.run(p2t2, ti); + face_begin(c); + add_point_in_face(t[0]); + add_point_in_face(t[1]); + add_point_in_face(t[2]); + face_end(); + + // Display the edges of the faces as segments with a + // light gray color for better visualization + add_segment(t[0], t[1], CGAL::Color(207, 213, 211)); + add_segment(t[1], t[2], CGAL::Color(207, 213, 211)); + add_segment(t[2], t[0], CGAL::Color(207, 213, 211)); + } + + void compute_domain() + { + Kernel::Iso_rectangle_2 orig_domain = p2t2.domain(); + std::array covering_sheets = p2t2.number_of_sheets(); + + for(int i = 0; i < covering_sheets[0]; i++){ + for(int j = 0; j < covering_sheets[1]; j++){ + Kernel::Vector_2 shift(i * (orig_domain.xmax() - orig_domain.xmin()), + j * orig_domain.ymax() - orig_domain.ymin()); + Kernel::Point_2 p1(orig_domain.min()); + Kernel::Point_2 p2(orig_domain.xmin(), orig_domain.ymax()); + Kernel::Point_2 p3(orig_domain.xmax(), orig_domain.ymin()); + Kernel::Point_2 p4(orig_domain.max()); + + add_segment(p1 + shift, p2 + shift, CGAL::Color(96, 104, 252)); + add_segment(p1 + shift, p3 + shift, CGAL::Color(96, 104, 252)); + add_segment(p2 + shift, p4 + shift, CGAL::Color(96, 104, 252)); + add_segment(p3 + shift, p4 + shift, CGAL::Color(96, 104, 252)); + } + } + } + + void compute_elements() { + // Clear the buffers + clear(); + + // Get the display type, iterate through periodic elements according + // to the display type + Iterator_type it_type = (Iterator_type)m_display_type; + + // Iterate through vertices, edges and faces, add elements to buffer + for (Periodic_point_iterator it = + p2t2.periodic_points_begin(it_type); + it != p2t2.periodic_points_end(it_type); it++) + { + compute_vertex(it); + } + + for (Periodic_segment_iterator it = + p2t2.periodic_segments_begin(it_type); + it != p2t2.periodic_segments_end(it_type); it++) + { + compute_edge(it); + } + + for (Periodic_triangle_iterator it = + p2t2.periodic_triangles_begin(it_type); + it != p2t2.periodic_triangles_end(it_type); it++) + { + compute_face(it); + } + + if(m_domain){ + // Compute the (9-sheet covering space) domain of the periodic triangulation + compute_domain(); + } + } + + virtual void keyPressEvent(QKeyEvent *e) + { + // Test key pressed: + // const ::Qt::KeyboardModifiers modifiers = e->modifiers(); + // if ((e->key()==Qt::Key_PageUp) && (modifiers==Qt::NoButton)) { ... } + + // Call: * compute_elements() if the model changed, followed by + // * redraw() if some viewing parameters changed that implies some + // modifications of the buffers + // (eg. type of normal, color/mono) + // * update() just to update the drawing + + // Call the base method to process others/classicals key + const ::Qt::KeyboardModifiers modifiers = e->modifiers(); + if (e->text()=="1") + { + m_display_type = Display_type::UNIQUE; + displayMessage(QString("Display type= UNIQUE")); + compute_elements(); + redraw(); + } else if (e->text()=="2") + { + m_display_type = Display_type::UNIQUE_COVER_DOMAIN; + displayMessage(QString("Display type= UNIQUE_COVER_DOMAIN")); + compute_elements(); + redraw(); + } else if (e->text()=="3") + { + m_display_type = Display_type::STORED; + displayMessage(QString("Display type= STORED")); + compute_elements(); + redraw(); + } else if (e->text()=="4") + { + m_display_type = Display_type::STORED_COVER_DOMAIN; + displayMessage(QString("Display type= STORED_COVER_DOMAIN")); + compute_elements(); + redraw(); + } else if ((e->key() == ::Qt::Key_D) && (modifiers == ::Qt::NoButton)) + { + m_domain=!m_domain; + displayMessage(QString("Draw domain=%1.").arg(m_domain?"true":"false")); + compute_elements(); + redraw(); + } else { + Base::keyPressEvent(e); + } + } + +protected: + const P2T2& p2t2; + bool m_nofaces; + const ColorFunctor& m_fcolor; + enum Display_type + { + STORED = 0, + UNIQUE, // 1 + STORED_COVER_DOMAIN, // 2 + UNIQUE_COVER_DOMAIN // 3 + }; + Display_type m_display_type; + bool m_domain; +}; + +// Specialization of draw function +#define CGAL_P2T2_TYPE CGAL::Periodic_2_triangulation_2 \ + + +template < class Gt, + class Tds > +void draw(const CGAL_P2T2_TYPE& ap2t2, + const char* title = "2D Periodic Triangulation Viewer", + bool nofill = false) +{ +#if defined(CGAL_TEST_SUITE) + bool cgal_test_suite=true; +#else + bool cgal_test_suite=qEnvironmentVariableIsSet("CGAL_TEST_SUITE"); +#endif + + if (!cgal_test_suite) + { + int argc=1; + const char* argv[2]={"p2t2_viewer","\0"}; + QApplication app(argc,const_cast(argv)); + DefaultColorFunctorP2T2 fcolor; + SimplePeriodic2Triangulation2ViewerQt + mainwindow(app.activeWindow(), ap2t2, title, nofill, fcolor); + mainwindow.show(); + app.exec(); + } +} + +} // namespace CGAL + +#endif // CGAL_USE_BASIC_VIEWER + +#endif // DRAW_PERIODIC_2_TRIANGULATION_2_H diff --git a/Periodic_2_triangulation_2/package_info/Periodic_2_triangulation_2/dependencies b/Periodic_2_triangulation_2/package_info/Periodic_2_triangulation_2/dependencies index 9ee86e3775d..a78447643d8 100644 --- a/Periodic_2_triangulation_2/package_info/Periodic_2_triangulation_2/dependencies +++ b/Periodic_2_triangulation_2/package_info/Periodic_2_triangulation_2/dependencies @@ -4,6 +4,7 @@ Circulator Distance_2 Distance_3 Filtered_kernel +GraphicsView Hash_map Installation Intersections_2 diff --git a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h index ad881bb4017..e27c762ed34 100644 --- a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h +++ b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h @@ -40,13 +40,12 @@ #include #include -#include -#include #include #include #include #include #include +#include #include diff --git a/Periodic_3_mesh_3/include/CGAL/refine_periodic_3_mesh_3.h b/Periodic_3_mesh_3/include/CGAL/refine_periodic_3_mesh_3.h index 9c50a2691c0..acb3b35decd 100644 --- a/Periodic_3_mesh_3/include/CGAL/refine_periodic_3_mesh_3.h +++ b/Periodic_3_mesh_3/include/CGAL/refine_periodic_3_mesh_3.h @@ -24,8 +24,7 @@ #include #include #include - -#include +#include #include #include diff --git a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/icons/license.txt b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/icons/license.txt index 2cf4f5398aa..f2819459410 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/icons/license.txt +++ b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/icons/license.txt @@ -1,2 +1,4 @@ The following file has been copied from Qt Free Edition version 4.4: fileOpen.png + +This Qt version was released under GPL-2 and GPL-3. diff --git a/Point_set_3/examples/Point_set_3/point_set_algo.cpp b/Point_set_3/examples/Point_set_3/point_set_algo.cpp index 80e42dcef6d..f87a4b3e4ef 100644 --- a/Point_set_3/examples/Point_set_3/point_set_algo.cpp +++ b/Point_set_3/examples/Point_set_3/point_set_algo.cpp @@ -70,7 +70,7 @@ int main (int, char**) parameters.normal_threshold = 0.9; ransac.detect(parameters); - BOOST_FOREACH(boost::shared_ptr shape, ransac.shapes()) + for(boost::shared_ptr shape : ransac.shapes()) if (Sphere* sphere = dynamic_cast(shape.get())) std::cerr << "Detected sphere of center " << sphere->center() // Center should be approx 0, 0, 0 << " and of radius " << sphere->radius() << std::endl; // Radius should be approx 1 diff --git a/Point_set_3/examples/Point_set_3/point_set_read_ply.cpp b/Point_set_3/examples/Point_set_3/point_set_read_ply.cpp index b115781847f..7bfc1cb45e0 100644 --- a/Point_set_3/examples/Point_set_3/point_set_read_ply.cpp +++ b/Point_set_3/examples/Point_set_3/point_set_read_ply.cpp @@ -14,14 +14,15 @@ typedef CGAL::Point_set_3 Point_set; int main (int argc, char** argv) { - std::ifstream f (argc > 1 ? argv[1] : "data/example.ply"); + std::ifstream f (argc > 1 ? argv[1] : "data/example.ply", + std::ios_base::binary); // Mandatory on Windows if input is binary PLY Point_set point_set; - if (!f || !CGAL::read_ply_point_set (f, point_set)) - { - std::cerr << "Can't read input file " << std::endl; - } + if (!f || !CGAL::read_ply_point_set (f, point_set)) // same as `f >> point_set` + { + std::cerr << "Can't read input file " << std::endl; + } // Shows which properties are defined std::vector properties = point_set.properties(); @@ -41,9 +42,19 @@ int main (int argc, char** argv) std::cerr << " * " << label_prop[*it] << std::endl; } - std::ofstream out ("out.ply"); - out.precision(17); - CGAL::write_ply_point_set (out, point_set); + if (argc > 2 && strcmp (argv[2], "-b") == 0) // Optional binary output + { + std::ofstream out ("out.ply", + std::ios_base::binary); // Mandatory on Windows + CGAL::set_binary_mode (out); // Select binary mode (ASCII is default) + out << point_set; // same as `CGAL::write_ply_point_set (out, point_set)` + } + else // ASCII output + { + std::ofstream out ("out.ply"); + out.precision(17); // Use sufficient precision in ASCII + CGAL::write_ply_point_set (out, point_set); // same as `out << point_set` + } return 0; } diff --git a/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/Search_traits_vertex_handle_3.h b/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/Search_traits_vertex_handle_3.h index fd89d4c832e..e7581e8bc6d 100644 --- a/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/Search_traits_vertex_handle_3.h +++ b/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/Search_traits_vertex_handle_3.h @@ -117,8 +117,10 @@ struct Construct_cartesian_const_iterator_vertex_handle_3 template struct Euclidean_distance_vertex_handle_3 { + typedef double FT; typedef CGAL::internal::Point_vertex_handle_3 Point_vertex_handle_3; typedef Point_vertex_handle_3 Query_item; + typedef Point_vertex_handle_3 Point_d; double transformed_distance(const Point_vertex_handle_3& p1, const Point_vertex_handle_3& p2) const { double distx = p1.x()-p2.x(); diff --git a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction.cpp b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction.cpp index c451cf51205..885a70b900e 100644 --- a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction.cpp +++ b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction.cpp @@ -360,7 +360,6 @@ int main(int argc, char * argv[]) // Constructs AABB tree and computes internal KD-tree // data structure to accelerate distance queries AABB_tree tree(faces(output_mesh).first, faces(output_mesh).second, output_mesh); - tree.accelerate_distance_queries(); // Computes distance from each input point to reconstructed mesh double max_distance = DBL_MIN; diff --git a/Polygon/include/CGAL/Polygon_2.h b/Polygon/include/CGAL/Polygon_2.h index 290a6a5a6e6..e18bf7bde52 100644 --- a/Polygon/include/CGAL/Polygon_2.h +++ b/Polygon/include/CGAL/Polygon_2.h @@ -445,7 +445,7 @@ class Polygon_2 { Point_2& vertex(std::size_t i) { CGAL_precondition( i < d_container.size() ); - return *(cpp11::next(d_container.begin(), i)); + return *(std::next(d_container.begin(), i)); } /// Returns a reference to the `i`-th vertex. Point_2& operator[](std::size_t i) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 00bf800f868..d543aa198bd 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -535,6 +535,8 @@ finding the nearest point on a mesh given a point or a ray (`CGAL::Polygon_mesh_processing::locate_with_AABB_tree()`, and similar), and location-based predicates (for example, `CGAL::Polygon_mesh_processing::is_on_face_border()`). +The example \ref Polygon_mesh_processing/locate_example.cpp presents a few of these functions. + **************************************** \section PMPOrientation Orientation diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt index 4165c6bf51b..a9350578648 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt @@ -25,4 +25,5 @@ \example Polygon_mesh_processing/repair_polygon_soup_example.cpp \example Polygon_mesh_processing/mesh_smoothing_example.cpp \example Polygon_mesh_processing/shape_smoothing_example.cpp +\example Polygon_mesh_processing/locate_example.cpp */ diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index 88701b9e196..95a539040ac 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -85,6 +85,7 @@ create_single_source_cgal_program( "detect_features_example.cpp" ) create_single_source_cgal_program( "manifoldness_repair_example.cpp" ) create_single_source_cgal_program( "repair_polygon_soup_example.cpp" ) create_single_source_cgal_program( "mesh_smoothing_example.cpp") +create_single_source_cgal_program( "locate_example.cpp") if(OpenMesh_FOUND) create_single_source_cgal_program( "compute_normals_example_OM.cpp" ) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/locate_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/locate_example.cpp new file mode 100644 index 00000000000..2235be77dfd --- /dev/null +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/locate_example.cpp @@ -0,0 +1,113 @@ +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef K::FT FT; +typedef K::Point_2 Point_2; +typedef K::Ray_2 Ray_2; +typedef K::Point_3 Point_3; +typedef K::Ray_3 Ray_3; + +typedef CGAL::Surface_mesh Mesh; +typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef typename boost::graph_traits::face_descriptor face_descriptor; + +namespace CP = CGAL::parameters; +namespace PMP = CGAL::Polygon_mesh_processing; + +typedef PMP::Barycentric_coordinates Barycentric_coordinates; +typedef PMP::Face_location Face_location; + +int main(int /*argc*/, char** /*argv*/) +{ + // Generate a simple 3D triangle mesh that with vertices on the plane xOy + Mesh tm; + CGAL::make_grid(10, 10, tm); + PMP::triangulate_faces(tm); + + // Basic usage + Face_location random_location = PMP::random_location_on_mesh(tm); + const face_descriptor f = random_location.first; + const Barycentric_coordinates& coordinates = random_location.second; + + std::cout << "Random location on the mesh: face " << f + << " and with coordinates [" << coordinates[0] << "; " + << coordinates[1] << "; " + << coordinates[2] << "]\n"; + std::cout << "It corresponds to point (" << PMP::construct_point(random_location, tm) << ")\n\n"; + + // Locate a known 3D point in the mesh + const Point_3 query(1.2, 7.4, 0); + Face_location query_location = PMP::locate(query, tm); + + std::cout << "Point (" << query << ") is located in face " << query_location.first + << " with barycentric coordinates [" << query_location.second[0] << "; " + << query_location.second[1] << "; " + << query_location.second[2] << "]\n\n"; + + // Locate a 3D point in the mesh as the intersection of the mesh and a 3D ray. + // The AABB tree can be cached in case many queries are performed (otherwise, it is rebuilt + // on each call, which is expensive). + typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; + typedef CGAL::AABB_traits AABB_face_graph_traits; + + CGAL::AABB_tree tree; + PMP::build_AABB_tree(tm, tree); + + const Ray_3 ray_3(Point_3(4.2, 6.8, 2.4), Point_3(7.2, 2.3, -5.8)); + Face_location ray_location = PMP::locate_with_AABB_tree(ray_3, tree, tm); + + std::cout << "Intersection of the 3D ray and the mesh is in face " << ray_location.first + << " with barycentric coordinates [" << ray_location.second[0] << " " + << ray_location.second[1] << " " + << ray_location.second[2] << "]\n"; + std::cout << "It corresponds to point (" << PMP::construct_point(ray_location, tm) << ")\n"; + std::cout << "Is it on the face's border? " << (PMP::is_on_face_border(ray_location, tm) ? "Yes" : "No") << "\n\n"; + + // ----------------------------------------------------------------------------------------------- + // Now, we artifically project the mesh to the natural 2D dimensional plane, with a little translation + // via a custom vertex point property map + + typedef CGAL::dynamic_vertex_property_t Point_2_property; + typedef typename boost::property_map::type Projection_pmap; + Projection_pmap projection_pmap = get(Point_2_property(), tm); + + for(vertex_descriptor v : vertices(tm)) + { + const Point_3& p = tm.point(v); + put(projection_pmap, v, Point_2(p.x() + 1, p.y())); // simply ignoring the z==0 coordinate and translating along Ox + } + + // Locate the same 3D point but in a 2D context + const Point_2 query_2(query.x() + 1, query.y()); + Face_location query_location_2 = PMP::locate(query_2, tm, CP::vertex_point_map(projection_pmap)); + + std::cout << "Point (" << query_2 << ") is located in face " << query_location_2.first + << " with barycentric coordinates [" << query_location_2.second[0] << "; " + << query_location_2.second[1] << "; " + << query_location_2.second[2] << "]\n\n"; + + // Shoot a 2D ray and locate the intersection with the mesh in 2D + const Ray_2 ray_2(Point_2(-10, -10), Point_2(10, 10)); + Face_location ray_location_2 = PMP::locate(ray_2, tm, CP::vertex_point_map(projection_pmap)); // This rebuilds an AABB tree on each call + + std::cout << "Intersection of the 2D ray and the mesh is in face " << ray_location_2.first + << " with barycentric coordinates [" << ray_location_2.second[0] << "; " + << ray_location_2.second[1] << "; " + << ray_location_2.second[2] << "]\n"; + std::cout << "It corresponds to point (" << PMP::construct_point(ray_location_2, tm, CP::vertex_point_map(projection_pmap)) << ")\n"; + + if(PMP::is_on_mesh_border(ray_location_2, tm)) + std::cout << "It is on the border of the mesh!\n" << std::endl; + + return EXIT_SUCCESS; +} diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h index de52cfac3f2..ee5e3c2e9bc 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h @@ -549,7 +549,6 @@ double approximate_Hausdorff_distance( Tree tree( faces(tm).first, faces(tm).second, tm); tree.build(); - tree.accelerate_distance_queries(); Point_3 hint = get(vpm, *vertices(tm).first); return internal::approximate_Hausdorff_distance_impl diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h index 3e585fe691c..2f93d176784 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h @@ -1259,7 +1259,7 @@ public: // non-manifold vertices would not be duplicated in interior // vertices of patche) // special code to handle non-manifold vertices on the boundary - BOOST_FOREACH (vertex_descriptor vd, vertices(tm1)) + for (vertex_descriptor vd : vertices(tm1)) { boost::optional op_h = is_border(vd, tm1); if (op_h == boost::none) continue; @@ -1629,12 +1629,12 @@ public: } // Code dedicated to the handling of non-manifold vertices - BOOST_FOREACH(vertex_descriptor vd, border_nm_vertices) + for(vertex_descriptor vd : border_nm_vertices) { // first check if at least one incident patch will be kept boost::unordered_set id_p_rm; bool all_removed=true; - BOOST_FOREACH(halfedge_descriptor h, halfedges_around_target(vd, tm1)) + for(halfedge_descriptor h : halfedges_around_target(vd, tm1)) { face_descriptor f = face(h, tm1); if ( f != GT::null_face() ) @@ -1649,7 +1649,7 @@ public: if (all_removed) id_p_rm.erase(id_p_rm.begin()); // remove the vertex from the interior vertices of patches to be removed - BOOST_FOREACH(std::size_t pid, id_p_rm) + for(std::size_t pid : id_p_rm) patches_of_tm1[pid].interior_vertices.erase(vd); // we now need to update the next/prev relationship induced by the future removal of patches @@ -1694,7 +1694,7 @@ public: else { // we push-back the halfedge for the next round only if it was not the first - if (h != *cpp11::prev(hit)) + if (h != *std::prev(hit)) --hit; break; } @@ -1703,7 +1703,7 @@ public: while(true); if (hit == end) break; } - BOOST_FOREACH ( const Hedge_pair& p, hedges_to_link) + for(const Hedge_pair& p : hedges_to_link) set_next(p.first, p.second, tm1); } } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h index d812475645a..6ff0e02c879 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h @@ -35,6 +35,7 @@ #include #include #include +#include namespace CGAL { namespace internal { 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 6f39248e215..e5ddeadf013 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 @@ -372,7 +372,6 @@ namespace internal { } for(std::size_t i=0; i < trees.size(); ++i){ trees[i]->build(); - trees[i]->accelerate_distance_queries(); } } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/remove_degeneracies.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/remove_degeneracies.h new file mode 100644 index 00000000000..f6e582cf93f --- /dev/null +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/remove_degeneracies.h @@ -0,0 +1,709 @@ +// Copyright (c) 2019 GeometryFactory (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) : Sebastien Loriot, +// Mael Rouxel-Labbé + +#ifndef CGAL_POLYGON_MESH_PROCESSING_REMOVE_DEGENERACIES_H +#define CGAL_POLYGON_MESH_PROCESSING_REMOVE_DEGENERACIES_H + +#include + +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES +#include +#include +#endif + +namespace CGAL { +namespace Polygon_mesh_processing { +namespace internal { + +template +std::array::halfedge_descriptor, 2> +is_badly_shaped(const typename boost::graph_traits::face_descriptor f, + TriangleMesh& tmesh, + const VPM& vpm, + const ECM& ecm, + const Traits& gt, + const double cap_threshold, // angle over 160° ==> cap + const double needle_threshold, // longest edge / shortest edge over this ratio ==> needle + const double collapse_length_threshold) // max length of edges allowed to be collapsed +{ + namespace PMP = CGAL::Polygon_mesh_processing; + + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + + const halfedge_descriptor null_h = boost::graph_traits::null_halfedge(); + + halfedge_descriptor res = PMP::is_needle_triangle_face(f, tmesh, needle_threshold, + parameters::vertex_point_map(vpm) + .geom_traits(gt)); + if(res != null_h && !get(ecm, edge(res, tmesh))) + { + // don't want to collapse edges that are too large + if(collapse_length_threshold == 0 || + edge_length(res, tmesh, parameters::vertex_point_map(vpm).geom_traits(gt)) <= collapse_length_threshold) + { + return make_array(res, null_h); + } + } + else // let's not make it possible to have a face be both a cap and a needle (for now) + { + res = PMP::is_cap_triangle_face(f, tmesh, cap_threshold, parameters::vertex_point_map(vpm).geom_traits(gt)); + if(res != null_h && !get(ecm, edge(res, tmesh))) + return make_array(null_h, res); + } + + return make_array(null_h, null_h); +} + +template +void collect_badly_shaped_triangles(const typename boost::graph_traits::face_descriptor f, + TriangleMesh& tmesh, + const VPM& vpm, + const ECM& ecm, + const Traits& gt, + const double cap_threshold, // angle over this threshold (as a cosine) ==> cap + const double needle_threshold, // longest edge / shortest edge over this ratio ==> needle + const double collapse_length_threshold, // max length of edges allowed to be collapsed + EdgeContainer& edges_to_collapse, + EdgeContainer& edges_to_flip) +{ + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + + std::array res = is_badly_shaped(f, tmesh, vpm, ecm, gt, cap_threshold, + needle_threshold, collapse_length_threshold); + + if(res[0] != boost::graph_traits::null_halfedge()) + { +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES + std::cout << "add new needle: " << edge(res[0], tmesh) << std::endl; +#endif + edges_to_collapse.insert(edge(res[0], tmesh)); + } + else // let's not make it possible to have a face be both a cap and a needle (for now) + { + if(res[1] != boost::graph_traits::null_halfedge()) + { +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES + std::cout << "add new cap: " << edge(res[1],tmesh) << std::endl; +#endif + edges_to_flip.insert(edge(res[1], tmesh)); + } + } +} + +/* +// Following Ronfard et al. 96 we look at variation of the normal after the collapse +// the collapse must be topologically valid +template +bool is_collapse_geometrically_valid(typename boost::graph_traits::halfedge_descriptor h, + const TriangleMesh& tmesh, + const NamedParameters& np) +{ + using CGAL::parameters::choose_parameter; + using CGAL::parameters::get_parameter; + + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + typedef typename GetVertexPointMap::const_type VPM; + typedef typename boost::property_traits::reference Point_ref; + typedef typename GetGeomTraits::type Traits; + + VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), + get_const_property_map(vertex_point, tmesh)); + Traits gt = choose_parameter(get_parameter(np, internal_np::geom_traits), Traits()); + +/// @todo handle boundary edges + + h = opposite(h, tmesh); // Euler::collapse edge keeps the target and removes the source + + // source is kept, target is removed + CGAL_assertion(target(h, tmesh) == vertex_removed); + Point_ref kept = get(vpm, source(h, tmesh)); + Point_ref removed= get(vpm, target(h, tmesh)); + + // consider triangles incident to the vertex removed + halfedge_descriptor stop = prev(opposite(h, tmesh), tmesh); + halfedge_descriptor hi = opposite(next(h, tmesh), tmesh); + + std::vector triangles; + while(hi != stop) + { + if(!is_border(hi, tmesh)) + { + Point_ref a = get(vpm, target(next(hi, tmesh), tmesh)); + Point_ref b = get(vpm, source(hi, tmesh)); + + //ack a-b-point_remove and a-b-point_kept has a compatible orientation + /// @todo use a predicate + typename Traits::Vector_3 n1 = gt.construct_cross_product_vector_3_object()(removed-a, b-a); + typename Traits::Vector_3 n2 = gt.construct_cross_product_vector_3_object()(kept-a, b-a); + if(gt.compute_scalar_product_3_object()(n1, n2) <= 0) + return false; + } + + hi = opposite(next(hi, tmesh), tmesh); + } + + return true; +} +*/ + +template +boost::optional get_collapse_volume(typename boost::graph_traits::halfedge_descriptor h, + const TriangleMesh& tmesh, + const VPM& vpm, + const Traits& gt) +{ + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + + typedef typename boost::property_traits::reference Point_ref; + typedef typename Traits::Vector_3 Vector_3; + + const typename Traits::Point_3 origin(ORIGIN); + +/// @todo handle boundary edges + + h = opposite(h, tmesh); // Euler::collapse edge keeps the target and removes the source + + // source is kept, target is removed + Point_ref kept = get(vpm, source(h, tmesh)); + Point_ref removed= get(vpm, target(h, tmesh)); + + // init volume with incident triangles (reversed orientation + double delta_vol = volume(removed, kept, get(vpm, target(next(h, tmesh), tmesh)), origin) + + volume(kept, removed, get(vpm, target(next(opposite(h, tmesh), tmesh), tmesh)), origin); + + // consider triangles incident to the vertex removed + halfedge_descriptor stop = prev(opposite(h, tmesh), tmesh); + halfedge_descriptor hi = opposite(next(h, tmesh), tmesh); + + std::vector triangles; + while(hi != stop) + { + if(!is_border(hi, tmesh)) + { + Point_ref a = get(vpm, target(next(hi, tmesh), tmesh)); + Point_ref b = get(vpm, source(hi, tmesh)); + + //ack a-b-point_remove and a-b-point_kept has a compatible orientation + /// @todo use a predicate + Vector_3 v_ab = gt.construct_vector_3_object()(a, b); + Vector_3 v_ar = gt.construct_vector_3_object()(a, removed); + Vector_3 v_ak = gt.construct_vector_3_object()(a, kept); + + Vector_3 n1 = gt.construct_cross_product_vector_3_object()(v_ar, v_ab); + Vector_3 n2 = gt.construct_cross_product_vector_3_object()(v_ak, v_ab); + if(gt.compute_scalar_product_3_object()(n1, n2) <= 0) + return boost::none; + + delta_vol += volume(b, a, removed, origin) + volume(a, b, kept, origin); // opposite orientation + } + + hi = opposite(next(hi, tmesh), tmesh); + } + + return CGAL::abs(delta_vol); +} + +template +typename boost::graph_traits::halfedge_descriptor +get_best_edge_orientation(typename boost::graph_traits::edge_descriptor e, + const TriangleMesh& tmesh, + const VPM& vpm, + const VCM& vcm, + const Traits& gt) +{ + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + + halfedge_descriptor h = halfedge(e, tmesh), ho = opposite(h, tmesh); + + CGAL_assertion(!get(vcm, source(h, tmesh)) || !get(vcm, target(h, tmesh))); + + boost::optional dv1 = get_collapse_volume(h, tmesh, vpm, gt); + boost::optional dv2 = get_collapse_volume(ho, tmesh, vpm, gt); + + // the resulting point of the collapse of a halfedge is the target of the halfedge before collapse + if(get(vcm, source(h, tmesh))) + return dv2 != boost::none ? ho + : boost::graph_traits::null_halfedge(); + + if(get(vcm, target(h, tmesh))) + return dv1 != boost::none ? h + : boost::graph_traits::null_halfedge(); + + if(dv1 != boost::none) + { + if(dv2 != boost::none) + return (*dv1 < *dv2) ? h : ho; + + return h; + } + + if(dv2 != boost::none) + return ho; + + return boost::graph_traits::null_halfedge(); +} + +// adapted from triangulate_faces +template +bool should_flip(typename boost::graph_traits::edge_descriptor e, + const TriangleMesh& tmesh, + const VPM& vpm, + const Traits& gt) +{ + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + + typedef typename boost::property_traits::reference Point_ref; + typedef typename Traits::Vector_3 Vector_3; + + CGAL_precondition(!is_border(e, tmesh)); + + halfedge_descriptor h = halfedge(e, tmesh); + + Point_ref p0 = get(vpm, target(h, tmesh)); + Point_ref p1 = get(vpm, target(next(h, tmesh), tmesh)); + Point_ref p2 = get(vpm, source(h, tmesh)); + Point_ref p3 = get(vpm, target(next(opposite(h, tmesh), tmesh), tmesh)); + + /* Chooses the diagonal that will split the quad in two triangles that maximize + * the scalar product of of the un-normalized normals of the two triangles. + * The lengths of the un-normalized normals (computed using cross-products of two vectors) + * are proportional to the area of the triangles. + * Maximize the scalar product of the two normals will avoid skinny triangles, + * and will also taken into account the cosine of the angle between the two normals. + * In particular, if the two triangles are oriented in different directions, + * the scalar product will be negative. + */ + +// CGAL::cross_product(p2-p1, p3-p2) * CGAL::cross_product(p0-p3, p1-p0); +// CGAL::cross_product(p1-p0, p1-p2) * CGAL::cross_product(p3-p2, p3-p0); + + const Vector_3 v01 = gt.construct_vector_3_object()(p0, p1); + const Vector_3 v12 = gt.construct_vector_3_object()(p1, p2); + const Vector_3 v23 = gt.construct_vector_3_object()(p2, p3); + const Vector_3 v30 = gt.construct_vector_3_object()(p3, p0); + + const double p1p3 = gt.compute_scalar_product_3_object()( + gt.construct_cross_product_vector_3_object()(v12, v23), + gt.construct_cross_product_vector_3_object()(v30, v01)); + + const Vector_3 v21 = gt.construct_opposite_vector_3_object()(v12); + const Vector_3 v03 = gt.construct_opposite_vector_3_object()(v30); + + const double p0p2 = gt.compute_scalar_product_3_object()( + gt.construct_cross_product_vector_3_object()(v01, v21), + gt.construct_cross_product_vector_3_object()(v23, v03)); + + return p0p2 <= p1p3; +} + +} // namespace internal + +namespace experimental { + +// @todo check what to use as priority queue with removable elements, set might not be optimal +template +bool remove_almost_degenerate_faces(const FaceRange& face_range, + TriangleMesh& tmesh, + const double cap_threshold, + const double needle_threshold, + const double collapse_length_threshold, + const NamedParameters& np) +{ + using CGAL::parameters::choose_parameter; + using CGAL::parameters::get_parameter; + + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + typedef typename boost::graph_traits::edge_descriptor edge_descriptor; + typedef typename boost::graph_traits::face_descriptor face_descriptor; + + typedef Constant_property_map Default_VCM; + typedef typename internal_np::Lookup_named_param_def::type VCM; + VCM vcm_np = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), Default_VCM(false)); + + typedef Constant_property_map Default_ECM; + typedef typename internal_np::Lookup_named_param_def::type ECM; + ECM ecm = choose_parameter(get_parameter(np, internal_np::edge_is_constrained), Default_ECM(false)); + + typedef typename GetVertexPointMap::const_type VPM; + VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), + get_const_property_map(vertex_point, tmesh)); + + typedef typename GetGeomTraits::type Traits; + Traits gt = choose_parameter(get_parameter(np, internal_np::geom_traits), Traits()); + + // Vertex property map that combines the VCM and the fact that extremities of a constrained edge should be constrained + typedef CGAL::dynamic_vertex_property_t Vertex_property_tag; + typedef typename boost::property_map::type DVCM; + DVCM vcm = get(Vertex_property_tag(), tmesh); + + for(face_descriptor f : face_range) + { + if(f == boost::graph_traits::null_face()) + continue; + + for(halfedge_descriptor h : CGAL::halfedges_around_face(halfedge(f, tmesh), tmesh)) + { + if(get(ecm, edge(h, tmesh))) + { + put(vcm, source(h, tmesh), true); + put(vcm, target(h, tmesh), true); + } + else if(get(vcm_np, target(h, tmesh))) + { + put(vcm, target(h, tmesh), true); + } + } + } + + // Start the process of removing bad elements + std::set edges_to_collapse; + std::set edges_to_flip; + + // @todo could probably do something a bit better by looping edges, consider the incident faces + // f1 / f2 and look at f1 if f1 next_edges_to_collapse; + std::set next_edges_to_flip; + + // treat needles +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA + int kk=0; + std::ofstream(std::string("tmp/n-00000.off")) << tmesh; +#endif + while(!edges_to_collapse.empty()) + { + edge_descriptor e = *edges_to_collapse.begin(); + edges_to_collapse.erase(edges_to_collapse.begin()); + + CGAL_assertion(!get(ecm, e)); + + if(get(vcm, source(e, tmesh)) && get(vcm, target(e, tmesh))) + continue; + +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES + std::cout << " treat needle: " << e << " (" << tmesh.point(source (e, tmesh)) + << " --- " << tmesh.point(target(e, tmesh)) << ")" << std::endl; +#endif + if(CGAL::Euler::does_satisfy_link_condition(e, tmesh)) + { + // the following edges are removed by the collapse + halfedge_descriptor h = halfedge(e, tmesh); + CGAL_assertion(!is_border(h, tmesh)); // because extracted from a face + + std::array nc = + internal::is_badly_shaped(face(h, tmesh), tmesh, vpm, ecm, gt, + cap_threshold, needle_threshold, collapse_length_threshold); + + if(nc[0] != h) + { +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES + std::cerr << "Warning: Needle criteria no longer verified " << tmesh.point(source(e, tmesh)) << " " + << tmesh.point(target(e, tmesh)) << std::endl; +#endif + // the opposite edge might also have been inserted in the set and might still be a needle + h = opposite(h, tmesh); + if(is_border(h, tmesh)) + continue; + + nc = internal::is_badly_shaped(face(h, tmesh), tmesh, vpm, ecm, gt, + cap_threshold, needle_threshold, + collapse_length_threshold); + if(nc[0] != h) + continue; + } + + for(int i=0; i<2; ++i) + { + if(!is_border(h, tmesh)) + { + edge_descriptor pe = edge(prev(h, tmesh), tmesh); + edges_to_flip.erase(pe); + next_edges_to_collapse.erase(pe); + edges_to_collapse.erase(pe); + } + + h = opposite(h, tmesh); + } + + // pick the orientation of edge to keep the vertex minimizing the volume variation + h = internal::get_best_edge_orientation(e, tmesh, vpm, vcm, gt); + + if(h == boost::graph_traits::null_halfedge()) + { +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES + std::cerr << "Warning: geometrically invalid edge collapse! " + << tmesh.point(source(e, tmesh)) << " " + << tmesh.point(target(e, tmesh)) << std::endl; +#endif + next_edges_to_collapse.insert(e); + continue; + } + + edges_to_flip.erase(e); + next_edges_to_collapse.erase(e); // for edges added in faces incident to a vertex kept after a collapse +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA + std::cerr << " " << kk << " -- Collapsing " << tmesh.point(source(h, tmesh)) << " " + << tmesh.point(target(h, tmesh)) << std::endl; +#endif + // moving to the midpoint is not a good idea. On a circle for example you might endpoint with + // a bad geometry because you iteratively move one point + // auto mp = midpoint(tmesh.point(source(h, tmesh)), tmesh.point(target(h, tmesh))); + + vertex_descriptor v = Euler::collapse_edge(edge(h, tmesh), tmesh); + + //tmesh.point(v) = mp; + // examine all faces incident to the vertex kept + for(halfedge_descriptor hv : halfedges_around_target(v, tmesh)) + { + if(!is_border(hv, tmesh)) + { + internal::collect_badly_shaped_triangles(face(hv, tmesh), tmesh, vpm, ecm, gt, + cap_threshold, needle_threshold, collapse_length_threshold, + edges_to_collapse, edges_to_flip); + } + } + +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA + std::string nb = std::to_string(++kk); + if(kk<10) nb = std::string("0")+nb; + if(kk<100) nb = std::string("0")+nb; + if(kk<1000) nb = std::string("0")+nb; + if(kk<10000) nb = std::string("0")+nb; + std::ofstream(std::string("tmp/n-")+nb+std::string(".off")) << tmesh; +#endif + something_was_done = true; + } + else + { +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES + std::cerr << "Warning: uncollapsable edge! " << tmesh.point(source(e, tmesh)) << " " + << tmesh.point(target(e, tmesh)) << std::endl; +#endif + next_edges_to_collapse.insert(e); + } + } + + // treat caps +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA + kk=0; + std::ofstream(std::string("tmp/c-000.off")) << tmesh; +#endif + while(!edges_to_flip.empty()) + { + edge_descriptor e = *edges_to_flip.begin(); + edges_to_flip.erase(edges_to_flip.begin()); + + CGAL_assertion(!get(ecm, e)); + + if(get(vcm, source(e, tmesh)) && get(vcm, target(e, tmesh))) + continue; + +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES + std::cout << "treat cap: " << e << " (" << tmesh.point(source(e, tmesh)) + << " --- " << tmesh.point(target(e, tmesh)) << ")" << std::endl; +#endif + + halfedge_descriptor h = halfedge(e, tmesh); + std::array nc = internal::is_badly_shaped(face(h, tmesh), tmesh, vpm, ecm, gt, + cap_threshold, needle_threshold, + collapse_length_threshold); + // First check the triangle is still a cap + if(nc[1] != h) + { +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES + std::cerr << "Warning: Cap criteria no longer verified " << tmesh.point(source(e, tmesh)) << " --- " + << tmesh.point(target(e, tmesh)) << std::endl; +#endif + // the opposite edge might also have been inserted in the set and might still be a cap + h = opposite(h, tmesh); + if(is_border(h, tmesh)) + continue; + + nc = internal::is_badly_shaped(face(h, tmesh), tmesh, vpm, ecm, gt, + cap_threshold, needle_threshold, collapse_length_threshold); + if(nc[1] != h) + continue; + } + + // special case on the border + if(is_border(opposite(h, tmesh), tmesh)) + { + // remove the triangle + edges_to_flip.erase(edge(prev(h, tmesh), tmesh)); + edges_to_flip.erase(edge(next(h, tmesh), tmesh)); + next_edges_to_collapse.erase(edge(prev(h, tmesh), tmesh)); + next_edges_to_collapse.erase(edge(next(h, tmesh), tmesh)); + Euler::remove_face(h, tmesh); + something_was_done = true; + continue; + } + + // condition for the flip to be valid (the edge to be created does not already exist) + if(!halfedge(target(next(h, tmesh), tmesh), + target(next(opposite(h, tmesh), tmesh), tmesh), tmesh).second) + { + + if(!internal::should_flip(e, tmesh, vpm, gt)) + { +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES + std::cout << "Flipping prevented: not the best diagonal" << std::endl; +#endif + next_edges_to_flip.insert(e); + continue; + } + +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES + std::cout << "Flipping" << std::endl; +#endif +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA + std::cerr << "step " << kk << "\n"; + std::cerr << " Flipping " << tmesh.point(source(h, tmesh)) << " " + << tmesh.point(target(h, tmesh)) << std::endl; +#endif + Euler::flip_edge(h, tmesh); + CGAL_assertion(edge(h, tmesh) == e); + + // handle face updates + for(int i=0; i<2; ++i) + { + CGAL_assertion(!is_border(h, tmesh)); + std::array nc = + internal::is_badly_shaped(face(h, tmesh), tmesh, vpm, ecm, gt, + cap_threshold, needle_threshold, collapse_length_threshold); + + if(nc[1] != boost::graph_traits::null_halfedge()) + { + if(edge(nc[1], tmesh) != e) + next_edges_to_flip.insert(edge(nc[1], tmesh)); + } + else + { + if(nc[0] != boost::graph_traits::null_halfedge()) + { + next_edges_to_collapse.insert(edge(nc[0], tmesh)); + } + } + h = opposite(h, tmesh); + } + something_was_done = true; + } +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES + else + { + std::cerr << "Warning: unflippable edge! " << tmesh.point(source(h, tmesh)) << " --- " + << tmesh.point(target(h, tmesh)) << std::endl; + next_edges_to_flip.insert(e); + } +#endif +#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA + std::string nb = std::to_string(++kk); + if(kk<10) nb = std::string("0")+nb; + if(kk<100) nb = std::string("0")+nb; + if(kk<1000) nb = std::string("0")+nb; + if(kk<10000) nb = std::string("0")+nb; + std::ofstream(std::string("tmp/c-")+nb+std::string(".off")) << tmesh; +#endif + } + + std::swap(edges_to_collapse, next_edges_to_collapse); + std::swap(edges_to_flip, next_edges_to_flip); + + if(!something_was_done) + return false; + } + + return false; +} + +template +bool remove_almost_degenerate_faces(const FaceRange& face_range, + TriangleMesh& tmesh, + const double cap_threshold, + const double needle_threshold, + const double collapse_length_threshold) +{ + return remove_almost_degenerate_faces(face_range, tmesh, + cap_threshold, needle_threshold, collapse_length_threshold, + CGAL::parameters::all_default()); +} + +template +bool remove_almost_degenerate_faces(TriangleMesh& tmesh, + const double cap_threshold, + const double needle_threshold, + const double collapse_length_threshold, + const CGAL_PMP_NP_CLASS& np) +{ + return remove_almost_degenerate_faces(faces(tmesh), tmesh, cap_threshold, needle_threshold, + collapse_length_threshold, np); +} + +template +bool remove_almost_degenerate_faces(TriangleMesh& tmesh, + const double cap_threshold, + const double needle_threshold, + const double collapse_length_threshold) +{ + return remove_almost_degenerate_faces(faces(tmesh), tmesh, + cap_threshold, needle_threshold, collapse_length_threshold, + CGAL::parameters::all_default()); +} + +} // namespace experimental +} // namespace Polygon_mesh_processing +} // namespace CGAL + +#endif // CGAL_POLYGON_MESH_PROCESSING_REMOVE_DEGENERACIES_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/locate.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/locate.h index 6d119cca9cc..86280d8d95d 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/locate.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/locate.h @@ -51,9 +51,7 @@ // - `w2` corresponds to `target(next(halfedge(f, tm), tm), tm)` namespace CGAL { - namespace Polygon_mesh_processing { - namespace internal { // The Ray must have the same ambient dimension as the property map's value type (aka, the point type) @@ -66,91 +64,87 @@ struct Ray_type_selector typedef typename Kernel::Ray_2 type; }; -template +template struct Ray_type_selector { typedef typename CGAL::Kernel_traits::type Kernel; typedef typename Kernel::Ray_3 type; }; +// Just for convenience +template > +struct Location_traits +{ + typedef typename GetVertexPointMap::const_type VertexPointMap; + typedef typename boost::property_traits::value_type Point; + typedef typename internal::Ray_type_selector::type Ray; + + typedef typename GetGeomTraits::type Geom_traits; + typedef typename Geom_traits::FT FT; + + typedef typename boost::graph_traits::face_descriptor face_descriptor; + + typedef std::array Barycentric_coordinates; + typedef std::pair Face_location; +}; + } // end namespace internal /// \ingroup PMP_locate_grp /// -/// \brief Helper class whose sole purpose is to make it easier to access some useful types. +/// A variant used in the function `get_descriptor_from_location()`. +template +using descriptor_variant = boost::variant::vertex_descriptor, + typename boost::graph_traits::halfedge_descriptor, + typename boost::graph_traits::face_descriptor>; + +/// \ingroup PMP_locate_grp /// -/// \tparam TriangleMesh a model of `FaceListGraph` -/// \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" +/// A triplet of coordinates describing the barycentric coordinates of a point +/// with respect to the vertices of a triangular face. /// -template > -class Location_traits -{ -public: - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef boost::variant descriptor_variant; +/// \sa `Face_location` +template +using Barycentric_coordinates = std::array; -#ifdef DOXYGEN_RUNNING - /// This is the type of the vertex point property map, either the one passed through the named parameters - /// or the default, internal one of the mesh. - typedef unspecified_type VPM; - - /// The traits class, either passed as a named parameter or deduced from the Point type - /// of the vertex property map (the point type must then be compatible with `CGAL::Kernel_traits`) - typedef unspecified_type Geom_traits; -#else - typedef typename GetVertexPointMap::const_type VPM; - typedef typename GetGeomTraits::type Geom_traits; -#endif - - typedef typename boost::property_traits::value_type Point; - typedef typename Geom_traits::FT FT; - -#ifdef DOXYGEN_RUNNING - /// Either Geom_traits::Ray_2 or Geom_traits::Ray_3, depending on the ambient dimension of the mesh - typedef unspecified_type Ray; -#else - typedef typename internal::Ray_type_selector::type Ray; -#endif - - typedef std::array Barycentric_coordinates; - - /// If `tm` is the input triangulated surface mesh and given the pair (`f`, `bc`) - /// such that `bc` is the triplet of barycentric coordinates `(w0, w1, w2)`, the correspondance - /// between the coordinates in `bc` and the vertices of the face `f` is the following: - /// - `w0` corresponds to `source(halfedge(f, tm), tm)` - /// - `w1` corresponds to `target(halfedge(f, tm), tm)` - /// - `w2` corresponds to `target(next(halfedge(f, tm), tm), tm)` - typedef std::pair Face_location; -}; +/// \ingroup PMP_locate_grp +/// +/// If `tm` is the input triangulated surface mesh and given the pair (`f`, `bc`) +/// such that `bc` is the triplet of barycentric coordinates `(w0, w1, w2)`, the correspondance +/// between the coordinates in `bc` and the vertices of the face `f` is the following: +/// - `w0` corresponds to `source(halfedge(f, tm), tm)` +/// - `w1` corresponds to `target(halfedge(f, tm), tm)` +/// - `w2` corresponds to `target(next(halfedge(f, tm), tm), tm)` +template +using Face_location = std::pair::face_descriptor, + Barycentric_coordinates >; // forward declarations -template -bool is_in_face(const typename Location_traits::Face_location& loc, +template +bool is_in_face(const std::pair::face_descriptor, + std::array >& loc, const TriangleMesh& tm); -template -typename Location_traits::descriptor_variant -get_descriptor_from_location(const typename Location_traits::Face_location& loc, +template +descriptor_variant +get_descriptor_from_location(const std::pair::face_descriptor, + std::array >& loc, const TriangleMesh& tm); -template -typename Location_traits::Face_location -locate_in_face(typename boost::graph_traits::halfedge_descriptor he, - typename Location_traits::FT t, +template +Face_location +locate_in_face(typename boost::graph_traits::halfedge_descriptor hd, + const FT t, const TriangleMesh& tm); // end of forward declarations namespace internal { -template +template OutputIterator -incident_faces(const typename Location_traits::Face_location& location, +incident_faces(const std::pair::face_descriptor, + std::array >& location, const TriangleMesh& tm, OutputIterator out) { @@ -158,11 +152,7 @@ incident_faces(const typename Location_traits::Face_location& loca typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef boost::variant descriptor_variant; - - descriptor_variant dv = get_descriptor_from_location(location, tm); + const descriptor_variant dv = get_descriptor_from_location(location, tm); if(const vertex_descriptor* vd_ptr = boost::get(&dv)) { @@ -186,14 +176,11 @@ incident_faces(const typename Location_traits::Face_location& loca } // Snapping coordinates for robustness -template +template bool -snap_coordinates_to_border(typename Location_traits::Barycentric_coordinates& coords, - const typename Location_traits::FT tolerance = - std::numeric_limits::FT>::epsilon()) +snap_coordinates_to_border(std::array& coords, + const FT tolerance = std::numeric_limits::epsilon()) { - typedef typename Location_traits::FT FT; - #ifdef CGAL_PMP_LOCATE_DEBUG std::cout << "Pre-snapping: " << coords[0] << " " << coords[1] << " " << coords[2] << std::endl; std::cout << "Sum: " << coords[0] + coords[1] + coords[2] << std::endl; @@ -201,7 +188,7 @@ snap_coordinates_to_border(typename Location_traits::Barycentric_c #endif // To still keep a sum roughly equals to 1, keep in memory the small changes - FT residue = 0.; + FT residue(0); bool snapped = false; for(int i=0; i<3; ++i) @@ -210,20 +197,20 @@ snap_coordinates_to_border(typename Location_traits::Barycentric_c { snapped = true; residue += coords[i]; - coords[i] = 0.; + coords[i] = FT(0); } - else if(CGAL::abs(1 - coords[i]) <= tolerance) + else if(CGAL::abs(FT(1) - coords[i]) <= tolerance) { snapped = true; - residue -= 1. - coords[i]; - coords[i] = 1.; + residue -= FT(1) - coords[i]; + coords[i] = FT(1); } } // Dump the residue into one of the barycentric values that is neither 0 nor 1 for(int i=0; i<3; ++i) { - if(coords[i] != 0. && coords[i] != 1.) + if(coords[i] != FT(0) && coords[i] != FT(1)) { coords[i] += residue; break; @@ -240,13 +227,14 @@ snap_coordinates_to_border(typename Location_traits::Barycentric_c return snapped; } -template +template bool -snap_location_to_border(typename Location_traits::Face_location& loc, - const typename Location_traits::FT tolerance = - std::numeric_limits::FT>::epsilon()) +snap_location_to_border(std::pair::face_descriptor, + std::array >& loc, + const TriangleMesh /*tm*/, + const FT tolerance = std::numeric_limits::epsilon()) { - return snap_coordinates_to_border(loc.second, tolerance); + return snap_coordinates_to_border(loc.second, tolerance); } template @@ -278,7 +266,7 @@ struct Barycentric_coordinate_calculator // 2D version FT d21 = csp2(v2, v1); FT denom = d00 * d11 - d01 * d01; - CGAL_assertion((d00 * d11 - d01 * d01) != FT(0)); // denom != 0. + CGAL_assertion((d00 * d11 - d01 * d01) != FT(0)); // denom != 0 FT v = (d11 * d20 - d01 * d21) / denom; FT w = (d00 * d21 - d01 * d20) / denom; @@ -315,8 +303,8 @@ struct Barycentric_coordinate_calculator FT d20 = csp3(v2, v0); FT d21 = csp3(v2, v1); - CGAL_assertion((d00 * d11 - d01 * d01) != FT(0)); // denom != 0. - FT denom_inv = 1. / (d00 * d11 - d01 * d01); + CGAL_assertion((d00 * d11 - d01 * d01) != FT(0)); // denom != 0 + FT denom_inv = FT(1) / (d00 * d11 - d01 * d01); FT v = (d11 * d20 - d01 * d21) * denom_inv; FT w = (d00 * d21 - d01 * d20) * denom_inv; @@ -334,7 +322,7 @@ struct Barycentric_point_constructor // 2D version const K& /*k*/) const { FT sum = wp + wq + wr; - CGAL_assertion(sum != 0); + CGAL_assertion(sum != FT(0)); // In theory, this should be compute_x_2(compute_point_2(...)) and construct_P() at the end... FT x = (wp * p.x() + wq * q.x() + wr * r.x()) / sum; @@ -353,7 +341,7 @@ struct Barycentric_point_constructor // 3D version const K& /*k*/) const { FT sum = wp + wq + wr; - CGAL_assertion(sum != 0); + CGAL_assertion(sum != FT(0)); FT x = (wp * p.x() + wq * q.x() + wr * r.x()) / sum; FT y = (wp * p.y() + wq * q.y() + wr * r.y()) / sum; FT z = (wp * p.z() + wq * q.z() + wr * r.z()) / sum; @@ -369,25 +357,24 @@ struct Barycentric_point_constructor // 3D version /// \brief Given a set of three points and a query point, computes the barycentric /// coordinates of the query point with respect to the first three points. /// +/// \tparam GeomTraits the type of a geometric traits. Must be a model of `Kernel` and be compatible +/// with the template parameter `Point`. /// \tparam Point the type of a geometric 2D or 3D point -/// \tparam K the type of a geometric traits. Must be a model of `Kernel`. /// /// \param p,q,r three points with respect to whom the barycentric coordinates of `query` will be computed /// \param query the query point whose barycentric coordinates will be computed -/// \param k an instance of the geometric traits +/// \param gt an instance of the geometric traits /// /// \pre `p`, `q`, and `r` are not collinear. -/// \pre It must be possible to extract a kernel type model of `Kernel`, using `CGAL::Kernel_traits

    ` -/// (this is the case for all standard %CGAL point types and classes inheriting such point types). /// \pre `query` lies on the plane defined by `p`, `q`, and `r`. /// -template -std::array +template +std::array barycentric_coordinates(const Point& p, const Point& q, const Point& r, const Point& query, - const K& k) + const GeomTraits& gt) { - internal::Barycentric_coordinate_calculator calculator; - return calculator(p, q, r, query, k); + internal::Barycentric_coordinate_calculator calculator; + return calculator(p, q, r, query, gt); } template @@ -411,24 +398,30 @@ barycentric_coordinates(const Point& p, const Point& q, const Point& r, const Po /// a value `t` between `0` and `1` and setting the barycentric coordinates to `t`, `1-t`, /// and `0` for respetively the source and target of `hd`, and the third vertex. /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam FT must be a model of `FieldNumberType` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// /// \param hd a halfedge of `tm` /// \param tm a triangulated surface mesh /// \param rnd optional random number generator /// -template -typename Location_traits::Face_location +template +Face_location random_location_on_halfedge(typename boost::graph_traits::halfedge_descriptor hd, const TriangleMesh& tm, CGAL::Random& rnd = get_default_random()) { - typedef typename Location_traits::FT FT; - CGAL_precondition(CGAL::is_triangle_mesh(tm)); - FT t(rnd.uniform_real(0., 1.)); - return locate_in_face(hd, t, tm); + const int h_id = halfedge_index_in_face(hd, tm); + const FT t(rnd.uniform_real(0., 1.)); + + std::array coordinates; + coordinates[h_id] = t; + coordinates[(h_id+1)%3] = FT(1)-t; + coordinates[(h_id+2)%3] = FT(0); + + return std::make_pair(face(hd, tm), coordinates); } /// \ingroup PMP_locate_grp @@ -440,20 +433,19 @@ random_location_on_halfedge(typename boost::graph_traits::halfedge /// a value `v` between `1-u`, and setting the barycentric coordinates to `u`, `v`, and /// `1-u-v` for respectively the source and target of `halfedge(fd, tm)`, and the third point. /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam FT must be a model of `FieldNumberType` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// /// \param fd a face of `tm` /// \param tm a triangulated surface mesh /// \param rnd optional random number generator /// -template -typename Location_traits::Face_location +template +Face_location random_location_on_face(typename boost::graph_traits::face_descriptor fd, const TriangleMesh& tm, CGAL::Random& rnd = get_default_random()) { - typedef typename Location_traits::FT FT; - CGAL_USE(tm); CGAL_precondition(CGAL::is_triangle_mesh(tm)); CGAL_precondition(fd != boost::graph_traits::null_face()); @@ -473,33 +465,33 @@ random_location_on_face(typename boost::graph_traits::face_descrip /// a random point on that face. The barycentric coordinates of the point in the face /// are thus all positive. Note that all faces have the same probability to be chosen. /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam FT must be a model of `FieldNumberType` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// /// \param tm a triangulated surface mesh /// \param rnd optional random number generator /// /// \sa `random_location_on_face()` /// -template -typename Location_traits::Face_location -random_location_on_mesh(const TriangleMesh& tm, CGAL::Random& rnd = get_default_random()) +template +Face_location +random_location_on_mesh(const TriangleMesh& tm, + CGAL::Random& rnd = get_default_random()) { typedef typename boost::graph_traits::face_descriptor face_descriptor; CGAL_precondition(CGAL::is_triangle_mesh(tm)); face_descriptor fd = CGAL::internal::random_face_in_mesh(tm, rnd); - return random_location_on_face(fd, tm, rnd); + return random_location_on_face(fd, tm, rnd); } /// @} /// \ingroup PMP_locate_grp /// -/// \brief Given a location, that is an ordered pair composed of a -/// `boost::graph_traits::%face_descriptor` and an array -/// of barycentric coordinates, returns a descriptor to the simplex -/// of smallest dimension on which the point corresponding to the location lies. +/// \brief Given a location, returns a descriptor to the simplex of smallest dimension +/// on which the point corresponding to the location lies. /// /// \details In other words: /// - if the point lies on a vertex, this function returns a `boost::graph_traits::%vertex_descriptor` `v`; @@ -508,24 +500,30 @@ random_location_on_mesh(const TriangleMesh& tm, CGAL::Random& rnd = get_default_ /// - otherwise, this function returns a `boost::graph_traits::%face_descriptor` /// `fd` (equal to `loc.first`). /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam FT must be a model of `FieldNumberType` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// /// \param loc a location with `loc.first` a face of `tm` /// \param tm a triangulated surface mesh /// -/// \pre the location corresponds to a point that is within a face of `tm`. -/// \pre `loc` describes the barycentric coordinates of a point that lives on the face (boundary included), +/// \pre `loc.first` is a face descriptor corresponding to a face of `tm`. +/// \pre `loc` describes the barycentric coordinates of a point that lives within the face (boundary included), /// meaning the barycentric coordinates are all positive. /// -template -typename Location_traits::descriptor_variant -get_descriptor_from_location(const typename Location_traits::Face_location& loc, +template +descriptor_variant +#ifdef DOXYGEN_RUNNING // just for convenience because template alias do not allow template deduction +get_descriptor_from_location(const Face_location& loc, +#else +get_descriptor_from_location(const std::pair::face_descriptor, + std::array >& loc, +#endif const TriangleMesh& tm) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename Location_traits::Barycentric_coordinates Barycentric_coordinates; + typedef Barycentric_coordinates Barycentric_coordinates; const face_descriptor fd = loc.first; const Barycentric_coordinates& bar = loc.second; @@ -540,7 +538,7 @@ get_descriptor_from_location(const typename Location_traits::Face_ // check if the point is a vertex for(int i=0; i<3; ++i) { - if(bar[i] == 1) // coordinate at target(hd, tm) + if(bar[i] == FT(1)) // coordinate at target(hd, tm) return target(hd, tm); hd = next(hd, tm); } @@ -549,7 +547,7 @@ get_descriptor_from_location(const typename Location_traits::Face_ // check if the point is on an edge for(int i=0; i<3; ++i) { - if(bar[i] == 0) // coordinate at target(hd, tm) + if(bar[i] == FT(0)) // coordinate at target(hd, tm) return prev(hd, tm); hd = next(hd, tm); } @@ -559,15 +557,14 @@ get_descriptor_from_location(const typename Location_traits::Face_ /// \ingroup PMP_locate_grp /// -/// \brief Given a location, that is an ordered pair composed of a -/// `boost::graph_traits::%face_descriptor` and an array -/// of barycentric coordinates, returns the geometric position described +/// \brief Given a location in a face, returns the geometric position described /// by these coordinates, as a point. /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam FT must be a model of `FieldNumberType` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" /// -/// \param loc the location to transform into a point +/// \param loc the location from which a point is constructed /// \param tm a triangulated surface mesh /// \param np an optional sequence of \ref pmp_namedparameters "Named Parameters" among the ones listed below: /// @@ -578,44 +575,61 @@ get_descriptor_from_location(const typename Location_traits::Face_ /// `boost::vertex_point_t` must be available in `TriangleMesh`. /// \cgalParamEnd /// \cgalParamBegin{geom_traits} -/// a geometric traits class instance, model of `Kernel`. +/// a geometric traits class instance, model of `Kernel`. If such traits class is provided, +/// its type `FT` must be identical to the template parameter `FT` of this function. /// \cgalParamEnd /// \cgalNamedParamsEnd /// /// \pre `loc.first` is a face descriptor corresponding to a face of `tm`. /// -template -typename Location_traits::Point -construct_point(const typename Location_traits::Face_location& loc, +/// \returns a point whose type is the same as the value type of the vertex point property map +/// provided by the user or via named parameters, or the internal point map of the mesh `tm`. +/// +template +#ifdef DOXYGEN_RUNNING +Point +construct_point(const Face_location& loc, +#else +typename internal::Location_traits::Point +construct_point(const std::pair::face_descriptor, + std::array >& loc, +#endif const TriangleMesh& tm, const NamedParameters& np) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + typedef typename GetGeomTraits::type Geom_traits; + typedef typename GetVertexPointMap::const_type VertexPointMap; typedef typename boost::property_traits::value_type Point; - typedef typename GetGeomTraits::type Geom_traits; + typedef typename boost::property_traits::reference Point_reference; + using parameters::get_parameter; using parameters::choose_parameter; CGAL_precondition(CGAL::is_triangle_mesh(tm)); - VertexPointMap vpm = parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_point), get_const_property_map(boost::vertex_point, tm)); Geom_traits gt = choose_parameter(get_parameter(np, internal_np::geom_traits), Geom_traits()); halfedge_descriptor hd = halfedge(loc.first, tm); - const Point& p0 = get(vpm, source(hd, tm)); - const Point& p1 = get(vpm, target(hd, tm)); - const Point& p2 = get(vpm, target(next(hd, tm), tm)); + const Point_reference p0 = get(vpm, source(hd, tm)); + const Point_reference p1 = get(vpm, target(hd, tm)); + const Point_reference p2 = get(vpm, target(next(hd, tm), tm)); internal::Barycentric_point_constructor bp_constructor; return bp_constructor(p0, loc.second[0], p1, loc.second[1], p2, loc.second[2], gt); } -template +template typename property_map_value::type -construct_point(const typename Location_traits::Face_location& loc, +#ifdef DOXYGEN_RUNNING +construct_point(const Face_location& loc, +#else +construct_point(const std::pair::face_descriptor, + std::array >& loc, +#endif const TriangleMesh& tm) { return construct_point(loc, tm, parameters::all_default()); @@ -626,10 +640,7 @@ construct_point(const typename Location_traits::Face_location& loc /// \ingroup PMP_locate_grp /// -/// \brief Given a location, that is an ordered pair composed of a -/// `boost::graph_traits::%face_descriptor` and an array -/// of barycentric coordinates, returns whether the location is -/// on the vertex `vd` or not. +/// \brief Given a location, returns whether the location is on the vertex `vd` or not. /// /// \details If `tm` is the input triangulated surface mesh and given the pair (`f`, `bc`) /// such that `bc` is the triplet of barycentric coordinates `(w0, w1, w2)`, the correspondance @@ -638,7 +649,8 @@ construct_point(const typename Location_traits::Face_location& loc /// - `w1` corresponds to `target(halfedge(f, tm), tm)` /// - `w2` corresponds to `target(next(halfedge(f, tm), tm), tm)` /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam FT must be a model of `FieldNumberType` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// /// \param loc a location with `loc.first` a face of `tm` /// \param vd a vertex of `tm` @@ -646,19 +658,23 @@ construct_point(const typename Location_traits::Face_location& loc /// /// \pre `loc.first` is a face descriptor corresponding to a face of `tm`. /// -template +template bool -is_on_vertex(const typename Location_traits::Face_location& loc, +#ifdef DOXYGEN_RUNNING +is_on_vertex(const Face_location& loc, +#else +is_on_vertex(const std::pair::face_descriptor, + std::array >& loc, +#endif const typename boost::graph_traits::vertex_descriptor vd, const TriangleMesh& tm) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef typename Location_traits::descriptor_variant descriptor_variant; if(!is_in_face(loc, tm)) return false; - descriptor_variant dv = get_descriptor_from_location(loc, tm); + const descriptor_variant dv = get_descriptor_from_location(loc, tm); if(const vertex_descriptor* vd_ptr = boost::get(&dv)) return (vd == *vd_ptr); @@ -668,10 +684,7 @@ is_on_vertex(const typename Location_traits::Face_location& loc, /// \ingroup PMP_locate_grp /// -/// \brief Given a location, that is an ordered pair composed of a -/// `boost::graph_traits::%face_descriptor` and an array -/// of barycentric coordinates, returns whether the location is -/// on the halfedge `hd` or not. +/// \brief Given a location, returns whether this location is on the halfedge `hd` or not. /// /// \details If `tm` is the input triangulated surface mesh and given the pair (`f`, `bc`) /// such that `bc` is the triplet of barycentric coordinates `(w0, w1, w2)`, the correspondance @@ -680,7 +693,8 @@ is_on_vertex(const typename Location_traits::Face_location& loc, /// - `w1` corresponds to `target(halfedge(f, tm), tm)` /// - `w2` corresponds to `target(next(halfedge(f, tm), tm), tm)` /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam FT must be a model of `FieldNumberType` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// /// \param loc a location with `loc.first` a face of `tm` /// \param hd a halfedge of `tm` @@ -688,20 +702,24 @@ is_on_vertex(const typename Location_traits::Face_location& loc, /// /// \pre `loc.first` is a face descriptor corresponding to a face of `tm`. /// -template +template bool -is_on_halfedge(const typename Location_traits::Face_location& loc, +#ifdef DOXYGEN_RUNNING +is_on_halfedge(const Face_location& loc, +#else +is_on_halfedge(const std::pair::face_descriptor, + std::array >& loc, +#endif const typename boost::graph_traits::halfedge_descriptor hd, const TriangleMesh& tm) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef typename Location_traits::descriptor_variant descriptor_variant; if(!is_in_face(loc, tm)) return false; - descriptor_variant dv = get_descriptor_from_location(loc, tm); + const descriptor_variant dv = get_descriptor_from_location(loc, tm); if(const vertex_descriptor* vd_ptr = boost::get(&dv)) return (*vd_ptr == source(hd, tm) || *vd_ptr == target(hd, tm)); @@ -724,14 +742,19 @@ is_on_halfedge(const typename Location_traits::Face_location& loc, /// - `w1` corresponds to `target(halfedge(f, tm), tm)` /// - `w2` corresponds to `target(next(halfedge(f, tm), tm), tm)` /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam FT must be a model of `FieldNumberType` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// /// \param bar an array of barycentric coordinates /// \param tm a triangulated surface mesh /// -template +template bool -is_in_face(const typename Location_traits::Barycentric_coordinates& bar, +#ifdef DOXYGEN_RUNNING +is_in_face(const Barycentric_coordinates& bar, +#else +is_in_face(const std::array& bar, +#endif const TriangleMesh& tm) { CGAL_USE(tm); @@ -741,7 +764,7 @@ is_in_face(const typename Location_traits::Barycentric_coordinates { // "|| bar[i] > 1." is not needed because if everything is positive and the sum is '1', // then each coefficient is below '1'. - if(bar[i] < 0.) + if(bar[i] < FT(0)) return false; } @@ -750,10 +773,7 @@ is_in_face(const typename Location_traits::Barycentric_coordinates /// \ingroup PMP_locate_grp /// -/// \brief Given a location, that is an ordered pair composed of a -/// `boost::graph_traits::%face_descriptor` and an array -/// of barycentric coordinates, returns whether the location is -/// in the face (boundary included) or not. +/// \brief Given a location, returns whether the location is in the face (boundary included) or not. /// /// \details If `tm` is the input triangulated surface mesh and given the pair (`f`, `bc`) /// such that `bc` is the triplet of barycentric coordinates `(w0, w1, w2)`, the correspondance @@ -762,16 +782,22 @@ is_in_face(const typename Location_traits::Barycentric_coordinates /// - `w1` corresponds to `target(halfedge(f, tm), tm)` /// - `w2` corresponds to `target(next(halfedge(f, tm), tm), tm)` /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam FT must be a model of `FieldNumberType` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// /// \param loc a location with `loc.first` a face of `tm` /// \param tm a triangulated surface mesh /// /// \pre `loc.first` is a face descriptor corresponding to a face of `tm`. /// -template +template bool -is_in_face(const typename Location_traits::Face_location& loc, +#ifdef DOXYGEN_RUNNING +is_in_face(const Face_location& loc, +#else +is_in_face(const std::pair::face_descriptor, + std::array >& loc, +#endif const TriangleMesh& tm) { return is_in_face(loc.second, tm); @@ -779,10 +805,7 @@ is_in_face(const typename Location_traits::Face_location& loc, /// \ingroup PMP_locate_grp /// -/// \brief Given a location, that is an ordered pair composed of a -/// `boost::graph_traits::%face_descriptor` and an array -/// of barycentric coordinates, returns whether the location is on the boundary -/// of the face or not. +/// \brief Given a location, returns whether the location is on the boundary of the face or not. /// /// \details If `tm` is the input triangulated surface mesh and given the pair (`f`, `bc`) /// such that `bc` is the triplet of barycentric coordinates `(w0, w1, w2)`, the correspondance @@ -791,28 +814,31 @@ is_in_face(const typename Location_traits::Face_location& loc, /// - `w1` corresponds to `target(halfedge(f, tm), tm)` /// - `w2` corresponds to `target(next(halfedge(f, tm), tm), tm)` /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam FT must be a model of `FieldNumberType` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// /// \param loc a location with `loc.first` a face of `tm` /// \param tm a triangulated surface mesh /// /// \pre `loc.first` is a face descriptor corresponding to a face of `tm`. /// -template +template bool -is_on_face_border(const typename Location_traits::Face_location& loc, +#ifdef DOXYGEN_RUNNING +is_on_face_border(const Face_location& loc, +#else +is_on_face_border(const std::pair::face_descriptor, + std::array >& loc, +#endif const TriangleMesh& tm) { - typedef typename Location_traits::Face_location Face_location; - typedef typename Face_location::second_type Barycentric_coordinates; - if(!is_in_face(loc, tm)) return false; - const Barycentric_coordinates& bar = loc.second; + const Barycentric_coordinates& bar = loc.second; for(int i=0; i<3; ++i) - if(bar[i] == 0.) + if(bar[i] == FT(0)) return true; return false; @@ -820,10 +846,7 @@ is_on_face_border(const typename Location_traits::Face_location& l /// \ingroup PMP_locate_grp /// -/// \brief Given a location, that is an ordered pair composed of a -/// `boost::graph_traits::%face_descriptor` and an array -/// of barycentric coordinates, returns whether the location is -/// on the border of the mesh or not. +/// \brief Given a location, returns whether the location is on the border of the mesh or not. /// /// \details If `tm` is the input triangulated surface mesh and given the pair (`f`, `bc`) /// such that `bc` is the triplet of barycentric coordinates `(w0, w1, w2)`, the correspondance @@ -832,26 +855,29 @@ is_on_face_border(const typename Location_traits::Face_location& l /// - `w1` corresponds to `target(halfedge(f, tm), tm)` /// - `w2` corresponds to `target(next(halfedge(f, tm), tm), tm)` /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam FT must be a model of `FieldNumberType` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// /// \param loc a location with `loc.first` a face of `tm` /// \param tm a triangulated surface mesh /// /// \pre `loc.first` is a face descriptor corresponding to a face of `tm`. /// -template +template bool -is_on_mesh_border(const typename Location_traits::Face_location& loc, +#ifdef DOXYGEN_RUNNING +is_on_mesh_border(const Face_location& loc, +#else +is_on_mesh_border(const std::pair::face_descriptor, + std::array >& loc, +#endif const TriangleMesh& tm) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename Location_traits::Face_location Face_location; - typedef typename Face_location::second_type Barycentric_coordinates; - const face_descriptor fd = loc.first; - const Barycentric_coordinates& bar = loc.second; + const Barycentric_coordinates& bar = loc.second; if(!is_in_face(bar, tm)) return false; @@ -862,7 +888,7 @@ is_on_mesh_border(const typename Location_traits::Face_location& l // check if the point is a vertex for(int i=0; i<3; ++i) { - if(bar[i] == 1.) // coordinate at target(hd, tm) + if(bar[i] == FT(1)) // coordinate at target(hd, tm) return bool(CGAL::is_border(target(hd, tm), tm)); hd = next(hd, tm); } @@ -871,7 +897,7 @@ is_on_mesh_border(const typename Location_traits::Face_location& l // check if the point is on an edge for(int i=0; i<3; ++i) { - if(bar[i] == 0.) // coordinate at target(hd, tm) + if(bar[i] == FT(0)) // coordinate at target(hd, tm) return CGAL::is_border(edge(prev(hd, tm), tm), tm); hd = next(hd, tm); } @@ -898,41 +924,41 @@ is_on_mesh_border(const typename Location_traits::Face_location& l /// - `w1` corresponds to `target(halfedge(f, tm), tm)` /// - `w2` corresponds to `target(next(halfedge(f, tm), tm), tm)` /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam FT must be a model of `FieldNumberType` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// /// \param vd a vertex of `tm` /// \param tm a triangulated surface mesh /// /// \pre `vd` is not an isolated vertex /// -template -typename Location_traits::Face_location -locate_in_face(typename boost::graph_traits::vertex_descriptor vd, - const TriangleMesh& tm) +template +Face_location +locate_vertex(typename boost::graph_traits::vertex_descriptor vd, + const TriangleMesh& tm) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename Location_traits::FT FT; - typedef typename Location_traits::Face_location Face_location; + typedef Face_location Face_location; - halfedge_descriptor he = halfedge(vd, tm); + halfedge_descriptor hd = halfedge(vd, tm); - // Find a real face in case 'he' is a border halfedge - for(halfedge_descriptor hd : halfedges_around_target(he, tm)) + // Find a real face in case 'hd' is a border halfedge + for(halfedge_descriptor thd : halfedges_around_target(hd, tm)) { - if(!is_border(hd, tm)) + if(!is_border(thd, tm)) { - he = hd; + hd = thd; break; } } - CGAL_postcondition(!CGAL::is_border(he, tm)); // must find a 'real' face incident to 'vd' + CGAL_postcondition(!CGAL::is_border(hd, tm)); // must find a 'real' face incident to 'vd' - face_descriptor fd = face(he, tm); + face_descriptor fd = face(hd, tm); - CGAL_assertion(target(he, tm) == vd); + CGAL_assertion(target(hd, tm) == vd); CGAL_assertion(fd != boost::graph_traits::null_face()); // isolated vertex @@ -940,8 +966,8 @@ locate_in_face(typename boost::graph_traits::vertex_descriptor vd, return Face_location(); FT coords[3] = { FT(0), FT(0), FT(0) }; - he = next(he, tm); // so that source(he, tm) == vd and it's simpler to handle 'index_in_face' - std::size_t halfedge_local_index = halfedge_index_in_face(he, tm); + hd = next(hd, tm); // so that source(hd, tm) == vd and it's simpler to handle 'index_in_face' + int halfedge_local_index = halfedge_index_in_face(hd, tm); coords[halfedge_local_index] = FT(1); return std::make_pair(fd, CGAL::make_array(coords[0], coords[1], coords[2])); @@ -960,7 +986,8 @@ locate_in_face(typename boost::graph_traits::vertex_descriptor vd, /// - `w1` corresponds to `target(halfedge(f, tm), tm)` /// - `w2` corresponds to `target(next(halfedge(f, tm), tm), tm)` /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam FT must be a model of `FieldNumberType` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// /// \param vd a vertex of `tm` and a vertex of the face `fd` /// \param fd a face of `tm` @@ -968,14 +995,12 @@ locate_in_face(typename boost::graph_traits::vertex_descriptor vd, /// /// \pre `fd` is not the null face /// -template -typename Location_traits::Face_location -locate_in_face(const typename boost::graph_traits::vertex_descriptor vd, - const typename boost::graph_traits::face_descriptor fd, - const TriangleMesh& tm) +template +Face_location +locate_vertex(const typename boost::graph_traits::vertex_descriptor vd, + const typename boost::graph_traits::face_descriptor fd, + const TriangleMesh& tm) { - typedef typename Location_traits::FT FT; - CGAL_precondition(fd != boost::graph_traits::null_face()); FT coords[3] = { FT(0), FT(0), FT(0) }; @@ -987,8 +1012,8 @@ locate_in_face(const typename boost::graph_traits::vertex_descript /// \ingroup PMP_locate_grp /// -/// \brief Given a point described by a halfedge `he` and a scalar `t` -/// as `p = (1 - t) * source(he, tm) + t * target(he, tm)`, +/// \brief Given a point described by a halfedge `hd` and a scalar `t` +/// as `p = (1 - t) * source(hd, tm) + t * target(hd, tm)`, /// returns this location along the given edge as a location, that is /// an ordered pair specifying a face containing the location and the /// barycentric coordinates of that location in that face. @@ -1000,23 +1025,23 @@ locate_in_face(const typename boost::graph_traits::vertex_descript /// - `w1` corresponds to `target(halfedge(f, tm), tm)` /// - `w2` corresponds to `target(next(halfedge(f, tm), tm), tm)` /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam FT must be a model of `FieldNumberType` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// -/// \param he a halfedge of `tm` -/// \param t the parametric distance of the desired point along `he` +/// \param hd a halfedge of `tm` +/// \param t the parametric distance of the desired point along `hd` /// \param tm a triangulated surface mesh /// -template -typename Location_traits::Face_location -locate_in_face(const typename boost::graph_traits::halfedge_descriptor he, - const typename Location_traits::FT t, - const TriangleMesh& tm) +template +Face_location +locate_on_halfedge(const typename boost::graph_traits::halfedge_descriptor hd, + const FT t, + const TriangleMesh& tm) { typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename Location_traits::FT FT; - face_descriptor fd = face(he, tm); - std::size_t edge_local_index = halfedge_index_in_face(he, tm); + face_descriptor fd = face(hd, tm); + int edge_local_index = halfedge_index_in_face(hd, tm); const FT one_minus_t(FT(1) - t); FT coords[3] = { FT(0), FT(0), FT(0) }; @@ -1040,10 +1065,11 @@ locate_in_face(const typename boost::graph_traits::halfedge_descri /// - `w1` corresponds to `target(halfedge(f, tm), tm)` /// - `w2` corresponds to `target(next(halfedge(f, tm), tm), tm)` /// -/// \tparam TriangleMesh a model of `FaceGraph` +/// \tparam TriangleMesh must be a model of `FaceGraph` /// \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" /// -/// \param query a point +/// \param query a point, whose type is equal to the value type of the vertex point property map +/// (either user-provided via named parameters or the internal point map of the mesh `tm`) /// \param fd a face of `tm` /// \param tm a triangulated surface mesh /// \param np an optional sequence of \ref pmp_namedparameters "Named Parameters" among the ones listed below: @@ -1055,7 +1081,9 @@ locate_in_face(const typename boost::graph_traits::halfedge_descri /// `boost::vertex_point_t` must be available in `TriangleMesh`. /// \cgalParamEnd /// \cgalParamBegin{geom_traits} -/// a geometric traits class instance, model of `Kernel`. +/// a geometric traits class instance, model of `Kernel`. If provided, the types `FT` and `Kernel::FT` +/// must be identical and the traits class must be compatible with the value type of the vertex point +/// property map. /// \cgalParamEnd /// \cgalParamBegin{snapping_tolerance} /// a tolerance value used to snap barycentric coordinates. Depending on the geometric traits used, @@ -1068,21 +1096,31 @@ locate_in_face(const typename boost::graph_traits::halfedge_descri /// /// \pre `fd` is not the null face /// +/// \returns a face location. The type `FT` is deduced from the geometric traits, either provided by +/// the user via named parameters (with `geom_traits`) or using `CGAL::Kernel_traits` +/// and the point type of the vertex point property map in use. +/// template -typename Location_traits::Face_location -locate_in_face(const typename Location_traits::Point& query, +#ifdef DOXYGEN_RUNNING +Face_location +locate_in_face(const Point& query, +#else +typename internal::Location_traits::Face_location +locate_in_face(const typename internal::Location_traits::Point& query, +#endif const typename boost::graph_traits::face_descriptor fd, const TriangleMesh& tm, const NamedParameters& np) { - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef typename Location_traits::FT FT; + typedef typename GetVertexPointMap::const_type VertexPointMap; + typedef typename boost::property_traits::value_type Point; + typedef typename boost::property_traits::reference Point_reference; + + typedef typename GetGeomTraits::type Geom_traits; + typedef typename Geom_traits::FT FT; - // VertexPointMap - typedef typename GetGeomTraits::type Geom_traits; - typedef typename GetVertexPointMap::const_type VertexPointMap; - typedef typename boost::property_traits::value_type Point; using parameters::get_parameter; using parameters::choose_parameter; @@ -1098,9 +1136,9 @@ locate_in_face(const typename Location_traits::Po vertex_descriptor vd1 = target(halfedge(fd, tm), tm); vertex_descriptor vd2 = target(next(halfedge(fd, tm), tm), tm); - const Point& p0 = get(vpm, vd0); - const Point& p1 = get(vpm, vd1); - const Point& p2 = get(vpm, vd2); + const Point_reference p0 = get(vpm, vd0); + const Point_reference p1 = get(vpm, vd1); + const Point_reference p2 = get(vpm, vd2); std::array coords = barycentric_coordinates(p0, p1, p2, query, gt); @@ -1111,7 +1149,7 @@ locate_in_face(const typename Location_traits::Po // Try to to snap the coordinates, hoping the problem is just a -1e-17ish epsilon // pushing the coordinates over the edge - internal::snap_coordinates_to_border(coords, snap_tolerance); + internal::snap_coordinates_to_border(coords, snap_tolerance); } return std::make_pair(fd, coords); @@ -1119,8 +1157,8 @@ locate_in_face(const typename Location_traits::Po #ifndef DOXYGEN_RUNNING // because this is in the middle of a @{ @} doxygen group template -typename Location_traits::Face_location -locate_in_face(const typename property_map_value::type& query, +typename internal::Location_traits::Face_location +locate_in_face(const typename internal::Location_traits::Point& query, const typename boost::graph_traits::face_descriptor f, const TriangleMesh& tm) { @@ -1130,10 +1168,7 @@ locate_in_face(const typename property_map_value::%face_descriptor` and an array -/// of barycentric coordinates, and a second face adjacent to the first, -/// return the location of the point in the second face. +/// \brief Given a location and a second face adjacent to the first, returns the location of the point in the second face. /// /// \details If `tm` is the input triangulated surface mesh and given the pair (`f`, `bc`) /// such that `bc` is the triplet of barycentric coordinates `(w0, w1, w2)`, the correspondance @@ -1142,41 +1177,40 @@ locate_in_face(const typename property_map_value -typename Location_traits::Face_location -locate_in_adjacent_face(const typename Location_traits::Face_location& loc, +template +Face_location +#ifdef DOXYGEN_RUNNING +locate_in_adjacent_face(const Face_location& loc, +#else +locate_in_adjacent_face(const std::pair::face_descriptor, + std::array >& loc, +#endif const typename boost::graph_traits::face_descriptor fd, const TriangleMesh& tm) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - - typedef boost::variant descriptor_variant; - - typedef typename Location_traits::Face_location Face_location; - typedef typename Location_traits::FT FT; + CGAL_assertion_code(typedef typename boost::graph_traits::face_descriptor face_descriptor;) if(loc.first == fd) return loc; - Face_location loc_in_fd = std::make_pair(fd, CGAL::make_array(FT(0), FT(0), FT(0))); - descriptor_variant dv = get_descriptor_from_location(loc, tm); + Face_location loc_in_fd = std::make_pair(fd, CGAL::make_array(FT(0), FT(0), FT(0))); + const descriptor_variant dv = get_descriptor_from_location(loc, tm); if(const vertex_descriptor* vd_ptr = boost::get(&dv)) { int index_of_vd = vertex_index_in_face(*vd_ptr, fd, tm); - loc_in_fd.second[index_of_vd] = 1.; + loc_in_fd.second[index_of_vd] = FT(1); // Note that the barycentric coordinates were initialized to 0, // so the second and third coordinates are already set up properly. } @@ -1225,21 +1259,22 @@ locate_in_adjacent_face(const typename Location_traits::Face_locat // - the first location must be known // - the second must be a point in a face incident to get_descriptor_from_location(known_location) // note: not returning the query location to emphasis that the known location can change too. -template +template bool -locate_in_common_face(typename Location_traits::Face_location& known_location, - const typename Location_traits::Point& query, - typename Location_traits::Face_location& query_location, +locate_in_common_face(std::pair::face_descriptor, + std::array >& known_location, + const typename internal::Location_traits::Point& query, + std::pair::face_descriptor, + std::array >& query_location, const TriangleMesh& tm, - const typename Location_traits::FT tolerance = - std::numeric_limits::FT>::epsilon()) + const NamedParameters& np, + const FT tolerance = std::numeric_limits::epsilon()) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef boost::variant descriptor_variant; - descriptor_variant dv = get_descriptor_from_location(known_location, tm); + descriptor_variant dv = get_descriptor_from_location(known_location, tm); bool is_query_location_in_face = false; @@ -1254,8 +1289,8 @@ locate_in_common_face(typename Location_traits::Face_location& kno continue; // check if 'query' can be found in that face - query_location = locate_in_face(query, fd, tm); - internal::snap_location_to_border(query_location, tolerance); // @tmp keep or not ? + query_location = locate_in_face(query, fd, tm, np); + internal::snap_location_to_border(query_location, tm, tolerance); // @tmp keep or not ? is_query_location_in_face = is_in_face(query_location, tm); @@ -1270,15 +1305,15 @@ locate_in_common_face(typename Location_traits::Face_location& kno if(fd != boost::graph_traits::null_face()) { - query_location = locate_in_face(query, fd, tm); - internal::snap_location_to_border(query_location, tolerance); // @tmp keep or not ? + query_location = locate_in_face(query, fd, tm, np); + internal::snap_location_to_border(query_location, tm, tolerance); // @tmp keep or not ? is_query_location_in_face = is_in_face(query_location, tm); } if(!is_query_location_in_face) { fd = face(opposite(hd, tm), tm); - query_location = locate_in_face(query, fd, tm); + query_location = locate_in_face(query, fd, tm, np); is_query_location_in_face = is_in_face(query_location, tm); } } @@ -1288,8 +1323,8 @@ locate_in_common_face(typename Location_traits::Face_location& kno CGAL_precondition(fd != boost::graph_traits::null_face()); - query_location = locate_in_face(query, fd, tm); - internal::snap_location_to_border(query_location, tolerance); // @tmp keep or not ? + query_location = locate_in_face(query, fd, tm, np); + internal::snap_location_to_border(query_location, tm, tolerance); // @tmp keep or not ? is_query_location_in_face = is_in_face(query_location, tm); } @@ -1302,10 +1337,12 @@ locate_in_common_face(typename Location_traits::Face_location& kno // Finding a common face to two locations // - both locations must be known but can change -template +template bool -locate_in_common_face(typename Location_traits::Face_location& first_location, - typename Location_traits::Face_location& second_location, +locate_in_common_face(std::pair::face_descriptor, + std::array >& first_location, + std::pair::face_descriptor, + std::array >& second_location, const TriangleMesh& tm) { typedef typename boost::graph_traits::face_descriptor face_descriptor; @@ -1371,38 +1408,38 @@ locate_in_common_face(typename Location_traits::Face_location& fir namespace internal { -template::value> +template ::value> struct Point_to_Point_3 // 2D case { - typedef typename Location_traits::Geom_traits::Point_3 Point_3; + typedef typename GetGeomTraits::type::Point_3 Point_3; Point_3 operator()(const Point& p) const { return Point_3(p.x(), p.y(), 0); } }; -template +template struct Point_to_Point_3::Geom_traits::Point_3, + typename GetGeomTraits::type::Point_3, 3> // 3D case with nothing to do { - typedef typename Location_traits::Geom_traits::Point_3 Point_3; + typedef typename GetGeomTraits::type::Point_3 Point_3; const Point_3& operator()(const Point_3& p) const { return p; } }; -template +template struct Point_to_Point_3 // Generic 3D case { - typedef typename Location_traits::Geom_traits::Point_3 Point_3; + typedef typename GetGeomTraits::type::Point_3 Point_3; Point_3 operator()(const Point& p) const { return Point_3(p.x(), p.y(), p.z()); } }; -template +template struct Ray_to_Ray_3 // 2D case { - typedef typename Location_traits::Geom_traits Geom_traits; + typedef typename GetGeomTraits::type Geom_traits; typedef typename Geom_traits::Ray_2 Ray_2; typedef typename Geom_traits::Ray_3 Ray_3; typedef Point_to_Point_3 P2_to_P3; @@ -1417,9 +1454,9 @@ struct Ray_to_Ray_3 // 2D case }; // Readable property map that converts the output of a given vertex point map to a 3D point -template::const_type> +template ::const_type> struct Point_to_Point_3_VPM { private: @@ -1502,7 +1539,7 @@ void build_AABB_tree(const TriangleMesh& tm, /// to call location functions on more than a single point (or ray) should first compute an AABB /// tree to store it (otherwise, it will be recomputed every time). Note that since the AABB tree /// class is a 3D structure, it might be required to wrap your point property map to convert your -/// point type to the 3D point type (i.e., your kernel's `%Point_3`) if you are working +/// point type to the 3D point type (i.e., your traits' `%Point_3`) if you are working /// with a 2D triangle structure. /// /// @{ @@ -1516,9 +1553,9 @@ void build_AABB_tree(const TriangleMesh& tm, /// `locate_with_AABB_tree()` that takes as parameter an AABB tree, instead of calling `locate()` /// multiple times, which will build a new AABB tree on every call. /// -/// \tparam TriangleMesh a model of `FaceListGraph` -/// \tparam Point3VPM a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` -/// as key type and the \cgal 3D point type (your kernel's `%Point_3`) as value type. +/// \tparam TriangleMesh must be a model of `FaceListGraph` +/// \tparam Point3VPM must be a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` +/// as key type and the \cgal 3D point type (your traits' `%Point_3`) as value type. /// \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" /// /// \param tm a triangulated surface mesh @@ -1531,18 +1568,28 @@ void build_AABB_tree(const TriangleMesh& tm, /// If this parameter is omitted, an internal property map for /// `boost::vertex_point_t` must be available in `TriangleMesh`. /// \cgalParamEnd +/// \cgalParamBegin{geom_traits} +/// a geometric traits class instance, model of `Kernel` compatible with the point type held +/// in the vertex point property map (either user-provided or internal to the mesh). +/// Must be identical to the traits used in the template parameter of the `AABB_traits`. +/// \cgalParamEnd /// \cgalNamedParamsEnd /// template -void build_AABB_tree(const TriangleMesh& tm, - AABB_tree< - CGAL::AABB_traits< - typename Location_traits::Geom_traits, - CGAL::AABB_face_graph_triangle_primitive - > >& outTree, - const NamedParameters& np) +void +build_AABB_tree(const TriangleMesh& tm, + AABB_tree< + AABB_traits< +#ifdef DOXYGEN_RUNNING + Geom_traits, +#else + typename GetGeomTraits::type, +#endif + CGAL::AABB_face_graph_triangle_primitive > >& outTree, + const NamedParameters& np) { typedef typename GetVertexPointMap::const_type VertexPointMap; + using parameters::get_parameter; using parameters::choose_parameter; @@ -1554,8 +1601,7 @@ void build_AABB_tree(const TriangleMesh& tm, #ifndef DOXYGEN_RUNNING template -void build_AABB_tree(const TriangleMesh& tm, - AABB_tree& outTree) +void build_AABB_tree(const TriangleMesh& tm, AABB_tree& outTree) { return build_AABB_tree(tm, outTree, parameters::all_default()); } @@ -1569,9 +1615,9 @@ void build_AABB_tree(const TriangleMesh& tm, /// is a 2D triangulation, or a CGAL::Surface_mesh >), as long as an appropriate /// vertex point property map is passed in the AABB tree, which will convert from 2D to 3D. /// -/// \tparam TriangleMesh a model of `FaceListGraph` -/// \tparam Point3VPM a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` -/// as key type and the \cgal 3D point type (your kernel's `%Point_3`) as value type. +/// \tparam TriangleMesh must be a model of `FaceListGraph` +/// \tparam Point3VPM must be a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` +/// as key type and the \cgal 3D point type (your traits' `%Point_3`) as value type. /// \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" /// /// \param p the point to locate on the input triangulated surface mesh @@ -1586,9 +1632,11 @@ void build_AABB_tree(const TriangleMesh& tm, /// `boost::vertex_point_t` must be available in `TriangleMesh`. /// \cgalParamEnd /// \cgalParamBegin{geom_traits} -/// a geometric traits class instance, model of `Kernel`. +/// a geometric traits class instance, model of `Kernel` compatible with the point type held +/// in the vertex point property map (either user-provided or internal to the mesh). +/// Must be identical to the traits used in the template parameter of the `AABB_traits`. /// \cgalParamEnd -/// \cgalParamBegin{snapping_tolerance} +/// \cgalParamBegin{snapping_tolerance} /// a tolerance value used to snap barycentric coordinates. Depending on the geometric traits used, /// the computation of the barycentric coordinates might be an inexact construction, thus leading /// to sometimes surprising values (e.g. a triplet `[0.5, 0.5, -1-e17]` for a point at the middle @@ -1597,36 +1645,47 @@ void build_AABB_tree(const TriangleMesh& tm, /// \cgalParamEnd /// \cgalNamedParamsEnd /// +/// \returns a face location. The type `FT` is deduced from the geometric traits, either provided by +/// the user via named parameters (with `geom_traits`) or using `CGAL::Kernel_traits` +/// and the point type of the vertex point property map in use. +/// template -typename Location_traits::Face_location -locate_with_AABB_tree(const typename Location_traits::Point& p, - const AABB_tree< - CGAL::AABB_traits< - typename Location_traits::Geom_traits, - CGAL::AABB_face_graph_triangle_primitive - > >& tree, +#ifdef DOXYGEN_RUNNING +Face_location +locate_with_AABB_tree(const Point& p, + const AABB_tree > >& tree, +#else +typename internal::Location_traits::Face_location +locate_with_AABB_tree(const typename internal::Location_traits::Point& p, + const AABB_tree::type, + CGAL::AABB_face_graph_triangle_primitive > >& tree, +#endif const TriangleMesh& tm, const NamedParameters& np) { - typedef typename Location_traits::Point Point; - typedef internal::Point_to_Point_3 P_to_P3; - typedef typename boost::property_traits::value_type Point_3; + typedef typename internal::Location_traits::Point Point; + typedef internal::Point_to_Point_3 P_to_P3; + typedef typename boost::property_traits::value_type Point_3; CGAL_static_assertion((std::is_same::value)); - typedef typename Location_traits::Geom_traits Geom_traits; - typedef typename CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef typename CGAL::AABB_traits AABB_traits; + typedef typename GetGeomTraits::type Geom_traits; + typedef typename CGAL::AABB_face_graph_triangle_primitive Primitive; + typedef typename CGAL::AABB_traits AABB_traits; - typedef typename GetVertexPointMap::const_type VertexPointMap; - typedef internal::Point_to_Point_3_VPM WrappedVPM; + typedef typename GetVertexPointMap::const_type VertexPointMap; + typedef internal::Point_to_Point_3_VPM WrappedVPM; const Point_3& p3 = P_to_P3()(p); typename AABB_tree::Point_and_primitive_id result = tree.closest_point_and_primitive(p3); + typedef typename GetGeomTraits::type Geom_traits; + using parameters::get_parameter; using parameters::choose_parameter; - // The VPM might return a point of any dimension, but the AABB tree necessarily returns + // The VPM might return a point of any dimension, but the AABB tree necl1671essarily returns // a Point_3. So, wrap the VPM (again) to give a Point_3. Even if it's already wrapped, we're just // forwarding a const& anyway. const VertexPointMap vpm = parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_point), @@ -1638,8 +1697,8 @@ locate_with_AABB_tree(const typename Location_traits -typename Location_traits::Face_location -locate_with_AABB_tree(const typename Location_traits::Point& p, +typename internal::Location_traits::Face_location +locate_with_AABB_tree(const typename internal::Location_traits::Point& p, const AABB_tree& tree, const TriangleMesh& tm) { @@ -1655,7 +1714,7 @@ locate_with_AABB_tree(const typename Location_traits::Point& p, /// to call this function more than once, first use `build_AABB_tree()` to create a /// an AABB tree that you can store and use the function `locate_with_AABB_tree()`. /// -/// \tparam TriangleMesh a model of `FaceListGraph`. +/// \tparam TriangleMesh must be a model of `FaceListGraph`. /// \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" /// /// \param p the point to locate on the input triangulated surface mesh @@ -1669,7 +1728,8 @@ locate_with_AABB_tree(const typename Location_traits::Point& p, /// `boost::vertex_point_t` must be available in `TriangleMesh`. /// \cgalParamEnd /// \cgalParamBegin{geom_traits} -/// a geometric traits class instance, model of `Kernel`. +/// a geometric traits class instance, model of `Kernel` compatible with the point type held +/// in the vertex point property map (either user-provided or internal to the mesh). /// \cgalParamEnd /// \cgalParamBegin{snapping_tolerance} /// a tolerance value used to snap barycentric coordinates. Depending on the geometric traits used, @@ -1681,24 +1741,29 @@ locate_with_AABB_tree(const typename Location_traits::Point& p, /// \cgalNamedParamsEnd /// template -typename Location_traits::Face_location -locate(const typename Location_traits::Point& p, +#ifdef DOXYGEN_RUNNING +Face_location +locate(const Point& p, +#else +typename internal::Location_traits::Face_location +locate(const typename internal::Location_traits::Point& p, +#endif const TriangleMesh& tm, const NamedParameters& np) { // Wrap the input VPM with a one converting to 3D (costs nothing if the input VPM // already has value type Kernel::Point_3) - typedef typename GetVertexPointMap::const_type VertexPointMap; - typedef internal::Point_to_Point_3_VPM WrappedVPM; - typedef typename Location_traits::Point Intrinsic_point; + typedef typename GetVertexPointMap::const_type VertexPointMap; + typedef internal::Point_to_Point_3_VPM WrappedVPM; + typedef typename internal::Location_traits::Point Intrinsic_point; - typedef AABB_face_graph_triangle_primitive AABB_face_graph_primitive; - typedef CGAL::AABB_traits< - typename Location_traits::Geom_traits, - AABB_face_graph_primitive> AABB_face_graph_traits; + typedef typename GetGeomTraits::type Geom_traits; - typedef internal::Point_to_Point_3 P_to_P3; - typedef typename AABB_face_graph_traits::Point_3 Point_3; + typedef AABB_face_graph_triangle_primitive AABB_face_graph_primitive; + typedef CGAL::AABB_traits AABB_face_graph_traits; + + typedef internal::Point_to_Point_3 P_to_P3; + typedef typename AABB_face_graph_traits::Point_3 Point_3; using parameters::get_parameter; using parameters::choose_parameter; @@ -1718,7 +1783,7 @@ locate(const typename Location_traits::Point& p, #ifndef DOXYGEN_RUNNING template -typename Location_traits::Face_location +typename internal::Location_traits::Face_location locate(const typename property_map_value::type& p, const TriangleMesh& tm) { @@ -1732,9 +1797,9 @@ locate(const typename property_map_value::t /// /// If the ray does not intersect the mesh, a default constructed location is returned. /// -/// \tparam TriangleMesh a model of `FaceListGraph`. -/// \tparam Point3VPM a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` -/// as key type and the \cgal 3D point type (your kernel's `%Point_3`) as value type. +/// \tparam TriangleMesh must be a model of `FaceListGraph`. +/// \tparam Point3VPM must be a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` +/// as key type and the \cgal 3D point type (your traits' `%Point_3`) as value type. /// \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" /// /// \param ray a ray to intersect with the input triangulated surface mesh @@ -1749,7 +1814,9 @@ locate(const typename property_map_value::t /// `boost::vertex_point_t` must be available in `TriangleMesh`. /// \cgalParamEnd /// \cgalParamBegin{geom_traits} -/// a geometric traits class instance, model of `Kernel`. +/// a geometric traits class instance, model of `Kernel` compatible with the point type held +/// in the vertex point property map (either user-provided or internal to the mesh). +/// Must be identical to the traits used in the template parameter of the `AABB_traits`. /// \cgalParamEnd /// \cgalParamBegin{snapping_tolerance} /// a tolerance value used to snap barycentric coordinates. Depending on the geometric traits used, @@ -1760,34 +1827,42 @@ locate(const typename property_map_value::t /// \cgalParamEnd /// \cgalNamedParamsEnd /// +/// \pre `ray` is an object with the same ambient dimension as the point type (the value type of the vertex point map). +/// template -typename Location_traits::Face_location -locate_with_AABB_tree(const typename Location_traits::Ray& ray, +#ifdef DOXYGEN_RUNNING +Face_location +locate_with_AABB_tree(const Ray& ray, + const AABB_tree > >& tree, +#else +typename internal::Location_traits::Face_location +locate_with_AABB_tree(const typename internal::Location_traits::Ray& ray, const AABB_tree< CGAL::AABB_traits< - typename Location_traits::Geom_traits, + typename GetGeomTraits::type, CGAL::AABB_face_graph_triangle_primitive > >& tree, +#endif const TriangleMesh& tm, const NamedParameters& np) { - typedef typename Location_traits::Geom_traits Geom_traits; + typedef typename GetGeomTraits::type Geom_traits; - typedef typename Geom_traits::FT FT; - typedef typename Geom_traits::Point_3 Point_3; - typedef typename Geom_traits::Ray_3 Ray_3; + typedef typename Geom_traits::FT FT; + typedef typename Geom_traits::Point_3 Point_3; + typedef typename Geom_traits::Ray_3 Ray_3; - typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename GetVertexPointMap::const_type VertexPointMap; - typedef internal::Point_to_Point_3_VPM WrappedVPM; - typedef internal::Ray_to_Ray_3 R_to_R3; + typedef typename GetVertexPointMap::const_type VertexPointMap; + typedef internal::Point_to_Point_3_VPM WrappedVPM; + typedef internal::Ray_to_Ray_3 R_to_R3; - typedef typename CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef typename CGAL::AABB_traits AABB_traits; - typedef AABB_tree AABB_face_graph_tree; + typedef typename CGAL::AABB_face_graph_triangle_primitive Primitive; + typedef typename CGAL::AABB_traits AABB_traits; + typedef AABB_tree AABB_face_graph_tree; typedef typename AABB_face_graph_tree::template Intersection_and_primitive_id::Type Intersection_type; - typedef boost::optional Ray_intersection; + typedef boost::optional Ray_intersection; using parameters::get_parameter; using parameters::choose_parameter; @@ -1840,8 +1915,8 @@ locate_with_AABB_tree(const typename Location_traits -typename Location_traits::Face_location -locate_with_AABB_tree(const typename Location_traits::Ray& ray, +typename internal::Location_traits::Face_location +locate_with_AABB_tree(const typename internal::Location_traits::Ray& ray, const AABB_tree& tree, const TriangleMesh& tm) { @@ -1860,7 +1935,7 @@ locate_with_AABB_tree(const typename Location_traits::Ray& ray, /// copy of the `AABB_tree`, and use the overloads of this function /// that accept a reference to an AABB tree as input. /// -/// \tparam TriangleMesh a model of `FaceListGraph`. +/// \tparam TriangleMesh must be a model of `FaceListGraph`. /// \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" /// /// \param ray a ray to intersect with the input triangulated surface mesh @@ -1874,9 +1949,10 @@ locate_with_AABB_tree(const typename Location_traits::Ray& ray, /// `boost::vertex_point_t` must be available in `TriangleMesh`. /// \cgalParamEnd /// \cgalParamBegin{geom_traits} -/// a geometric traits class instance, model of `Kernel`. +/// a geometric traits class instance, model of `Kernel` compatible with the point type held +/// in the vertex point property map (either user-provided or internal to the mesh). /// \cgalParamEnd -/// \cgalParamBegin{snapping_tolerance} +/// \cgalParamBegin{snapping_tolerance} /// a tolerance value used to snap barycentric coordinates. Depending on the geometric traits used, /// the computation of the barycentric coordinates might be an inexact construction, thus leading /// to sometimes surprising values (e.g. a triplet `[0.5, 0.5, -1-e17]` for a point at the middle @@ -1885,9 +1961,16 @@ locate_with_AABB_tree(const typename Location_traits::Ray& ray, /// \cgalParamEnd /// \cgalNamedParamsEnd /// +/// \pre `ray` is an object with the same ambient dimension as the point type (the value type of the vertex point map). +/// template -typename Location_traits::Face_location -locate(const typename Location_traits::Ray& ray, +#ifdef DOXYGEN_RUNNING +Face_location +locate(const Ray& ray, +#else +typename internal::Location_traits::Face_location +locate(const typename internal::Location_traits::Ray& ray, +#endif const TriangleMesh& tm, const NamedParameters& np) { @@ -1897,9 +1980,10 @@ locate(const typename Location_traits::Ray& ray, // already has value type Geom_traits::Point_3) typedef internal::Point_to_Point_3_VPM VPM; + typedef typename GetGeomTraits::type Geom_traits; + typedef AABB_face_graph_triangle_primitive AABB_face_graph_primitive; - typedef CGAL::AABB_traits::Geom_traits, - AABB_face_graph_primitive> AABB_face_graph_traits; + typedef CGAL::AABB_traits AABB_face_graph_traits; using parameters::get_parameter; using parameters::choose_parameter; @@ -1915,9 +1999,9 @@ locate(const typename Location_traits::Ray& ray, #ifndef DOXYGEN_RUNNING template -typename Location_traits::Face_location +typename internal::Location_traits::Face_location locate(const typename internal::Ray_type_selector< - typename Location_traits::Point>::type& ray, + typename internal::Location_traits::Point>::type& ray, const TriangleMesh& tm) { return locate(ray, tm, parameters::all_default()); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h index 1d713155870..555b63fff70 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h @@ -74,7 +74,6 @@ namespace internal { if(do_project) { tree.rebuild(faces(tmesh).first, faces(tmesh).second, tmesh); - tree.accelerate_distance_queries(); } typename GT::Construct_translated_point_3 translate = gt.construct_translated_point_3_object(); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_mesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_mesh.h index 3cb883f11d2..bbe02cfda6b 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_mesh.h @@ -221,7 +221,6 @@ void smooth_mesh(const FaceRange& faces, } Tree aabb_tree(input_triangles.begin(), input_triangles.end()); - aabb_tree.accelerate_distance_queries(); // Setup the working ranges and check some preconditions Angle_smoother angle_smoother(tmesh, vpmap, vcmap, gt); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h index 5bad5aa49f5..6a2a519fca4 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h @@ -799,12 +799,15 @@ std::size_t stitch_boundary_cycles(PolygonMesh& pm) } ///\cond SKIP_IN_MANUAL +// The VPM is only used here for debugging info purposes as in this overload, the halfedges +// to stitch are already provided and all further checks are combinatorial and not geometrical. +// There is thus nothing interesting to pass via named parameters and this overload is not documented. template -void stitch_borders(PolygonMesh& pmesh, - const HalfedgePairsRange& hedge_pairs_to_stitch, - const CGAL_PMP_NP_CLASS& np) +std::size_t stitch_borders(PolygonMesh& pmesh, + const HalfedgePairsRange& hedge_pairs_to_stitch, + const CGAL_PMP_NP_CLASS& np) { using parameters::choose_parameter; using parameters::get_parameter; @@ -813,7 +816,7 @@ void stitch_borders(PolygonMesh& pmesh, VPMap vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(vertex_point, pmesh)); - internal::stitch_borders_impl(pmesh, hedge_pairs_to_stitch, vpm); + return internal::stitch_borders_impl(pmesh, hedge_pairs_to_stitch, vpm); } ///\endcond @@ -834,13 +837,15 @@ void stitch_borders(PolygonMesh& pmesh, * @param pmesh the polygon mesh to be modified by stitching * @param hedge_pairs_to_stitch a range of `std::pair` of halfedges to be stitched together * +* @return the number of pairs of halfedges that were stitched. +* */ template -void stitch_borders(PolygonMesh& pmesh, +std::size_t stitch_borders(PolygonMesh& pmesh, const HalfedgePairsRange& hedge_pairs_to_stitch) { - stitch_borders(pmesh, hedge_pairs_to_stitch, CGAL::parameters::all_default()); + return stitch_borders(pmesh, hedge_pairs_to_stitch, CGAL::parameters::all_default()); } /// \ingroup PMP_repairing_grp @@ -869,11 +874,14 @@ void stitch_borders(PolygonMesh& pmesh, /// \cgalParamBegin{face_index_map} a property map containing the index of each face of `pmesh` \cgalParamEnd /// \cgalNamedParamsEnd /// +/// @return the number of pairs of halfedges that were stitched. +/// /// @sa `stitch_boundary_cycle()` /// @sa `stitch_boundary_cycles()` /// template -void stitch_borders(PolygonMesh& pmesh, const CGAL_PMP_NP_CLASS& np) +std::size_t stitch_borders(PolygonMesh& pmesh, + const CGAL_PMP_NP_CLASS& np) { using parameters::choose_parameter; using parameters::get_parameter; @@ -902,26 +910,27 @@ void stitch_borders(PolygonMesh& pmesh, const CGAL_PMP_NP_CLASS& np) internal::Less_for_halfedge(pmesh, vpm), vpm, np); - stitch_borders(pmesh, hedge_pairs_to_stitch, np); + res += stitch_borders(pmesh, hedge_pairs_to_stitch, np); #ifdef CGAL_PMP_STITCHING_DEBUG + std::cout << "------- Stitched " << res << " after cycles & general" << std::endl; std::cout << "------- Stitch cycles (#2)..." << std::endl; #endif res += stitch_boundary_cycles(pmesh, np); #ifdef CGAL_PMP_STITCHING_DEBUG - std::cout << "------- Stitched " << res << " in boundary cycles" << std::endl; + std::cout << "------- Stitched " << res << " (total)" << std::endl; #endif - CGAL_USE(res); + return res; } ///\cond SKIP_IN_MANUAL template -void stitch_borders(PolygonMesh& pmesh) +std::size_t stitch_borders(PolygonMesh& pmesh) { - stitch_borders(pmesh, CGAL::parameters::all_default()); + return stitch_borders(pmesh, CGAL::parameters::all_default()); } ///\endcond diff --git a/Polygon_mesh_processing/include/CGAL/Side_of_triangle_mesh.h b/Polygon_mesh_processing/include/CGAL/Side_of_triangle_mesh.h index e750502a863..b059006a57c 100644 --- a/Polygon_mesh_processing/include/CGAL/Side_of_triangle_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Side_of_triangle_mesh.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -66,7 +67,7 @@ namespace CGAL { */ template + typename VertexPointMap__> struct AABB_tree_default { typedef CGAL::AABB_face_graph_triangle_primitive Primitive; + VertexPointMap__> Primitive; typedef CGAL::AABB_traits Traits; typedef CGAL::AABB_tree type; }; typedef typename Default::Lazy_get + VertexPointMap_> >::type AABB_tree_; + typedef typename Default::Get::const_type>::type + VertexPointMap; typedef typename GeomTraits::Point_3 Point; //members typename GeomTraits::Construct_ray_3 ray_functor; typename GeomTraits::Construct_vector_3 vector_functor; - const AABB_tree_* tree_ptr; + mutable const AABB_tree_* tree_ptr; + const TriangleMesh* tm_ptr; + boost::optional opt_vpm; bool own_tree; + CGAL::Bbox_3 box; +#ifdef CGAL_HAS_THREADS + mutable CGAL_MUTEX tree_mutex; +#endif public: @@ -118,14 +129,14 @@ public: const GeomTraits& gt=GeomTraits()) : ray_functor(gt.construct_ray_3_object()) , vector_functor(gt.construct_vector_3_object()) + , tree_ptr(nullptr) + , tm_ptr(&tmesh) + , opt_vpm(vpmap) , own_tree(true) { CGAL_assertion(CGAL::is_triangle_mesh(tmesh)); CGAL_assertion(CGAL::is_closed(tmesh)); - - tree_ptr = new AABB_tree(faces(tmesh).first, - faces(tmesh).second, - tmesh, vpmap); + box = Polygon_mesh_processing::bbox(tmesh, parameters::vertex_point_map(vpmap)); } /** @@ -138,17 +149,8 @@ public: */ Side_of_triangle_mesh(const TriangleMesh& tmesh, const GeomTraits& gt=GeomTraits()) - : ray_functor(gt.construct_ray_3_object()) - , vector_functor(gt.construct_vector_3_object()) - , own_tree(true) - { - CGAL_assertion(CGAL::is_triangle_mesh(tmesh)); - CGAL_assertion(CGAL::is_closed(tmesh)); - - tree_ptr = new AABB_tree(faces(tmesh).first, - faces(tmesh).second, - tmesh); - } + : Side_of_triangle_mesh(tmesh, get(vertex_point, tmesh), gt) + {} /** * Constructor that takes a pre-built \cgal `AABB_tree` @@ -166,11 +168,12 @@ public: , tree_ptr(&tree) , own_tree(false) { + box = tree.bbox(); } ~Side_of_triangle_mesh() { - if (own_tree) + if (own_tree && tree_ptr!=nullptr) delete tree_ptr; } @@ -186,8 +189,36 @@ public: */ Bounded_side operator()(const Point& point) const { - return internal::Point_inside_vertical_ray_cast()( - point, *tree_ptr, ray_functor, vector_functor); + if(point.x() < box.xmin() + || point.x() > box.xmax() + || point.y() < box.ymin() + || point.y() > box.ymax() + || point.z() < box.zmin() + || point.z() > box.zmax()) + { + return CGAL::ON_UNBOUNDED_SIDE; + } + else + { + // Lazily build the tree only when needed + if (tree_ptr==nullptr) + { +#ifdef CGAL_HAS_THREADS + CGAL_SCOPED_LOCK(tree_mutex); +#endif + CGAL_assertion(tm_ptr != nullptr && opt_vpm!=boost::none); + if (tree_ptr==nullptr) + { + tree_ptr = new AABB_tree(faces(*tm_ptr).first, + faces(*tm_ptr).second, + *tm_ptr, *opt_vpm); + const_cast(tree_ptr)->build(); + } + } + + return internal::Point_inside_vertical_ray_cast()( + point, *tree_ptr, ray_functor, vector_functor); + } } }; diff --git a/Polygon_mesh_processing/include/CGAL/polygon_mesh_processing.h b/Polygon_mesh_processing/include/CGAL/polygon_mesh_processing.h index 5c0a733e061..82f712fdc16 100644 --- a/Polygon_mesh_processing/include/CGAL/polygon_mesh_processing.h +++ b/Polygon_mesh_processing/include/CGAL/polygon_mesh_processing.h @@ -45,6 +45,7 @@ #include #include #include +#include // the named parameter header being not documented the doc is put here for now #ifdef DOXYGEN_RUNNING diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index 40a606b3124..02f55be25dd 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -95,6 +95,7 @@ endif() create_single_source_cgal_program("remove_degeneracies_test.cpp") create_single_source_cgal_program("test_pmp_manifoldness.cpp") create_single_source_cgal_program("test_mesh_smoothing.cpp") + create_single_source_cgal_program("test_remove_caps_needles.cpp") if( TBB_FOUND ) CGAL_target_use_TBB(test_pmp_distance) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/data/pig.off b/Polygon_mesh_processing/test/Polygon_mesh_processing/data/pig.off new file mode 100644 index 00000000000..a6cd4ef4653 --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/data/pig.off @@ -0,0 +1,1361 @@ +OFF +468 891 0 +0.063974 0.101970 -0.415827 +0.028523 0.114259 -0.442328 +0.063412 0.118087 -0.415381 +0.077614 0.162174 -0.435627 +0.128990 0.122892 -0.393541 +0.122864 -0.147913 0.401369 +0.178320 -0.063881 0.376630 +0.131227 -0.089511 0.441084 +0.164639 -0.008344 0.415245 +0.103820 -0.043044 -0.278399 +0.091834 -0.084101 -0.204746 +0.079859 -0.055424 -0.310790 +0.118637 -0.026027 -0.235186 +0.099707 0.153598 0.166104 +0.094930 0.196480 0.152483 +0.115864 0.191688 0.136248 +0.171734 0.181103 0.136002 +0.193585 0.183376 0.154622 +0.164526 0.109059 0.214381 +-0.153221 0.150924 -0.394866 +-0.081493 0.167834 -0.436769 +-0.072517 0.124239 -0.414300 +-0.161186 0.176848 -0.378966 +-0.176790 0.132941 -0.334836 +-0.171249 0.164538 -0.303896 +-0.080475 0.201851 -0.109296 +-0.071494 0.183497 -0.140195 +-0.097522 0.199020 -0.144832 +-0.056652 0.190914 -0.054368 +-0.039241 0.197263 -0.153247 +-0.141604 0.199711 -0.154047 +-0.129425 0.157767 -0.137661 +-0.165583 0.197728 -0.148208 +-0.190944 0.201695 -0.114791 +-0.184883 0.199199 -0.132786 +-0.178540 0.131594 -0.070966 +-0.153766 0.018107 -0.272151 +-0.130012 -0.023104 -0.280793 +-0.113295 -0.035252 -0.248969 +-0.199246 0.193683 0.195561 +-0.180750 0.123251 0.255085 +-0.181651 0.208804 0.233547 +-0.193764 0.183287 0.154611 +-0.183901 0.083655 0.279856 +-0.171726 0.068282 0.231479 +0.149160 0.094349 0.371830 +0.173037 0.085349 0.334114 +0.168678 0.151411 0.318997 +-0.168351 0.090355 0.342446 +-0.191982 0.004460 0.346603 +0.010306 -0.068937 0.495666 +-0.054048 -0.045698 0.495964 +-0.036648 -0.113382 0.498431 +0.049415 -0.137244 0.485860 +-0.135590 0.204770 -0.026654 +-0.164959 0.204458 -0.052698 +-0.119997 0.140111 0.025175 +0.172825 0.080263 -0.317843 +0.160628 0.062369 -0.340044 +0.177177 0.143953 -0.350070 +0.118606 0.021487 -0.375861 +0.165354 0.008939 -0.353730 +0.237839 0.022829 -0.306004 +0.212030 0.037710 -0.318516 +0.235958 0.004327 -0.346347 +0.269290 -0.012961 -0.323921 +0.177418 -0.011732 -0.301843 +0.134912 0.006718 -0.402388 +0.237840 -0.015554 -0.414292 +0.177088 -0.010878 -0.417488 +0.234583 -0.001111 -0.396570 +0.165512 -0.038754 -0.394103 +0.274848 -0.015963 -0.391667 +0.284810 -0.026997 -0.376984 +0.281300 -0.029101 -0.338206 +0.217331 -0.034592 -0.352687 +0.196409 -0.028130 -0.326693 +0.146613 0.129225 0.183979 +0.125633 0.114296 0.184366 +0.168417 0.063049 0.228672 +0.131279 0.094069 0.157481 +0.093427 0.144615 0.148946 +0.151538 0.030944 0.165340 +0.040532 0.197143 -0.154026 +0.056681 0.209038 -0.212225 +0.002775 0.206856 -0.166610 +0.117369 0.153354 -0.205966 +0.124488 0.200090 -0.152498 +0.086066 0.183902 -0.142107 +0.091309 0.198441 -0.138090 +0.064272 0.187025 -0.133132 +0.080301 0.201940 -0.109295 +0.087605 0.207177 -0.050256 +0.071100 0.186484 -0.043141 +0.144787 0.163143 -0.404482 +0.163037 0.176611 -0.376916 +0.093064 0.199241 -0.432443 +0.133133 0.208266 -0.382604 +0.143249 0.191538 -0.272444 +0.158095 0.192739 -0.314330 +-0.139488 0.186720 -0.261262 +-0.151500 0.199626 -0.324260 +-0.098372 0.223627 -0.288685 +-0.078536 0.189639 -0.197355 +-0.039805 0.227673 -0.260155 +0.097127 0.229527 -0.341482 +0.062369 0.228756 -0.395152 +0.036595 0.231173 -0.450000 +-0.028016 0.125004 -0.448876 +-0.036461 0.096667 -0.434533 +-0.083077 0.090894 -0.414311 +-0.082268 0.070800 -0.428081 +-0.123341 -0.003528 -0.217671 +-0.111649 -0.041351 -0.203434 +-0.143481 0.129458 -0.120457 +-0.166571 0.125111 -0.100292 +-0.091445 0.155603 -0.139780 +-0.108949 0.126603 -0.132705 +-0.155764 -0.002392 -0.117269 +-0.109909 -0.047484 -0.302472 +-0.091801 -0.053960 -0.282808 +-0.111273 -0.076464 -0.152548 +-0.089774 -0.101654 -0.175408 +-0.131191 -0.018764 -0.145092 +-0.117239 -0.118603 -0.106400 +-0.186719 -0.019496 0.218873 +0.094316 -0.206017 0.232131 +0.055117 -0.224837 0.203521 +0.079552 -0.189464 0.070678 +0.040403 -0.204104 0.063479 +0.071493 -0.170167 -0.083686 +-0.180726 -0.068980 0.362373 +-0.182633 -0.099623 0.308202 +-0.158938 -0.138266 0.334999 +0.085658 0.200413 0.176418 +0.065852 0.170004 0.177725 +-0.001292 0.195544 -0.033434 +-0.285400 -0.031989 -0.344981 +-0.271603 -0.015198 -0.325428 +-0.278372 -0.020235 -0.389284 +-0.206668 0.006555 -0.349794 +-0.225044 -0.007684 -0.420462 +-0.238803 0.004342 -0.347955 +-0.158634 0.013703 -0.350809 +-0.228727 0.004252 -0.318223 +-0.223154 0.035457 -0.308571 +-0.193549 0.057123 -0.317739 +-0.210450 -0.029622 -0.405169 +0.172645 -0.045708 -0.037575 +0.158143 -0.075581 -0.062747 +0.161129 -0.053779 -0.087832 +0.151586 -0.077141 0.017952 +0.172046 0.216581 0.250518 +0.160045 0.220693 0.263343 +0.199056 0.193772 0.195561 +0.181331 0.122923 0.257005 +0.183238 0.081029 0.279971 +0.186394 0.009376 0.360522 +0.200356 -0.009475 0.302375 +0.186432 0.204012 -0.088367 +0.166519 0.185025 -0.035652 +0.178625 0.148640 -0.039831 +0.162273 -0.038823 0.020282 +0.164324 0.000657 0.028308 +0.191989 -0.031903 0.230015 +0.188950 -0.072032 0.237843 +0.159438 -0.018081 0.152399 +0.179961 -0.012368 0.206350 +0.154184 -0.071463 0.150146 +0.157446 -0.054932 0.128257 +0.146606 -0.094660 0.103787 +-0.085574 0.204703 0.235486 +-0.100152 0.207801 0.255866 +-0.059913 0.174502 0.263217 +-0.177675 0.138122 0.302573 +-0.166640 0.138235 0.331535 +-0.160235 0.220604 0.263332 +0.065130 0.176233 0.262848 +0.085351 0.204781 0.235497 +0.062759 0.177657 0.222293 +0.099947 0.207890 0.255911 +0.029319 0.167713 0.235458 +-0.007308 0.176521 0.212726 +0.018184 0.155832 0.282328 +0.016196 0.134242 0.331153 +-0.115478 0.114685 0.373666 +-0.138087 0.098705 0.375545 +-0.107498 0.047438 0.447839 +-0.136533 0.029923 0.438192 +-0.151444 0.150957 0.333934 +-0.128669 0.172997 0.320075 +-0.141960 0.217696 0.269060 +-0.070700 0.154566 0.313918 +-0.089073 0.135316 0.352129 +0.113012 -0.180473 0.171463 +0.103166 -0.168475 0.072737 +0.137034 -0.171125 0.287599 +0.153718 -0.147893 0.232349 +0.149223 0.117836 -0.382727 +0.122958 0.086674 -0.404777 +0.070966 0.060503 -0.432879 +0.046513 0.085855 -0.431266 +0.092912 0.013673 -0.404533 +0.090952 -0.016720 -0.385023 +0.077405 -0.042537 -0.356280 +0.058093 -0.059147 -0.335116 +0.068427 -0.123215 -0.187213 +0.101335 -0.132006 -0.117248 +0.097814 -0.149292 -0.079001 +0.122020 -0.125228 -0.016951 +0.126097 -0.138388 0.097790 +0.126318 -0.145156 0.141802 +0.174282 -0.112276 0.330051 +0.190029 -0.084340 0.294626 +0.058942 -0.222818 0.301995 +0.098418 -0.193164 0.340401 +0.058809 -0.206985 0.375651 +0.021923 -0.222862 0.367343 +0.014505 -0.238117 0.299646 +0.122283 0.121443 0.075831 +0.113763 0.148142 0.020311 +0.140282 0.123337 0.018261 +0.027980 -0.177863 -0.119253 +0.026130 -0.193179 -0.070708 +-0.001321 -0.211350 0.079165 +-0.001523 -0.197311 -0.066313 +0.166925 0.094073 -0.266778 +0.163733 0.142170 -0.259072 +0.127467 0.088406 -0.181953 +0.150376 0.077937 0.039615 +0.190766 0.201784 -0.114791 +0.178517 0.136767 -0.071037 +0.184704 0.199288 -0.132775 +0.166379 0.133552 -0.102642 +0.165222 0.047122 -0.102044 +0.078264 0.226830 -0.278641 +0.019112 0.233265 -0.274429 +-0.039110 -0.233486 0.287357 +-0.021609 -0.223013 0.367699 +0.001943 -0.188166 0.439819 +-0.066652 -0.213379 0.338708 +0.027726 -0.233930 0.210941 +-0.000203 -0.237188 0.219039 +-0.136376 -0.172085 0.288837 +-0.099814 -0.201744 0.258297 +-0.027582 -0.234160 0.217991 +-0.060662 -0.218919 0.186226 +-0.055734 -0.201562 0.080354 +-0.029186 -0.209148 0.081362 +-0.029001 -0.192501 -0.071644 +-0.160342 0.063827 0.024713 +-0.177523 0.015890 -0.001911 +-0.162105 0.020607 0.040724 +-0.180080 0.125890 -0.032858 +-0.185297 0.023823 -0.038772 +-0.175803 -0.030161 -0.021666 +-0.149501 -0.083919 0.026313 +-0.160461 -0.041091 0.033786 +-0.156993 -0.049877 0.148952 +-0.179046 0.029177 -0.073993 +-0.177954 -0.024883 -0.058372 +-0.151976 0.126423 -0.229667 +-0.163106 0.092405 -0.253555 +-0.121432 0.099265 -0.173188 +-0.111794 0.137703 -0.178117 +-0.166077 0.091402 -0.340017 +-0.161312 0.070001 -0.345025 +-0.167665 0.059706 -0.282855 +-0.171035 0.078014 -0.296062 +-0.126978 0.030384 -0.171087 +-0.129126 0.050437 -0.192177 +-0.131368 0.059086 -0.126361 +-0.134950 0.025663 -0.131342 +-0.143437 -0.069595 -0.109286 +-0.148269 -0.039929 -0.120515 +-0.163978 -0.065334 -0.065543 +-0.167235 -0.061629 -0.042774 +0.002745 0.189510 0.110554 +0.036689 0.188942 0.019665 +-0.036527 0.174422 0.177147 +-0.087796 0.207088 -0.050265 +-0.076524 0.172540 0.006138 +-0.087508 0.177933 -0.017043 +-0.108099 0.206330 -0.029115 +-0.072629 0.172458 0.181190 +-0.090040 0.162292 0.168261 +-0.089665 0.198396 0.161152 +-0.063826 0.178856 0.211964 +-0.149794 0.182785 0.130788 +-0.116064 0.191599 0.136236 +-0.150418 0.160583 0.151346 +-0.171912 0.181013 0.135924 +-0.138972 0.123679 0.183787 +-0.105455 0.169777 0.154956 +-0.106937 0.141313 0.167043 +-0.064997 0.162208 0.148704 +-0.089200 0.146757 0.141467 +-0.116460 0.121274 0.141967 +0.130312 0.041995 0.435860 +0.129704 -0.002210 0.453987 +0.119563 0.095019 0.389830 +0.106258 -0.067817 0.474757 +0.072458 -0.092968 0.490348 +0.035744 -0.100524 0.501598 +0.090915 -0.018706 0.481902 +0.063954 -0.018620 0.488394 +0.012687 0.019863 0.473158 +-0.066639 0.014188 0.477250 +-0.001853 -0.014358 0.486138 +-0.073991 0.051995 0.453618 +0.015992 0.056915 0.445325 +-0.072272 0.083609 0.419400 +0.125713 0.148591 0.340006 +0.151075 0.147959 0.335541 +0.120626 0.212102 0.266920 +0.069491 0.149561 0.322080 +0.091434 0.136280 0.349720 +0.076196 0.038920 0.461948 +0.080702 0.078897 0.423801 +0.006477 0.083890 0.414722 +0.003928 0.102802 0.385224 +-0.068084 0.039517 -0.430070 +-0.017676 0.023776 -0.427482 +0.193970 0.042648 -0.293997 +0.172856 0.064667 -0.285834 +0.158578 0.030796 -0.272331 +0.140866 -0.005417 -0.270488 +0.134432 0.029296 -0.214306 +0.126251 0.015555 -0.188439 +0.132124 0.003792 -0.136979 +0.125810 -0.029504 -0.153529 +0.129423 0.061526 -0.128092 +0.108063 0.127431 -0.132395 +0.091794 0.155522 -0.139751 +0.124048 0.145248 -0.131126 +0.184444 0.016147 -0.030529 +0.181489 -0.003989 -0.053023 +0.141425 0.199800 -0.154047 +0.165405 0.197817 -0.148141 +0.144876 0.183940 -0.146208 +0.154368 0.144703 -0.122262 +0.146068 0.119123 -0.117735 +0.154841 -0.033503 -0.111889 +0.143738 -0.032315 -0.128787 +0.113871 -0.078221 -0.157136 +0.112005 -0.054404 -0.183556 +0.010090 -0.146944 0.487883 +0.011570 -0.146473 0.485554 +0.010090 -0.136782 0.493756 +-0.015165 -0.128494 0.494118 +-0.010143 -0.136180 0.492642 +-0.030104 -0.153530 0.480762 +-0.010143 -0.146454 0.487048 +-0.006480 -0.157970 0.476349 +0.045456 -0.167686 0.453108 +0.029848 -0.154023 0.480267 +0.030579 -0.132753 -0.220866 +0.021176 -0.090002 -0.310105 +0.181147 0.115479 -0.036001 +0.175183 0.070269 -0.003253 +0.161619 0.042238 0.028286 +0.156945 0.037056 0.086395 +0.051155 0.182427 -0.491632 +0.031566 0.180896 -0.501667 +0.002176 0.193366 -0.489790 +-0.037122 0.180476 -0.500027 +-0.025020 0.194670 -0.492815 +0.055556 0.214167 -0.473439 +0.066526 0.214610 -0.467774 +-0.082413 0.208049 -0.429210 +-0.065055 0.215687 -0.469354 +-0.062206 0.204472 -0.479930 +-0.036973 0.231911 -0.450571 +-0.036983 0.226530 -0.458574 +-0.125722 0.187261 -0.415111 +-0.091376 0.197028 -0.433439 +-0.109535 0.220672 -0.374442 +-0.132871 0.206436 -0.383456 +-0.068993 0.234380 -0.324450 +-0.054731 0.231939 -0.379365 +-0.015007 0.238836 -0.387236 +0.010198 0.238083 -0.347126 +-0.171832 0.010661 0.394832 +-0.164229 -0.033313 0.411342 +-0.071226 -0.093884 0.490608 +-0.099723 -0.021444 0.479401 +-0.106460 -0.079934 0.470702 +-0.126287 -0.023902 0.459235 +-0.151985 -0.067142 0.420950 +-0.147699 -0.107939 0.402674 +-0.109438 -0.119557 0.446423 +-0.020037 -0.195034 0.426407 +-0.045003 -0.203863 0.398142 +-0.079909 -0.190588 0.383979 +-0.073176 -0.153947 0.447608 +-0.060832 -0.134709 0.479062 +-0.132591 -0.160951 0.350157 +-0.119567 -0.148332 0.402715 +-0.065793 -0.128601 -0.175205 +-0.097272 -0.145676 -0.099799 +-0.002565 -0.181714 -0.122217 +-0.024515 -0.179484 -0.119506 +-0.064586 -0.176266 -0.074826 +-0.059683 -0.167369 -0.114486 +-0.099658 -0.163716 0.022325 +-0.040368 -0.148020 -0.173886 +-0.152092 0.033745 0.173508 +-0.159192 -0.012910 0.157435 +-0.186610 0.203923 -0.088370 +-0.183267 0.184340 -0.063974 +-0.136575 0.103373 0.069442 +-0.143137 0.116556 0.022602 +-0.200449 -0.005081 0.293234 +-0.198541 -0.044298 0.289997 +-0.176233 -0.086749 0.211940 +-0.129605 -0.146690 0.159205 +-0.172832 -0.114168 0.232984 +-0.146311 -0.094428 0.150409 +-0.147372 -0.095199 0.103658 +-0.110455 -0.178169 0.151965 +-0.128236 -0.127687 0.039765 +-0.128792 -0.120162 -0.025065 +0.064160 0.162938 0.145558 +0.035172 0.172321 0.185202 +-0.006127 0.202885 -0.099910 +-0.034296 0.191647 -0.029673 +-0.131196 0.116627 -0.390365 +-0.142598 0.108734 -0.385698 +-0.118388 0.084666 -0.406795 +-0.122705 0.099621 -0.397329 +-0.118280 0.017285 -0.383763 +-0.138200 0.021970 -0.357392 +-0.083219 -0.042897 -0.356408 +-0.171574 -0.015949 -0.418570 +-0.079870 -0.020831 -0.382774 +-0.146033 -0.002291 -0.413268 +-0.099733 0.026973 -0.404345 +-0.098251 0.013991 -0.401317 +0.044369 -0.016396 -0.405838 +0.042389 0.006708 -0.423304 +-0.042891 -0.004873 -0.416215 +-0.012107 -0.020909 -0.408756 +-0.205436 -0.024781 -0.328409 +-0.223220 -0.034022 -0.353666 +-0.149992 -0.036689 -0.391942 +-0.164885 -0.044415 -0.367829 +-0.091425 -0.051851 -0.329759 +-0.067188 -0.061962 -0.316028 +0.032718 -0.045780 -0.374356 +0.001142 -0.045018 -0.382344 +-0.008169 -0.088329 -0.317598 +-0.061474 -0.052657 -0.346404 +-0.036931 -0.052082 -0.363104 +-0.163689 -0.139768 0.263934 +-0.134461 -0.171429 0.220297 +-0.093110 -0.202067 0.185697 +-0.083335 -0.193614 0.109481 +-0.161181 0.096630 0.214117 +-0.169578 0.129140 0.197122 +-0.136316 0.091909 0.186973 +-0.137551 0.081713 0.154719 +0.129236 0.172656 -0.007278 +0.135409 0.204859 -0.026639 +0.107912 0.206419 -0.029102 +0.080873 0.173368 -0.015229 +0.100091 0.179921 -0.016858 +-0.000035 -0.119696 -0.260509 +-0.020383 -0.117167 -0.258779 +3 0 1 2 +3 2 3 4 +3 1 3 2 +3 5 6 7 +3 6 8 7 +3 9 10 11 +3 9 12 10 +3 13 14 15 +3 15 16 13 +3 17 18 16 +3 19 20 21 +3 22 23 24 +3 23 22 19 +3 25 26 27 +3 28 29 26 +3 30 31 32 +3 27 26 30 +3 30 26 31 +3 33 34 35 +3 36 37 38 +3 39 40 41 +3 42 40 39 +3 43 40 44 +3 45 46 47 +3 48 43 49 +3 50 51 52 +3 5 7 53 +3 54 55 56 +3 57 58 59 +3 60 58 61 +3 62 63 57 +3 63 64 61 +3 63 61 58 +3 63 58 57 +3 65 64 63 +3 65 63 62 +3 66 65 62 +3 61 67 60 +3 68 69 70 +3 71 69 68 +3 69 67 70 +3 70 67 61 +3 61 64 70 +3 72 73 68 +3 72 68 70 +3 72 70 64 +3 72 65 73 +3 72 64 65 +3 73 65 74 +3 68 73 71 +3 75 74 76 +3 74 65 76 +3 76 65 66 +3 76 66 9 +3 75 76 11 +3 76 9 11 +3 75 11 71 +3 71 73 75 +3 73 74 75 +3 77 16 18 +3 78 77 18 +3 78 18 79 +3 78 80 81 +3 78 13 77 +3 16 77 13 +3 13 78 81 +3 78 82 80 +3 82 78 79 +3 83 84 85 +3 83 86 84 +3 85 29 28 +3 87 88 89 +3 89 88 90 +3 91 89 90 +3 92 91 93 +3 90 93 91 +3 94 95 59 +3 95 94 96 +3 95 96 97 +3 3 96 94 +3 86 98 84 +3 59 95 99 +3 99 95 97 +3 100 101 24 +3 101 22 24 +3 101 100 102 +3 103 102 100 +3 102 103 104 +3 103 29 104 +3 104 29 85 +3 99 105 98 +3 105 97 106 +3 99 97 105 +3 96 106 97 +3 106 96 107 +3 21 108 109 +3 21 20 108 +3 110 21 109 +3 110 109 111 +3 112 38 113 +3 112 36 38 +3 114 115 32 +3 114 32 31 +3 115 35 34 +3 34 32 115 +3 116 117 114 +3 116 114 31 +3 31 26 116 +3 29 116 26 +3 116 29 103 +3 114 118 115 +3 117 118 114 +3 119 120 37 +3 38 37 120 +3 121 113 122 +3 38 122 113 +3 38 120 122 +3 123 113 121 +3 122 124 121 +3 44 125 43 +3 126 127 128 +3 128 129 130 +3 129 128 127 +3 131 132 133 +3 134 14 135 +3 135 14 13 +3 13 81 135 +3 136 90 83 +3 137 138 139 +3 140 141 142 +3 139 142 141 +3 139 138 142 +3 140 143 141 +3 144 36 145 +3 138 144 145 +3 143 145 146 +3 143 140 145 +3 140 142 145 +3 138 145 142 +3 36 144 37 +3 147 137 139 +3 141 147 139 +3 148 149 150 +3 151 149 148 +3 152 153 47 +3 154 152 47 +3 47 46 154 +3 18 155 156 +3 79 18 156 +3 18 17 155 +3 154 155 17 +3 156 155 46 +3 154 46 155 +3 157 6 158 +3 156 157 158 +3 46 157 156 +3 157 46 45 +3 157 45 8 +3 8 6 157 +3 159 160 161 +3 162 148 163 +3 151 148 162 +3 164 156 158 +3 164 158 165 +3 166 82 167 +3 167 79 164 +3 79 156 164 +3 82 79 167 +3 168 169 166 +3 168 170 169 +3 167 168 166 +3 164 168 167 +3 164 165 168 +3 170 151 169 +3 162 169 151 +3 163 169 162 +3 163 166 169 +3 171 172 173 +3 41 174 175 +3 40 174 41 +3 40 43 174 +3 175 174 48 +3 48 174 43 +3 41 175 176 +3 177 178 179 +3 177 180 178 +3 134 179 178 +3 134 135 179 +3 181 182 183 +3 179 181 183 +3 183 182 173 +3 183 184 177 +3 177 179 183 +3 179 135 181 +3 185 186 187 +3 48 186 175 +3 188 186 48 +3 188 187 186 +3 176 189 190 +3 190 189 185 +3 176 175 189 +3 189 175 186 +3 186 185 189 +3 191 176 190 +3 192 193 184 +3 192 184 183 +3 173 192 183 +3 192 173 172 +3 193 192 191 +3 192 172 191 +3 191 190 193 +3 190 185 193 +3 194 128 195 +3 128 130 195 +3 196 194 197 +3 196 126 194 +3 126 128 194 +3 198 199 0 +3 4 198 0 +3 198 4 3 +3 198 3 94 +3 94 59 198 +3 58 198 59 +3 198 58 199 +3 60 199 58 +3 200 201 199 +3 109 108 201 +3 201 108 1 +3 201 1 0 +3 199 201 0 +3 202 67 203 +3 199 202 200 +3 202 199 60 +3 67 202 60 +3 67 69 203 +3 71 203 69 +3 203 204 202 +3 71 204 203 +3 205 204 11 +3 11 10 205 +3 204 71 11 +3 130 206 207 +3 10 207 206 +3 206 205 10 +3 207 150 149 +3 195 208 209 +3 151 170 209 +3 195 130 208 +3 208 130 207 +3 149 209 208 +3 149 151 209 +3 208 207 149 +3 209 210 195 +3 170 210 209 +3 210 168 211 +3 210 170 168 +3 168 165 211 +3 197 211 165 +3 195 210 211 +3 194 211 197 +3 194 195 211 +3 212 197 213 +3 213 197 165 +3 213 165 158 +3 213 6 212 +3 213 158 6 +3 5 212 6 +3 5 196 212 +3 212 196 197 +3 214 215 216 +3 215 126 196 +3 5 215 196 +3 5 216 215 +3 216 217 214 +3 218 214 217 +3 214 218 127 +3 215 214 126 +3 127 126 214 +3 219 220 81 +3 80 219 81 +3 220 219 221 +3 221 161 160 +3 222 130 223 +3 223 130 129 +3 129 224 223 +3 223 225 222 +3 225 223 224 +3 226 227 228 +3 226 59 227 +3 226 57 59 +3 59 99 227 +3 227 99 98 +3 227 98 86 +3 228 227 86 +3 161 221 229 +3 221 219 229 +3 229 219 80 +3 161 230 159 +3 230 161 231 +3 232 230 233 +3 233 231 234 +3 230 231 233 +3 235 105 236 +3 98 105 235 +3 104 85 236 +3 235 236 84 +3 235 84 98 +3 84 236 85 +3 237 218 238 +3 217 238 218 +3 217 239 238 +3 237 238 240 +3 224 241 242 +3 129 241 224 +3 127 241 129 +3 242 241 218 +3 241 127 218 +3 218 237 242 +3 240 243 244 +3 240 244 237 +3 242 245 224 +3 246 245 237 +3 237 244 246 +3 245 242 237 +3 247 248 246 +3 248 247 249 +3 248 249 225 +3 224 248 225 +3 245 248 224 +3 245 246 248 +3 250 251 252 +3 253 251 250 +3 251 254 255 +3 254 251 253 +3 253 35 254 +3 256 257 255 +3 257 258 252 +3 252 251 257 +3 255 257 251 +3 259 118 260 +3 35 259 254 +3 35 115 259 +3 118 259 115 +3 254 259 260 +3 260 255 254 +3 261 24 262 +3 261 100 24 +3 24 23 262 +3 263 264 261 +3 264 263 117 +3 117 116 264 +3 116 103 264 +3 264 103 100 +3 261 264 100 +3 265 266 146 +3 23 19 265 +3 267 268 146 +3 267 262 268 +3 268 262 23 +3 268 23 265 +3 146 268 265 +3 145 267 146 +3 145 36 267 +3 267 36 112 +3 269 263 270 +3 270 112 269 +3 270 263 261 +3 270 261 262 +3 267 270 262 +3 270 267 112 +3 112 113 269 +3 123 269 113 +3 271 272 118 +3 123 272 269 +3 117 271 118 +3 272 271 263 +3 272 263 269 +3 263 271 117 +3 121 273 274 +3 124 273 121 +3 274 260 118 +3 272 274 118 +3 272 123 274 +3 274 123 121 +3 275 276 260 +3 276 256 255 +3 276 255 260 +3 275 260 274 +3 275 274 273 +3 275 273 124 +3 136 277 278 +3 277 136 279 +3 277 279 182 +3 93 90 278 +3 278 90 136 +3 28 26 280 +3 25 280 26 +3 281 282 56 +3 281 28 282 +3 280 282 28 +3 283 282 280 +3 283 54 282 +3 56 282 54 +3 284 285 286 +3 284 286 287 +3 171 287 286 +3 171 173 287 +3 182 287 173 +3 279 284 287 +3 279 287 182 +3 288 289 290 +3 288 290 291 +3 290 292 291 +3 293 294 290 +3 292 290 294 +3 289 293 290 +3 289 286 293 +3 293 285 294 +3 286 285 293 +3 295 281 296 +3 284 279 295 +3 56 296 281 +3 56 297 296 +3 297 294 296 +3 295 296 285 +3 284 295 285 +3 285 296 294 +3 298 299 8 +3 8 45 298 +3 45 300 298 +3 7 8 301 +3 299 301 8 +3 53 301 302 +3 301 53 7 +3 303 53 302 +3 301 304 302 +3 299 304 301 +3 298 304 299 +3 304 305 303 +3 304 303 302 +3 303 305 50 +3 306 307 308 +3 305 306 308 +3 51 308 307 +3 50 308 51 +3 308 50 305 +3 309 307 306 +3 310 309 306 +3 193 185 311 +3 311 187 309 +3 309 187 307 +3 185 187 311 +3 153 312 313 +3 313 47 153 +3 153 314 312 +3 313 312 45 +3 45 47 313 +3 300 45 312 +3 315 180 177 +3 315 177 184 +3 300 312 316 +3 316 314 315 +3 314 180 315 +3 314 316 312 +3 317 318 310 +3 310 306 317 +3 305 317 306 +3 305 304 317 +3 298 317 304 +3 317 298 318 +3 298 300 318 +3 318 300 316 +3 319 320 311 +3 315 184 320 +3 320 184 193 +3 193 311 320 +3 319 311 309 +3 310 319 309 +3 318 319 310 +3 320 319 316 +3 316 315 320 +3 318 316 319 +3 321 111 322 +3 109 322 111 +3 201 322 109 +3 201 200 322 +3 62 323 66 +3 57 324 323 +3 62 57 323 +3 324 57 226 +3 66 325 326 +3 9 326 12 +3 66 326 9 +3 323 325 66 +3 323 324 325 +3 324 226 325 +3 327 228 328 +3 328 12 327 +3 12 326 327 +3 326 325 327 +3 226 327 325 +3 226 228 327 +3 329 330 328 +3 329 328 228 +3 331 329 228 +3 331 228 332 +3 333 332 86 +3 332 228 86 +3 333 86 83 +3 83 90 333 +3 90 88 333 +3 333 88 334 +3 335 148 336 +3 335 163 148 +3 148 150 336 +3 336 231 335 +3 336 234 231 +3 337 338 339 +3 88 339 334 +3 337 339 87 +3 87 339 88 +3 340 341 334 +3 339 340 334 +3 340 339 338 +3 340 338 232 +3 233 340 232 +3 233 341 340 +3 233 234 341 +3 341 332 333 +3 341 333 334 +3 234 336 342 +3 343 342 150 +3 336 150 342 +3 331 343 329 +3 331 332 343 +3 332 341 343 +3 342 343 234 +3 343 330 329 +3 343 341 234 +3 330 344 345 +3 328 345 12 +3 328 330 345 +3 330 343 344 +3 344 343 150 +3 344 150 207 +3 345 344 10 +3 12 345 10 +3 207 10 344 +3 346 347 348 +3 303 347 53 +3 347 303 348 +3 349 350 303 +3 348 303 350 +3 50 349 303 +3 50 52 349 +3 52 351 349 +3 352 349 353 +3 352 350 349 +3 349 351 353 +3 351 239 353 +3 346 352 353 +3 353 347 346 +3 354 53 355 +3 354 355 239 +3 347 355 53 +3 347 353 355 +3 355 353 239 +3 354 239 217 +3 216 354 217 +3 5 354 216 +3 5 53 354 +3 205 356 357 +3 356 205 206 +3 356 206 130 +3 222 356 130 +3 335 231 358 +3 161 358 231 +3 358 161 359 +3 359 161 229 +3 335 358 359 +3 335 359 163 +3 360 361 163 +3 359 360 163 +3 360 229 361 +3 359 229 360 +3 80 361 229 +3 361 80 82 +3 361 82 166 +3 163 361 166 +3 3 362 96 +3 362 1 363 +3 1 362 3 +3 364 363 365 +3 363 1 365 +3 1 108 365 +3 364 365 366 +3 20 365 108 +3 367 107 368 +3 96 368 107 +3 368 96 362 +3 363 367 368 +3 364 367 363 +3 362 363 368 +3 369 370 371 +3 371 366 365 +3 365 20 371 +3 372 373 370 +3 107 373 372 +3 369 372 370 +3 107 367 373 +3 373 367 364 +3 364 366 373 +3 366 371 373 +3 371 370 373 +3 20 374 375 +3 375 369 371 +3 375 371 20 +3 19 374 20 +3 374 19 22 +3 376 369 377 +3 369 375 377 +3 377 101 376 +3 377 375 374 +3 374 22 377 +3 101 377 22 +3 101 102 376 +3 378 379 376 +3 369 379 372 +3 376 379 369 +3 376 102 378 +3 102 104 378 +3 380 378 381 +3 379 380 372 +3 379 378 380 +3 378 104 381 +3 236 381 104 +3 105 381 236 +3 105 106 381 +3 381 107 380 +3 380 107 372 +3 381 106 107 +3 382 383 188 +3 383 382 131 +3 188 48 382 +3 48 49 382 +3 49 131 382 +3 384 52 51 +3 384 51 385 +3 307 385 51 +3 386 385 387 +3 387 385 188 +3 386 384 385 +3 187 385 307 +3 187 188 385 +3 387 188 383 +3 388 131 389 +3 131 133 389 +3 389 390 388 +3 388 390 386 +3 386 387 388 +3 387 383 388 +3 388 383 131 +3 238 391 392 +3 392 393 240 +3 240 238 392 +3 239 391 238 +3 351 392 391 +3 391 239 351 +3 392 394 393 +3 351 395 394 +3 392 351 394 +3 52 395 351 +3 384 395 52 +3 395 384 386 +3 395 390 394 +3 395 386 390 +3 396 393 397 +3 393 394 397 +3 390 397 394 +3 389 397 390 +3 396 397 133 +3 389 133 397 +3 243 396 133 +3 243 240 396 +3 240 393 396 +3 124 398 399 +3 124 122 398 +3 122 120 398 +3 400 356 222 +3 400 222 225 +3 249 401 400 +3 225 249 400 +3 402 399 403 +3 399 402 404 +3 398 403 399 +3 398 405 403 +3 405 401 403 +3 249 402 403 +3 247 402 249 +3 403 401 249 +3 406 252 407 +3 407 252 258 +3 407 258 125 +3 406 407 44 +3 125 44 407 +3 408 33 409 +3 408 409 55 +3 33 35 409 +3 409 35 253 +3 250 410 411 +3 250 252 410 +3 411 410 56 +3 56 410 297 +3 411 56 55 +3 411 55 409 +3 253 411 409 +3 411 253 250 +3 412 125 413 +3 412 413 49 +3 413 132 131 +3 413 131 49 +3 412 49 43 +3 412 43 125 +3 414 415 416 +3 414 125 258 +3 416 413 414 +3 414 413 125 +3 416 132 413 +3 415 417 418 +3 414 417 415 +3 418 417 258 +3 414 258 417 +3 418 258 257 +3 256 418 257 +3 404 419 420 +3 415 420 419 +3 418 420 415 +3 418 256 420 +3 404 420 421 +3 420 256 421 +3 421 256 276 +3 275 421 276 +3 124 421 275 +3 124 399 421 +3 404 421 399 +3 422 135 81 +3 81 220 422 +3 422 278 423 +3 423 278 277 +3 277 182 423 +3 182 181 423 +3 135 422 423 +3 423 181 135 +3 136 424 425 +3 281 295 425 +3 295 279 425 +3 425 279 136 +3 424 136 83 +3 424 83 85 +3 425 424 28 +3 28 281 425 +3 424 85 28 +3 426 19 21 +3 265 427 266 +3 265 19 427 +3 19 426 427 +3 428 266 427 +3 429 428 427 +3 426 429 427 +3 429 110 428 +3 110 111 428 +3 430 143 431 +3 146 431 143 +3 266 431 146 +3 141 143 430 +3 432 433 434 +3 141 435 433 +3 141 430 435 +3 141 433 147 +3 431 436 430 +3 431 266 436 +3 266 428 436 +3 111 436 428 +3 436 111 321 +3 430 436 437 +3 436 321 437 +3 434 433 437 +3 435 437 433 +3 435 430 437 +3 438 439 202 +3 202 204 438 +3 322 200 439 +3 439 200 202 +3 437 440 434 +3 437 321 440 +3 322 440 321 +3 441 440 439 +3 441 439 438 +3 322 439 440 +3 442 144 443 +3 443 119 442 +3 138 443 144 +3 137 443 138 +3 147 443 137 +3 119 37 442 +3 37 144 442 +3 444 432 445 +3 147 444 445 +3 444 147 433 +3 432 444 433 +3 147 445 443 +3 446 447 119 +3 119 443 446 +3 445 446 443 +3 432 446 445 +3 398 447 405 +3 120 447 398 +3 120 119 447 +3 438 448 449 +3 449 448 357 +3 448 438 204 +3 448 204 205 +3 357 448 205 +3 450 449 357 +3 449 441 438 +3 451 405 447 +3 451 447 446 +3 432 451 446 +3 451 434 452 +3 451 432 434 +3 452 434 440 +3 441 452 440 +3 449 452 441 +3 451 452 450 +3 449 450 452 +3 133 453 243 +3 133 132 453 +3 416 454 453 +3 416 453 132 +3 416 415 454 +3 419 454 415 +3 243 453 454 +3 454 244 243 +3 455 456 247 +3 246 455 247 +3 244 455 246 +3 244 454 455 +3 455 419 456 +3 419 455 454 +3 404 456 419 +3 402 456 404 +3 402 247 456 +3 292 457 458 +3 458 457 40 +3 457 44 40 +3 458 40 42 +3 291 458 42 +3 292 458 291 +3 44 457 459 +3 459 457 292 +3 294 459 292 +3 460 406 459 +3 459 297 460 +3 459 406 44 +3 459 294 297 +3 297 410 460 +3 410 252 460 +3 406 460 252 +3 461 160 462 +3 462 463 461 +3 220 221 461 +3 221 160 461 +3 159 462 160 +3 422 464 278 +3 464 220 465 +3 464 422 220 +3 461 465 220 +3 463 465 461 +3 463 92 465 +3 464 465 93 +3 464 93 278 +3 93 465 92 +3 466 357 356 +3 400 466 356 +3 466 400 467 +3 400 401 467 +3 467 401 405 +3 405 451 467 +3 466 467 450 +3 466 450 357 +3 450 467 451 diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/data/unit-grid.off b/Polygon_mesh_processing/test/Polygon_mesh_processing/data/unit-grid.off new file mode 100644 index 00000000000..22af0f9741f --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/data/unit-grid.off @@ -0,0 +1,323 @@ +OFF +121 200 0 +0 0 0 +0.10000000000000001 0 0 +0.20000000000000001 0 0 +0.29999999999999999 0 0 +0.40000000000000002 0 0 +0.5 0 0 +0.59999999999999998 0 0 +0.69999999999999996 0 0 +0.80000000000000004 0 0 +0.90000000000000002 0 0 +1 0 0 +0 0.10000000000000001 0 +0.10000000000000001 0.10000000000000001 0 +0.20000000000000001 0.10000000000000001 0 +0.29999999999999999 0.10000000000000001 0 +0.40000000000000002 0.10000000000000001 0 +0.5 0.10000000000000001 0 +0.59999999999999998 0.10000000000000001 0 +0.69999999999999996 0.10000000000000001 0 +0.80000000000000004 0.10000000000000001 0 +0.90000000000000002 0.10000000000000001 0 +1 0.10000000000000001 0 +0 0.20000000000000001 0 +0.10000000000000001 0.20000000000000001 0 +0.20000000000000001 0.20000000000000001 0 +0.29999999999999999 0.20000000000000001 0 +0.40000000000000002 0.20000000000000001 0 +0.5 0.20000000000000001 0 +0.59999999999999998 0.20000000000000001 0 +0.69999999999999996 0.20000000000000001 0 +0.80000000000000004 0.20000000000000001 0 +0.90000000000000002 0.20000000000000001 0 +1 0.20000000000000001 0 +0 0.29999999999999999 0 +0.10000000000000001 0.29999999999999999 0 +0.20000000000000001 0.29999999999999999 0 +0.29999999999999999 0.29999999999999999 0 +0.40000000000000002 0.29999999999999999 0 +0.5 0.29999999999999999 0 +0.59999999999999998 0.29999999999999999 0 +0.69999999999999996 0.29999999999999999 0 +0.80000000000000004 0.29999999999999999 0 +0.90000000000000002 0.29999999999999999 0 +1 0.29999999999999999 0 +0 0.40000000000000002 0 +0.10000000000000001 0.40000000000000002 0 +0.20000000000000001 0.40000000000000002 0 +0.29999999999999999 0.40000000000000002 0 +0.40000000000000002 0.40000000000000002 0 +0.5 0.40000000000000002 0 +0.59999999999999998 0.40000000000000002 0 +0.69999999999999996 0.40000000000000002 0 +0.80000000000000004 0.40000000000000002 0 +0.90000000000000002 0.40000000000000002 0 +1 0.40000000000000002 0 +0 0.5 0 +0.10000000000000001 0.5 0 +0.20000000000000001 0.5 0 +0.29999999999999999 0.5 0 +0.40000000000000002 0.5 0 +0.5 0.5 0 +0.59999999999999998 0.5 0 +0.69999999999999996 0.5 0 +0.80000000000000004 0.5 0 +0.90000000000000002 0.5 0 +1 0.5 0 +0 0.59999999999999998 0 +0.10000000000000001 0.59999999999999998 0 +0.20000000000000001 0.59999999999999998 0 +0.29999999999999999 0.59999999999999998 0 +0.40000000000000002 0.59999999999999998 0 +0.5 0.59999999999999998 0 +0.59999999999999998 0.59999999999999998 0 +0.69999999999999996 0.59999999999999998 0 +0.80000000000000004 0.59999999999999998 0 +0.90000000000000002 0.59999999999999998 0 +1 0.59999999999999998 0 +0 0.69999999999999996 0 +0.10000000000000001 0.69999999999999996 0 +0.20000000000000001 0.69999999999999996 0 +0.29999999999999999 0.69999999999999996 0 +0.40000000000000002 0.69999999999999996 0 +0.5 0.69999999999999996 0 +0.59999999999999998 0.69999999999999996 0 +0.69999999999999996 0.69999999999999996 0 +0.80000000000000004 0.69999999999999996 0 +0.90000000000000002 0.69999999999999996 0 +1 0.69999999999999996 0 +0 0.80000000000000004 0 +0.10000000000000001 0.80000000000000004 0 +0.20000000000000001 0.80000000000000004 0 +0.29999999999999999 0.80000000000000004 0 +0.40000000000000002 0.80000000000000004 0 +0.5 0.80000000000000004 0 +0.59999999999999998 0.80000000000000004 0 +0.69999999999999996 0.80000000000000004 0 +0.80000000000000004 0.80000000000000004 0 +0.90000000000000002 0.80000000000000004 0 +1 0.80000000000000004 0 +0 0.90000000000000002 0 +0.10000000000000001 0.90000000000000002 0 +0.20000000000000001 0.90000000000000002 0 +0.29999999999999999 0.90000000000000002 0 +0.40000000000000002 0.90000000000000002 0 +0.5 0.90000000000000002 0 +0.59999999999999998 0.90000000000000002 0 +0.69999999999999996 0.90000000000000002 0 +0.80000000000000004 0.90000000000000002 0 +0.90000000000000002 0.90000000000000002 0 +1 0.90000000000000002 0 +0 1 0 +0.10000000000000001 1 0 +0.20000000000000001 1 0 +0.29999999999999999 1 0 +0.40000000000000002 1 0 +0.5 1 0 +0.59999999999999998 1 0 +0.69999999999999996 1 0 +0.80000000000000004 1 0 +0.90000000000000002 1 0 +1 1 0 +3 0 1 11 +3 1 12 11 +3 11 12 22 +3 12 23 22 +3 22 23 33 +3 23 34 33 +3 33 34 44 +3 34 45 44 +3 44 45 55 +3 45 56 55 +3 55 56 66 +3 56 67 66 +3 66 67 77 +3 67 78 77 +3 77 78 88 +3 78 89 88 +3 88 89 99 +3 89 100 99 +3 99 100 110 +3 100 111 110 +3 1 2 12 +3 2 13 12 +3 12 13 23 +3 13 24 23 +3 23 24 34 +3 24 35 34 +3 34 35 45 +3 35 46 45 +3 45 46 56 +3 46 57 56 +3 56 57 67 +3 57 68 67 +3 67 68 78 +3 68 79 78 +3 78 79 89 +3 79 90 89 +3 89 90 100 +3 90 101 100 +3 100 101 111 +3 101 112 111 +3 2 3 13 +3 3 14 13 +3 13 14 24 +3 14 25 24 +3 24 25 35 +3 25 36 35 +3 35 36 46 +3 36 47 46 +3 46 47 57 +3 47 58 57 +3 57 58 68 +3 58 69 68 +3 68 69 79 +3 69 80 79 +3 79 80 90 +3 80 91 90 +3 90 91 101 +3 91 102 101 +3 101 102 112 +3 102 113 112 +3 3 4 14 +3 4 15 14 +3 14 15 25 +3 15 26 25 +3 25 26 36 +3 26 37 36 +3 36 37 47 +3 37 48 47 +3 47 48 58 +3 48 59 58 +3 58 59 69 +3 59 70 69 +3 69 70 80 +3 70 81 80 +3 80 81 91 +3 81 92 91 +3 91 92 102 +3 92 103 102 +3 102 103 113 +3 103 114 113 +3 4 5 15 +3 5 16 15 +3 15 16 26 +3 16 27 26 +3 26 27 37 +3 27 38 37 +3 37 38 48 +3 38 49 48 +3 48 49 59 +3 49 60 59 +3 59 60 70 +3 60 71 70 +3 70 71 81 +3 71 82 81 +3 81 82 92 +3 82 93 92 +3 92 93 103 +3 93 104 103 +3 103 104 114 +3 104 115 114 +3 5 6 16 +3 6 17 16 +3 16 17 27 +3 17 28 27 +3 27 28 38 +3 28 39 38 +3 38 39 49 +3 39 50 49 +3 49 50 60 +3 50 61 60 +3 60 61 71 +3 61 72 71 +3 71 72 82 +3 72 83 82 +3 82 83 93 +3 83 94 93 +3 93 94 104 +3 94 105 104 +3 104 105 115 +3 105 116 115 +3 6 7 17 +3 7 18 17 +3 17 18 28 +3 18 29 28 +3 28 29 39 +3 29 40 39 +3 39 40 50 +3 40 51 50 +3 50 51 61 +3 51 62 61 +3 61 62 72 +3 62 73 72 +3 72 73 83 +3 73 84 83 +3 83 84 94 +3 84 95 94 +3 94 95 105 +3 95 106 105 +3 105 106 116 +3 106 117 116 +3 7 8 18 +3 8 19 18 +3 18 19 29 +3 19 30 29 +3 29 30 40 +3 30 41 40 +3 40 41 51 +3 41 52 51 +3 51 52 62 +3 52 63 62 +3 62 63 73 +3 63 74 73 +3 73 74 84 +3 74 85 84 +3 84 85 95 +3 85 96 95 +3 95 96 106 +3 96 107 106 +3 106 107 117 +3 107 118 117 +3 8 9 19 +3 9 20 19 +3 19 20 30 +3 20 31 30 +3 30 31 41 +3 31 42 41 +3 41 42 52 +3 42 53 52 +3 52 53 63 +3 53 64 63 +3 63 64 74 +3 64 75 74 +3 74 75 85 +3 75 86 85 +3 85 86 96 +3 86 97 96 +3 96 97 107 +3 97 108 107 +3 107 108 118 +3 108 119 118 +3 9 10 20 +3 10 21 20 +3 20 21 31 +3 21 32 31 +3 31 32 42 +3 32 43 42 +3 42 43 53 +3 43 54 53 +3 53 54 64 +3 54 65 64 +3 64 65 75 +3 65 76 75 +3 75 76 86 +3 76 87 86 +3 86 87 97 +3 87 98 97 +3 97 98 108 +3 98 109 108 +3 108 109 119 +3 109 120 119 diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp index 223a1c58aa0..526bea44ee6 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp @@ -28,7 +28,7 @@ bool is_ccw(int xi, int yi, CGAL::Polygon_2 polygon; if(polyline.front() == polyline.back()) { - BOOST_FOREACH(const typename K::Point_3& p, polyline) + for(const typename K::Point_3& p : polyline) { polygon.push_back(typename K::Point_2(p[xi], p[yi])); } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp index e94e16c511b..f330133421e 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp @@ -296,7 +296,7 @@ void test() ss.str(std::string()); ss << "OFF\n 7 4 0\n 0 0 0\n2 0 0\n4 0 0\n4 1 0\n0 1 0\n3 1 0\n 1 1 0\n3 0 1 4\n3 1 2 3\n3 1 5 6\n3 1 3 5\n"; ss >> tm1; - CGAL::Euler::remove_face(halfedge(*CGAL::cpp11::prev(faces(tm1).end()),tm1),tm1); + CGAL::Euler::remove_face(halfedge(*std::prev(faces(tm1).end()),tm1),tm1); PMP::clip(tm1, K::Plane_3(-1,0,0,2)); assert(vertices(tm1).size()==6); CGAL::clear(tm1); @@ -305,7 +305,7 @@ void test() ss << "OFF\n 9 7 0\n 0 0 0\n2 0 0\n4 0 0\n4 1 0\n0 1 0\n3 1 0\n 1 1 0\n3 -1 0\n1 -1 0\n3 0 1 4\n3 1 2 3\n3 1 5 6\n3 1 8 7\n3 1 3 5\n3 1 6 4\n3 1 0 8\n"; ss >> tm1; for (int i=0;i<3;++i) - CGAL::Euler::remove_face(halfedge(*CGAL::cpp11::prev(faces(tm1).end()),tm1),tm1); + CGAL::Euler::remove_face(halfedge(*std::prev(faces(tm1).end()),tm1),tm1); PMP::clip(tm1, K::Plane_3(-1,0,0,2)); assert(vertices(tm1).size()==7); CGAL::clear(tm1); @@ -314,7 +314,7 @@ void test() ss << "OFF\n 9 7 0\n 0 0 0\n2 0 0\n4 0 0\n4 1 0\n0 1 0\n3 1 0\n 1 1 0\n3 -1 0\n1 -1 0\n3 0 1 4\n3 1 2 3\n3 1 5 6\n3 1 8 7\n3 1 3 5\n3 1 6 4\n3 1 0 8\n"; ss >> tm1; for (int i=0;i<3;++i) - CGAL::Euler::remove_face(halfedge(*CGAL::cpp11::prev(faces(tm1).end()),tm1),tm1); + CGAL::Euler::remove_face(halfedge(*std::prev(faces(tm1).end()),tm1),tm1); PMP::clip(tm1, K::Plane_3(0,1,0,0)); assert(vertices(tm1).size()==3); CGAL::clear(tm1); @@ -323,7 +323,7 @@ void test() ss << "OFF\n 9 7 0\n 0 0 0\n2 0 0\n4 0 0\n4 1 0\n0 1 0\n3 1 0\n 1 1 0\n3 -1 0\n1 -1 0\n3 0 1 4\n3 1 2 3\n3 1 5 6\n3 1 8 7\n3 1 3 5\n3 1 6 4\n3 1 0 8\n"; ss >> tm1; for (int i=0;i<3;++i) - CGAL::Euler::remove_face(halfedge(*CGAL::cpp11::prev(faces(tm1).end()),tm1),tm1); + CGAL::Euler::remove_face(halfedge(*std::prev(faces(tm1).end()),tm1),tm1); PMP::clip(tm1, K::Plane_3(0,-1,0,0)); assert(vertices(tm1).size()==7); CGAL::clear(tm1); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_locate.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_locate.cpp index 5b704de13bb..3b285fc6a50 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_locate.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_locate.cpp @@ -42,6 +42,7 @@ namespace PMP = CGAL::Polygon_mesh_processing; typedef CGAL::Exact_predicates_inexact_constructions_kernel EPICK; typedef CGAL::Exact_predicates_exact_constructions_kernel EPECK; + typedef CGAL::Simple_cartesian::Type> Exact_kernel; template @@ -96,32 +97,31 @@ bool is_equal(const FT& a, const FT& b) return (a == b); } -template +template void test_snappers(const G& g) { std::cout << " test snappers..." << std::endl; - typedef typename PMP::Location_traits::FT FT; + typedef typename K::FT FT; - typename PMP::Location_traits::Barycentric_coordinates coords = CGAL::make_array(FT(1e-6), FT(0.9999999999999999999), FT(1e-7)); - typename PMP::Location_traits::Face_location loc = std::make_pair(*(faces(g).first), coords); + PMP::Barycentric_coordinates coords = CGAL::make_array(FT(1e-6), FT(0.9999999999999999999), FT(1e-7)); + PMP::Face_location loc = std::make_pair(*(faces(g).first), coords); // --------------------------------------------------------------------------- - PMP::internal::snap_coordinates_to_border(coords); // uses numeric_limits' epsilon() + PMP::internal::snap_coordinates_to_border(coords); // uses numeric_limits' epsilon() assert(coords[0] == FT(1e-6) && coords[1] == FT(1) && coords[2] == FT(1e-7)); - PMP::internal::snap_coordinates_to_border(coords, 1e-5); + PMP::internal::snap_coordinates_to_border(coords, FT(1e-5)); assert(coords[0] == FT(0) && coords[1] == FT(1) && coords[2] == FT(0)); // --------------------------------------------------------------------------- - PMP::internal::snap_location_to_border(loc); // uses numeric_limits' epsilon() + PMP::internal::snap_location_to_border(loc, g); // uses numeric_limits' epsilon() assert(!PMP::is_on_face_border(loc, g)); - PMP::internal::snap_location_to_border(loc, 1e-7); + PMP::internal::snap_location_to_border(loc, g, FT(1e-7)); assert(PMP::is_on_face_border(loc, g)); } - template struct Point_to_bare_point { @@ -134,49 +134,48 @@ struct Point_to_bare_point typedef typename K::Point_3 type; }; -template -void test_constructions(const G& g, CGAL::Random& rnd) +template +void test_constructions(const G& g, + const VPM vpm, + CGAL::Random& rnd) { std::cout << " test constructions..." << std::endl; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename PMP::Location_traits::descriptor_variant descriptor_variant; + typedef typename PMP::descriptor_variant descriptor_variant; - typedef typename boost::property_map_value::type Point; - typedef typename CGAL::Kernel_traits::type Kernel; - typedef typename Kernel::FT FT; - typedef typename Point_to_bare_point::type Bare_point; + typedef typename boost::property_traits::value_type Point; + typedef typename boost::property_traits::reference Point_reference; + typedef typename K::FT FT; + typedef typename Point_to_bare_point::type Bare_point; - typedef typename PMP::Location_traits::Barycentric_coordinates Barycentric_coordinates; - typedef typename PMP::Location_traits::Face_location Face_location; - - typedef typename boost::property_map::const_type VPM; - VPM vpm = CGAL::get_const_property_map(boost::vertex_point, g); + typedef typename PMP::Barycentric_coordinates Barycentric_coordinates; + typedef typename PMP::Face_location Face_location; face_descriptor f = CGAL::internal::random_face_in_mesh(g, rnd); halfedge_descriptor h = halfedge(f, g); vertex_descriptor v = source(h, g); - Point p = get(vpm, v); - Point q = get(vpm, target(h, g)); - Point r = get(vpm, target(next(h, g), g)); + Point_reference p = get(vpm, v); + Point_reference q = get(vpm, target(h, g)); + Point_reference r = get(vpm, target(next(h, g), g)); - Bare_point bp(p); - Bare_point bq(q); - Bare_point br(r); + const Bare_point bp(p); + const Bare_point bq(q); + const Bare_point br(r); Barycentric_coordinates bar; Face_location loc; loc.first = f; // --------------------------------------------------------------------------- - bar = PMP::barycentric_coordinates(p, q, r, p, Kernel()); + bar = PMP::barycentric_coordinates(p, q, r, p, K()); assert(is_equal(bar[0], FT(1)) && is_equal(bar[1], FT(0)) && is_equal(bar[2], FT(0))); - bar = PMP::barycentric_coordinates(p, q, r, q, Kernel()); + bar = PMP::barycentric_coordinates(p, q, r, q, K()); assert(is_equal(bar[0], FT(0)) && is_equal(bar[1], FT(1)) && is_equal(bar[2], FT(0))); - bar = PMP::barycentric_coordinates(p, q, r, r, Kernel()); + bar = PMP::barycentric_coordinates(p, q, r, r, K()); assert(is_equal(bar[0], FT(0)) && is_equal(bar[1], FT(0)) && is_equal(bar[2], FT(1))); Point mp = Point(CGAL::midpoint(bp, bq)); @@ -190,12 +189,18 @@ void test_constructions(const G& g, CGAL::Random& rnd) const FT b = rnd.get_double(-1., 1.); const FT c = 1. - a - b; + // Point to location and inversely Bare_point barycentric_pt = CGAL::barycenter(bp, a, bq, b, br, c); bar = PMP::barycentric_coordinates(p, q, r, Point(barycentric_pt)); assert(is_equal(bar[0], a) && is_equal(bar[1], b) && is_equal(bar[2], c)); loc.second = bar; - const FT sq_dist = CGAL::squared_distance(barycentric_pt, Bare_point(PMP::construct_point(loc, g))); + const Bare_point barycentric_pt_2 = + Bare_point(PMP::construct_point(loc, g, + CGAL::parameters::vertex_point_map(vpm) + .geom_traits(K()))); + + const FT sq_dist = CGAL::squared_distance(barycentric_pt, barycentric_pt_2); assert(is_equal(sq_dist, FT(0))); } @@ -216,13 +221,12 @@ void test_constructions(const G& g, CGAL::Random& rnd) if(const vertex_descriptor* v = boost::get(&dv)) { } else { assert(false); } // --------------------------------------------------------------------------- - - Point s = PMP::construct_point(loc, g, CGAL::parameters::all_default()); - s = PMP::construct_point(loc, g); - assert(s == get(vpm, source(halfedge(f, g), g))); + // just to check the API + PMP::construct_point(loc, g); + PMP::construct_point(loc, g, CGAL::parameters::all_default()); } -template +template void test_random_entities(const G& g, CGAL::Random& rnd) { std::cout << " test random entities..." << std::endl; @@ -230,11 +234,8 @@ void test_random_entities(const G& g, CGAL::Random& rnd) typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename PMP::Location_traits::Face_location Face_location; - - typedef typename boost::property_map_value::type Point; - typedef typename CGAL::Kernel_traits::type Kernel; - typedef typename Kernel::FT FT; + typedef typename K::FT FT; + typedef typename PMP::Face_location Face_location; // --------------------------------------------------------------------------- Face_location loc; @@ -247,19 +248,19 @@ void test_random_entities(const G& g, CGAL::Random& rnd) int nn = 100; while(nn --> 0) // the infamous 'go to zero' operator { - loc = PMP::random_location_on_mesh(g, rnd); + loc = PMP::random_location_on_mesh(g, rnd); assert(loc.first != boost::graph_traits::null_face()); assert(loc.second[0] >= FT(0) && loc.second[0] <= FT(1) && loc.second[1] >= FT(0) && loc.second[1] <= FT(1) && loc.second[2] >= FT(0) && loc.second[2] <= FT(1)); - loc = PMP::random_location_on_face(f, g, rnd); + loc = PMP::random_location_on_face(f, g, rnd); assert(loc.first == f); assert(loc.second[0] >= FT(0) && loc.second[0] <= FT(1) && loc.second[1] >= FT(0) && loc.second[1] <= FT(1) && loc.second[2] >= FT(0) && loc.second[2] <= FT(1)); - loc = PMP::random_location_on_halfedge(h, g, rnd); + loc = PMP::random_location_on_halfedge(h, g, rnd); assert(loc.first == face(h, g)); assert(loc.second[0] >= FT(0) && loc.second[0] <= FT(1) && loc.second[1] >= FT(0) && loc.second[1] <= FT(1) && @@ -269,7 +270,7 @@ void test_random_entities(const G& g, CGAL::Random& rnd) } } -template +template void test_helpers(const G& g, CGAL::Random& rnd) { std::cout << " test helpers..." << std::endl; @@ -278,7 +279,8 @@ void test_helpers(const G& g, CGAL::Random& rnd) typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename PMP::Location_traits::Face_location Face_location; + typedef typename K::FT FT; + typedef typename PMP::Face_location Face_location; face_descriptor f = CGAL::internal::random_face_in_mesh(g, rnd); halfedge_descriptor h = halfedge(f, g); @@ -302,31 +304,31 @@ void test_helpers(const G& g, CGAL::Random& rnd) // --------------------------------------------------------------------------- // Incident faces - Face_location loc = PMP::random_location_on_face(f, g, rnd); + Face_location loc = PMP::random_location_on_face(f, g, rnd); std::set s; PMP::internal::incident_faces(loc, g, std::inserter(s, s.begin())); assert(PMP::is_on_face_border(loc, g) || s.size() == 1); - loc = PMP::random_location_on_halfedge(h, g, rnd); + loc = PMP::random_location_on_halfedge(h, g, rnd); std::vector vec; PMP::internal::incident_faces(loc, g, std::back_inserter(vec)); - assert(PMP::is_on_vertex(loc, source(h, g), g) || PMP::is_on_vertex(loc, target(h, g), g) || vec.size() == 2); + assert(PMP::is_on_vertex(loc, source(h, g), g) || + PMP::is_on_vertex(loc, target(h, g), g) || + vec.size() == 2); } -template +template void test_predicates(const G& g, CGAL::Random& rnd) { std::cout << " test predicates..." << std::endl; - typedef typename boost::property_map_value::type Point; - typedef typename CGAL::Kernel_traits::type Kernel; - typedef typename Kernel::FT FT; + typedef typename K::FT FT; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename PMP::Location_traits::Face_location Face_location; + typedef typename PMP::Face_location Face_location; face_descriptor f = CGAL::internal::random_face_in_mesh(g, rnd); halfedge_descriptor h = halfedge(f, g); @@ -334,39 +336,39 @@ void test_predicates(const G& g, CGAL::Random& rnd) // --------------------------------------------------------------------------- Face_location loc(f, CGAL::make_array(FT(1), FT(0), FT(0))); - assert(PMP::is_on_vertex(loc, v, g)); + assert(PMP::is_on_vertex(loc, v, g)); loc = Face_location(f, CGAL::make_array(FT(0), FT(1), FT(0))); - assert(PMP::is_on_vertex(loc, target(h, g), g)); + assert(PMP::is_on_vertex(loc, target(h, g), g)); loc = Face_location(f, CGAL::make_array(FT(0), FT(0), FT(1))); - assert(PMP::is_on_vertex(loc, target(next(h, g), g), g)); + assert(PMP::is_on_vertex(loc, target(next(h, g), g), g)); loc = Face_location(f, CGAL::make_array(FT(-1), FT(1), FT(1))); - assert(!PMP::is_on_vertex(loc, target(next(h, g), g), g)); + assert(!PMP::is_on_vertex(loc, target(next(h, g), g), g)); // --------------------------------------------------------------------------- loc = Face_location(f, CGAL::make_array(FT(0.5), FT(0.5), FT(0))); - assert(PMP::is_on_halfedge(loc, h, g)); + assert(PMP::is_on_halfedge(loc, h, g)); loc = Face_location(f, CGAL::make_array(FT(0), FT(0.5), FT(0.5))); - assert(PMP::is_on_halfedge(loc, next(h, g), g)); + assert(PMP::is_on_halfedge(loc, next(h, g), g)); loc = Face_location(f, CGAL::make_array(FT(-0.5), FT(1.5), FT(0))); - assert(!PMP::is_on_halfedge(loc, h, g)); + assert(!PMP::is_on_halfedge(loc, h, g)); loc = Face_location(f, CGAL::make_array(FT(0.1), FT(-0.6), FT(1.5))); - assert(!PMP::is_on_halfedge(loc, h, g)); + assert(!PMP::is_on_halfedge(loc, h, g)); // --------------------------------------------------------------------------- loc = Face_location(f, CGAL::make_array(FT(0.3), FT(0.3), FT(0.4))); - assert(PMP::is_in_face(loc, g)); + assert(PMP::is_in_face(loc, g)); loc = Face_location(f, CGAL::make_array(FT(0), FT(0), FT(1))); - assert(PMP::is_in_face(loc, g)); + assert(PMP::is_in_face(loc, g)); loc = Face_location(f, CGAL::make_array(FT(0), FT(2), FT(-1))); - assert(!PMP::is_in_face(loc, g)); + assert(!PMP::is_in_face(loc, g)); // --------------------------------------------------------------------------- loc = Face_location(f, CGAL::make_array(FT(0.3), FT(0.3), FT(0.4))); - assert(!PMP::is_on_face_border(loc, g)); + assert(!PMP::is_on_face_border(loc, g)); loc = Face_location(f, CGAL::make_array(FT(0), FT(0.6), FT(0.4))); - assert(PMP::is_on_face_border(loc, g)); + assert(PMP::is_on_face_border(loc, g)); loc = Face_location(f, CGAL::make_array(FT(0), FT(0), FT(1))); - assert(PMP::is_on_face_border(loc, g)); + assert(PMP::is_on_face_border(loc, g)); loc = Face_location(f, CGAL::make_array(FT(-0.2), FT(0), FT(1.2))); assert(!PMP::is_on_face_border(loc, g)); @@ -388,68 +390,69 @@ void test_predicates(const G& g, CGAL::Random& rnd) loc.second[(id_of_h+1)%3] = FT(0); loc.second[(id_of_h+2)%3] = FT(0); boost::optional opt_hd = CGAL::is_border(source(h, g), g); - assert(PMP::is_on_mesh_border(loc, g) == (opt_hd != boost::none)); + assert(PMP::is_on_mesh_border(loc, g) == (opt_hd != boost::none)); loc.second[id_of_h] = FT(0.5); loc.second[(id_of_h+1)%3] = FT(0.5); - assert(PMP::is_on_mesh_border(loc, g) == CGAL::is_border(edge(h, g), g)); + assert(PMP::is_on_mesh_border(loc, g) == CGAL::is_border(edge(h, g), g)); // Even if the point does lie on the border of the mesh, 'false' is returned because // another face descriptor should be used. loc.second[id_of_h] = -0.5; loc.second[(id_of_h+1)%3] = 1.5; - assert(!PMP::is_on_mesh_border(loc, g)); + assert(!PMP::is_on_mesh_border(loc, g)); if(++counter > max) break; } } -template -void test_locate_in_face(const G& g, CGAL::Random& rnd) +template +void test_locate_in_face(const G& g, + const VPM vpm, + CGAL::Random& rnd) { std::cout << " test locate_in_face()..." << std::endl; - typedef typename boost::property_map_value::type Point; - typedef typename CGAL::Kernel_traits::type Kernel; - typedef typename Kernel::FT FT; + typedef typename boost::property_traits::reference Point_reference; + typedef typename K::FT FT; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename PMP::Location_traits::Face_location Face_location; - - typedef typename boost::property_map::const_type VertexPointMap; - VertexPointMap vpm = CGAL::get_const_property_map(boost::vertex_point, g); + typedef typename PMP::Face_location Face_location; const face_descriptor f = CGAL::internal::random_face_in_mesh(g, rnd); const halfedge_descriptor h = halfedge(f, g); const vertex_descriptor v = target(h, g); Face_location loc; - typename PMP::Location_traits::FT a = 0.1; - Point p = get(vpm, v); + FT a = 0.1; + Point_reference p = get(vpm, v); - loc = PMP::locate_in_face(v, g); + loc = PMP::locate_vertex(v, g); assert(is_equal(loc.second[CGAL::vertex_index_in_face(v, loc.first, g)], FT(1))); assert(is_equal(loc.second[(CGAL::vertex_index_in_face(v, loc.first, g)+1)%3], FT(0))); assert(is_equal(loc.second[(CGAL::vertex_index_in_face(v, loc.first, g)+2)%3], FT(0))); - loc = PMP::locate_in_face(v, f, g); + loc = PMP::locate_vertex(v, f, g); assert(loc.first == f); assert(is_equal(loc.second[0], FT(0)) && is_equal(loc.second[1], FT(1)) && is_equal(loc.second[2], FT(0))); - loc = PMP::locate_in_face(h, a, g); + loc = PMP::locate_on_halfedge(h, a, g); const int h_id = CGAL::halfedge_index_in_face(h, g); assert(loc.first == f && is_equal(loc.second[(h_id+2)%3], FT(0))); - loc = PMP::locate_in_face(p, f, g, CGAL::parameters::all_default()); + loc = PMP::locate_in_face(p, f, g, CGAL::parameters::vertex_point_map(vpm).geom_traits(K())); int v_id = CGAL::vertex_index_in_face(v, f, g); assert(loc.first == f && is_equal(loc.second[v_id], FT(1))); - loc = PMP::locate_in_face(p, f, g); - v_id = CGAL::vertex_index_in_face(v, f, g); + // Internal vertex point pmap + typedef typename boost::property_map_value::type Point; + + Point p2 = get(CGAL::vertex_point, g, v); + PMP::locate_in_face(p2, f, g); assert(loc.first == f && is_equal(loc.second[v_id], FT(1))); // --------------------------------------------------------------------------- @@ -473,84 +476,82 @@ void test_locate_in_face(const G& g, CGAL::Random& rnd) PMP::locate_in_adjacent_face(loc, neigh_f, g); - assert(PMP::locate_in_common_face(loc, neigh_loc, g)); + assert(PMP::locate_in_common_face(loc, neigh_loc, g)); - assert(PMP::locate_in_common_face(loc, p, neigh_loc, g)); - assert(PMP::locate_in_common_face(loc, p, neigh_loc, g, 1e-7)); + assert(PMP::locate_in_common_face(loc, p, neigh_loc, g, CGAL::parameters::vertex_point_map(vpm).geom_traits(K()))); + assert(PMP::locate_in_common_face(loc, p, neigh_loc, g, CGAL::parameters::vertex_point_map(vpm).geom_traits(K()), 1e-7)); } } -template +template ::value_type>::value> struct Locate_with_AABB_tree_Tester // 2D case { template - void operator()(const G& g, CGAL::Random& rnd) const + void test(const G& g, const VPM vpm, CGAL::Random& rnd) const { std::cout << " test locate_with_AABB_tree (2D)..." << std::endl; - typedef typename boost::property_map_value::type Point; + typedef typename boost::property_traits::reference Point_reference; - typedef typename boost::property_map::const_type VertexPointMap; - - typedef typename CGAL::Kernel_traits::type Kernel; - typedef typename Kernel::FT FT; - typedef typename Kernel::Ray_2 Ray_2; - typedef typename Kernel::Ray_3 Ray_3; - typedef typename Kernel::Point_3 Point_3; + typedef typename K::FT FT; + typedef typename K::Ray_2 Ray_2; + typedef typename K::Ray_3 Ray_3; + typedef typename K::Point_3 Point_3; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename PMP::Location_traits::Face_location Face_location; + typedef typename PMP::Face_location Face_location; face_descriptor f = CGAL::internal::random_face_in_mesh(g, rnd); halfedge_descriptor h = halfedge(f, g); vertex_descriptor v = target(h, g); // --------------------------------------------------------------------------- - typedef typename boost::property_traits::value_type Intrinsic_point; + typedef typename boost::property_traits::value_type Intrinsic_point; typedef PMP::internal::Point_to_Point_3 Intrinsic_point_to_Point_3; - typedef PMP::internal::Point_to_Point_3_VPM WrappedVertexPointMap; - typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; - typedef CGAL::AABB_traits AABB_face_graph_traits; + typedef PMP::internal::Point_to_Point_3_VPM WrappedVPM; + typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; + typedef CGAL::AABB_traits AABB_face_graph_traits; CGAL_static_assertion((std::is_same::value)); Intrinsic_point_to_Point_3 to_p3; CGAL::AABB_tree tree_a; - VertexPointMap vpm_a = CGAL::get_const_property_map(boost::vertex_point, g); - typename boost::property_traits::value_type p_a = get(vpm_a, v); + Point_reference p_a = get(vpm, v); const Point_3& p3_a = to_p3(p_a); CGAL::AABB_tree tree_b; - WrappedVertexPointMap vpm_b(g); + WrappedVPM vpm_b(vpm); // --------------------------------------------------------------------------- - PMP::build_AABB_tree(g, tree_a); - assert(tree_a.size() == num_faces(g)); - + PMP::build_AABB_tree(g, tree_a, CGAL::parameters::vertex_point_map(vpm)); PMP::build_AABB_tree(g, tree_b, CGAL::parameters::vertex_point_map(vpm_b)); assert(tree_b.size() == num_faces(g)); - Face_location loc = PMP::locate_with_AABB_tree(p_a, tree_a, g); + Face_location loc = PMP::locate_with_AABB_tree(p_a, tree_a, g, CGAL::parameters::vertex_point_map(vpm)); // sanitize otherwise some test platforms fail - PMP::internal::snap_location_to_border(loc, 1e-7); + PMP::internal::snap_location_to_border(loc, g, FT(1e-7)); assert(PMP::is_on_vertex(loc, v, g)); // might fail du to precision issues... assert(is_equal(loc.second[CGAL::vertex_index_in_face(v, loc.first, g)], FT(1))); assert(is_equal(loc.second[(CGAL::vertex_index_in_face(v, loc.first, g)+1)%3], FT(0))); assert(is_equal(loc.second[(CGAL::vertex_index_in_face(v, loc.first, g)+2)%3], FT(0))); - assert(is_equal(CGAL::squared_distance(to_p3(PMP::construct_point(loc, g)), p3_a), FT(0))); + assert(is_equal(CGAL::squared_distance(to_p3( + PMP::construct_point(loc, g, CGAL::parameters::vertex_point_map(vpm))), p3_a), FT(0))); - loc = PMP::locate_with_AABB_tree(p_a, tree_a, g, CGAL::parameters::vertex_point_map(vpm_a)); - assert(is_equal(CGAL::squared_distance(to_p3(PMP::construct_point(loc, g)), p3_a), FT(0))); + loc = PMP::locate_with_AABB_tree(p_a, tree_a, g, CGAL::parameters::vertex_point_map(vpm)); + assert(is_equal(CGAL::squared_distance(to_p3( + PMP::construct_point(loc, g, CGAL::parameters::vertex_point_map(vpm))), p3_a), FT(0))); // --------------------------------------------------------------------------- - loc = PMP::locate(p_a, g); - assert(is_equal(CGAL::squared_distance(to_p3(PMP::construct_point(loc, g)), p3_a), FT(0))); + loc = PMP::locate(p_a, g, CGAL::parameters::vertex_point_map(vpm)); + assert(is_equal(CGAL::squared_distance(to_p3( + PMP::construct_point(loc, g, CGAL::parameters::vertex_point_map(vpm))), p3_a), FT(0))); assert(PMP::is_in_face(loc, g)); loc = PMP::locate_with_AABB_tree(CGAL::ORIGIN, tree_b, g, CGAL::parameters::vertex_point_map(vpm_b)); @@ -561,12 +562,13 @@ struct Locate_with_AABB_tree_Tester // 2D case // --------------------------------------------------------------------------- Ray_2 r2 = random_2D_ray >(tree_a, rnd); - loc = PMP::locate_with_AABB_tree(r2, tree_a, g); + loc = PMP::locate_with_AABB_tree(r2, tree_a, g, CGAL::parameters::vertex_point_map(vpm)); if(loc.first != boost::graph_traits::null_face()) assert(PMP::is_in_face(loc, g)); Ray_3 r3 = random_3D_ray >(tree_b, rnd); - loc = PMP::locate_with_AABB_tree(r3, tree_b, g, CGAL::parameters::vertex_point_map(vpm_b)); + loc = PMP::locate_with_AABB_tree(r3, tree_b, g, CGAL::parameters::vertex_point_map(vpm_b) + .geom_traits(K())); } }; @@ -575,7 +577,7 @@ struct My_3D_Point { typedef typename K::FT FT; - typedef K R; + typedef K R; // so that we can use Kernel_traits typedef CGAL::Dimension_tag<3> Ambient_dimension; typedef CGAL::Dimension_tag<0> Feature_dimension; @@ -591,112 +593,117 @@ private: FT cx, cy, cz; }; -template <> -struct Locate_with_AABB_tree_Tester<3> // 3D +template +struct Locate_with_AABB_tree_Tester // 3D { template - void operator()(const G& g, CGAL::Random& rnd) const + void test(const G& g, const VPM vpm, CGAL::Random& rnd) const { std::cout << " test locate_with_AABB_tree (3D)..." << std::endl; - typedef typename boost::property_map_value::type Point; - - typedef typename CGAL::Kernel_traits::type Kernel; - typedef typename Kernel::FT FT; - typedef typename Kernel::Ray_3 Ray_3; - typedef typename Kernel::Point_3 Point_3; + typedef typename boost::property_traits::reference Point_reference; + typedef typename K::FT FT; + typedef typename K::Ray_3 Ray_3; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename PMP::Location_traits::Face_location Face_location; + typedef typename PMP::Face_location Face_location; face_descriptor f = CGAL::internal::random_face_in_mesh(g, rnd); halfedge_descriptor h = halfedge(f, g); vertex_descriptor v = target(h, g); // --------------------------------------------------------------------------- - typedef typename PMP::Location_traits::VPM VertexPointMap; - typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; - typedef CGAL::AABB_traits AABB_face_graph_traits; + typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; + typedef CGAL::AABB_traits AABB_face_graph_traits; + CGAL_assertion_code(typedef typename K::Point_3 Point_3;) CGAL_static_assertion((std::is_same::value)); CGAL::AABB_tree tree_a; - VertexPointMap vpm_a = CGAL::get_const_property_map(boost::vertex_point, g); - typename boost::property_traits::value_type p3_a = get(vpm_a, v); + Point_reference p3_a = get(vpm, v); // below tests the case where the value type of the VPM is not Kernel::Point_3 - typedef My_3D_Point Intrinsic_point; - typedef std::map Custom_map; + typedef My_3D_Point Custom_point; + typedef std::map Custom_map; typedef boost::associative_property_map Custom_VPM; - typedef PMP::internal::Point_to_Point_3_VPM WrappedVertexPointMap; - typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive_with_WVPM; - typedef CGAL::AABB_traits AABB_face_graph_traits_with_WVPM; + typedef PMP::internal::Point_to_Point_3_VPM WrappedVPM; + typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive_with_WVPM; + typedef CGAL::AABB_traits AABB_face_graph_traits_with_WVPM; CGAL::AABB_tree tree_b; Custom_map custom_map; for(vertex_descriptor vd : vertices(g)) { - const Point_3& p = get(vpm_a, vd); - custom_map[vd] = Intrinsic_point(p.x(), p.y(), p.z()); + const Point_reference p = get(vpm, vd); + custom_map[vd] = Custom_point(p.x(), p.y(), p.z()); } Custom_VPM custom_vpm(custom_map); - WrappedVertexPointMap vpm_b(custom_vpm); + WrappedVPM custom_vpm_3D(custom_vpm); // --------------------------------------------------------------------------- - PMP::build_AABB_tree(g, tree_a); + PMP::build_AABB_tree(g, tree_a); // just for the API assert(tree_a.size() == num_faces(g)); - PMP::build_AABB_tree(g, tree_b, CGAL::parameters::vertex_point_map(vpm_b)); + PMP::build_AABB_tree(g, tree_a, CGAL::parameters::vertex_point_map(vpm)); + PMP::build_AABB_tree(g, tree_b, CGAL::parameters::vertex_point_map(custom_vpm_3D)); assert(tree_b.size() == num_faces(g)); - Face_location loc = PMP::locate_with_AABB_tree(p3_a, tree_a, g); + Face_location loc = PMP::locate_with_AABB_tree(p3_a, tree_a, g, CGAL::parameters::vertex_point_map(vpm)); assert(is_equal(loc.second[CGAL::vertex_index_in_face(v, loc.first, g)], FT(1))); assert(is_equal(loc.second[(CGAL::vertex_index_in_face(v, loc.first, g)+1)%3], FT(0))); assert(is_equal(loc.second[(CGAL::vertex_index_in_face(v, loc.first, g)+2)%3], FT(0))); assert(is_equal(CGAL::squared_distance(PMP::construct_point(loc, g), p3_a), FT(0))); - loc = PMP::locate_with_AABB_tree(p3_a, tree_a, g, CGAL::parameters::vertex_point_map(vpm_a)); + loc = PMP::locate_with_AABB_tree(p3_a, tree_a, g, CGAL::parameters::vertex_point_map(vpm)); assert(is_equal(CGAL::squared_distance(PMP::construct_point(loc, g), p3_a), FT(0))); // --------------------------------------------------------------------------- loc = PMP::locate(p3_a, g, CGAL::parameters::snapping_tolerance(1e-7)); - std::cout << "loc: " << loc.second[0] << " " << loc.second[1] << " " << loc.second[2] << std::endl; // @tmp assert(is_equal(CGAL::squared_distance(PMP::construct_point(loc, g), p3_a), FT(0))); assert(PMP::is_in_face(loc, g)); - loc = PMP::locate_with_AABB_tree(CGAL::ORIGIN, tree_b, g, CGAL::parameters::vertex_point_map(vpm_b)); + loc = PMP::locate_with_AABB_tree(CGAL::ORIGIN, tree_b, g, CGAL::parameters::vertex_point_map(custom_vpm_3D)); assert(PMP::is_in_face(loc, g)); - // doesn't necessarily have to wrap with a P_to_P3 here, it'll do it internally + // Doesn't necessarily have to wrap with a P_to_P3: it can be done automatically internally loc = PMP::locate(CGAL::ORIGIN, g, CGAL::parameters::vertex_point_map(custom_vpm)); assert(PMP::is_in_face(loc, g)); // --------------------------------------------------------------------------- Ray_3 r3 = random_3D_ray >(tree_b, rnd); - loc = PMP::locate_with_AABB_tree(r3, tree_b, g, CGAL::parameters::vertex_point_map(vpm_b)); + loc = PMP::locate_with_AABB_tree(r3, tree_b, g, CGAL::parameters::vertex_point_map(custom_vpm_3D)); } }; -template -void test_locate(const G& g, CGAL::Random& rnd) +template +void test_locate(const G& g, + const VPM vpm, + CGAL::Random& rnd) { assert(num_vertices(g) != 0 && num_faces(g) != 0); - test_snappers(g); - test_constructions(g, rnd); - test_random_entities(g, rnd); - test_helpers(g, rnd); - test_predicates(g, rnd); - test_locate_in_face(g, rnd); + test_snappers(g); + test_constructions(g, vpm, rnd); + test_random_entities(g, rnd); + test_helpers(g, rnd); + test_predicates(g, rnd); + test_locate_in_face(g, vpm, rnd); // This test has slight syntax changes between 2D and 3D (e.g. testing ray_2 in 3D makes no sense) - Locate_with_AABB_tree_Tester< - CGAL::Ambient_dimension::Point>::value>()(g, rnd); + Locate_with_AABB_tree_Tester AABB_tester; + AABB_tester.test(g, vpm, rnd); +} + +template +void test_locate(const G& g, CGAL::Random& rnd) +{ + return test_locate(g, CGAL::get_const_property_map(boost::vertex_point, g), rnd); } template @@ -737,7 +744,7 @@ void test_2D_triangulation(const char* fname, CGAL::Random& rnd) std::cout << " (" << tr.number_of_vertices() << " vertices)..." << std::endl; std::cout << "Kernel: " << typeid(K()).name() << std::endl; - test_locate(tr, rnd); + test_locate(tr, rnd); } template @@ -759,16 +766,16 @@ void test_2D_surface_mesh(const char* fname, CGAL::Random& rnd) return; } - test_locate(tm, rnd); + test_locate(tm, rnd); } template -void test_3D_surface_mesh(const char* fname, CGAL::Random& rnd) +void test_surface_mesh_3D(const char* fname, CGAL::Random& rnd) { typedef typename K::Point_3 Point; typedef CGAL::Surface_mesh Mesh; - std::cout << "Testing Surface_mesh " << fname << "..." << std::endl; + std::cout << "Testing (3D) Surface_mesh " << fname << "..." << std::endl; std::cout << "Kernel: " << typeid(K()).name() << std::endl; std::ifstream input(fname); @@ -779,7 +786,42 @@ void test_3D_surface_mesh(const char* fname, CGAL::Random& rnd) return; } - test_locate(tm, rnd); + typedef typename boost::property_map::const_type VertexPointMap; + VertexPointMap vpm = CGAL::get_const_property_map(boost::vertex_point, tm); + + test_locate(tm, vpm, rnd); +} + +template +void test_surface_mesh_projection(const char* fname, CGAL::Random& rnd) +{ + typedef typename K::Point_3 Point; + typedef CGAL::Surface_mesh Mesh; + typedef typename K::Point_2 Projected_point; + + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + + std::cout << "Testing Projected Surface_mesh " << fname << "..." << std::endl; + std::cout << "Kernel: " << typeid(K()).name() << std::endl; + + std::ifstream input(fname); + Mesh tm; + if(!input || !(input >> tm)) + { + std::cerr << "Error: cannot read file."; + return; + } + + const auto& proj_vpm = tm.template add_property_map("P2", Projected_point()).first; + + for(vertex_descriptor v : vertices(tm)) + { + const Point& p = tm.point(v); + put(proj_vpm, v, Projected_point(p.x(), p.y())); + } + + test_locate(tm, proj_vpm, rnd); } template @@ -798,15 +840,16 @@ void test_polyhedron(const char* fname, CGAL::Random& rnd) return; } - test_locate(poly, rnd); + test_locate(poly, rnd); } template void test(CGAL::Random& rnd) { test_2D_triangulation("data/stair.xy", rnd); -// test_2D_surface_mesh("data/blobby_2D.off", rnd); // temporarily, until Surface_mesh's IO is "fixed" - test_3D_surface_mesh("data/mech-holes-shark.off", rnd); +// test_2D_surface_mesh("data/blobby_2D.off", rnd); // temporarily disabled, until Surface_mesh's IO is "fixed" + test_surface_mesh_3D("data/mech-holes-shark.off", rnd); + test_surface_mesh_projection("data/unit-grid.off", rnd); test_polyhedron("data-coref/elephant_split_2.off", rnd); } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_manifoldness.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_manifoldness.cpp index 788a22e428a..c4b8a98d2fa 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_manifoldness.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_manifoldness.cpp @@ -6,8 +6,6 @@ #include #include -#include - #include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_remove_caps_needles.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_remove_caps_needles.cpp new file mode 100644 index 00000000000..f6e418b23a7 --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_remove_caps_needles.cpp @@ -0,0 +1,47 @@ +#include +#include + +#include +#include +#include + +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Surface_mesh Mesh; + +typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; +typedef boost::graph_traits::edge_descriptor edge_descriptor; +typedef boost::graph_traits::face_descriptor face_descriptor; + +namespace PMP = CGAL::Polygon_mesh_processing; + +int main(int argc, char** argv) +{ + const char* filename = (argc > 1) ? argv[1] : "data/pig.off"; + std::ifstream input(filename); + + Mesh mesh; + if (!input || !(input >> mesh) || !CGAL::is_triangle_mesh(mesh)) { + std::cerr << "Not a valid input file." << std::endl; + return 1; + } + + std::cout << "Input mesh has " << edges(mesh).size() << " edges\n"; + if (PMP::does_self_intersect(mesh)) + std::cout << "Input mesh has self-intersections\n"; + + PMP::experimental::remove_almost_degenerate_faces(mesh, + std::cos(160. / 180 * CGAL_PI), + 4, + 0.14); + std::ofstream out("cleaned_mesh.off"); + out << std::setprecision(17) << mesh; + + std::cout << "Output mesh has " << edges(mesh).size() << " edges\n"; + if (PMP::does_self_intersect(mesh)) + std::cout << "Output mesh has self-intersections\n"; + + return 0; +} diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_stitching.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_stitching.cpp index e001896c859..f2ae9f68f60 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_stitching.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_stitching.cpp @@ -33,12 +33,15 @@ void test_stitch_boundary_cycles(const char* fname, } std::size_t res = PMP::stitch_boundary_cycles(mesh); + std::cout << "res: " << res << " (expected: " << expected_n << ")" << std::endl; + assert(res == expected_n); assert(is_valid(mesh)); } template -void test_polyhedron(const char* fname) +void test_polyhedron(const char* fname, + const std::size_t expected_n) { std::cout << "Testing Polyhedron_3 " << fname << "..." << std::flush; @@ -53,15 +56,19 @@ void test_polyhedron(const char* fname) assert(poly.size_of_vertices() > 0); - PMP::stitch_borders(poly); + std::size_t res = PMP::stitch_borders(poly); poly.normalize_border(); + std::cout << "res: " << res << " (expected: " << expected_n << ")" << std::endl; assert(poly.is_valid(false, 5)); + assert(res == expected_n); + std::cout << "OK\n"; } template -void test_polyhedron_cc(const char* fname) +void test_polyhedron_cc(const char* fname, + const std::size_t expected_n) { std::cout << "Testing Polyhedron_3 " << fname << "..." << std::flush; @@ -76,14 +83,18 @@ void test_polyhedron_cc(const char* fname) assert(poly.size_of_vertices() > 0); - PMP::stitch_borders(poly, params::apply_per_connected_component(true)); + std::size_t res = PMP::stitch_borders(poly, params::apply_per_connected_component(true)); poly.normalize_border(); + std::cout << "res: " << res << " (expected: " << expected_n << ")" << std::endl; assert(poly.is_valid(false, 5)); + assert(res == expected_n); + std::cout << "OK\n"; } -void test_surface_mesh(const char* fname) +void test_surface_mesh(const char* fname, + const std::size_t expected_n) { std::cout << "Testing Surface_mesh " << fname << "..." << std::flush; @@ -96,13 +107,17 @@ void test_surface_mesh(const char* fname) return; } - PMP::stitch_borders(mesh); + std::size_t res = PMP::stitch_borders(mesh); + std::cout << "res: " << res << " (expected: " << expected_n << ")" << std::endl; + + assert(res == expected_n); assert(is_valid_polygon_mesh(mesh)); std::cout << "OK\n"; } -void test_surface_mesh_cc(const char* fname) +void test_surface_mesh_cc(const char* fname, + const std::size_t expected_n) { std::cout << "Testing Surface_mesh " << fname << "..." << std::flush; @@ -115,7 +130,10 @@ void test_surface_mesh_cc(const char* fname) return; } - PMP::stitch_borders(mesh, params::apply_per_connected_component(true)); + std::size_t res = PMP::stitch_borders(mesh, params::apply_per_connected_component(true)); + std::cout << "res: " << res << " (expected: " << expected_n << ")" << std::endl; + + assert(res == expected_n); assert(is_valid(mesh)); std::cout << "OK\n"; @@ -140,32 +158,32 @@ int main() test_stitch_boundary_cycles("data_stitching/boundary_cycle.off", 4); test_stitch_boundary_cycles("data_stitching/boundary_cycle_2.off", 2); - test_polyhedron("data_stitching/full_border.off"); - test_polyhedron("data_stitching/full_border.off"); - test_polyhedron("data_stitching/full_border_quads.off"); - test_polyhedron("data_stitching/half_border.off"); - test_polyhedron("data_stitching/mid_border.off"); - test_polyhedron("data_stitching/multiple_incidence.off"); - test_polyhedron("data_stitching/incidence_3.off"); - test_polyhedron("data_stitching/incoherent_patch_orientation.off"); - test_polyhedron("data_stitching/non_stitchable.off"); - test_polyhedron("data_stitching/deg_border.off"); - test_polyhedron("data_stitching/two_patches.off"); - test_polyhedron("data_stitching/non_manifold.off"); - test_polyhedron("data_stitching/non_manifold2.off"); - test_polyhedron_cc("data_stitching/nm_cubes.off"); + test_polyhedron("data_stitching/deg_border.off", 2); + test_polyhedron("data_stitching/full_border.off", 4); + test_polyhedron("data_stitching/full_border.off", 4); + test_polyhedron("data_stitching/full_border_quads.off", 4); + test_polyhedron("data_stitching/half_border.off", 2); + test_polyhedron("data_stitching/incidence_3.off", 3); + test_polyhedron("data_stitching/incoherent_patch_orientation.off", 1); + test_polyhedron("data_stitching/mid_border.off", 2); + test_polyhedron("data_stitching/multiple_incidence.off", 10); + test_polyhedron("data_stitching/non_stitchable.off", 0); + test_polyhedron("data_stitching/non_manifold.off", 0); + test_polyhedron("data_stitching/non_manifold2.off", 0); + test_polyhedron("data_stitching/two_patches.off", 3); + test_polyhedron_cc("data_stitching/nm_cubes.off", 4); - test_surface_mesh("data_stitching/full_border.off"); - test_surface_mesh("data_stitching/full_border_quads.off"); - test_surface_mesh("data_stitching/half_border.off"); - test_surface_mesh("data_stitching/mid_border.off"); - test_surface_mesh("data_stitching/multiple_incidence.off"); - test_surface_mesh("data_stitching/incidence_3.off"); - test_surface_mesh("data_stitching/incoherent_patch_orientation.off"); - test_surface_mesh("data_stitching/non_stitchable.off"); - test_surface_mesh("data_stitching/deg_border.off"); - test_surface_mesh("data_stitching/non_manifold.off"); - test_surface_mesh_cc("data_stitching/nm_cubes.off"); + test_surface_mesh("data_stitching/deg_border.off", 2); + test_surface_mesh("data_stitching/full_border.off", 4); + test_surface_mesh("data_stitching/full_border_quads.off", 4); + test_surface_mesh("data_stitching/half_border.off", 2); + test_surface_mesh("data_stitching/incidence_3.off", 3); + test_surface_mesh("data_stitching/incoherent_patch_orientation.off", 1); + test_surface_mesh("data_stitching/mid_border.off", 2); + test_surface_mesh("data_stitching/multiple_incidence.off", 10); + test_surface_mesh("data_stitching/non_stitchable.off", 0); + test_surface_mesh("data_stitching/non_manifold.off", 0); + test_surface_mesh_cc("data_stitching/nm_cubes.off", 4); bug_test(); diff --git a/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies b/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies index 8ad0841f42c..cf61d44e4ba 100644 --- a/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies +++ b/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies @@ -20,17 +20,17 @@ Modular_arithmetic Number_types Point_set_3 Point_set_processing_3 -Polygonal_surface_reconstruction Polygon +Polygonal_surface_reconstruction Principal_component_analysis Principal_component_analysis_LGPL Profiling_tools -Solver_interface Property_map Random_numbers +STL_Extension +Solver_interface Spatial_searching Spatial_sorting -STL_Extension Stream_support Surface_mesh TDS_2 diff --git a/Polyhedron/demo/Polyhedron/CGAL_double_edit.cpp b/Polyhedron/demo/Polyhedron/CGAL_double_edit.cpp new file mode 100644 index 00000000000..07c630b7828 --- /dev/null +++ b/Polyhedron/demo/Polyhedron/CGAL_double_edit.cpp @@ -0,0 +1,78 @@ +#include "CGAL_double_edit.h" + +#include + +class DoubleValidator : public QDoubleValidator +{ +public: + DoubleValidator(QObject* parent = nullptr) + : QDoubleValidator(parent) + { + setLocale(QLocale::C); + } + + void fixup ( QString & input ) const + { + input.replace(".", locale().decimalPoint()); + input.replace(",", locale().decimalPoint()); + QDoubleValidator::fixup(input); + } + QValidator::State validate ( QString & input, int & pos ) const + { + fixup(input); + return QDoubleValidator::validate(input, pos); + } +}; + + DoubleEdit::DoubleEdit(QWidget *parent) + : QLineEdit(parent) + { + validator = new DoubleValidator(this); + this->setValidator(validator); + } + + DoubleEdit::~DoubleEdit() + { + delete validator; + } + + + double DoubleEdit::value() const + { + return this->text().toDouble(); + } + + void DoubleEdit::setValue(double d) + { + this->setText(tr("%1").arg(d)); + } + + void DoubleEdit::setMinimum(double d) + { + this->validator->setBottom(d); + } + + void DoubleEdit::setMaximum(double d) + { + this->validator->setTop(d); + } + + void DoubleEdit::setRange(double min, double max) + { + this->validator->setRange(min, max); + } + + double DoubleEdit::getValue() + { + return this->value(); + } + + double DoubleEdit::getMinimum() + { + return this->validator->bottom(); + } + + double DoubleEdit::getMaximum() + { + return this->validator->top(); + } diff --git a/Polyhedron/demo/Polyhedron/CGAL_double_edit.h b/Polyhedron/demo/Polyhedron/CGAL_double_edit.h new file mode 100644 index 00000000000..1b542d2bb22 --- /dev/null +++ b/Polyhedron/demo/Polyhedron/CGAL_double_edit.h @@ -0,0 +1,33 @@ +#ifndef CGAL_DOUBLE_EDIT_H +#define CGAL_DOUBLE_EDIT_H + + + +#include +#include +#include +#include "Scene_config.h" + + +class DoubleValidator; +class SCENE_EXPORT DoubleEdit : public QLineEdit { + + Q_OBJECT + Q_PROPERTY(double value READ getValue WRITE setValue) + Q_PROPERTY(double minimum READ getMinimum WRITE setMinimum) + Q_PROPERTY(double maximum READ getMaximum WRITE setMaximum) +public: + DoubleEdit(QWidget* parent = nullptr); + ~DoubleEdit(); + double value() const; + void setValue(double d); + void setMinimum(double d); + void setMaximum(double d); + void setRange(double min, double max); + double getValue(); + double getMinimum(); + double getMaximum(); +private: + DoubleValidator* validator; +}; +#endif // CGAL_DOUBLE_EDIT_H diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index fc4afa3bb09..6427dc55d7d 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -190,7 +190,8 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) Scene_item_rendering_helper.cpp Scene_item_rendering_helper_moc.cpp Primitive_container.cpp - Polyhedron_demo_plugin_helper.cpp) + Polyhedron_demo_plugin_helper.cpp + CGAL_double_edit.cpp) target_link_libraries(demo_framework PUBLIC Qt5::OpenGL Qt5::Widgets Qt5::Gui Qt5::Script ) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 9fb344a24b3..d80f0485a0c 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -2275,6 +2275,11 @@ void MainWindow::on_actionPreferences_triggered() this->s_defaultPSRM = CGAL::Three::Three::modeFromName(text); }); + connect(prefdiag.backFrontColor_pushButton, &QPushButton::clicked, + this, [](){ + qobject_cast(CGAL::Three::Three::activeViewer())->setBackFrontColors(); + }); + std::vector items; QBrush successBrush(Qt::green), errorBrush(Qt::red), @@ -2959,6 +2964,9 @@ void MainWindow::setupViewer(Viewer* viewer, SubViewer* subviewer) } viewer->setTotalPass(nb); }); + action= subviewer->findChild("actionBackFrontShading"); + connect(action, SIGNAL(toggled(bool)), + viewer, SLOT(setBackFrontShading(bool))); connect(viewer, SIGNAL(requestContextMenu(QPoint)), this, SLOT(contextMenuRequested(QPoint))); connect(viewer, SIGNAL(selected(int)), @@ -3127,6 +3135,11 @@ SubViewer::SubViewer(QWidget *parent, MainWindow* mw, Viewer* mainviewer) QAction* actionTotalPass = new QAction("Set Transparency Pass &Number...",this); actionTotalPass->setObjectName("actionTotalPass"); viewMenu->addAction(actionTotalPass); + QAction* actionBackFrontShading = new QAction("Activate Back/Front shading.",this); + actionBackFrontShading->setObjectName("actionBackFrontShading"); + actionBackFrontShading->setCheckable(true); + actionBackFrontShading->setChecked(false); + viewMenu->addAction(actionBackFrontShading); if(mainviewer) setAttribute(Qt::WA_DeleteOnClose); setWindowIcon(QIcon(":/cgal/icons/resources/menu.png")); diff --git a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp index ca66b7ce18a..d7a3863ce3a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp @@ -258,7 +258,7 @@ public: is_tree_empty = tree.empty(); nb_lines = positions_lines.size(); setEdgeContainer(0, new Ec(Vi::PROGRAM_NO_SELECTION, false)); - BOOST_FOREACH(auto v, CGAL::QGLViewer::QGLViewerPool()) + for(auto v : CGAL::QGLViewer::QGLViewerPool()) { CGAL::Three::Viewer_interface* viewer = static_cast(v); initGL(viewer); @@ -488,7 +488,7 @@ public: setEdgeContainer(0, new Ec(Vi::PROGRAM_NO_SELECTION, false)); texture = new ::Texture(m_grid_size,m_grid_size); getTriangleContainer(0)->setTextureSize(QSize(m_grid_size, m_grid_size)); - BOOST_FOREACH(auto v, CGAL::QGLViewer::QGLViewerPool()) + for(auto v : CGAL::QGLViewer::QGLViewerPool()) { CGAL::Three::Viewer_interface* viewer = static_cast(v); initGL(viewer); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Classification_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Classification/Classification_plugin.cpp index b02c0e2f14d..7ae9229ba59 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Classification_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Classification_plugin.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include "CGAL_double_edit.h" #include #include @@ -619,10 +619,7 @@ public Q_SLOTS: scales->setRange (1, 99); scales->setValue (5); - QDoubleSpinBox* voxel_size = dialog.add ("Voxel size (0 for automatic):"); - voxel_size->setRange (0.0, 10000.0); - voxel_size->setValue (0.0); - voxel_size->setSingleStep (0.01); + DoubleEdit* voxel_size = dialog.add ("Voxel size (0 for automatic):"); if (dialog.exec() != QDialog::Accepted) return; @@ -921,10 +918,9 @@ public Q_SLOTS: subdivisions->setRange (1, 9999); subdivisions->setValue (16); - QDoubleSpinBox* smoothing = dialog.add ("Regularization weight: "); - smoothing->setRange (0.0, 100.0); - smoothing->setValue (0.5); - smoothing->setSingleStep (0.1); + DoubleEdit* smoothing = dialog.add ("Regularization weight: "); + + smoothing->setText(tr("%1").arg(0.5)); if (dialog.exec() != QDialog::Accepted) return; @@ -1371,10 +1367,9 @@ public Q_SLOTS: QSpinBox* trials = dialog.add ("Number of trials: ", "trials"); trials->setRange (1, 99999); trials->setValue (500); - QDoubleSpinBox* rate = dialog.add ("Learning rate: ", "learning_rate"); + DoubleEdit* rate = dialog.add ("Learning rate: ", "learning_rate"); rate->setRange (0.00001, 10000.0); rate->setValue (0.001); - rate->setDecimals (5); QSpinBox* batch = dialog.add ("Batch size: ", "batch_size"); batch->setRange (1, 2000000000); batch->setValue (1000); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp b/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp index d962e2f491d..2db5ec4b353 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp @@ -910,7 +910,7 @@ void Cluster_classification::train(int classifier, const QMultipleInputDialog& d m_neural_network->train (training, dialog.get("restart")->isChecked(), dialog.get("trials")->value(), - dialog.get("learning_rate")->value(), + dialog.get("learning_rate")->value(), dialog.get("batch_size")->value(), hidden_layers); 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 aee56b923e6..feb5779e208 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.cpp @@ -800,7 +800,7 @@ void Point_set_item_classification::train(int classifier, const QMultipleInputDi m_neural_network->train (training, dialog.get("restart")->isChecked(), dialog.get("trials")->value(), - dialog.get("learning_rate")->value(), + dialog.get("learning_rate")->value(), dialog.get("batch_size")->value(), hidden_layers); 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 bdd3adbf9c5..2c032b631f9 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Surface_mesh_item_classification.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Surface_mesh_item_classification.cpp @@ -366,7 +366,7 @@ void Surface_mesh_item_classification::train (int classifier, const QMultipleInp m_neural_network->train (training, dialog.get("restart")->isChecked(), dialog.get("trials")->value(), - dialog.get("learning_rate")->value(), + dialog.get("learning_rate")->value(), dialog.get("batch_size")->value(), hidden_layers); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property.ui b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property.ui index 2513e099a25..95538bdfcff 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property.ui @@ -110,44 +110,18 @@ - - - - - - 2.000000000000000 + + + 0.00 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Compute Ramp Extremas - - - Reset - - - false - - - - + + + 2.00 + + @@ -223,6 +197,13 @@ + + + DoubleEdit + QLineEdit +

    CGAL_double_edit.h
    + + diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 71ffd20d3df..df09bc33f2d 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -443,9 +443,6 @@ public: connect(dock_widget->deleteButton, &QPushButton::clicked, this, &DisplayPropertyPlugin::delete_group); - connect(dock_widget->resetButton, &QPushButton::pressed, - this, &DisplayPropertyPlugin::resetRampExtremas); - dock_widget->zoomToMaxButton->setEnabled(false); dock_widget->zoomToMinButton->setEnabled(false); Scene* scene_obj =static_cast(scene); @@ -464,29 +461,6 @@ private Q_SLOTS: dock_widget->raise(); } } - void resetRampExtremas() - { - Scene_surface_mesh_item* item = - qobject_cast(scene->item(scene->mainSelectionIndex())); - if(!item) - return; - QApplication::setOverrideCursor(Qt::WaitCursor); - item->face_graph()->collect_garbage(); - bool ok; - switch(dock_widget->propertyBox->currentIndex()) - { - case 0: - ok = resetAngles(item); - break; - default: - ok = resetScaledJacobian(item); - break; - } - QApplication::restoreOverrideCursor(); - if(!ok) - QMessageBox::warning(mw, "Error", "You must first run colorize once to initialize the values."); - } - void colorize() { Scene_heat_item* h_item = nullptr; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_2/Mesh_2_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_2/Mesh_2_plugin.cpp index c007f78408f..c552ae91eb0 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_2/Mesh_2_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_2/Mesh_2_plugin.cpp @@ -195,8 +195,6 @@ private: ui.edgeLength_dspinbox, SLOT(setEnabled(bool))); //Set default parameter edge length - ui.edgeLength_dspinbox->setDecimals(3); - ui.edgeLength_dspinbox->setSingleStep(0.001); ui.edgeLength_dspinbox->setRange(1e-6 * diag_length, //min 2. * diag_length);//max ui.edgeLength_dspinbox->setValue(0.05 * diag_length); @@ -252,20 +250,19 @@ private: bool runMesh2 = ui.runMesh2_checkbox->isChecked(); double target_length = ui.edgeLength_dspinbox->value(); unsigned int nb_iter = ui.nbIterations_spinbox->value(); - bool runLloyd = ui.runLloyd_checkbox->isChecked(); - + bool runLloyd = runMesh2?ui.runLloyd_checkbox->isChecked():false; // wait cursor QApplication::setOverrideCursor(Qt::WaitCursor); - typedef ProjectionTraits Gt; - typedef CGAL::Delaunay_mesh_vertex_base_2 Vb; - typedef CGAL::Delaunay_mesh_face_base_2 Fm; - typedef CGAL::Triangulation_face_base_with_info_2 Fb; - typedef CGAL::Triangulation_data_structure_2 TDS; - typedef CGAL::No_intersection_tag Tag; - typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; - typedef CGAL::Delaunay_mesh_size_criteria_2 Criteria; - typedef CGAL::Delaunay_mesher_2 Mesher; + typedef ProjectionTraits Gt; + typedef CGAL::Delaunay_mesh_vertex_base_2 Vb; + typedef CGAL::Delaunay_mesh_face_base_2 Fm; + typedef CGAL::Triangulation_face_base_with_info_2 Fb; + typedef CGAL::Triangulation_data_structure_2 TDS; + typedef CGAL::No_constraint_intersection_requiring_constructions_tag Tag; + typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; + typedef CGAL::Delaunay_mesh_size_criteria_2 Criteria; + typedef CGAL::Delaunay_mesher_2 Mesher; QTime time; // global timer time.start(); @@ -334,11 +331,12 @@ private: } // export result as a surface_mesh item - QString iname = - polylines_items.size()==1? - polylines_items.front()->name()+QString("_meshed_"): - QString("2dmesh_"); - iname+=QString::number(target_length); + QString iname = runMesh2 ? (( polylines_items.size()==1? + polylines_items.front()->name()+QString("_meshed_"): + QString("2dmesh_") )+QString::number(target_length) ) + : ( polylines_items.size()==1? + polylines_items.front()->name()+QString("_triangulated"): + QString("polylines_triangulation") ); if (runLloyd) iname+=QString("_Lloyd_")+QString::number(nb_iter); Scene_surface_mesh_item* poly_item = new Scene_surface_mesh_item(); poly_item->setName(iname); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_2/mesh_2_dialog.ui b/Polyhedron/demo/Polyhedron/Plugins/Mesh_2/mesh_2_dialog.ui index 566c4df41c5..b809786a2b6 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_2/mesh_2_dialog.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_2/mesh_2_dialog.ui @@ -10,7 +10,7 @@ 0 0 424 - 301 + 302 @@ -38,9 +38,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - edgeLength_dspinbox - @@ -56,22 +53,6 @@ - - - - - 110 - 0 - - - - 1000.000000000000000 - - - 0.100000000000000 - - - @@ -157,6 +138,13 @@ + + + + 0.00 + + + @@ -185,6 +173,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    buttonBox diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp index 12c3dd6649d..89b8a92ecc3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp @@ -305,7 +305,9 @@ get_parameters_from_dialog() QDialog dialog(mw); Ui::Rib_dialog ui; ui.setupUi(&dialog); - + ui.ambientIntensity->setMaximum(1.0); + ui.shadowIntensity->setMaximum(1.0); + connect(ui.buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept())); connect(ui.buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject())); connect(ui.resWidth, SIGNAL(valueChanged(int)), this, SLOT(width_changed(int))); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Local_optimizers_dialog.ui b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Local_optimizers_dialog.ui index 7b910b9acf3..b9b36481a0b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Local_optimizers_dialog.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Local_optimizers_dialog.ui @@ -6,7 +6,7 @@ 0 0 - 546 + 556 317 @@ -50,43 +50,11 @@ Parameters - - - + + + - Max CPU running time (s) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - maxTime - - - - - - - - 100 - 0 - - - - 1 - - - 9999.000000000000000 - - - 60.000000000000000 - - - - - - - No time limit + No angle bound @@ -98,37 +66,36 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - sliverBound + + + + + + No time limit - - - - - 100 - 0 - + + + + Max CPU running time (s) - - false + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - 1 - - - 180.000000000000000 - - - 8.000000000000000 + + + + + + 60.0 - + - No angle bound + 8.0 @@ -180,6 +147,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp index 7b3324cc49d..8a6f182fa17 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp @@ -293,6 +293,13 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) Ui::Meshing_dialog ui; ui.setupUi(&dialog); + ui.facetAngle->setRange(0.0, 30.0); + ui.facetAngle->setValue(25.0); + ui.edgeSizing->setMinimum(0.0); + ui.sharpEdgesAngle->setMaximum(180); + ui.iso_value_spinBox->setRange(-65536.0, 65536.0); + ui.tetShape->setMinimum(1.0); + ui.advanced->setVisible(false); connect(ui.facetTopologyLabel, &QLabel::linkActivated, @@ -361,22 +368,16 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) double diag = CGAL::sqrt((bbox.xmax()-bbox.xmin())*(bbox.xmax()-bbox.xmin()) + (bbox.ymax()-bbox.ymin())*(bbox.ymax()-bbox.ymin()) + (bbox.zmax()-bbox.zmin())*(bbox.zmax()-bbox.zmin())); int decimals = 0; double sizing_default = get_approximate(diag * 0.05, 2, decimals); - ui.facetSizing->setDecimals(-decimals+2); - ui.facetSizing->setSingleStep(std::pow(10.,decimals)); ui.facetSizing->setRange(diag * 10e-6, // min diag); // max ui.facetSizing->setValue(sizing_default); // default value ui.edgeSizing->setValue(sizing_default); - ui.tetSizing->setDecimals(-decimals+2); - ui.tetSizing->setSingleStep(std::pow(10.,decimals)); ui.tetSizing->setRange(diag * 10e-6, // min diag); // max ui.tetSizing->setValue(sizing_default); // default value double approx_default = get_approximate(diag * 0.005, 2, decimals); - ui.approx->setDecimals(-decimals+2); - ui.approx->setSingleStep(std::pow(10.,decimals)); ui.approx->setRange(diag * 10e-7, // min diag); // max ui.approx->setValue(approx_default); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Meshing_dialog.ui b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Meshing_dialog.ui index 56e918bf8b8..a29054048fa 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Meshing_dialog.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Meshing_dialog.ui @@ -115,9 +115,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - sharpEdgesAngle - @@ -128,9 +125,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - edgeSizing - @@ -140,29 +134,6 @@ - - - - 4 - - - 0.000000000000000 - - - 0.000000000000000 - - - - - - - 180.000000000000000 - - - 60.000000000000000 - - - @@ -186,6 +157,20 @@ + + + + 60.00 + + + + + + + 0.0 + + + @@ -216,9 +201,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - approx - @@ -234,16 +216,6 @@ - - - - - 110 - 0 - - - - @@ -252,22 +224,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - facetAngle - - - - - - - - 110 - 0 - - - - 4 - @@ -359,27 +315,25 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - facetSizing + + + + + + 0.00 + + + - - - - 110 - 0 - + + + 25,00 - - 0.000000000000000 - - - 30.000000000000000 - - - 25.000000000000000 + + 25,00 @@ -418,35 +372,6 @@ - - - - - 110 - 0 - - - - 1.000000000000000 - - - 3.000000000000000 - - - - - - - - 110 - 0 - - - - 4 - - - @@ -455,9 +380,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - tetShape - @@ -468,8 +390,19 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - tetSizing + + + + + + 0.00 + + + + + + + 3.00 @@ -504,22 +437,6 @@ - - - - -65536.000000000000000 - - - 65536.000000000000000 - - - 3.000000000000000 - - - - - - @@ -559,6 +476,20 @@ + + + + 0.00 + + + + + + + 3.00 + + + @@ -597,16 +528,18 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    - approx noApprox - facetSizing noFacetSizing - facetAngle noAngle - tetSizing noTetSizing - tetShape noTetShape checkBox manifoldCheckBox diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Optimization_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Optimization_plugin.cpp index 303e38fd5cc..d069d109672 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Optimization_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Optimization_plugin.cpp @@ -227,6 +227,9 @@ Mesh_3_optimization_plugin::odt() QDialog dialog(mw); Ui::Smoother_dialog ui; ui.setupUi(&dialog); + ui.convergenceRatio->setMaximum(1.0); + ui.convergenceRatio->setMinimum(0.0001); + ui.freezeRatio->setMinimum(0.0); dialog.setWindowFlags(Qt::Dialog|Qt::CustomizeWindowHint|Qt::WindowCloseButtonHint); dialog.setWindowTitle(tr("ODT-smoothing parameters")); @@ -362,6 +365,7 @@ Mesh_3_optimization_plugin::perturb() QDialog dialog(mw); Ui::LocalOptim_dialog ui; ui.setupUi(&dialog); + ui.sliverBound->setRange(0,180); dialog.setWindowFlags(Qt::Dialog|Qt::CustomizeWindowHint|Qt::WindowCloseButtonHint); dialog.setWindowTitle(tr("Sliver perturbation parameters")); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Rib_dialog.ui b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Rib_dialog.ui index 03a4514d7b6..c3639f5115a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Rib_dialog.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Rib_dialog.ui @@ -22,20 +22,6 @@ - - - - 4 - - - - - - - 4 - - - @@ -50,6 +36,20 @@ + + + + 0.00 + + + + + + + 0.00 + + + @@ -70,13 +70,6 @@ - - - - Ambient Light - - - @@ -87,29 +80,10 @@ - - - - 1.000000000000000 - - - 0.010000000000000 - - - 0.150000000000000 - - - - - - - 1.000000000000000 - - - 0.010000000000000 - - - 0.850000000000000 + + + + Shadow Light @@ -123,10 +97,24 @@ - - + + - Shadow Light + Ambient Light + + + + + + + 0.15 + + + + + + + 0.85 @@ -245,6 +233,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Smoother_dialog.ui b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Smoother_dialog.ui index 1f4fdcc0a8f..85ee2953a27 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Smoother_dialog.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Smoother_dialog.ui @@ -7,7 +7,7 @@ 0 0 507 - 328 + 331 @@ -50,7 +50,7 @@ Parameters - + 8 @@ -68,9 +68,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - maxTime -
    @@ -84,21 +81,9 @@ - - - - 100 - 0 - - - - 1 - - - 9999.000000000000000 - - - 60.000000000000000 + + + 60.0 @@ -122,7 +107,7 @@ false - + 8 @@ -148,19 +133,6 @@
    - - - - 0 - - - 200.000000000000000 - - - 100.000000000000000 - - - @@ -177,22 +149,6 @@ - - - - 4 - - - 0.000100000000000 - - - 1.000000000000000 - - - 0.010000000000000 - - - @@ -207,27 +163,29 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - freezeRatio + + + + + + 0.001 - - - - 4 - - - 0.000000000000000 + + + + 0.000 + + + + - 1.000000000000000 - - - 0.001000000000000 + 200 - 0.000000000000000 + 100 @@ -279,6 +237,13 @@
    + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp index b9766dec3ff..98851af36e8 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp @@ -64,7 +64,7 @@ public: bbox.xmax(),bbox.ymax(),bbox.zmax())); nb_points = points.size(); - BOOST_FOREACH(auto v, CGAL::QGLViewer::QGLViewerPool()) + for(auto v : CGAL::QGLViewer::QGLViewerPool()) { CGAL::Three::Viewer_interface* viewer = static_cast(v); initGL(viewer); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_widget.ui b/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_widget.ui index 4e215cf956f..865622d53a5 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_widget.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_widget.ui @@ -18,7 +18,7 @@ - 0 + 2 @@ -31,7 +31,7 @@ - :/cgal/Polyhedron_3/resources/prism.png + :/cgal/Polyhedron_3/resources/prism.png false @@ -136,15 +136,9 @@ QGroupBox::title { - - - 5 - - - 1000000000000000000.000000000000000 - - - 1.000000000000000 + + + 1.00 @@ -163,15 +157,9 @@ QGroupBox::title { - - - 5 - - - 1000000000000000000.000000000000000 - - - 1.000000000000000 + + + 1.00 @@ -235,7 +223,7 @@ QGroupBox::title { - :/cgal/Polyhedron_3/resources/icosphere.png + :/cgal/Polyhedron_3/resources/icosphere.png @@ -424,18 +412,15 @@ QGroupBox::title { - - - 5 + + + + 0 + 0 + - - -999999.000000000000000 - - - 999999.000000000000000 - - - 1.000000000000000 + + 1.00 @@ -469,7 +454,7 @@ QGroupBox::title { - + @@ -481,18 +466,15 @@ QGroupBox::title { - - - 5 + + + + 0 + 0 + - - -999999.000000000000000 - - - 999999.000000000000000 - - - 1.000000000000000 + + 1.00 @@ -558,7 +540,7 @@ QGroupBox::title { - :/cgal/Polyhedron_3/resources/hexahedron.png + :/cgal/Polyhedron_3/resources/hexahedron.png false @@ -768,7 +750,7 @@ QGroupBox::title { - :/cgal/Polyhedron_3/resources/tetrahedron.png + :/cgal/Polyhedron_3/resources/tetrahedron.png @@ -899,7 +881,7 @@ QGroupBox::title { - :/cgal/Polyhedron_3/resources/grid.png + :/cgal/Polyhedron_3/resources/grid.png @@ -1068,7 +1050,7 @@ QGroupBox::title { <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p></body></html> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;"><br /></p></body></html> false @@ -1105,7 +1087,7 @@ p, li { white-space: pre-wrap; } <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p></body></html> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;"><br /></p></body></html> false @@ -1183,11 +1165,13 @@ p, li { white-space: pre-wrap; } - - - - - - + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    + diff --git a/Polyhedron/demo/Polyhedron/Plugins/PCA/MeshOnGrid_dialog.ui b/Polyhedron/demo/Polyhedron/Plugins/PCA/MeshOnGrid_dialog.ui index f4ae9f081f0..2529489ac10 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PCA/MeshOnGrid_dialog.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/PCA/MeshOnGrid_dialog.ui @@ -26,13 +26,6 @@ Along X
    - - - - 99999999999999999475366575191804932315794610450682175621941694731908308538307845136842752.000000000000000 - - - @@ -57,6 +50,13 @@ + + + + 0.00 + + + @@ -66,13 +66,6 @@ Along Y - - - - 99999999999999999475366575191804932315794610450682175621941694731908308538307845136842752.000000000000000 - - - @@ -97,6 +90,13 @@ + + + + 0.00 + + + @@ -106,13 +106,6 @@ Along Z - - - - 99999999999999999475366575191804932315794610450682175621941694731908308538307845136842752.000000000000000 - - - @@ -137,6 +130,13 @@ + + + + 0.00 + + + @@ -165,6 +165,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt index 669b8e85ce1..b97c86f9879 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt @@ -78,7 +78,8 @@ target_link_libraries(corefinement_plugin PUBLIC scene_surface_mesh_item) polyhedron_demo_plugin(surface_intersection_plugin Surface_intersection_plugin KEYWORDS PMP) target_link_libraries(surface_intersection_plugin PUBLIC scene_surface_mesh_item scene_polylines_item scene_points_with_normal_item) -polyhedron_demo_plugin(repair_polyhedron_plugin Repair_polyhedron_plugin KEYWORDS PMP) +qt5_wrap_ui( repairUI_FILES RemoveNeedlesDialog.ui) +polyhedron_demo_plugin(repair_polyhedron_plugin Repair_polyhedron_plugin ${repairUI_FILES} KEYWORDS PMP) target_link_libraries(repair_polyhedron_plugin PUBLIC scene_surface_mesh_item) qt5_wrap_ui( isotropicRemeshingUI_FILES Isotropic_remeshing_dialog.ui) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp index 1a7b64458dd..6c9347d72d7 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp @@ -133,7 +133,6 @@ private: typedef CGAL::AABB_tree< Traits > Tree; Tree tree( faces(m).first, faces(m).second, m); - tree.accelerate_distance_queries(); tree.build(); boost::graph_traits::vertex_descriptor vd = *(vertices(m).first); Traits::Point_3 hint = get(CGAL::vertex_point,m, vd); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Engrave_text_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Engrave_text_plugin.cpp index fbd416ee949..9d9f937cbe1 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Engrave_text_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Engrave_text_plugin.cpp @@ -105,11 +105,11 @@ struct Top typedef EPICK Gt; typedef CGAL::Triangulation_vertex_base_2 Vb; -typedef CGAL::Triangulation_face_base_with_info_2 Fbb; +typedef CGAL::Triangulation_face_base_with_info_2 Fbb; typedef CGAL::Constrained_triangulation_face_base_2 Fb; -typedef CGAL::Triangulation_data_structure_2 TDS; -typedef CGAL::No_intersection_tag Tag; -typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; +typedef CGAL::Triangulation_data_structure_2 TDS; +typedef CGAL::No_constraint_intersection_requiring_constructions_tag Tag; +typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; //Parameterization and text displaying class ParamItem : public QGraphicsItem diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Fairing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Fairing_plugin.cpp index e35106929a4..f496b01bcd2 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Fairing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Fairing_plugin.cpp @@ -64,6 +64,7 @@ public: dock_widget->setVisible(false); ui_widget.setupUi(dock_widget); + ui_widget.Density_control_factor_spin_box->setMaximum(96.989999999999995); addDockWidget(dock_widget); dock_widget->setWindowTitle(tr( "Fairing " diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Fairing_widget.ui b/Polyhedron/demo/Polyhedron/Plugins/PMP/Fairing_widget.ui index 0b516bbf303..632322e2edd 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Fairing_widget.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Fairing_widget.ui @@ -99,15 +99,9 @@ - - - 96.989999999999995 - - - 0.200000000000000 - - - 2.410000000000000 + + + 2.41 @@ -139,6 +133,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp index ca87a529133..fcdb9f65551 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp @@ -443,6 +443,7 @@ void Polyhedron_demo_hole_filling_plugin::init(QMainWindow* mainWindow, dock_widget->installEventFilter(this); ui_widget.setupUi(dock_widget); + ui_widget.Density_control_factor_spin_box->setMaximum(96.989999999999995); ui_widget.Accept_button->setVisible(false); ui_widget.Reject_button->setVisible(false); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_widget.ui b/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_widget.ui index 40f8d143cf7..7fae391312e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_widget.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_widget.ui @@ -87,18 +87,9 @@ - - - 0 - - - 999999999.000000000000000 - - - 1.000000000000000 - - - 10.000000000000000 + + + 10.0 @@ -123,15 +114,18 @@ - - - 96.989999999999995 + + + + 0 + 0 + - - 0.200000000000000 + + 1.41 - - 1.410000000000000 + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -333,6 +327,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_dialog.ui b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_dialog.ui index 155c8331f9f..68b8ee3a92f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_dialog.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_dialog.ui @@ -10,7 +10,7 @@ 0 0 376 - 368 + 369 @@ -98,9 +98,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - edgeLength_dspinbox - @@ -176,22 +173,6 @@ - - - - - 110 - 0 - - - - 1000.000000000000000 - - - 0.100000000000000 - - - @@ -208,6 +189,22 @@ + + + + Qt::ImhNone + + + + + + + + + 0.00 + + + @@ -239,9 +236,15 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    splitEdgesOnly_checkbox - edgeLength_dspinbox nbIterations_spinbox nbSmoothing_spinbox protect_checkbox diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp index 8f1ec8d723e..66c8db3bef5 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp @@ -51,6 +51,7 @@ typedef Scene_surface_mesh_item Scene_facegraph_item; typedef Scene_facegraph_item::Face_graph FaceGraph; typedef boost::graph_traits::face_descriptor face_descriptor; + // give a halfedge and a target edge length, put in `out` points // which the edge equally spaced such that splitting the edge // using the sequence of points make the edges shorter than @@ -904,13 +905,8 @@ private: double diago_length = CGAL::sqrt((bbox.xmax()-bbox.xmin())*(bbox.xmax()-bbox.xmin()) + (bbox.ymax()-bbox.ymin())*(bbox.ymax()-bbox.ymin()) + (bbox.zmax()-bbox.zmin())*(bbox.zmax()-bbox.zmin())); - double log = std::log10(diago_length); - unsigned int nb_decimals = (log > 0) ? 5 : (std::ceil(-log)+3); - ui.edgeLength_dspinbox->setDecimals(nb_decimals); - ui.edgeLength_dspinbox->setSingleStep(1e-3); - ui.edgeLength_dspinbox->setRange(1e-6 * diago_length, //min - 2. * diago_length);//max + ui.edgeLength_dspinbox->setValue(0.05 * diago_length); std::ostringstream oss; diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Mean_curvature_flow_skeleton_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Mean_curvature_flow_skeleton_plugin.cpp index f6a1137ff31..f31f81bcdba 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Mean_curvature_flow_skeleton_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Mean_curvature_flow_skeleton_plugin.cpp @@ -189,17 +189,9 @@ public: "to a surface mesh item. The generated mcf group must be selected in " "order to continue an on-going set of operations. "));}); ui->omega_H->setValue(0.1); - ui->omega_H->setSingleStep(0.1); - ui->omega_H->setDecimals(3); ui->omega_P->setValue(0.2); - ui->omega_P->setSingleStep(0.1); - ui->omega_P->setDecimals(3); - ui->min_edge_length->setDecimals(7); ui->min_edge_length->setValue(0.002 * diag); - ui->min_edge_length->setSingleStep(0.0000001); - ui->delta_area->setDecimals(7); ui->delta_area->setValue(1e-4); - ui->delta_area->setSingleStep(1e-5); ui->is_medially_centered->setChecked(false); ui->label_omega_H->setToolTip(QString("omega_H controls the velocity of movement and approximation quality")); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Mean_curvature_flow_skeleton_plugin.ui b/Polyhedron/demo/Polyhedron/Plugins/PMP/Mean_curvature_flow_skeleton_plugin.ui index 9bb3b0c53f1..f7c8563efb8 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Mean_curvature_flow_skeleton_plugin.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Mean_curvature_flow_skeleton_plugin.ui @@ -6,7 +6,7 @@ 0 0 - 483 + 498 279 @@ -51,7 +51,7 @@ - + @@ -60,12 +60,22 @@ - + + + + 0 + 0 + + + + 0.00 + + - + @@ -74,12 +84,22 @@ - + + + + 0 + 0 + + + + 0.00 + + - + @@ -88,12 +108,16 @@ - + + + 0.00 + + - + @@ -102,7 +126,17 @@ - + + + + 0 + 0 + + + + 0.00 + + @@ -203,6 +237,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_dialog.ui b/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_dialog.ui index 3013e3b95dd..1d368c3dd59 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_dialog.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_dialog.ui @@ -10,7 +10,7 @@ 0 0 377 - 292 + 293 @@ -55,9 +55,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - moveSize_dspinbox -
    @@ -70,22 +67,6 @@ - - - - - 110 - 0 - - - - 1000.000000000000000 - - - 0.100000000000000 - - - @@ -96,6 +77,19 @@ + + + + + 0 + 0 + + + + 0.00 + + + @@ -198,8 +192,14 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    - moveSize_dspinbox project_checkbox buttonBox diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp index c7f58900e67..f5ee0e486c8 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp @@ -196,12 +196,8 @@ public Q_SLOTS: double diago_length = CGAL::sqrt((bbox.xmax() - bbox.xmin())*(bbox.xmax() - bbox.xmin()) + (bbox.ymax() - bbox.ymin())*(bbox.ymax() - bbox.ymin()) + (bbox.zmax() - bbox.zmin())*(bbox.zmax() - bbox.zmin())); - double log = std::log10(diago_length); - unsigned int nb_decimals = (log > 0) ? 5 : (std::ceil(-log) + 3); //parameters - ui.moveSize_dspinbox->setDecimals(nb_decimals); - ui.moveSize_dspinbox->setSingleStep(1e-3); ui.moveSize_dspinbox->setRange(0., diago_length); ui.moveSize_dspinbox->setValue(0.05 * diago_length); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/RemoveNeedlesDialog.ui b/Polyhedron/demo/Polyhedron/Plugins/PMP/RemoveNeedlesDialog.ui new file mode 100644 index 00000000000..4ade4b7b8a1 --- /dev/null +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/RemoveNeedlesDialog.ui @@ -0,0 +1,161 @@ + + + NeedleDialog + + + + 0 + 0 + 400 + 300 + + + + Remove Needles and Cap + + + + + + + + Threshold in degrees + + + Cap Threshold + + + + + + + + + + + + + + 2 + + + 360.000000000000000 + + + 160.000000000000000 + + + + + + + + + + + + (size+big edge )/(size+small edge) + + + Needle Threshold + + + + + + + + Threshold in degrees + + + 2 + + + 1000.000000000000000 + + + 4.000000000000000 + + + + + + + + + + + + Do not collapse edges begger than this threshold. + + + Collapse Length Threshold + + + + + + + + Threshold in degrees + + + 2 + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + NeedleDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + NeedleDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp index a02cae1f847..1e8fb6578ef 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp @@ -16,6 +16,9 @@ #include #include #include +#include + +#include "ui_RemoveNeedlesDialog.h" using namespace CGAL::Three; class Polyhedron_demo_repair_polyhedron_plugin : @@ -43,6 +46,7 @@ public: actionDuplicateNMVertices = new QAction(tr("Duplicate Non-Manifold Vertices"), mw); actionAutorefine = new QAction(tr("Autorefine Mesh"), mw); actionAutorefineAndRMSelfIntersections = new QAction(tr("Autorefine and Remove Self-Intersections"), mw); + actionRemoveNeedlesAndCaps = new QAction(tr("Remove Needles And Caps")); actionRemoveIsolatedVertices->setObjectName("actionRemoveIsolatedVertices"); actionRemoveDegenerateFaces->setObjectName("actionRemoveDegenerateFaces"); @@ -51,6 +55,7 @@ public: actionDuplicateNMVertices->setObjectName("actionDuplicateNMVertices"); actionAutorefine->setObjectName("actionAutorefine"); actionAutorefineAndRMSelfIntersections->setObjectName("actionAutorefineAndRMSelfIntersections"); + actionRemoveNeedlesAndCaps->setObjectName("actionRemoveNeedlesAndCaps"); actionRemoveDegenerateFaces->setProperty("subMenuName", "Polygon Mesh Processing/Repair/Experimental"); actionStitchCloseBorderHalfedges->setProperty("subMenuName", "Polygon Mesh Processing/Repair/Experimental"); @@ -59,6 +64,7 @@ public: actionDuplicateNMVertices->setProperty("subMenuName", "Polygon Mesh Processing/Repair"); actionAutorefine->setProperty("subMenuName", "Polygon Mesh Processing/Repair/Experimental"); actionAutorefineAndRMSelfIntersections->setProperty("subMenuName", "Polygon Mesh Processing/Repair/Experimental"); + actionRemoveNeedlesAndCaps->setProperty("subMenuName", "Polygon Mesh Processing/Repair/Experimental"); autoConnectActions(); } @@ -71,7 +77,8 @@ public: << actionStitchCloseBorderHalfedges << actionDuplicateNMVertices << actionAutorefine - << actionAutorefineAndRMSelfIntersections; + << actionAutorefineAndRMSelfIntersections + << actionRemoveNeedlesAndCaps; } bool applicable(QAction*) const @@ -102,6 +109,7 @@ public Q_SLOTS: void on_actionDuplicateNMVertices_triggered(); void on_actionAutorefine_triggered(); void on_actionAutorefineAndRMSelfIntersections_triggered(); + void on_actionRemoveNeedlesAndCaps_triggered(); private: QAction* actionRemoveIsolatedVertices; @@ -111,6 +119,7 @@ private: QAction* actionDuplicateNMVertices; QAction* actionAutorefine; QAction* actionAutorefineAndRMSelfIntersections; + QAction* actionRemoveNeedlesAndCaps; Messages_interface* messages; }; // end Polyhedron_demo_repair_polyhedron_plugin @@ -140,6 +149,32 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveIsolatedVertices_t QApplication::restoreOverrideCursor(); } +void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveNeedlesAndCaps_triggered() +{ + QCursor tmp_cursor(Qt::WaitCursor); + CGAL::Three::Three::CursorScopeGuard guard(tmp_cursor); + + const Scene_interface::Item_id index = scene->mainSelectionIndex(); + Scene_surface_mesh_item* sm_item = qobject_cast(scene->item(index)); + if(!sm_item) + { + return; + } + + QDialog dialog; + Ui::NeedleDialog ui; + ui.setupUi(&dialog); + ui.collapseBox->setValue(sm_item->diagonalBbox()*0.01); + if(dialog.exec() != QDialog::Accepted) + return; + CGAL::Polygon_mesh_processing::experimental::remove_almost_degenerate_faces(*sm_item->face_graph(), + std::cos((ui.capBox->value()/180.0) * CGAL_PI), + ui.needleBox->value(), + ui.collapseBox->value()); + sm_item->invalidateOpenGLBuffers(); + sm_item->itemChanged(); +} + template void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveDegenerateFaces_triggered(Scene_interface::Item_id index) { diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.cpp index 98c9059b02b..3f463f6ce60 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.cpp @@ -95,7 +95,6 @@ public: void init_ui() { ui_widget.time_step_spinBox->setValue(0.00001); - ui_widget.time_step_spinBox->setSingleStep(0.00001); ui_widget.time_step_spinBox->setMinimum(1e-6); ui_widget.smooth_iter_spinBox->setValue(1); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.ui b/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.ui index a67bce5ef47..d2d5b957acf 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.ui @@ -31,13 +31,13 @@ Shape Smoothing - - - - 6 + + + + The time step should not be too large or the smoothing will be unsatisfactory - - 0.000001000000000 + + Time Step: @@ -48,13 +48,16 @@ - - - - The time step should not be too large or the smoothing will be unsatisfactory + + + + + 0 + 0 + - Time Step: + 0.000001 @@ -173,6 +176,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp index bda125617a5..86d819b5b21 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp @@ -305,7 +305,7 @@ Scene_alpha_shape_item::Scene_alpha_shape_item(Scene_points_with_normal_item *po vertices.push_back(it->point().y()+offset.y); vertices.push_back(it->point().z()+offset.z); } - BOOST_FOREACH(auto v, CGAL::QGLViewer::QGLViewerPool()) + for(auto v : CGAL::QGLViewer::QGLViewerPool()) { CGAL::Three::Viewer_interface* viewer = static_cast(v); if(!isInit(viewer)) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Features_detection_plugin.ui b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Features_detection_plugin.ui index 98e2975c184..b6d841ec851 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Features_detection_plugin.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Features_detection_plugin.ui @@ -6,8 +6,8 @@ 0 0 - 254 - 153 + 271 + 141 @@ -15,7 +15,7 @@ - + @@ -24,22 +24,22 @@ - - - 3 + + + + 0 + 0 + - - 0.050000000000000 - - - 0.100000000000000 + + 0.100 - + @@ -48,19 +48,22 @@ - - - 3 + + + + 0 + 0 + - - 0.050000000000000 + + 0.00 - + @@ -69,15 +72,15 @@ - - - 3 + + + + 0 + 0 + - - 0.020000000000000 - - - 0.160000000000000 + + 0.160 @@ -108,6 +111,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_normal_estimation_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_normal_estimation_plugin.cpp index 89ef88a006a..ff215dfa0e3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_normal_estimation_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_normal_estimation_plugin.cpp @@ -152,6 +152,7 @@ class Point_set_demo_normal_estimation_dialog : public QDialog, private Ui::Norm Point_set_demo_normal_estimation_dialog(QWidget* /*parent*/ = 0) { setupUi(this); + m_offset_radius->setMinimum(0.01); } int pca_neighbors() const { return m_pca_neighbors->value(); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_normal_estimation_plugin.ui b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_normal_estimation_plugin.ui index 8ceaeaea887..baf03b4ef0c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_normal_estimation_plugin.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_normal_estimation_plugin.ui @@ -6,7 +6,7 @@ 0 0 - 301 + 330 372 @@ -139,22 +139,6 @@ - - - - 0.010000000000000 - - - 0.010000000000000 - - - 0.100000000000000 - - - - - - @@ -185,6 +169,20 @@ + + + + 0.10 + + + + + + + 0.00 + + + @@ -213,6 +211,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    @@ -263,22 +268,6 @@ - - buttonRadius - toggled(bool) - m_convolution_radius - setEnabled(bool) - - - 90 - 242 - - - 285 - 245 - - - buttonNeighbors toggled(bool) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_outliers_removal_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_outliers_removal_plugin.cpp index db4b46da4eb..62e27951f45 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_outliers_removal_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_outliers_removal_plugin.cpp @@ -92,6 +92,7 @@ class Point_set_demo_outlier_removal_dialog : public QDialog, private Ui::Outlie Point_set_demo_outlier_removal_dialog(QWidget * /*parent*/ = 0) { setupUi(this); + m_distanceThreshold->setMinimum(0.0); } double percentage() const { return m_inputPercentage->value(); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_outliers_removal_plugin.ui b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_outliers_removal_plugin.ui index bda8af50aa6..af3b64b7ea8 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_outliers_removal_plugin.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_outliers_removal_plugin.ui @@ -91,26 +91,21 @@ - - - 6 - - - 0.000000000000000 - - - 100000.000000000000000 - - - 0.100000000000000 - - - 0.500000000000000 + + + 0.5 + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_selection_plugin.cpp index ebff326b116..9ed293d1f51 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_selection_plugin.cpp @@ -30,9 +30,10 @@ #include #include #include +#include #include -#include +#include "CGAL_double_edit.h" #include #include @@ -821,19 +822,15 @@ protected Q_SLOTS: return; QMultipleInputDialog dialog ("Region Selection Parameters", mw); - QDoubleSpinBox* epsilon = dialog.add ("Epsilon: "); - epsilon->setRange (0.00001, 1000000.); - epsilon->setDecimals (5); + DoubleEdit* epsilon = dialog.add ("Epsilon: "); if (rg_epsilon < 0.) rg_epsilon = (std::max)(0.00001, 0.005 * scene->len_diagonal()); - epsilon->setValue (rg_epsilon); + epsilon->setValue(rg_epsilon); - QDoubleSpinBox* cluster_epsilon = dialog.add ("Cluster epsilon: "); - cluster_epsilon->setRange (0.00001, 1000000.); - cluster_epsilon->setDecimals (5); + DoubleEdit* cluster_epsilon = dialog.add ("Cluster epsilon: "); if (rg_cluster_epsilon < 0.) rg_cluster_epsilon = (std::max)(0.00001, 0.03 * scene->len_diagonal()); - cluster_epsilon->setValue (rg_cluster_epsilon); + cluster_epsilon->setText(tr("%1").arg(rg_cluster_epsilon)); QSpinBox* normal_threshold = dialog.add ("Normal threshold: "); normal_threshold->setRange (0, 90); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_shape_detection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_shape_detection_plugin.cpp index 27057b15b54..d9497aba999 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_shape_detection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_shape_detection_plugin.cpp @@ -79,6 +79,11 @@ public: Point_set_demo_point_set_shape_detection_dialog(QWidget * /*parent*/ = 0) { setupUi(this); + m_normal_tolerance_field->setMaximum(1.0); + m_probability_field->setRange(0.00001, 1.0); + m_epsilon_field->setMinimum(0.000001); + m_normal_tolerance_field->setMinimum(0.01); + m_cluster_epsilon_field->setMinimum(0.000001); } bool region_growing() const { return m_region_growing->isChecked(); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_shape_detection_plugin.ui b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_shape_detection_plugin.ui index 185d418fffc..684acace812 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_shape_detection_plugin.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_shape_detection_plugin.ui @@ -124,7 +124,7 @@ - + @@ -133,31 +133,22 @@ - - - Fitting tolerance in Euclidean distance + + + + 0 + 0 + - - 8 - - - 0.000001000000000 - - - 1000000.000000000000000 - - - 0.001000000000000 - - - 0.002000000000000 + + 0.002 - + @@ -166,28 +157,22 @@ - - - Normal angle deviation tolerance as cosine of the angle + + + + 0 + 0 + - - 0.010000000000000 - - - 1.000000000000000 - - - 0.010000000000000 - - - 0.900000000000000 + + 0.90 - + @@ -214,7 +199,7 @@ - + @@ -223,31 +208,22 @@ - - - Maximum world distance between points on a shape to be considered as connected + + + + 0 + 0 + - - 8 - - - 0.000001000000000 - - - 1000000.000000000000000 - - - 0.010000000000000 - - - 0.020000000000000 + + 0.002 - + @@ -259,27 +235,15 @@ - - - false + + + + 0 + 0 + - - Probability to overlook the largest primitive in one extraction iteration - - - 5 - - - 0.000010000000000 - - - 1.000000000000000 - - - 0.010000000000000 - - - 0.050000000000000 + + 0.05 @@ -356,6 +320,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    @@ -486,21 +457,5 @@ - - ransac - toggled(bool) - m_probability_field - setEnabled(bool) - - - 70 - 46 - - - 352 - 214 - - - diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.cpp index 9d838794b69..c027c4275da 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.cpp @@ -134,6 +134,7 @@ class Point_set_demo_point_set_simplification_dialog : public QDialog, private U Point_set_demo_point_set_simplification_dialog(QWidget * /*parent*/ = 0) { setupUi(this); + m_maximumSurfaceVariation->setRange(0.000010, 0.33330); } unsigned int simplificationMethod() const diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.ui b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.ui index 3293552fd46..45b189faf13 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.ui @@ -7,24 +7,20 @@ 0 0 392 - 248 + 249 Simplification - - + + - Maximum Cluster Size + Random - - - - - - Grid + + true @@ -44,37 +40,6 @@ - - - - Maximum Surface Variation - - - - - - - Random - - - true - - - - - - - Hierarchy - - - - - - - Points to Remove Randomly - - - @@ -82,16 +47,6 @@ - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - @@ -114,28 +69,10 @@ - - - - false - - - - - - 5 - - - 0.000010000000000 - - - 0.333330000000000 - - - 0.012340000000000 - - - 0.333330000000000 + + + + Maximum Surface Variation @@ -177,8 +114,60 @@ + + + + Maximum Cluster Size + + + + + + + Points to Remove Randomly + + + + + + + Grid + + + + + + + Hierarchy + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + 0.333333 + + + + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp index 797a5ba644a..e0d8c395e8a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp @@ -77,7 +77,6 @@ double compute_distances(const Mesh& m, typedef CGAL::AABB_tree< Traits > Tree; Tree tree( faces(m).first, faces(m).second, m); - tree.accelerate_distance_queries(); tree.build(); typedef typename boost::property_map::const_type VPMap; VPMap vpmap = get(boost::vertex_point, m); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_widget.ui b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_widget.ui index 9b90b30d4e5..e6c3dac8755 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_widget.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_widget.ui @@ -140,16 +140,6 @@ - - - - Points further than this distance will be selected. - - - 6 - - - @@ -167,6 +157,13 @@ + + + + 0.00 + + + @@ -190,6 +187,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_upsampling_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_upsampling_plugin.cpp index 2fba3abfcb8..c3740307ffa 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_upsampling_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_upsampling_plugin.cpp @@ -67,6 +67,10 @@ public: Point_set_demo_point_set_upsampling_dialog(QWidget * /*parent*/ = 0) { setupUi(this); + m_edgeSensitivity->setMaximum(1.0); + m_neighborhoodRadius->setRange(0.1, 10.0); + + } unsigned int sharpness_angle () const { return m_sharpnessAngle->value(); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_upsampling_plugin.ui b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_upsampling_plugin.ui index 1bd40c30b9e..f8da092c47a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_upsampling_plugin.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_upsampling_plugin.ui @@ -7,13 +7,36 @@ 0 0 348 - 167 + 168 Edge Aware Upsampling + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -21,6 +44,59 @@ + + + + Neighborhood Radius + + + + + + + Edge Sensitivity + + + + + + + ° + + + 90 + + + 25 + + + + + + + + + + * input size + + + 1.000000000000000 + + + 1000.000000000000000 + + + 4.000000000000000 + + + + + + + Sharpness Angle + + + @@ -43,94 +119,22 @@ - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 1.000000000000000 - - - 0.010000000000000 - - - - - - - - - - * input size - - - 1.000000000000000 - - - 1000.000000000000000 - - - 4.000000000000000 - - - - - + - Edge Sensitivity + 0.00 - - - - Sharpness Angle - - - - - - - Neighborhood Radius - - - - - - - ° - - - 90 - - - 25 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_plugin.ui b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_plugin.ui index 8cbfe7f1c2a..084a6a9a81e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_plugin.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_plugin.ui @@ -6,7 +6,7 @@ 0 0 - 404 + 427 482 @@ -736,7 +736,6 @@ - tabWidget_2 diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_poisson_impl.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_poisson_impl.cpp index 77511d670f4..a6987e4f759 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_poisson_impl.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_poisson_impl.cpp @@ -358,7 +358,6 @@ SMesh* poisson_reconstruct(Point_set& points, // Constructs AABB tree and computes internal KD-tree // data structure to accelerate distance queries AABB_tree tree(faces(*mesh).first, faces(*mesh).second, *mesh); - tree.accelerate_distance_queries(); // Computes distance from each input point to reconstructed mesh double max_distance = DBL_MIN; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_plane_detection_dialog.ui b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_plane_detection_dialog.ui index 9e7625e4af3..e855d47f55c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_plane_detection_dialog.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_plane_detection_dialog.ui @@ -23,25 +23,6 @@ - - - - 5 - - - 0.000010000000000 - - - 1000000.000000000000000 - - - 0.010000000000000 - - - 0.010000000000000 - - - @@ -65,6 +46,13 @@ + + + + 0.01 + + + @@ -92,6 +80,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_plane_detection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_plane_detection_plugin.cpp index 28de24b4acc..989131b3ec3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_plane_detection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_plane_detection_plugin.cpp @@ -191,7 +191,7 @@ void Polyhedron_demo_mesh_plane_detection_plugin::on_actionPlaneDetection_trigge QDialog dialog(mw); Ui::Mesh_plane_detection_dialog ui; ui.setupUi(&dialog); - + ui.minimumAreaDoubleSpinBox->setMinimum(0.00001); // check user cancellation if(dialog.exec() == QDialog::Rejected) return; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_segmentation_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_segmentation_plugin.cpp index 0546a3555bb..66ac1b6dd68 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_segmentation_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_segmentation_plugin.cpp @@ -92,6 +92,7 @@ public: dock_widget = new QDockWidget("Mesh segmentation parameters", mw); dock_widget->setVisible(false); // do not show at the beginning ui_widget.setupUi(dock_widget); + ui_widget.Smoothness_spin_box->setMaximum(10.0); mw->addDockWidget(Qt::LeftDockWidgetArea, dock_widget); connect(ui_widget.Partition_button, SIGNAL(clicked()), this, SLOT(on_Partition_button_clicked())); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_segmentation_widget.ui b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_segmentation_widget.ui index b2d0588f42c..ce8020ce7e3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_segmentation_widget.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_segmentation_widget.ui @@ -31,13 +31,6 @@ - - - - 25 - - - @@ -58,6 +51,13 @@ + + + + 25 + + + @@ -100,19 +100,6 @@ - - - - 10.000000000000000 - - - 0.010000000000000 - - - 0.260000000000000 - - - @@ -136,6 +123,13 @@ + + + + 0.26 + + + @@ -194,6 +188,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_simplification_dialog.ui b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_simplification_dialog.ui index e544450deb2..7b973c78bf1 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_simplification_dialog.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_simplification_dialog.ui @@ -105,15 +105,9 @@ - - - true - - - 5 - - - 10000.000000000000000 + + + 0.000 @@ -144,6 +138,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Offset_meshing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Offset_meshing_plugin.cpp index ebaf3adee56..ef5b585b890 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Offset_meshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Offset_meshing_plugin.cpp @@ -58,7 +58,6 @@ public: , m_is_closed( is_closed(tm) ) { CGAL_assertion(!m_tree_ptr->empty()); - m_tree_ptr->accelerate_distance_queries(); } double operator()(const typename GeomTraits::Point_3& p) const @@ -188,7 +187,6 @@ public: , m_offset_distance(offset_distance) { CGAL_assertion(! m_tree_ptr->empty() ); - m_tree_ptr->accelerate_distance_queries(); } double operator()(const EPICK::Point_3& p) const @@ -452,17 +450,16 @@ void Polyhedron_demo_offset_meshing_plugin::offset_meshing() QDialog dialog(mw); Ui::Remeshing_dialog ui; ui.setupUi(&dialog); + ui.angle->setRange(1.0, 30.0); connect(ui.buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept())); connect(ui.buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject())); - ui.sizing->setDecimals(4); ui.sizing->setRange(diag * 10e-6, // min diag); // max ui.sizing->setValue(diag * 0.05); // default value - ui.approx->setDecimals(6); ui.approx->setRange(diag * 10e-7, // min diag); // max ui.approx->setValue(diag * 0.005); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Remeshing_dialog.ui b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Remeshing_dialog.ui index cfd2350787d..8366a6dcab3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Remeshing_dialog.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Remeshing_dialog.ui @@ -15,69 +15,14 @@ - - - - - &Angle: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - angle - - - - - - - 1.000000000000000 - - - 30.000000000000000 - - - 25.000000000000000 - - - - - - - &Size: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - sizing - - - + - - - 4 - - - - - + - Approximation &error: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - approx + 0.00 - - - @@ -97,6 +42,36 @@ + + + + &Angle: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + &Size: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Approximation &error: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + @@ -110,6 +85,20 @@ + + + + 0.00 + + + + + + + 25.0 + + + @@ -137,6 +126,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Surface_mesh_approximation_dockwidget.ui b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Surface_mesh_approximation_dockwidget.ui index 8b67236b224..d8a1dec5bc3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Surface_mesh_approximation_dockwidget.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Surface_mesh_approximation_dockwidget.ui @@ -6,7 +6,7 @@ 0 0 - 667 + 652 360 @@ -64,20 +64,19 @@ - - - - + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - Error drop + + QAbstractSpinBox::NoButtons - - - - - - #Proxies + + 999 + + + 20 @@ -88,6 +87,26 @@ + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -104,47 +123,20 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - + + - Negative value is ignored + - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + Error drop - - QAbstractSpinBox::NoButtons - - - 4 - - - 0.001000000000000 - - - 1.000000000000000 - - - 0.010000000000000 - - - 0.100000000000000 + + + + + + #Proxies @@ -168,26 +160,10 @@ - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - QAbstractSpinBox::NoButtons - - - 999 - - - 20 - - - - - + + - + 0.1 @@ -410,25 +386,6 @@ - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - QAbstractSpinBox::NoButtons - - - 10.000000000000000 - - - 0.100000000000000 - - - 3.000000000000000 - - - @@ -436,6 +393,19 @@ + + + + + 0 + 0 + + + + 3.00 + + + @@ -491,23 +461,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    - - - enable_error_drop - toggled(bool) - error_drop - setEnabled(bool) - - - 127 - 168 - - - 153 - 167 - - - - + diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Surface_mesh_approximation_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Surface_mesh_approximation_plugin.cpp index befcbbd0099..cebffa08e4d 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Surface_mesh_approximation_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Surface_mesh_approximation_plugin.cpp @@ -81,6 +81,8 @@ public: dock_widget = new QDockWidget("Mesh approximation parameters", mw); dock_widget->setVisible(false); ui_widget.setupUi(dock_widget); + ui_widget.chord_error->setRange(0.0, 10.0); + ui_widget.error_drop->setRange(0.01, 1.0); mw->addDockWidget(Qt::LeftDockWidgetArea, dock_widget); // connect ui actions diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/Deform_mesh.ui b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/Deform_mesh.ui index 28d648d8c43..2f7fdca658e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/Deform_mesh.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/Deform_mesh.ui @@ -199,7 +199,7 @@ - + @@ -214,7 +214,11 @@ - + + + 0.00 + + @@ -435,6 +439,13 @@ + + + DoubleEdit + QLineEdit +
    CGAL_double_edit.h
    +
    +
    diff --git a/Polyhedron/demo/Polyhedron/Preferences.ui b/Polyhedron/demo/Polyhedron/Preferences.ui index 34613871e8d..10a7f773f85 100644 --- a/Polyhedron/demo/Polyhedron/Preferences.ui +++ b/Polyhedron/demo/Polyhedron/Preferences.ui @@ -58,9 +58,9 @@ 0 - 0 - 278 - 499 + -96 + 275 + 528 @@ -285,6 +285,13 @@
    + + + + Change Back/Front Colors... + + + diff --git a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp index a1343e70134..9ad4cfa9dc2 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp @@ -532,7 +532,7 @@ void Scene_c3t3_item::common_constructor(bool is_surface) setEdgeContainer(Grid_edges, new Ec(Vi::PROGRAM_NO_SELECTION, false)); setEdgeContainer(C3t3_edges, new Ec(Vi::PROGRAM_C3T3_EDGES, false)); setPointContainer(C3t3_points, new Pc(Vi::PROGRAM_C3T3_EDGES, false)); - BOOST_FOREACH(auto v, CGAL::QGLViewer::QGLViewerPool()) + for(auto v : CGAL::QGLViewer::QGLViewerPool()) { v->installEventFilter(this); } @@ -611,7 +611,7 @@ void Scene_c3t3_item::updateCutPlane() if(!d) return; if(d->need_changed) { - BOOST_FOREACH(auto v, CGAL::QGLViewer::QGLViewerPool()) + for(auto v : CGAL::QGLViewer::QGLViewerPool()) { CGAL::Three::Viewer_interface* viewer = static_cast(v); d->are_intersection_buffers_filled[viewer] = false; @@ -1581,7 +1581,7 @@ Scene_c3t3_item::setColor(QColor c) d->compute_color_map(c); invalidateOpenGLBuffers(); d->invalidate_stats(); - BOOST_FOREACH(auto v, CGAL::QGLViewer::QGLViewerPool()) + for(auto v : CGAL::QGLViewer::QGLViewerPool()) { CGAL::Three::Viewer_interface* viewer = static_cast(v); d->are_intersection_buffers_filled[viewer] = false; @@ -1636,7 +1636,7 @@ void Scene_c3t3_item::show_intersection(bool b) d->intersection->setRenderingMode(renderingMode()); connect(d->intersection, SIGNAL(destroyed()), this, SLOT(reset_intersection_item())); - BOOST_FOREACH(auto v, CGAL::QGLViewer::QGLViewerPool()) + for(auto v : CGAL::QGLViewer::QGLViewerPool()) { CGAL::Three::Viewer_interface* viewer = static_cast(v); d->are_intersection_buffers_filled[viewer] = false; diff --git a/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp b/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp index 362c34ee29b..86ac3f146fa 100644 --- a/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp @@ -204,8 +204,9 @@ void Scene_nef_polyhedron_item_priv::compute_normals_and_vertices(void) const f != end; ++f) { if(f->is_twin()) continue; + bool incident_volume_marked = f->incident_volume()->mark(); count++; - Nef_polyhedron::Vector_3 v = f->plane().orthogonal_vector(); + Nef_polyhedron::Vector_3 v = (incident_volume_marked? -1:1) * f->plane().orthogonal_vector(); P_traits cdt_traits(v); CDT cdt(cdt_traits); @@ -283,17 +284,6 @@ void Scene_nef_polyhedron_item_priv::compute_normals_and_vertices(void) const } - - - Nef_polyhedron::Vector_3 v = f->plane().orthogonal_vector(); - if(f->plane().a() != 0) - v /= f->plane().a(); - else if(f->plane().b() != 0) - v /= f->plane().b(); - else if(f->plane().c() != 0) - v /= f->plane().c(); - else if(f->plane().d() != 0) - v /= f->plane().d(); GLfloat normal[3]; normal[0] = CGAL::to_double(v.x()); normal[1] = CGAL::to_double(v.y()); diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index 09dd204eff6..a25bd48cadf 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -1295,7 +1295,7 @@ void Scene_surface_mesh_item::invalidate(Gl_data_names name) getEdgeContainer(0)->reset_vbos(name); getPointContainer(0)->reset_vbos(name); bool has_been_init = false; - BOOST_FOREACH(CGAL::QGLViewer* v, CGAL::QGLViewer::QGLViewerPool()) + for(CGAL::QGLViewer* v : CGAL::QGLViewer::QGLViewerPool()) { CGAL::Three::Viewer_interface* viewer = static_cast(v); if(!isInit(viewer)) diff --git a/Polyhedron/demo/Polyhedron/Scene_textured_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_textured_surface_mesh_item.cpp index 816d37d3e60..8d9f55a455f 100644 --- a/Polyhedron/demo/Polyhedron/Scene_textured_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_textured_surface_mesh_item.cpp @@ -165,7 +165,7 @@ void Scene_textured_surface_mesh_item::common_constructor() setEdgeContainer(0, new Ec(Vi::PROGRAM_WITH_TEXTURED_EDGES, false));//edges getTriangleContainer(0)->setTextureSize(QSize(d->texture.GetWidth(), d->texture.GetHeight())); getEdgeContainer(0)->setTextureSize(QSize(d->texture.GetWidth(), d->texture.GetHeight())); - BOOST_FOREACH(auto v, CGAL::QGLViewer::QGLViewerPool()) + for(auto v : CGAL::QGLViewer::QGLViewerPool()) { CGAL::Three::Viewer_interface* viewer = static_cast(v); initGL(viewer); diff --git a/Polyhedron/demo/Polyhedron/Viewer.cpp b/Polyhedron/demo/Polyhedron/Viewer.cpp index cc5cb24d158..bfb1a2331ad 100644 --- a/Polyhedron/demo/Polyhedron/Viewer.cpp +++ b/Polyhedron/demo/Polyhedron/Viewer.cpp @@ -50,6 +50,10 @@ public: QVector4D diffuse; QVector4D specular; float spec_power; + + //Back and Front Colors + QColor front_color; + QColor back_color; // M e s s a g e s QString message; @@ -250,12 +254,23 @@ void Viewer::doBindings() specular.split(",").at(1).toFloat(), specular.split(",").at(2).toFloat(), 1.0f); - + + QString front_color = viewer_settings.value("front_color", QString("1.0,0.0,0.0")).toString(); + d->front_color= QColor(255*front_color.split(",").at(0).toFloat(), + 255*front_color.split(",").at(1).toFloat(), + 255*front_color.split(",").at(2).toFloat(), + 1.0f); + QString back_color = viewer_settings.value("back_color", QString("0.0,0.0,1.0")).toString(); + d->back_color= QColor( 255*back_color.split(",").at(0).toFloat(), + 255*back_color.split(",").at(1).toFloat(), + 255*back_color.split(",").at(2).toFloat(), + 1.0f); d->spec_power = viewer_settings.value("spec_power", 51.8).toFloat(); d->scene = 0; d->projection_is_ortho = false; d->twosides = false; this->setProperty("draw_two_sides", false); + this->setProperty("back_front_shading", false); d->macro_mode = false; d->inFastDrawing = true; d->inDrawWithNames = false; @@ -333,6 +348,7 @@ Viewer::Viewer(QWidget* parent, is_sharing = true; d->antialiasing = antialiasing; this->setProperty("draw_two_sides", false); + this->setProperty("back_front_shading", false); this->setProperty("helpText", QString("This is a sub-viewer. It displays the scene " "from another point of view. \n ")); is_ogl_4_3 = sharedWidget->is_ogl_4_3; @@ -367,6 +383,17 @@ Viewer::~Viewer() .arg(d->specular.z())); viewer_settings.setValue("spec_power", d->spec_power); + viewer_settings.setValue("front_color", + QString("%1,%2,%3") + .arg(d->front_color.redF()) + .arg(d->front_color.greenF()) + .arg(d->front_color.blueF())); + viewer_settings.setValue("back_color", + QString("%1,%2,%3") + .arg(d->back_color.redF()) + .arg(d->back_color.greenF()) + .arg(d->back_color.blueF())); + if(d->_recentFunctions) delete d->_recentFunctions; if(d->painter) @@ -401,6 +428,13 @@ void Viewer::setTwoSides(bool b) } +void Viewer::setBackFrontShading(bool b) +{ + this->setProperty("back_front_shading", b); + update(); +} + + void Viewer::setFastDrawing(bool b) { d->inFastDrawing = b; @@ -947,7 +981,10 @@ void Viewer::attribBuffers(int program_name) const { program->setUniformValue("light_spec", d->specular); program->setUniformValue("light_amb", d->ambient); program->setUniformValue("spec_power", d->spec_power); + program->setUniformValue("front_color", d->front_color); + program->setUniformValue("back_color", d->back_color); program->setUniformValue("is_two_side", d->twosides); + program->setUniformValue("back_front_shading", this->property("back_front_shading").toBool()); break; } switch(program_name) @@ -1805,6 +1842,65 @@ void Viewer::setLighting() } } +void Viewer::setBackFrontColors() +{ + + //save current settings; + + QColor prev_front_color = d->front_color; + QColor prev_back_color = d->back_color; + QDialog *dialog = new QDialog(this); + QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok + | QDialogButtonBox::Cancel, dialog); + + connect(buttonBox, &QDialogButtonBox::accepted, dialog, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject); + + QGridLayout* layout = new QGridLayout(dialog); + layout->addWidget(new QLabel("Front color: ",dialog),0,0); + QPalette front_palette; + front_palette.setColor(QPalette::Button, d->front_color); + QPushButton* frontButton = new QPushButton(dialog); + frontButton->setPalette(front_palette); + QPalette back_palette; + back_palette.setColor(QPalette::Button, d->back_color); + QPushButton* backButton = new QPushButton(dialog); + backButton->setPalette(back_palette); + layout->addWidget(frontButton,0,1); + layout->addWidget(new QLabel("Back color: ",dialog),1,0); + layout->addWidget(backButton,1,1); + layout->addWidget(buttonBox); + dialog->setLayout(layout); + connect(frontButton, &QPushButton::clicked, + [this, dialog, frontButton](){ + QColorDialog *color_dial = new QColorDialog(dialog); + color_dial->exec(); + QColor front_color = color_dial->selectedColor(); + QPalette palette; + palette.setColor(QPalette::Button, front_color); + frontButton->setPalette(palette); + d->front_color= front_color; + }); + connect(backButton, &QPushButton::clicked, + [this, dialog, backButton](){ + QColorDialog *color_dial = new QColorDialog(dialog); + color_dial->exec(); + QColor back_color = color_dial->selectedColor(); + QPalette palette; + palette.setColor(QPalette::Button, back_color); + backButton->setPalette(palette); + d->back_color= back_color; + + }); + if(!dialog->exec()) + { + //restore previous settings + d->front_color= prev_front_color; + d->back_color= prev_back_color; + return; + } +} + void Viewer::setGlPointSize(const GLfloat &p) { d->gl_point_size = p; } const GLfloat& Viewer::getGlPointSize() const { return d->gl_point_size; } diff --git a/Polyhedron/demo/Polyhedron/Viewer.h b/Polyhedron/demo/Polyhedron/Viewer.h index 6d33097f672..600b9a6f041 100644 --- a/Polyhedron/demo/Polyhedron/Viewer.h +++ b/Polyhedron/demo/Polyhedron/Viewer.h @@ -101,6 +101,7 @@ public Q_SLOTS: //! If b is true, facets will be ligted from both internal and external sides. //! If b is false, only the side that is exposed to the light source will be lighted. void setTwoSides(bool b) Q_DECL_OVERRIDE; + void setBackFrontShading(bool b) Q_DECL_OVERRIDE; void SetOrthoProjection( bool b) Q_DECL_OVERRIDE; //! If b is true, some items are displayed in a simplified version when moving the camera. //! If b is false, items display is never altered, even when moving. @@ -127,6 +128,7 @@ public Q_SLOTS: } void setLighting(); + void setBackFrontColors(); void messageLogged(QOpenGLDebugMessage); diff --git a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_light.frag b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_light.frag index 2c0b38aa039..302fa0e6123 100644 --- a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_light.frag +++ b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_light.frag @@ -3,6 +3,8 @@ varying highp vec4 color; varying highp vec4 fP; varying highp vec3 fN; varying highp float dist[6]; +uniform highp vec4 front_color; +uniform highp vec4 back_color; uniform highp vec4 light_pos; uniform highp vec4 light_diff; uniform highp vec4 light_spec; @@ -17,6 +19,7 @@ uniform highp float width; uniform highp float height; uniform bool comparing; uniform bool writing; +uniform bool back_front_shading; uniform sampler2D sampler; uniform highp float alpha; @@ -44,7 +47,6 @@ void main(void) { gl_FragColor = vec4(d,d,d,1.0); else { - highp vec4 my_color = vec4(color.xyz, 1.0); highp vec3 L = light_pos.xyz - fP.xyz; highp vec3 V = -fP.xyz; highp vec3 N; @@ -56,6 +58,19 @@ void main(void) { V = normalize(V); highp vec3 R = reflect(-L, N); highp vec4 diffuse; + float dot_prod = dot(N,L); + highp vec4 my_color; + if(back_front_shading) + { + if (dot_prod > 0) + my_color = front_color; + else + my_color = back_color; + } + else + { + my_color = highp vec4(color.xyz, 1.0); + } if(is_two_side == 1) diffuse = abs(dot(N,L)) * light_diff * color; else diff --git a/Polyhedron/demo/Polyhedron/resources/shader_with_light.frag b/Polyhedron/demo/Polyhedron/resources/shader_with_light.frag index 2bb3354848f..e1fbe4d1139 100644 --- a/Polyhedron/demo/Polyhedron/resources/shader_with_light.frag +++ b/Polyhedron/demo/Polyhedron/resources/shader_with_light.frag @@ -3,6 +3,8 @@ in vec4 color; in vec4 fP; in vec3 fN; in float dist[6]; +uniform vec4 front_color; +uniform vec4 back_color; uniform vec4 light_pos; uniform vec4 light_diff; uniform vec4 light_spec; @@ -17,6 +19,7 @@ uniform float width; uniform float height; uniform bool comparing; uniform bool writing; +uniform bool back_front_shading; uniform sampler2D sampler; uniform float alpha; out vec4 out_color; @@ -45,7 +48,6 @@ void main(void) { out_color = vec4(d,d,d,1.0); else { - vec4 my_color = vec4(color.xyz, 1.0); vec3 L = light_pos.xyz - fP.xyz; vec3 V = -fP.xyz; vec3 N; @@ -57,10 +59,24 @@ void main(void) { V = normalize(V); vec3 R = reflect(-L, N); vec4 diffuse; - if(is_two_side == 1) - diffuse = abs(dot(N,L)) * light_diff * color; + float dot_prod = dot(N,L); + vec4 my_color; + if(back_front_shading) + { + if (dot_prod > 0) + my_color = front_color; + else + my_color = back_color; + } else - diffuse = max(dot(N,L), 0.0) * light_diff * my_color; + { + my_color = vec4(color.xyz, 1.0); + } + if(is_two_side == 1) + diffuse = abs(dot_prod) * light_diff * color; + else + diffuse = max(dot_prod, 0.0) * light_diff * my_color; + vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; vec4 ret_color = vec4((my_color*light_amb).xyz + diffuse.xyz + specular.xyz,1); if(is_selected) diff --git a/Polyhedron/package_info/Polyhedron/dependencies b/Polyhedron/package_info/Polyhedron/dependencies index b810ef1e411..379a6bb6921 100644 --- a/Polyhedron/package_info/Polyhedron/dependencies +++ b/Polyhedron/package_info/Polyhedron/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations BGL Circulator Distance_2 +Distance_3 GraphicsView HalfedgeDS Hash_map @@ -19,4 +20,3 @@ Profiling_tools Property_map STL_Extension Stream_support -Distance_3 diff --git a/Polyhedron_IO/include/CGAL/IO/PLY_reader.h b/Polyhedron_IO/include/CGAL/IO/PLY_reader.h index 2700ac740ff..ada0165c981 100644 --- a/Polyhedron_IO/include/CGAL/IO/PLY_reader.h +++ b/Polyhedron_IO/include/CGAL/IO/PLY_reader.h @@ -266,7 +266,7 @@ namespace CGAL{ { has_uv = true; } - cpp11::tuple new_hedge; + std::tuple new_hedge; for (std::size_t j = 0; j < element.number_of_items(); ++ j) { for (std::size_t k = 0; k < element.number_of_properties(); ++ k) diff --git a/Polyline_simplification_2/demo/Polyline_simplification_2/Polyline_simplification_2.cpp b/Polyline_simplification_2/demo/Polyline_simplification_2/Polyline_simplification_2.cpp index 30a29401f2a..610fefba342 100644 --- a/Polyline_simplification_2/demo/Polyline_simplification_2/Polyline_simplification_2.cpp +++ b/Polyline_simplification_2/demo/Polyline_simplification_2/Polyline_simplification_2.cpp @@ -406,12 +406,12 @@ void MainWindow::loadWKT(QString if(! points.empty()){ std::cout << "Ignore " << points.size() << " isolated points" << std::endl; } - BOOST_FOREACH(LineString poly, polylines){ + for(LineString poly : polylines){ if ( poly.size() > 2 ){ m_pct.insert_constraint(poly.begin(), poly.end()); } } - BOOST_FOREACH(Polygon_with_holes_2 poly, polygons){ + for(Polygon_with_holes_2 poly : polygons){ m_pct.insert_constraint(poly.outer_boundary().vertices_begin(), poly.outer_boundary().vertices_end()); for(Polygon_with_holes_2::Hole_const_iterator it = poly.holes_begin(); it != poly.holes_end(); ++it){ const Polygon_2& hole = *it; diff --git a/Property_map/package_info/Property_map/dependencies b/Property_map/package_info/Property_map/dependencies index 4b1b3cb93f3..90b94d36b57 100644 --- a/Property_map/package_info/Property_map/dependencies +++ b/Property_map/package_info/Property_map/dependencies @@ -1,4 +1,11 @@ +Algebraic_foundations +BGL Installation +Interval_support Kernel_23 +Modular_arithmetic +Number_types Profiling_tools +Property_map STL_Extension +Stream_support diff --git a/README.md b/README.md index 95dffac80e6..0166c3f78ae 100644 --- a/README.md +++ b/README.md @@ -6,19 +6,30 @@ The Computational Geometry Algorithms Library (CGAL) is a C++ library that aims to provide easy access to efficient and reliable algorithms in computational geometry. -CGAL releases +CGAL Releases ============= The primary vector of distribution of CGAL are sources tarballs, released twice a year, announced on [the web site of CGAL](https://www.cgal.org/). -The sources distributed that way can be built using the -[CGAL installation manual](https://doc.cgal.org/latest/Manual/installation.html). -CGAL Git repository layout +Getting Started with CGAL +========================= + +**Since version 5.0, CGAL is a header-only library, meaning that +it is no longer needed to build CGAL libraries before it can be used.** + +Head over to the [CGAL manual](https://doc.cgal.org/latest/Manual/general_intro.html) +for usage guides and tutorials that will get you started smoothly. + +License +======= +See the file [LICENSE.md](LICENSE.md). + +CGAL Git Repository Layout ========================== The Git repository of CGAL has a different layout from release tarballs. It -contains a `CMakeLists.txt` file that serves as anchor for building, and a -set of subfolders, so called *packages*. Most packages +contains a `CMakeLists.txt` file that serves as anchor for configuring and building programs, +and a set of subfolders, so called *packages*. Most packages implement a data structure or an algorithm for CGAL (e.g., `Convex_hull_2`, or `Triangulation_3`); however some packages serve special needs: @@ -30,24 +41,7 @@ or `Triangulation_3`); however some packages serve special needs: * `Documentation` - infrastructure for CGAL's manual * `STL_Extension` - extensions to the standard template library -Compilation and installation -============================ -The compilation and installation of CGAL from a sources tarball are -described in the -[CGAL installation manual](https://doc.cgal.org/latest/Manual/installation.html) -and in the file [INSTALL.md](Installation/INSTALL.md) that is at the root -of any sources tarball. - -CGAL developers, however, usually compile CGAL directly from a local Git -repository. That kind of compilation is called a *branch build*, and is -described in the file [INSTALL.md](INSTALL.md) that is at the root of the -Git repository. - -License -======= -See the file [LICENSE.md](LICENSE.md). - -More information +More Information ================ * [The CGAL web site](https://www.cgal.org/) * [Latest CGAL release documentation pages](https://doc.cgal.org/) diff --git a/STL_Extension/doc/STL_Extension/PackageDescription.txt b/STL_Extension/doc/STL_Extension/PackageDescription.txt index df921c5c6e0..b5d4b0141d1 100644 --- a/STL_Extension/doc/STL_Extension/PackageDescription.txt +++ b/STL_Extension/doc/STL_Extension/PackageDescription.txt @@ -41,11 +41,8 @@ - `CGAL::Multiset` \cgalCRPSection{Generic Algorithms} -- `std::copy_n` - `CGAL::copy_n` - `CGAL::min_max_element` -- `std::next` -- `std::prev` - `CGAL::predecessor` - `CGAL::successor` diff --git a/STL_Extension/include/CGAL/Compact_container.h b/STL_Extension/include/CGAL/Compact_container.h index ced9e98a82c..ee83c6c4d0b 100644 --- a/STL_Extension/include/CGAL/Compact_container.h +++ b/STL_Extension/include/CGAL/Compact_container.h @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -82,24 +83,6 @@ namespace CGAL { -#define CGAL_GENERATE_MEMBER_DETECTOR(X) \ -template class has_##X { \ - struct Fallback { int X; }; \ - struct Derived : T, Fallback { }; \ - \ - template struct Check; \ - \ - typedef char ArrayOfOne[1]; \ - typedef char ArrayOfTwo[2]; \ - \ - template static ArrayOfOne & func( \ - Check *); \ - template static ArrayOfTwo & func(...); \ - public: \ - typedef has_##X type; \ - enum { value = sizeof(func(0)) == 2 }; \ -} // semicolon is after the macro call - #define CGAL_INIT_COMPACT_CONTAINER_BLOCK_SIZE 14 #define CGAL_INCREMENT_COMPACT_CONTAINER_BLOCK_SIZE 16 diff --git a/STL_Extension/include/CGAL/Concurrent_compact_container.h b/STL_Extension/include/CGAL/Concurrent_compact_container.h index 0f847b8a10d..5fad68c1719 100644 --- a/STL_Extension/include/CGAL/Concurrent_compact_container.h +++ b/STL_Extension/include/CGAL/Concurrent_compact_container.h @@ -115,15 +115,40 @@ namespace CCC_internal { template< typename pointer, typename size_type, typename CCC > class Free_list { public: - Free_list() : m_head(nullptr), m_size(0) {} + Free_list() : m_head(nullptr), m_size(0) { +#if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + // Note that the performance penalty with + // CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE=1 is + // measured to be 3%, in a parallel insertion of 100k random + // points, in Delaunay_triangulation_3. + refresh_approximate_size(); +#endif // CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + } void init() { m_head = nullptr; m_size = 0; } pointer head() const { return m_head; } void set_head(pointer p) { m_head = p; } size_type size() const { return m_size; } - void set_size(size_type s) { m_size = s; } - void inc_size() { ++m_size; } - void dec_size() { --m_size; } + void set_size(size_type s) { + m_size = s; +#if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + refresh_approximate_size(); +#endif + } + void inc_size() { + ++m_size; +#if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + if(m_size > (m_approximate_size * precision_of_approximate_size_plus_1)) + refresh_approximate_size(); +#endif // CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + } + void dec_size() { + --m_size; +#if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + if((m_size * precision_of_approximate_size_plus_1) < m_approximate_size) + refresh_approximate_size(); +#endif // CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + } bool empty() { return size() == 0; } // Warning: copy the pointer, not the data! Free_list& operator= (const Free_list& other) @@ -149,9 +174,26 @@ public: other.init(); // clear other } +#if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + size_type approximate_size() const { + return m_atomic_approximate_size.load(std::memory_order_relaxed); + } +#endif // CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + protected: pointer m_head; // the free list head pointer size_type m_size; // the free list size + +#if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + // `m_size` plus or minus `precision_of_approximate_size - 1` + static constexpr double precision_of_approximate_size_plus_1 = 1.10; + size_type m_approximate_size; + std::atomic m_atomic_approximate_size; + void refresh_approximate_size() { + m_approximate_size = m_size; + m_atomic_approximate_size.store(m_size, std::memory_order_relaxed); + } +#endif // CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE }; // Class Concurrent_compact_container @@ -247,12 +289,16 @@ public: void swap(Self &c) { std::swap(m_alloc, c.m_alloc); - std::swap(m_capacity, c.m_capacity); +#if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE { // non-atomic swap - size_type other_size = c.m_size; - c.m_size = size_type(m_size); - m_size = other_size; + size_type other_capacity = c.m_capacity; + c.m_capacity = size_type(m_capacity); + m_capacity = other_capacity; } +#else // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + std::swap(m_capacity, c.m_capacity); +#endif // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + std::swap(m_block_size, c.m_block_size); std::swap(m_first_item, c.m_first_item); std::swap(m_last_item, c.m_last_item); @@ -338,7 +384,6 @@ private: #ifndef CGAL_NO_ASSERTIONS std::memset(&*x, 0, sizeof(T)); #endif*/ - --m_size; put_on_free_list(&*x, fl); } public: @@ -359,12 +404,14 @@ public: // The complexity is O(size(free list = capacity-size)). void merge(Self &d); - // If `CGAL_NO_ATOMIC` is defined, do not call this function while others - // are inserting/erasing elements + // Do not call this function while others are inserting/erasing elements size_type size() const { -#ifdef CGAL_NO_ATOMIC +#if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + size_type size = m_capacity.load(std::memory_order_relaxed); +#else // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE size_type size = m_capacity; +#endif // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE for( typename Free_lists::iterator it_free_list = m_free_lists.begin() ; it_free_list != m_free_lists.end() ; ++it_free_list ) @@ -372,11 +419,22 @@ public: size -= it_free_list->size(); } return size; -#else // atomic can be used - return m_size; -#endif } +#if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + size_type approximate_size() const + { + size_type size = m_capacity.load(std::memory_order_relaxed); + for( typename Free_lists::iterator it_free_list = m_free_lists.begin() ; + it_free_list != m_free_lists.end() ; + ++it_free_list ) + { + size -= it_free_list->approximate_size(); + } + return size; + } +#endif // CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + size_type max_size() const { return std::allocator_traits::max_size(m_alloc); @@ -384,7 +442,11 @@ public: size_type capacity() const { +#if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + return m_capacity.load(std::memory_order_relaxed); +#else // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE return m_capacity; +#endif // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE } // void resize(size_type sz, T c = T()); // TODO makes sense ??? @@ -482,7 +544,6 @@ private: { CGAL_assertion(type(ret) == USED); fl->dec_size(); - ++m_size; m_time_stamper->set_time_stamp(ret); return iterator(ret, 0); } @@ -575,23 +636,21 @@ private: m_first_item = nullptr; m_last_item = nullptr; m_all_items = All_items(); - m_size = 0; m_time_stamper->reset(); } allocator_type m_alloc; +#if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + std::atomic m_capacity; +#else // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE size_type m_capacity; +#endif // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE size_type m_block_size; Free_lists m_free_lists; pointer m_first_item; pointer m_last_item; All_items m_all_items; mutable Mutex m_mutex; -#ifdef CGAL_NO_ATOMIC - size_type m_size; -#else - CGAL::cpp11::atomic m_size; -#endif // This is a pointer, so that the definition of Compact_container does // not require a complete type `T`. @@ -601,7 +660,6 @@ private: template < class T, class Allocator > void Concurrent_compact_container::merge(Self &d) { - m_size += d.m_size; CGAL_precondition(&d != this); // Allocators must be "compatible" : @@ -640,7 +698,11 @@ void Concurrent_compact_container::merge(Self &d) } m_all_items.insert(m_all_items.end(), d.m_all_items.begin(), d.m_all_items.end()); // Add the capacities. +#if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + m_capacity.fetch_add(d.m_capacity, std::memory_order_relaxed); +#else // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE m_capacity += d.m_capacity; +#endif // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE // It seems reasonnable to take the max of the block sizes. m_block_size = (std::max)(m_block_size, d.m_block_size); // Clear d. @@ -678,7 +740,11 @@ void Concurrent_compact_container:: old_block_size = m_block_size; new_block = m_alloc.allocate(old_block_size + 2); m_all_items.push_back(std::make_pair(new_block, old_block_size + 2)); +#if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE + m_capacity.fetch_add(old_block_size, std::memory_order_relaxed); +#else // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE m_capacity += old_block_size; +#endif // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE // We insert this new block at the end. if (m_last_item == nullptr) // First time diff --git a/STL_Extension/include/CGAL/Hash_handles_with_or_without_timestamps.h b/STL_Extension/include/CGAL/Hash_handles_with_or_without_timestamps.h deleted file mode 100644 index 1b557a4bca0..00000000000 --- a/STL_Extension/include/CGAL/Hash_handles_with_or_without_timestamps.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2014-2017 GeometryFactory Sarl (France) -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org) -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial -// -// Author(s) : Laurent Rineau, -// Mael Rouxel-LabbĆ© - -#ifndef CGAL_HASH_HANDLES_WITH_OR_WITHOUT_TIMESTAMPS_H -#define CGAL_HASH_HANDLES_WITH_OR_WITHOUT_TIMESTAMPS_H - -#include - -#include - -#include -#include - -namespace CGAL { - -struct Hash_handles_with_or_without_timestamps -{ - template - std::size_t operator()(const Handle h) const - { - typedef typename std::iterator_traits::value_type Type; - - return hash(h, Boolean_tag::value>()); - } - - template - std::size_t hash(const Handle h, Tag_false) const - { - return boost::hash_value(&*h); - } - - template - std::size_t hash(const Handle h, Tag_true) const - { - return h->time_stamp(); - } -}; - -} // namespace CGAL - -#endif // CGAL_HASH_HANDLES_WITH_OR_WITHOUT_TIMESTAMPS_H diff --git a/STL_Extension/include/CGAL/Iterator_range.h b/STL_Extension/include/CGAL/Iterator_range.h index 06a71f09240..204d0cd1730 100644 --- a/STL_Extension/include/CGAL/Iterator_range.h +++ b/STL_Extension/include/CGAL/Iterator_range.h @@ -13,8 +13,8 @@ #define CGAL_ITERATOR_RANGE_H #include -#include #include +#include namespace CGAL { diff --git a/STL_Extension/include/CGAL/Small_unordered_map.h b/STL_Extension/include/CGAL/Small_unordered_map.h new file mode 100644 index 00000000000..4272d16bb5b --- /dev/null +++ b/STL_Extension/include/CGAL/Small_unordered_map.h @@ -0,0 +1,159 @@ +// Copyright (c) 2019 GeometryFactory Sarl (France) +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Andreas Fabri + +#ifndef CGAL_SMALL_UNORDERED_MAP_H +#define CGAL_SMALL_UNORDERED_MAP_H + +#include +#include + +//#define CGAL_SMALL_UNORDERED_MAP_STATS +namespace CGAL { + + +template +class Small_unordered_map{ +#ifdef CGAL_SMALL_UNORDERED_MAP_STATS + std::array collisions = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +#endif + int head = -2; + mutable std::array occupied; + std::array unfreelist; + std::array, M> data; + const H hash = {}; + +public: + Small_unordered_map() + { + occupied.fill(-1); + } + +#ifdef CGAL_SMALL_UNORDERED_MAP_STATS + ~Small_unordered_map() + { + int total = 0; + std::cout << "0 " << collisions[0] << std::endl; + for(int i = 1; i < 20; i++){ + total += collisions[i]; + if(collisions[i] != 0){ + std::cout << i << " " << collisions[i] << std::endl; + } + } + std::cout << "Total: " << total << " " << 100 * (double(total) / double(total + collisions[0])) << "%" << std::endl; + } +#endif + + /// Set only once for a key and not more than N + void set(const K& k, const T& t) + { + unsigned int h = hash(k)%M; + unsigned i = h; +#ifdef CGAL_SMALL_UNORDERED_MAP_STATS + int collision = 0; +#endif + do { + if(occupied[i]== -1){ + occupied[i] = 1; + data[i].first = k; + data[i].second = t; + unfreelist[i] = head; + head = i; +#ifdef CGAL_SMALL_UNORDERED_MAP_STATS + if(collision>19){ + std::cerr << collision << " collisions" << std::endl; + }else{ + ++collisions[collision]; + } +#endif + return; + } + i = (i+1)%M; +#ifdef CGAL_SMALL_UNORDERED_MAP_STATS + ++collision; +#endif + }while(i != h); + CGAL_error(); + } + + // et only once as it is erased + const T& get_and_erase(const K& k) const + { + unsigned int h = hash(k)%M; + unsigned int i = h; + do{ + if((occupied[i] == 1) && (data[i].first == k)){ + occupied[i] = -1; + return data[i].second; + } + i = (i+1)%M; + }while(i != h); + CGAL_error(); + } + + void clear() + { + head = -2; + // without erase we would have to call occupied.fill(-1); which is costly + } + + struct iterator { + const Small_unordered_map& map; + int pos; + + iterator(const Small_unordered_map& map) + : map(map),pos(-2) + {} + + iterator(const Small_unordered_map& map, int pos) + : map(map), pos(pos) + {} + + bool operator==(const iterator& other) const + { + return pos == other.pos; + } + + bool operator!=(const iterator& other) const + { + return pos != other.pos; + } + iterator operator++() + { + pos = map.unfreelist[pos]; + return *this; + } + + const std::pair& operator*()const + { + return map.data[pos]; + } + }; + + iterator begin() const + { + return iterator(*this,head); + } + + iterator end() const + { + return iterator(*this); + } + + void clear(const iterator it) + { + occupied[it.pos] = -1; + } + + friend struct iterator; +}; + +} // namespace CGAL +#endif // CGAL_SMALL_UNORDERED_MAP_H diff --git a/STL_Extension/include/CGAL/Time_stamper.h b/STL_Extension/include/CGAL/Time_stamper.h index 82961b37269..6d65ec3cfb1 100644 --- a/STL_Extension/include/CGAL/Time_stamper.h +++ b/STL_Extension/include/CGAL/Time_stamper.h @@ -17,6 +17,14 @@ namespace CGAL { +namespace internal { + +constexpr size_t rounded_down_log2(size_t n) +{ + return ( (n<2) ? 0 : 1+rounded_down_log2(n/2)); +} +} // namespace internal + template struct Time_stamper { @@ -118,7 +126,9 @@ public: } static std::size_t hash_value(const T* p) { - return reinterpret_cast(p)/sizeof(T); + + constexpr std::size_t shift = internal::rounded_down_log2(sizeof(T)); + return reinterpret_cast(p) >> shift; } void reset() {} @@ -149,6 +159,17 @@ struct Get_time_stamper{ template struct Time_stamper_impl : public Get_time_stamper::type {}; +struct Hash_handles_with_or_without_timestamps +{ + template + std::size_t operator()(const Handle h) const + { + typedef typename std::iterator_traits::value_type Type; + + return Get_time_stamper::type::hash_value(&*h); + } +}; + } //end of namespace CGAL #endif // CGAL_TIME_STAMPER_H diff --git a/STL_Extension/include/CGAL/is_streamable.h b/STL_Extension/include/CGAL/is_streamable.h index b19ff487c4e..b20898a2664 100644 --- a/STL_Extension/include/CGAL/is_streamable.h +++ b/STL_Extension/include/CGAL/is_streamable.h @@ -1,15 +1,6 @@ // Copyright (c) 2012 GeometryFactory Sarl (France) // All rights reserved. // -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// // $URL$ // $Id$ // SPDX-License-Identifier: BSL-1.0 diff --git a/Scripts/developer_scripts/cgal_create_release_with_cmake.cmake b/Scripts/developer_scripts/cgal_create_release_with_cmake.cmake index f6b3e42b7d7..38905c3e239 100644 --- a/Scripts/developer_scripts/cgal_create_release_with_cmake.cmake +++ b/Scripts/developer_scripts/cgal_create_release_with_cmake.cmake @@ -154,6 +154,10 @@ foreach(pkg ${files}) process_package(${pkg}) endif() endforeach() +if(EXISTS ${GIT_REPO}/Maintenance/release_building/public_release_name) + file(COPY "${GIT_REPO}/Maintenance/release_building/public_release_name" + DESTINATION "${release_dir}/doc") +endif() #create VERSION file(WRITE ${release_dir}/VERSION "${CGAL_VERSION}") diff --git a/Scripts/developer_scripts/create_new_release b/Scripts/developer_scripts/create_new_release index c34fc3c9a3e..bbd9c5bf8b3 100755 --- a/Scripts/developer_scripts/create_new_release +++ b/Scripts/developer_scripts/create_new_release @@ -322,6 +322,9 @@ fi if [ -n "$DO_PUBLIC" ]; then if docker version > /dev/null; then + # Re-extract the full version of CGAL, with examples/, and doc_html/ + rm -rf ./${public_release_name} + tar -xf "${HTML_DIR}/${release_name}-public/${public_release_name}.tar.xz" # Build the Windows installer docker pull cgal/cgal-nsis-dockerfile docker create -v `realpath ${DESTINATION}/${public_release_name}`:/mnt/cgal_release:ro,z \ diff --git a/Scripts/developer_scripts/licensecheck b/Scripts/developer_scripts/licensecheck index 8a1c55ee178..ce7a9c537d6 100755 --- a/Scripts/developer_scripts/licensecheck +++ b/Scripts/developer_scripts/licensecheck @@ -594,6 +594,10 @@ sub parselicense { $license = "LGPL (v3)"; } + if ($licensetext =~ /SPDX-License-Identifier BSL-1.0/i) { + $license = "BSL 1.0"; + } + if ($licensetext =~ /SPDX-License-Identifier LicenseRef-RFL/i) { $license = "MIT/X11 (BSD like)"; } diff --git a/Scripts/developer_scripts/test_merge_of_branch b/Scripts/developer_scripts/test_merge_of_branch index fca78d160d2..89a1d80a6e6 100755 --- a/Scripts/developer_scripts/test_merge_of_branch +++ b/Scripts/developer_scripts/test_merge_of_branch @@ -48,7 +48,7 @@ detect_wrong_permissions || exit 1 echo '.. Testing licenses...' detect_packages_licenses || exit 1 if ! ${git} diff --exit-code > /dev/null; then - echo '=> There are modifications in licenses:' + echo '=> There are modifications in licenses (check if all modified/added headers files contain a valid SPDX tag compatible with the one in package_info/PKG/license and that no license text is present):' ${git} status --porcelain exit 1 fi diff --git a/Scripts/scripts/cgal_create_CMakeLists b/Scripts/scripts/cgal_create_CMakeLists index 683dc355ccd..2be5be308a3 100755 --- a/Scripts/scripts/cgal_create_CMakeLists +++ b/Scripts/scripts/cgal_create_CMakeLists @@ -90,6 +90,8 @@ create_cmake_script_with_options() # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) + EOF #--------------------------------------------------------------------------- if [ "$SINGLE_SOURCE" = "n" ]; then @@ -102,8 +104,6 @@ EOF cat << 'EOF' -cmake_minimum_required(VERSION 2.8.11) - # CGAL and its components EOF if [ -n "$ENABLE_CTEST" ]; then diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/K_neighbor_query.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/K_neighbor_query.h index b9384daf005..7010fab2e1f 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/K_neighbor_query.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/K_neighbor_query.h @@ -95,7 +95,7 @@ namespace Point_set { CGAL::Sliding_midpoint; using Search_tree = - CGAL::Kd_tree; + CGAL::Kd_tree; using Neighbor_search = CGAL::Orthogonal_k_neighbor_search< diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Sphere_neighbor_query.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Sphere_neighbor_query.h index ab6aa884b24..fc19f59b53a 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Sphere_neighbor_query.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Sphere_neighbor_query.h @@ -101,7 +101,7 @@ namespace Point_set { = CGAL::Fuzzy_sphere; using Tree - = CGAL::Kd_tree; + = CGAL::Kd_tree; /// \endcond /// @} diff --git a/Shape_detection/package_info/Shape_detection/dependencies b/Shape_detection/package_info/Shape_detection/dependencies index 2d92a3bf769..b5a74b46fe7 100644 --- a/Shape_detection/package_info/Shape_detection/dependencies +++ b/Shape_detection/package_info/Shape_detection/dependencies @@ -1,33 +1,33 @@ Algebraic_foundations +Arithmetic_kernel +BGL +Cartesian_kernel Circulator Distance_2 Distance_3 +Filtered_kernel +HalfedgeDS +Hash_map +Homogeneous_kernel Installation +Intersections_2 +Intersections_3 Interval_support Kernel_23 Kernel_d +Modifier Modular_arithmetic Number_types -Shape_detection +Polyhedron +Polyhedron_IO Principal_component_analysis Principal_component_analysis_LGPL Profiling_tools Property_map Random_numbers STL_Extension +Shape_detection Solver_interface Spatial_searching Stream_support -BGL -Arithmetic_kernel -Cartesian_kernel -Filtered_kernel -HalfedgeDS -Hash_map -Homogeneous_kernel -Intersections_2 -Intersections_3 -Modifier -Polyhedron -Polyhedron_IO Surface_mesh diff --git a/Solver_interface/include/CGAL/GLPK_mixed_integer_program_traits.h b/Solver_interface/include/CGAL/GLPK_mixed_integer_program_traits.h index 4890c92c4bf..5023c1cc456 100644 --- a/Solver_interface/include/CGAL/GLPK_mixed_integer_program_traits.h +++ b/Solver_interface/include/CGAL/GLPK_mixed_integer_program_traits.h @@ -13,278 +13,262 @@ #include -#ifdef CGAL_USE_GLPK +#if defined(CGAL_USE_GLPK) || defined(DOXYGEN_RUNNING) #include +#include +#include namespace CGAL { +namespace internal { - /// \ingroup PkgSolver - /// - /// This class provides an interface for formulating and solving - /// mixed integer programs (constrained or unconstrained) using - /// \ref thirdpartyGLPK. - /// - /// \ref thirdpartyGLPK must be available on the system. - /// \note For better performance, please consider using - /// `SCIP_mixed_integer_program_traits`, or derive a new - /// model from `Mixed_integer_program_traits`. - /// - /// \cond SKIP_IN_MANUAL - /// \tparam FT Number type - /// \endcond - /// - /// \cgalModels `MixedIntegerProgramTraits` - /// - /// \sa `SCIP_mixed_integer_program_traits` +// Infers "bound type" (required by GLPK) from the bounds values +template +int bound_type(FT lb, FT ub) +{ + typedef CGAL::Variable Variable; - template - class GLPK_mixed_integer_program_traits : public Mixed_integer_program_traits - { - /// \cond SKIP_IN_MANUAL - public: - typedef CGAL::Mixed_integer_program_traits Base_class; - typedef typename Base_class::Variable Variable; - typedef typename Base_class::Linear_constraint Linear_constraint; - typedef typename Base_class::Linear_objective Linear_objective; - typedef typename Linear_objective::Sense Sense; - typedef typename Variable::Variable_type Variable_type; + if (lb <= -Variable::infinity() && ub >= Variable::infinity()) { + return GLP_FR; // free (unbounded) variable + } else if (lb > -Variable::infinity() && ub >= Variable::infinity()) { + return GLP_LO; // variable with lower bound + } else if (lb <= -Variable::infinity() && ub < Variable::infinity()) { + return GLP_UP; // variable with upper bound + } else { + // lb > -Variable::infinity() && ub < Variable::infinity() + if (lb == ub) + return GLP_FX; // fixed variable + else + return GLP_DB; // double-bounded variable + } +} - public: +} // namespace internal - /// Solves the program. Returns false if fails. - virtual bool solve(); - /// \endcond - }; +/// \ingroup PkgSolver +/// +/// This class provides an interface for formulating and solving +/// constrained or unconstrained mixed integer programs using +/// \ref thirdpartyGLPK, which must be available on the system. +/// +/// \note For better performance, please consider using +/// `SCIP_mixed_integer_program_traits`, or derive a new +/// model from `Mixed_integer_program_traits`. +/// +/// \cgalModels `MixedIntegerProgramTraits` +/// +/// \sa `SCIP_mixed_integer_program_traits` +template +class GLPK_mixed_integer_program_traits + : public Mixed_integer_program_traits +{ + /// \cond SKIP_IN_MANUAL +public: + typedef CGAL::Mixed_integer_program_traits Base_class; + typedef typename Base_class::Variable Variable; + typedef typename Base_class::Linear_constraint Linear_constraint; + typedef typename Base_class::Linear_objective Linear_objective; + typedef typename Linear_objective::Sense Sense; + typedef typename Variable::Variable_type Variable_type; - ////////////////////////////////////////////////////////////////////////// +public: + /// Solves the program. Returns `false` if fails. + virtual bool solve() + { + Base_class::error_message_.clear(); - // implementation + glp_prob* lp = glp_create_prob(); + if (!lp) { + Base_class::error_message_ = "failed creating GLPK program"; + return false; + } - /// \cond SKIP_IN_MANUAL + std::size_t num_integer_variables = 0; - namespace internal { + // Creates variables - // Infers "bound type" (required by GLPK) from the bounds values - template - int bound_type(FT lb, FT ub) { - typedef CGAL::Variable Variable; + // This "static_cast<>" suppresses many annoying warnings: "conversion from 'size_t' to 'int', possible loss of data" + int num_variables = static_cast(Base_class::variables_.size()); - if (lb <= -Variable::infinity() && ub >= Variable::infinity()) - return GLP_FR; // free (unbounded) variable + glp_add_cols(lp, num_variables); + for (int i = 0; i < num_variables; ++i) { + const Variable* var = Base_class::variables_[i]; + glp_set_col_name(lp, i + 1, var->name().c_str()); - else if (lb > -Variable::infinity() && ub >= Variable::infinity()) - return GLP_LO; // variable with lower bound + if (var->variable_type() == Variable::INTEGER) { + glp_set_col_kind(lp, i + 1, GLP_IV); // glpk uses 1-based arrays + ++num_integer_variables; + } else if (var->variable_type() == Variable::BINARY) { + glp_set_col_kind(lp, i + 1, GLP_BV); // glpk uses 1-based arrays + ++num_integer_variables; + } else { + glp_set_col_kind(lp, i + 1, GLP_CV); // Continuous variable + } - else if (lb <= -Variable::infinity() && ub < Variable::infinity()) - return GLP_UP; // variable with upper bound + FT lb, ub; + var->get_bounds(lb, ub); - else {// lb > -Variable::infinity() && ub < Variable::infinity() - if (lb == ub) - return GLP_FX; // fixed variable - else - return GLP_DB; // double-bounded variable - } - } - } - /// \endcond + int type = internal::bound_type(lb, ub); + glp_set_col_bnds(lp, i + 1, type, lb, ub); + } - template - bool GLPK_mixed_integer_program_traits::solve() { - Base_class::error_message_.clear(); + // Adds constraints - glp_prob* lp = glp_create_prob(); - if (!lp) { - Base_class::error_message_ = "failed creating GLPK program"; - return false; - } + // This "static_cast<>" suppresses many annoying warnings: "conversion from 'size_t' to 'int', possible loss of data" + int num_constraints = static_cast(Base_class::constraints_.size()); + glp_add_rows(lp, num_constraints); - std::size_t num_integer_variables = 0; + for (int i = 0; i < num_constraints; ++i) { + const Linear_constraint* c = Base_class::constraints_[i]; + const std::unordered_map& coeffs = c->coefficients(); + typename std::unordered_map::const_iterator cur = coeffs.begin(); - // Creates variables + std::vector indices(coeffs.size() + 1, 0); // glpk uses 1-based arrays + std::vector coefficients(coeffs.size() + 1, 0.0); // glpk uses 1-based arrays + std::size_t idx = 1; // glpk uses 1-based arrays + for (; cur != coeffs.end(); ++cur) { + int var_idx = cur->first->index(); + FT coeff = cur->second; - // This "static_cast<>" suppresses many annoying warnings: "conversion from 'size_t' to 'int', possible loss of data" - int num_variables = static_cast(Base_class::variables_.size()); + indices[idx] = var_idx + 1; // glpk uses 1-based arrays + coefficients[idx] = coeff; + ++idx; + } - glp_add_cols(lp, num_variables); - for (int i = 0; i < num_variables; ++i) { - const Variable* var = Base_class::variables_[i]; - glp_set_col_name(lp, i + 1, var->name().c_str()); + glp_set_mat_row(lp, i + 1, static_cast(coeffs.size()), indices.data(), coefficients.data()); - if (var->variable_type() == Variable::INTEGER) { - glp_set_col_kind(lp, i + 1, GLP_IV); // glpk uses 1-based arrays - ++num_integer_variables; - } - else if (var->variable_type() == Variable::BINARY) { - glp_set_col_kind(lp, i + 1, GLP_BV); // glpk uses 1-based arrays - ++num_integer_variables; - } - else - glp_set_col_kind(lp, i + 1, GLP_CV); // Continuous variable + FT lb, ub; + c->get_bounds(lb, ub); - FT lb, ub; - var->get_bounds(lb, ub); + int type = internal::bound_type(lb, ub); + glp_set_row_bnds(lp, i + 1, type, lb, ub); - int type = internal::bound_type(lb, ub); - glp_set_col_bnds(lp, i + 1, type, lb, ub); - } + glp_set_row_name(lp, i + 1, c->name().c_str()); + } - // Adds constraints + // Sets objective - // This "static_cast<>" suppresses many annoying warnings: "conversion from 'size_t' to 'int', possible loss of data" - int num_constraints = static_cast(Base_class::constraints_.size()); - glp_add_rows(lp, num_constraints); + // Determines the coefficient of each variable in the objective function + const std::unordered_map& obj_coeffs = Base_class::objective_->coefficients(); + typename std::unordered_map::const_iterator cur = obj_coeffs.begin(); + for (; cur != obj_coeffs.end(); ++cur) { + int var_idx = cur->first->index(); + FT coeff = cur->second; + glp_set_obj_coef(lp, var_idx + 1, coeff); // glpk uses 1-based arrays + } - for (int i = 0; i < num_constraints; ++i) { - const Linear_constraint* c = Base_class::constraints_[i]; - const std::unordered_map& coeffs = c->coefficients(); - typename std::unordered_map::const_iterator cur = coeffs.begin(); + // Sets objective function sense + bool minimize = (Base_class::objective_->sense() == Linear_objective::MINIMIZE); + glp_set_obj_dir(lp, minimize ? GLP_MIN : GLP_MAX); + int msg_level = GLP_MSG_ERR; + int status = -1; + if (num_integer_variables == 0) { // Continuous problem + glp_smcp parm; + glp_init_smcp(&parm); + parm.msg_lev = msg_level; + status = glp_simplex(lp, &parm); + } + else { // Solves as MIP problem + glp_iocp parm; + glp_init_iocp(&parm); + parm.msg_lev = msg_level; + parm.presolve = GLP_ON; + // The routine glp_intopt is a driver to the MIP solver based on the branch-and-cut method, + // which is a hybrid of branch-and-bound and cutting plane methods. + status = glp_intopt(lp, &parm); + } - std::vector indices(coeffs.size() + 1, 0); // glpk uses 1-based arrays - std::vector coefficients(coeffs.size() + 1, 0.0); // glpk uses 1-based arrays - std::size_t idx = 1; // glpk uses 1-based arrays - for (; cur != coeffs.end(); ++cur) { - int var_idx = cur->first->index(); - FT coeff = cur->second; + switch (status) { + case 0: { + if (num_integer_variables == 0) { // continuous problem + Base_class::result_.resize(num_variables); + for (int i = 0; i < num_variables; ++i) { + FT x = glp_get_col_prim(lp, i + 1); // glpk uses 1-based arrays + Variable* v = Base_class::variables_[i]; + v->set_solution_value(x); + Base_class::result_[i] = x; + } + } + else { // MIP problem + Base_class::result_.resize(num_variables); + for (int i = 0; i < num_variables; ++i) { + FT x = glp_mip_col_val(lp, i + 1); // glpk uses 1-based arrays - indices[idx] = var_idx + 1; // glpk uses 1-based arrays - coefficients[idx] = coeff; - ++idx; - } + Variable* v = Base_class::variables_[i]; + if (v->variable_type() != Variable::CONTINUOUS) + x = static_cast(std::round(x)); - glp_set_mat_row(lp, i + 1, static_cast(coeffs.size()), indices.data(), coefficients.data()); + v->set_solution_value(x); + Base_class::result_[i] = x; + } + } + break; + } - FT lb, ub; - c->get_bounds(lb, ub); + case GLP_EBOUND: + Base_class::error_message_ = + "Unable to start the search, because some FT-bounded variables have incorrect" + "bounds or some integer variables have non - integer(fractional) bounds."; + break; - int type = internal::bound_type(lb, ub); - glp_set_row_bnds(lp, i + 1, type, lb, ub); + case GLP_EROOT: + Base_class::error_message_ = + "Unable to start the search, because optimal basis for initial LP relaxation is not" + "provided. (This code may appear only if the presolver is disabled.)"; + break; - glp_set_row_name(lp, i + 1, c->name().c_str()); - } + case GLP_ENOPFS: + Base_class::error_message_ = + "Unable to start the search, because LP relaxation of the MIP problem instance has" + "no primal feasible solution. (This code may appear only if the presolver is enabled.)"; + break; - // Sets objective + case GLP_ENODFS: + Base_class::error_message_ = + "Unable to start the search, because LP relaxation of the MIP problem instance has" + "no dual feasible solution.In other word, this code means that if the LP relaxation" + "has at least one primal feasible solution, its optimal solution is unbounded, so if the" + "MIP problem has at least one integer feasible solution, its(integer) optimal solution" + "is also unbounded. (This code may appear only if the presolver is enabled.)"; + break; - // Determines the coefficient of each variable in the objective function - const std::unordered_map& obj_coeffs = Base_class::objective_->coefficients(); - typename std::unordered_map::const_iterator cur = obj_coeffs.begin(); - for (; cur != obj_coeffs.end(); ++cur) { - int var_idx = cur->first->index(); - FT coeff = cur->second; - glp_set_obj_coef(lp, var_idx + 1, coeff); // glpk uses 1-based arrays - } + case GLP_EFAIL: + Base_class::error_message_ = + "The search was prematurely terminated due to the solver failure."; + break; - // Sets objective function sense - bool minimize = (Base_class::objective_->sense() == Linear_objective::MINIMIZE); - glp_set_obj_dir(lp, minimize ? GLP_MIN : GLP_MAX); - int msg_level = GLP_MSG_ERR; - int status = -1; - if (num_integer_variables == 0) { // Continuous problem - glp_smcp parm; - glp_init_smcp(&parm); - parm.msg_lev = msg_level; - status = glp_simplex(lp, &parm); - } - else { // Solves as MIP problem - glp_iocp parm; - glp_init_iocp(&parm); - parm.msg_lev = msg_level; - parm.presolve = GLP_ON; - // The routine glp_intopt is a driver to the MIP solver based on the branch-and-cut method, - // which is a hybrid of branch-and-bound and cutting plane methods. - status = glp_intopt(lp, &parm); - } + case GLP_EMIPGAP: + Base_class::error_message_ = + "The search was prematurely terminated, because the relative mip gap tolerance has been reached."; + break; - switch (status) { - case 0: { - if (num_integer_variables == 0) { // continuous problem - Base_class::result_.resize(num_variables); - for (int i = 0; i < num_variables; ++i) { - FT x = glp_get_col_prim(lp, i + 1); // glpk uses 1-based arrays - Variable* v = Base_class::variables_[i]; - v->set_solution_value(x); - Base_class::result_[i] = x; - } - } - else { // MIP problem - Base_class::result_.resize(num_variables); - for (int i = 0; i < num_variables; ++i) { - FT x = glp_mip_col_val(lp, i + 1); // glpk uses 1-based arrays + case GLP_ETMLIM: + Base_class::error_message_ = + "The search was prematurely terminated, because the time limit has been exceeded."; + break; - Variable* v = Base_class::variables_[i]; - if (v->variable_type() != Variable::CONTINUOUS) - x = static_cast(std::round(x)); + case GLP_ESTOP: + Base_class::error_message_ = + "The search was prematurely terminated by application. (This code may appear only" + "if the advanced solver interface is used.)"; + break; - v->set_solution_value(x); - Base_class::result_[i] = x; - } - } - break; - } + default: + Base_class::error_message_ = + "optimization was stopped with status code " + std::to_string(status); + break; + } - case GLP_EBOUND: - Base_class::error_message_ = - "Unable to start the search, because some FT-bounded variables have incorrect" - "bounds or some integer variables have non - integer(fractional) bounds."; - break; - - case GLP_EROOT: - Base_class::error_message_ = - "Unable to start the search, because optimal basis for initial LP relaxation is not" - "provided. (This code may appear only if the presolver is disabled.)"; - break; - - case GLP_ENOPFS: - Base_class::error_message_ = - "Unable to start the search, because LP relaxation of the MIP problem instance has" - "no primal feasible solution. (This code may appear only if the presolver is enabled.)"; - break; - - case GLP_ENODFS: - Base_class::error_message_ = - "Unable to start the search, because LP relaxation of the MIP problem instance has" - "no dual feasible solution.In other word, this code means that if the LP relaxation" - "has at least one primal feasible solution, its optimal solution is unbounded, so if the" - "MIP problem has at least one integer feasible solution, its(integer) optimal solution" - "is also unbounded. (This code may appear only if the presolver is enabled.)"; - break; - - case GLP_EFAIL: - Base_class::error_message_ = - "The search was prematurely terminated due to the solver failure."; - break; - - case GLP_EMIPGAP: - Base_class::error_message_ = - "The search was prematurely terminated, because the relative mip gap tolerance has been reached."; - break; - - case GLP_ETMLIM: - Base_class::error_message_ = - "The search was prematurely terminated, because the time limit has been exceeded."; - break; - - case GLP_ESTOP: - Base_class::error_message_ = - "The search was prematurely terminated by application. (This code may appear only" - "if the advanced solver interface is used.)"; - break; - - default: - Base_class::error_message_ = - "optimization was stopped with status code " + std::to_string(status); - break; - } - - glp_delete_prob(lp); - - return (status == 0); - } + glp_delete_prob(lp); + return (status == 0); + } + /// \endcond +}; } // namespace CGAL -#endif // CGAL_USE_GLPK +#endif // CGAL_USE_GLPK or DOXYGEN_RUNNING #endif // CGAL_GLPK_MIXED_INTEGER_PROGRAM_TRAITS_H diff --git a/Solver_interface/include/CGAL/SCIP_mixed_integer_program_traits.h b/Solver_interface/include/CGAL/SCIP_mixed_integer_program_traits.h index 6f2952bf0eb..00a35145187 100644 --- a/Solver_interface/include/CGAL/SCIP_mixed_integer_program_traits.h +++ b/Solver_interface/include/CGAL/SCIP_mixed_integer_program_traits.h @@ -13,226 +13,217 @@ #include -#ifdef CGAL_USE_SCIP +#if defined(CGAL_USE_SCIP) || defined(DOXYGEN_RUNNING) #include "scip/scip.h" #include "scip/scipdefplugins.h" +#include +#include +#include +#include + namespace CGAL { - /// \ingroup PkgSolver - /// - /// This class provides an interface for formulating and solving - /// mixed integer programs (constrained or unconstrained) using - /// \ref thirdpartySCIP. - /// - /// \ref thirdpartySCIP must be available on the system. - /// - /// \cond SKIP_IN_MANUAL - /// \tparam FT Number type - /// \endcond - /// - /// \cgalModels `MixedIntegerProgramTraits` - /// - /// \sa `GLPK_mixed_integer_program_traits` +/// \ingroup PkgSolver +/// +/// This class provides an interface for formulating and solving +/// constrained or unconstrained mixed integer programs using +/// \ref thirdpartySCIP (which must be available on the system). +/// +/// \cgalModels `MixedIntegerProgramTraits` +/// +/// \sa `GLPK_mixed_integer_program_traits` +template +class SCIP_mixed_integer_program_traits + : public Mixed_integer_program_traits +{ + /// \cond SKIP_IN_MANUAL +public: + typedef CGAL::Mixed_integer_program_traits Base_class; + typedef typename Base_class::Variable Variable; + typedef typename Base_class::Linear_constraint Linear_constraint; + typedef typename Base_class::Linear_objective Linear_objective; + typedef typename Linear_objective::Sense Sense; + typedef typename Variable::Variable_type Variable_type; - template - class SCIP_mixed_integer_program_traits : public Mixed_integer_program_traits - { - /// \cond SKIP_IN_MANUAL - public: - typedef CGAL::Mixed_integer_program_traits Base_class; - typedef typename Base_class::Variable Variable; - typedef typename Base_class::Linear_constraint Linear_constraint; - typedef typename Base_class::Linear_objective Linear_objective; - typedef typename Linear_objective::Sense Sense; - typedef typename Variable::Variable_type Variable_type; +public: + /// Solves the program. Returns `false` if fails. + virtual bool solve() + { + Base_class::error_message_.clear(); - public: + Scip* scip = 0; + SCIP_CALL(SCIPcreate(&scip)); + SCIP_CALL(SCIPincludeDefaultPlugins(scip)); - /// Solves the program. Returns false if fails. - virtual bool solve(); - /// \endcond - }; + // Disables scip output to stdout + SCIPmessagehdlrSetQuiet(SCIPgetMessagehdlr(scip), TRUE); - ////////////////////////////////////////////////////////////////////////// + // Uses wall clock time because getting CPU user seconds + // involves calling times() which is very expensive + SCIP_CALL(SCIPsetIntParam(scip, "timing/clocktype", SCIP_CLOCKTYPE_WALL)); - // implementation + // Creates empty problem + SCIP_CALL(SCIPcreateProbBasic(scip, "Solver_interface")); - template - bool SCIP_mixed_integer_program_traits::solve() - { - Base_class::error_message_.clear(); + // Creates variables + std::vector scip_variables; + for (std::size_t i = 0; i < Base_class::variables_.size(); ++i) { + const Variable* var = Base_class::variables_[i]; + SCIP_VAR* v = 0; - Scip* scip = 0; - SCIP_CALL(SCIPcreate(&scip)); - SCIP_CALL(SCIPincludeDefaultPlugins(scip)); + double lb, ub; + var->get_bounds(lb, ub); - // Disables scip output to stdout - SCIPmessagehdlrSetQuiet(SCIPgetMessagehdlr(scip), TRUE); + switch (var->variable_type()) + { + case Variable::CONTINUOUS: + SCIP_CALL(SCIPcreateVar(scip, &v, var->name().c_str(), lb, ub, 0.0, SCIP_VARTYPE_CONTINUOUS, TRUE, FALSE, 0, 0, 0, 0, 0)); + break; + case Variable::INTEGER: + SCIP_CALL(SCIPcreateVar(scip, &v, var->name().c_str(), lb, ub, 0.0, SCIP_VARTYPE_INTEGER, TRUE, FALSE, 0, 0, 0, 0, 0)); + break; + case Variable::BINARY: + SCIP_CALL(SCIPcreateVar(scip, &v, var->name().c_str(), 0, 1, 0.0, SCIP_VARTYPE_BINARY, TRUE, FALSE, 0, 0, 0, 0, 0)); + break; + } + // Adds the SCIP_VAR object to the scip problem + SCIP_CALL(SCIPaddVar(scip, v)); - // Uses wall clock time because getting CPU user seconds - // involves calling times() which is very expensive - SCIP_CALL(SCIPsetIntParam(scip, "timing/clocktype", SCIP_CLOCKTYPE_WALL)); + // Stores the SCIP_VAR pointer for later access + scip_variables.push_back(v); + } - // Creates empty problem - SCIP_CALL(SCIPcreateProbBasic(scip, "Solver_interface")); + // Adds constraints - // Creates variables - std::vector scip_variables; - for (std::size_t i = 0; i < Base_class::variables_.size(); ++i) { - const Variable* var = Base_class::variables_[i]; - SCIP_VAR* v = 0; + std::vector scip_constraints; + for (std::size_t i = 0; i < Base_class::constraints_.size(); ++i) { + const Linear_constraint* c = Base_class::constraints_[i]; + const std::unordered_map& coeffs = c->coefficients(); + typename std::unordered_map::const_iterator cur = coeffs.begin(); - double lb, ub; - var->get_bounds(lb, ub); + std::vector cstr_variables(coeffs.size()); + std::vector cstr_values(coeffs.size()); + std::size_t idx = 0; + for (; cur != coeffs.end(); ++cur) { + std::size_t var_idx = cur->first->index(); + double coeff = cur->second; + cstr_variables[idx] = scip_variables[var_idx]; + cstr_values[idx] = coeff; + ++idx; + } - switch (var->variable_type()) - { - case Variable::CONTINUOUS: - SCIP_CALL(SCIPcreateVar(scip, &v, var->name().c_str(), lb, ub, 0.0, SCIP_VARTYPE_CONTINUOUS, TRUE, FALSE, 0, 0, 0, 0, 0)); - break; - case Variable::INTEGER: - SCIP_CALL(SCIPcreateVar(scip, &v, var->name().c_str(), lb, ub, 0.0, SCIP_VARTYPE_INTEGER, TRUE, FALSE, 0, 0, 0, 0, 0)); - break; - case Variable::BINARY: - SCIP_CALL(SCIPcreateVar(scip, &v, var->name().c_str(), 0, 1, 0.0, SCIP_VARTYPE_BINARY, TRUE, FALSE, 0, 0, 0, 0, 0)); - break; - } - // Adds the SCIP_VAR object to the scip problem - SCIP_CALL(SCIPaddVar(scip, v)); + // Creates SCIP_CONS object + SCIP_CONS* cons = 0; + const std::string& name = c->name(); - // Stores the SCIP_VAR pointer for later access - scip_variables.push_back(v); - } + double lb, ub; + c->get_bounds(lb, ub); - // Adds constraints + SCIP_CALL(SCIPcreateConsLinear(scip, &cons, name.c_str(), int(coeffs.size()), cstr_variables.data(), cstr_values.data(), lb, ub, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE)); - std::vector scip_constraints; - for (std::size_t i = 0; i < Base_class::constraints_.size(); ++i) { - const Linear_constraint* c = Base_class::constraints_[i]; - const std::unordered_map& coeffs = c->coefficients(); - typename std::unordered_map::const_iterator cur = coeffs.begin(); + // Adds the constraint to scip + SCIP_CALL(SCIPaddCons(scip, cons)); - std::vector cstr_variables(coeffs.size()); - std::vector cstr_values(coeffs.size()); - std::size_t idx = 0; - for (; cur != coeffs.end(); ++cur) { - std::size_t var_idx = cur->first->index(); - double coeff = cur->second; - cstr_variables[idx] = scip_variables[var_idx]; - cstr_values[idx] = coeff; - ++idx; - } + // Stores the constraint for later on + scip_constraints.push_back(cons); + } - // Creates SCIP_CONS object - SCIP_CONS* cons = 0; - const std::string& name = c->name(); + // Sets objective - double lb, ub; - c->get_bounds(lb, ub); + // Determines the coefficient of each variable in the objective function + const std::unordered_map& obj_coeffs = Base_class::objective_->coefficients(); + typename std::unordered_map::const_iterator cur = obj_coeffs.begin(); + for (; cur != obj_coeffs.end(); ++cur) { + const Variable* var = cur->first; + double coeff = cur->second; + SCIP_CALL(SCIPchgVarObj(scip, scip_variables[var->index()], coeff)); + } - SCIP_CALL(SCIPcreateConsLinear(scip, &cons, name.c_str(), int(coeffs.size()), cstr_variables.data(), cstr_values.data(), lb, ub, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE)); + // Sets the objective sense + bool minimize = (Base_class::objective_->sense() == Linear_objective::MINIMIZE); + SCIP_CALL(SCIPsetObjsense(scip, minimize ? SCIP_OBJSENSE_MINIMIZE : SCIP_OBJSENSE_MAXIMIZE)); - // Adds the constraint to scip - SCIP_CALL(SCIPaddCons(scip, cons)); + // Turns presolve on (it's the SCIP default). + bool presolve = true; + if (presolve) + SCIP_CALL(SCIPsetIntParam(scip, "presolving/maxrounds", -1)); // maximal number of presolving rounds (-1: unlimited, 0: off) + else + SCIP_CALL(SCIPsetIntParam(scip, "presolving/maxrounds", 0)); // disable presolve - // Stores the constraint for later on - scip_constraints.push_back(cons); - } + bool status = false; + // This tells scip to start the solution process + if (SCIPsolve(scip) == SCIP_OKAY) { + // Gets the best found solution from scip + SCIP_SOL* sol = SCIPgetBestSol(scip); + if (sol) { + // If optimal or feasible solution is found. + Base_class::result_.resize(Base_class::variables_.size()); + for (std::size_t i = 0; i < Base_class::variables_.size(); ++i) { + FT x = SCIPgetSolVal(scip, sol, scip_variables[i]); - // Sets objective + Variable* v = Base_class::variables_[i]; + if (v->variable_type() != Variable::CONTINUOUS) + x = static_cast(std::round(x)); - // Determines the coefficient of each variable in the objective function - const std::unordered_map& obj_coeffs = Base_class::objective_->coefficients(); - typename std::unordered_map::const_iterator cur = obj_coeffs.begin(); - for (; cur != obj_coeffs.end(); ++cur) { - const Variable* var = cur->first; - double coeff = cur->second; - SCIP_CALL(SCIPchgVarObj(scip, scip_variables[var->index()], coeff)); - } + v->set_solution_value(x); + Base_class::result_[i] = x; + } + status = true; + } + } - // Sets the objective sense - bool minimize = (Base_class::objective_->sense() == Linear_objective::MINIMIZE); - SCIP_CALL(SCIPsetObjsense(scip, minimize ? SCIP_OBJSENSE_MINIMIZE : SCIP_OBJSENSE_MAXIMIZE)); + // Reports the status: optimal, infeasible, etc. + SCIP_STATUS scip_status = SCIPgetStatus(scip); + switch (scip_status) { + case SCIP_STATUS_OPTIMAL: + // Provides info only if fails. + break; + case SCIP_STATUS_GAPLIMIT: + // To be consistent with the other solvers. + // Provides info only if fails. + break; + case SCIP_STATUS_INFEASIBLE: + Base_class::error_message_ = "model was infeasible"; + break; + case SCIP_STATUS_UNBOUNDED: + Base_class::error_message_ = "model was unbounded"; + break; + case SCIP_STATUS_INFORUNBD: + Base_class::error_message_ = "model was either infeasible or unbounded"; + break; + case SCIP_STATUS_TIMELIMIT: + Base_class::error_message_ = "aborted due to time limit"; + break; + default: + Base_class::error_message_ = "aborted with status: " + std::to_string(scip_status); + break; + } - // Turns presolve on (it's the SCIP default). - bool presolve = true; - if (presolve) - SCIP_CALL(SCIPsetIntParam(scip, "presolving/maxrounds", -1)); // maximal number of presolving rounds (-1: unlimited, 0: off) - else - SCIP_CALL(SCIPsetIntParam(scip, "presolving/maxrounds", 0)); // disable presolve + SCIP_CALL(SCIPresetParams(scip)); - bool status = false; - // This tells scip to start the solution process - if (SCIPsolve(scip) == SCIP_OKAY) { - // Gets the best found solution from scip - SCIP_SOL* sol = SCIPgetBestSol(scip); - if (sol) { - // If optimal or feasible solution is found. - Base_class::result_.resize(Base_class::variables_.size()); - for (std::size_t i = 0; i < Base_class::variables_.size(); ++i) { - FT x = SCIPgetSolVal(scip, sol, scip_variables[i]); + // Since the SCIPcreateVar captures all variables, we have to release them now + for (std::size_t i = 0; i < scip_variables.size(); ++i) + SCIP_CALL(SCIPreleaseVar(scip, &scip_variables[i])); + scip_variables.clear(); - Variable* v = Base_class::variables_[i]; - if (v->variable_type() != Variable::CONTINUOUS) - x = static_cast(std::round(x)); + // The same for the constraints + for (std::size_t i = 0; i < scip_constraints.size(); ++i) + SCIP_CALL(SCIPreleaseCons(scip, &scip_constraints[i])); + scip_constraints.clear(); - v->set_solution_value(x); - Base_class::result_[i] = x; - } - status = true; - } - } + // After releasing all vars and cons we can free the scip problem. + // Remember this has always to be the last call to scip + SCIP_CALL(SCIPfree(&scip)); - // Reports the status: optimal, infeasible, etc. - SCIP_STATUS scip_status = SCIPgetStatus(scip); - switch (scip_status) { - case SCIP_STATUS_OPTIMAL: - // Provides info only if fails. - break; - case SCIP_STATUS_GAPLIMIT: - // To be consistent with the other solvers. - // Provides info only if fails. - break; - case SCIP_STATUS_INFEASIBLE: - Base_class::error_message_ = "model was infeasible"; - break; - case SCIP_STATUS_UNBOUNDED: - Base_class::error_message_ = "model was unbounded"; - break; - case SCIP_STATUS_INFORUNBD: - Base_class::error_message_ = "model was either infeasible or unbounded"; - break; - case SCIP_STATUS_TIMELIMIT: - Base_class::error_message_ = "aborted due to time limit"; - break; - default: - Base_class::error_message_ = "aborted with status: " + std::to_string(scip_status); - break; - } - - SCIP_CALL(SCIPresetParams(scip)); - - // Since the SCIPcreateVar captures all variables, we have to release them now - for (std::size_t i = 0; i < scip_variables.size(); ++i) - SCIP_CALL(SCIPreleaseVar(scip, &scip_variables[i])); - scip_variables.clear(); - - // The same for the constraints - for (std::size_t i = 0; i < scip_constraints.size(); ++i) - SCIP_CALL(SCIPreleaseCons(scip, &scip_constraints[i])); - scip_constraints.clear(); - - // After releasing all vars and cons we can free the scip problem. - // Remember this has always to be the last call to scip - SCIP_CALL(SCIPfree(&scip)); - - return status; - } + return status; + } + /// \endcond +}; } // namespace CGAL -#endif // CGAL_USE_SCIP +#endif // CGAL_USE_SCIP or DOXYGEN_RUNNING #endif // CGAL_SCIP_MIXED_INTEGER_PROGRAM_TRAITS_H diff --git a/Spatial_searching/doc/Spatial_searching/CGAL/Euclidean_distance.h b/Spatial_searching/doc/Spatial_searching/CGAL/Euclidean_distance.h index 5c6388c92b8..6f57a8454f4 100644 --- a/Spatial_searching/doc/Spatial_searching/CGAL/Euclidean_distance.h +++ b/Spatial_searching/doc/Spatial_searching/CGAL/Euclidean_distance.h @@ -64,6 +64,24 @@ Returns the squared Euclidean distance between `q` and `p`. */ FT transformed_distance(Query_item q, Point_d p) const; +/*! +Returns the transformed distance between `q` and the point whose Cartesian +coordinates are contained in the range [`begin`, `end`). +*/ +template +FT transformed_distance_from_coordinates( + Query_item q, Coord_iterator begin, Coord_iterator end) const; + +/*! +Returns the transformed distance between `q` and the point whose Cartesian +coordinates are contained in the range [`begin`, `end`), or any value +\f$ \geq \f$ `stop_if_geq_to_this` if the transformed distance is +\f$ \geq \f$ `stop_if_geq_to_this`. +*/ +template +FT interruptible_transformed_distance( + Query_item q, Coord_iterator begin, Coord_iterator end, FT stop_if_geq_to_this) const; + /*! Returns the squared Euclidean distance between `q` and the point on the boundary of `r` closest to `q`. diff --git a/Spatial_searching/doc/Spatial_searching/CGAL/Fuzzy_iso_box.h b/Spatial_searching/doc/Spatial_searching/CGAL/Fuzzy_iso_box.h index 134640fea7f..90f40892091 100644 --- a/Spatial_searching/doc/Spatial_searching/CGAL/Fuzzy_iso_box.h +++ b/Spatial_searching/doc/Spatial_searching/CGAL/Fuzzy_iso_box.h @@ -73,6 +73,13 @@ Test whether the fuzzy iso box contains `p`. */ bool contains(Point_d p) const; +/*! +Test whether the fuzzy iso box contains the point whose Cartesian +coordinates are contained in the range [`begin`, `end`). +*/ +template +bool contains_point_given_as_coordinates(Coord_iterator begin, Coord_iterator end) const; + /*! Test whether the inner box intersects the rectangle associated with a node of a tree. diff --git a/Spatial_searching/doc/Spatial_searching/CGAL/Fuzzy_sphere.h b/Spatial_searching/doc/Spatial_searching/CGAL/Fuzzy_sphere.h index e5340061349..dac7c110cb0 100644 --- a/Spatial_searching/doc/Spatial_searching/CGAL/Fuzzy_sphere.h +++ b/Spatial_searching/doc/Spatial_searching/CGAL/Fuzzy_sphere.h @@ -75,6 +75,13 @@ less than \f$ r\f$. */ bool contains(const Point_d& p) const; +/*! +Test whether the fuzzy sphere contains the point whose Cartesian coordinates +are contained in the range [`begin`, `end`). +*/ +template +bool contains_point_given_as_coordinates(Coord_iterator begin, Coord_iterator end) const; + /*! Test whether the inner sphere intersects the rectangle associated with a node of a tree. diff --git a/Spatial_searching/doc/Spatial_searching/CGAL/Incremental_neighbor_search.h b/Spatial_searching/doc/Spatial_searching/CGAL/Incremental_neighbor_search.h index 2375a23ffd8..3273f5b39ca 100644 --- a/Spatial_searching/doc/Spatial_searching/CGAL/Incremental_neighbor_search.h +++ b/Spatial_searching/doc/Spatial_searching/CGAL/Incremental_neighbor_search.h @@ -20,8 +20,8 @@ and `Euclidean_distance` otherwise. The default type is `Sliding_midpoint`. \tparam SpatialTree must be a model of the concept `SpatialTree`. -The default type is `Kd_tree`. The -template argument `Tag_false` makes that the tree is built with unextended nodes. +The default type is `Kd_tree`. The +third template argument `Tag_false` makes that the tree is built with unextended nodes. \sa `CGAL::Orthogonal_incremental_neighbor_search` diff --git a/Spatial_searching/doc/Spatial_searching/CGAL/K_neighbor_search.h b/Spatial_searching/doc/Spatial_searching/CGAL/K_neighbor_search.h index 25704b43517..8f21698a2e2 100644 --- a/Spatial_searching/doc/Spatial_searching/CGAL/K_neighbor_search.h +++ b/Spatial_searching/doc/Spatial_searching/CGAL/K_neighbor_search.h @@ -11,14 +11,17 @@ extended or unextended nodes. \tparam Traits must be an implementation of the concept `SearchTraits`, for example `Simple_cartesian`. -\tparam Splitter must be a model of the +\tparam GeneralDistance must be a model of the concept `GeneralDistance`. If `Traits` is `Search_traits_adapter` the default type is `Distance_adapter >`, and `Euclidean_distance` otherwise. +\tparam Splitter must be a model of the concept `Splitter`. +The default type is `Sliding_midpoint`. + \tparam SpatialTree must be an implementation of the concept `SpatialTree`. -The default type is `Kd_tree`. The +The default type is `Kd_tree`. The third template argument `Tag_false` makes that the tree is built with unextended nodes. \sa `CGAL::Orthogonal_k_neighbor_search` diff --git a/Spatial_searching/doc/Spatial_searching/CGAL/Kd_tree.h b/Spatial_searching/doc/Spatial_searching/CGAL/Kd_tree.h index 3c7a21b94de..9a86c03e7fe 100644 --- a/Spatial_searching/doc/Spatial_searching/CGAL/Kd_tree.h +++ b/Spatial_searching/doc/Spatial_searching/CGAL/Kd_tree.h @@ -14,13 +14,28 @@ It defaults to `Sliding_midpoint`. \tparam UseExtendedNode must be `Tag_true`, if the tree shall be built with extended nodes, and `Tag_false` otherwise. +\tparam EnablePointsCache can be `Tag_true` or `Tag_false`. +Not storing the points coordinates inside the tree usually generates a +lot of cache misses, leading to non-optimal performance. This is the case +for example when indices are stored inside the tree, +or to a lesser extent when the points coordinates are stored +in a dynamically allocated array (e.g., `Epick_d` with dynamic +dimension) — we says "to a lesser extent" because the points +are re-created by the kd-tree in a cache-friendly order after its construction, +so the coordinates are more likely to be stored in a near-optimal order on the +heap. When EnablePointsCache` is set to `Tag_true`, the points +coordinates will be cached in an optimal way. This will +increase memory consumption but provide better search performance. +See also the `GeneralDistance` and `FuzzyQueryItem` concepts for +additional requirements when using such a cache. + \sa `CGAL::Kd_tree_node` \sa `CGAL::Search_traits_2` \sa `CGAL::Search_traits_3` \sa `CGAL::Search_traits` */ -template< typename Traits, typename Splitter, typename UseExtendedNode > +template< typename Traits, typename Splitter, typename UseExtendedNode, typename EnablePointsCache > class Kd_tree { public: diff --git a/Spatial_searching/doc/Spatial_searching/CGAL/Orthogonal_incremental_neighbor_search.h b/Spatial_searching/doc/Spatial_searching/CGAL/Orthogonal_incremental_neighbor_search.h index c783b1711db..86a6d31438e 100644 --- a/Spatial_searching/doc/Spatial_searching/CGAL/Orthogonal_incremental_neighbor_search.h +++ b/Spatial_searching/doc/Spatial_searching/CGAL/Orthogonal_incremental_neighbor_search.h @@ -18,7 +18,7 @@ and `Euclidean_distance` otherwise. The default type is `Sliding_midpoint`. \tparam SpatialTree must be a model of the concept `SpatialTree`. -The default type is `Kd_tree`. The +The default type is `Kd_tree`. The third template argument must be `Tag_true` because orthogonal search needs extended kd tree nodes. diff --git a/Spatial_searching/doc/Spatial_searching/CGAL/Orthogonal_k_neighbor_search.h b/Spatial_searching/doc/Spatial_searching/CGAL/Orthogonal_k_neighbor_search.h index 5656a07bf1c..0c6cd01b711 100644 --- a/Spatial_searching/doc/Spatial_searching/CGAL/Orthogonal_k_neighbor_search.h +++ b/Spatial_searching/doc/Spatial_searching/CGAL/Orthogonal_k_neighbor_search.h @@ -14,15 +14,13 @@ for example `Search_traits_2 >`. concept `OrthogonalDistance`. If `Traits` is `Search_traits_adapter` the default type is `Distance_adapter >`, -and `Euclidean_distance` otherwise. - -The default type is `Euclidean_distance`. +and `Euclidean_distance` otherwise. \tparam Splitter must be a model of the concept `Splitter`. The default type is `Sliding_midpoint`. \tparam SpatialTree must be a model of the concept `SpatialTree`. -The default type is `Kd_tree`. The +The default type is `Kd_tree`. The third template argument must be `Tag_true` because orthogonal search needs extended kd tree nodes. diff --git a/Spatial_searching/doc/Spatial_searching/Concepts/FuzzyQueryItem.h b/Spatial_searching/doc/Spatial_searching/Concepts/FuzzyQueryItem.h index cc163a57e7e..de33e1e8140 100644 --- a/Spatial_searching/doc/Spatial_searching/Concepts/FuzzyQueryItem.h +++ b/Spatial_searching/doc/Spatial_searching/Concepts/FuzzyQueryItem.h @@ -40,6 +40,15 @@ Test whether the query item contains `p`. */ bool contains(Point_d p) const; +/*! +Optional: must be defined when used with a `Kd_tree` where `EnablePointsCache` +is set to `Tag_true`. +Test whether the query item contains the point whose Cartesian coordinates +are contained in the range [`begin`, `end`). +*/ +template +bool contains_point_given_as_coordinates(Coord_iterator begin, Coord_iterator end) const; + /*! Test whether the inner approximation of the spatial object intersects a rectangle associated with a node of a tree. diff --git a/Spatial_searching/doc/Spatial_searching/Concepts/GeneralDistance.h b/Spatial_searching/doc/Spatial_searching/Concepts/GeneralDistance.h index d78dd827aee..647f719e25a 100644 --- a/Spatial_searching/doc/Spatial_searching/Concepts/GeneralDistance.h +++ b/Spatial_searching/doc/Spatial_searching/Concepts/GeneralDistance.h @@ -49,6 +49,34 @@ Returns the transformed distance between `q` and `r`. */ FT transformed_distance(Query_item q, Point_d r); +/*! +Optional: must be defined when used with a `Kd_tree` where `EnablePointsCache` +is set to `Tag_true`. + +Returns the transformed distance between `q` and the point whose Cartesian +coordinates are contained in the range [`begin`, `end`). +*/ +template +FT transformed_distance_from_coordinates( + Query_item q, Coord_iterator begin, Coord_iterator end) const; + +/*! +Optional: in most cases (e.g., Euclidean distance), the distance computation +algorithm knows before its end that the distance will be greater than or equal +to some given value. In this function, the computation can be stopped when the +distance is going to be greater than or equal to `stop_if_geq_to_this`. In this case, +the only requirement of the return value it to be \f$ \geq \f$ `stop_if_geq_to_this`. +Note that points cache does not have to be activated to enable this optimization. + +Returns the transformed distance between `q` and the point whose Cartesian +coordinates are contained in the range [`begin`, `end`), or any value +\f$ \geq \f$ `stop_if_geq_to_this` if the transformed distance is +\f$ \geq \f$ `stop_if_geq_to_this`. +*/ +template +FT interruptible_transformed_distance( + Query_item q, Coord_iterator begin, Coord_iterator end, FT stop_if_geq_to_this) const; + /*! Returns the transformed distance between `q` and the point on the boundary of `r` closest to `q`. diff --git a/Spatial_searching/doc/Spatial_searching/Spatial_searching.txt b/Spatial_searching/doc/Spatial_searching/Spatial_searching.txt index 41854e29a79..fb7fa79d487 100644 --- a/Spatial_searching/doc/Spatial_searching/Spatial_searching.txt +++ b/Spatial_searching/doc/Spatial_searching/Spatial_searching.txt @@ -503,6 +503,21 @@ instead of the distance itself. For instance for the Euclidean distance, to avoid the expensive computation of square roots, squared distances are used instead of the Euclidean distance itself. +Not storing the points coordinates inside the tree usually generates a +lot of cache misses, leading to non-optimal performance. This is the case +for example when indices are stored inside the tree, +or to a lesser extent when the points coordinates are stored +in a dynamically allocated array (e.g., `Epick_d` with dynamic +dimension) — we says "to a lesser extent" because the points +are re-created by the kd-tree in a cache-friendly order after its construction, +so the coordinates are more likely to be stored in a near-optimal order on the +heap. +In this case, the `EnablePointsCache` template parameter of the `Kd_tree` class can be +set to `Tag_true`. The points coordinates will then be cached in an optimal +way. This will increase memory consumption but provide better search +performance. See also the `GeneralDistance` and `FuzzyQueryItem` concepts for +additional requirements when using such a cache. + \section Spatial_searchingImplementationHistory Implementation History The initial implementation of this package was done by Hans Tangelder and diff --git a/Spatial_searching/examples/Spatial_searching/Distance.h b/Spatial_searching/examples/Spatial_searching/Distance.h index 6334724c7bc..147ffc6e7ff 100644 --- a/Spatial_searching/examples/Spatial_searching/Distance.h +++ b/Spatial_searching/examples/Spatial_searching/Distance.h @@ -1,5 +1,6 @@ struct Distance { typedef Point Query_item; + typedef Point Point_d; typedef double FT; typedef CGAL::Dimension_tag<3> D; diff --git a/Spatial_searching/include/CGAL/Euclidean_distance.h b/Spatial_searching/include/CGAL/Euclidean_distance.h index 5f49eda15c0..161d5b2dd55 100644 --- a/Spatial_searching/include/CGAL/Euclidean_distance.h +++ b/Spatial_searching/include/CGAL/Euclidean_distance.h @@ -9,6 +9,7 @@ // // // Author(s) : Hans Tangelder () +// Clement Jamin (clement.jamin.pro@gmail.com) #ifndef CGAL_EUCLIDEAN_DISTANCE_H @@ -21,6 +22,7 @@ #include #include #include +#include namespace CGAL { @@ -52,147 +54,201 @@ namespace CGAL { // default constructor Euclidean_distance(const SearchTraits& traits_=SearchTraits()):traits(traits_) {} - - inline FT transformed_distance(const Query_item& q, const Point_d& p) const { - return transformed_distance(q,p, D()); + inline FT transformed_distance(const Query_item& q, const Point_d& p) const + { + typename SearchTraits::Construct_cartesian_const_iterator_d construct_it = traits.construct_cartesian_const_iterator_d_object(); + typename SearchTraits::Cartesian_const_iterator_d p_begin = construct_it(p), p_end = construct_it(p, 0); + return transformed_distance_from_coordinates(q, p_begin, p_end); } - //Dynamic version for runtime dimension - inline FT transformed_distance(const Query_item& q, const Point_d& p, Dynamic_dimension_tag) const { - FT distance = FT(0); - typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object(); - typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q), - qe = construct_it(q,1), pit = construct_it(p); - for(; qit != qe; qit++, pit++){ - distance += ((*qit)-(*pit))*((*qit)-(*pit)); - } - return distance; + template + inline FT transformed_distance_from_coordinates(const Query_item& q, + Coord_iterator it_coord_begin, Coord_iterator it_coord_end) const + { + return transformed_distance_from_coordinates(q, it_coord_begin, it_coord_end, D()); } - //Generic version for DIM > 3 - template < int DIM > - inline FT transformed_distance(const Query_item& q, const Point_d& p, Dimension_tag) const { - FT distance = FT(0); - typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object(); - typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q), - qe = construct_it(q,1), pit = construct_it(p); - for(; qit != qe; qit++, pit++){ - distance += ((*qit)-(*pit))*((*qit)-(*pit)); + // Static dim = 2 loop unrolled + template + inline FT transformed_distance_from_coordinates(const Query_item& q, + Coord_iterator it_coord_begin, Coord_iterator /*unused*/, + Dimension_tag<2>) const + { + typename SearchTraits::Construct_cartesian_const_iterator_d construct_it = traits.construct_cartesian_const_iterator_d_object(); + typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q); + FT distance = square(*qit - *it_coord_begin); + qit++; it_coord_begin++; + distance += square(*qit - *it_coord_begin); + return distance; + } + + // Static dim = 3 loop unrolled + template + inline FT transformed_distance_from_coordinates(const Query_item& q, + Coord_iterator it_coord_begin, Coord_iterator /*unused*/, + Dimension_tag<3>) const + { + typename SearchTraits::Construct_cartesian_const_iterator_d construct_it = traits.construct_cartesian_const_iterator_d_object(); + typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q); + FT distance = square(*qit - *it_coord_begin); + qit++; it_coord_begin++; + distance += square(*qit - *it_coord_begin); + qit++; it_coord_begin++; + distance += square(*qit - *it_coord_begin); + return distance; + } + + // Other cases: static dim > 3 or dynamic dim + template + inline FT transformed_distance_from_coordinates(const Query_item& q, + Coord_iterator it_coord_begin, Coord_iterator /*unused*/, + Dim) const + { + FT distance = FT(0); + typename SearchTraits::Construct_cartesian_const_iterator_d construct_it = traits.construct_cartesian_const_iterator_d_object(); + typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q), qe = construct_it(q, 1); + for (; qit != qe; ++qit, ++it_coord_begin) + { + FT diff = (*qit) - (*it_coord_begin); + distance += diff*diff; + } + return distance; + } + + // During the computation, if the partially-computed distance `pcd` gets greater or equal + // to `stop_if_geq_to_this`, the computation is stopped and `pcd` is returned + template + inline FT interruptible_transformed_distance(const Query_item& q, + Coord_iterator it_coord_begin, Coord_iterator /*unused*/, + FT stop_if_geq_to_this) const + { + FT distance = FT(0); + typename SearchTraits::Construct_cartesian_const_iterator_d construct_it = traits.construct_cartesian_const_iterator_d_object(); + typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q), qe = construct_it(q, 1); + if (std::distance(qit, qe) >= 6) + { + // Every 4 coordinates, the current partially-computed distance + // is compared to stop_if_geq_to_this + // Note: the concept SearchTraits specifies that Cartesian_const_iterator_d + // must be a random-access iterator + typename SearchTraits::Cartesian_const_iterator_d qe_minus_5 = qe; + std::advance(qe, -5); + for (;;) + { + FT diff = (*qit) - (*it_coord_begin); + distance += diff*diff; + ++qit; ++it_coord_begin; + diff = (*qit) - (*it_coord_begin); + distance += diff*diff; + ++qit; ++it_coord_begin; + diff = (*qit) - (*it_coord_begin); + distance += diff*diff; + ++qit; ++it_coord_begin; + diff = (*qit) - (*it_coord_begin); + distance += diff*diff; + ++qit, ++it_coord_begin; + + if (distance >= stop_if_geq_to_this) + return distance; + + if (std::distance(qe_minus_5, qit) >= 0) + break; } - return distance; + } + for (; qit != qe; ++qit, ++it_coord_begin) + { + FT diff = (*qit) - (*it_coord_begin); + distance += diff*diff; + } + return distance; } - //DIM = 2 loop unrolled - inline FT transformed_distance(const Query_item& q, const Point_d& p, Dimension_tag<2> ) const { - typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object(); - typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q),pit = construct_it(p); - FT distance = square(*qit - *pit); - qit++;pit++; - distance += square(*qit - *pit); - return distance; + inline FT min_distance_to_rectangle(const Query_item& q, + const Kd_tree_rectangle& r) const { + FT distance = FT(0); + typename SearchTraits::Construct_cartesian_const_iterator_d construct_it = traits.construct_cartesian_const_iterator_d_object(); + typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q), + qe = construct_it(q, 1); + for (unsigned int i = 0; qit != qe; i++, qit++) { + if ((*qit) < r.min_coord(i)) + distance += + (r.min_coord(i) - (*qit))*(r.min_coord(i) - (*qit)); + else if ((*qit) > r.max_coord(i)) + distance += + ((*qit) - r.max_coord(i))*((*qit) - r.max_coord(i)); + + } + return distance; } - //DIM = 3 loop unrolled - inline FT transformed_distance(const Query_item& q, const Point_d& p, Dimension_tag<3> ) const { - typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object(); - typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q),pit = construct_it(p); - FT distance = square(*qit - *pit); - qit++;pit++; - distance += square(*qit - *pit); - qit++;pit++; - distance += square(*qit - *pit); - return distance; + inline FT min_distance_to_rectangle(const Query_item& q, + const Kd_tree_rectangle& r, std::vector& dists) const { + FT distance = FT(0); + typename SearchTraits::Construct_cartesian_const_iterator_d construct_it = traits.construct_cartesian_const_iterator_d_object(); + typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q), + qe = construct_it(q, 1); + for (unsigned int i = 0; qit != qe; i++, qit++) { + if ((*qit) < r.min_coord(i)) { + dists[i] = (r.min_coord(i) - (*qit)); + distance += dists[i] * dists[i]; + } + else if ((*qit) > r.max_coord(i)) { + dists[i] = ((*qit) - r.max_coord(i)); + distance += dists[i] * dists[i]; + } + + } + return distance; } - + inline FT max_distance_to_rectangle(const Query_item& q, + const Kd_tree_rectangle& r) const { + FT distance = FT(0); + typename SearchTraits::Construct_cartesian_const_iterator_d construct_it = traits.construct_cartesian_const_iterator_d_object(); + typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q), + qe = construct_it(q, 1); + for (unsigned int i = 0; qit != qe; i++, qit++) { + if ((*qit) <= (r.min_coord(i) + r.max_coord(i)) / FT(2.0)) + distance += (r.max_coord(i) - (*qit))*(r.max_coord(i) - (*qit)); + else + distance += ((*qit) - r.min_coord(i))*((*qit) - r.min_coord(i)); + }; + return distance; + } + inline FT max_distance_to_rectangle(const Query_item& q, + const Kd_tree_rectangle& r, std::vector& dists) const { + FT distance = FT(0); + typename SearchTraits::Construct_cartesian_const_iterator_d construct_it = traits.construct_cartesian_const_iterator_d_object(); + typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q), + qe = construct_it(q, 1); + for (unsigned int i = 0; qit != qe; i++, qit++) { + if ((*qit) <= (r.min_coord(i) + r.max_coord(i)) / FT(2.0)) { + dists[i] = (r.max_coord(i) - (*qit)); + distance += dists[i] * dists[i]; + } + else { + dists[i] = ((*qit) - r.min_coord(i)); + distance += dists[i] * dists[i]; + } + }; + return distance; + } - inline FT min_distance_to_rectangle(const Query_item& q, - const Kd_tree_rectangle& r) const { - FT distance = FT(0); - typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object(); - typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q), - qe = construct_it(q,1); - for(unsigned int i = 0;qit != qe; i++, qit++){ - if((*qit) < r.min_coord(i)) - distance += - (r.min_coord(i)-(*qit))*(r.min_coord(i)-(*qit)); - else if ((*qit) > r.max_coord(i)) - distance += - ((*qit)-r.max_coord(i))*((*qit)-r.max_coord(i)); - - } - return distance; - } + inline FT new_distance(FT dist, FT old_off, FT new_off, + int /* cutting_dimension */) const { - inline FT min_distance_to_rectangle(const Query_item& q, - const Kd_tree_rectangle& r,std::vector& dists) const { - FT distance = FT(0); - typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object(); - typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q), - qe = construct_it(q,1); - for(unsigned int i = 0;qit != qe; i++, qit++){ - if((*qit) < r.min_coord(i)){ - dists[i] = (r.min_coord(i)-(*qit)); - distance += dists[i] * dists[i]; - } - else if ((*qit) > r.max_coord(i)){ - dists[i] = ((*qit)-r.max_coord(i)); - distance += dists[i] * dists[i]; - } - - } - return distance; - } + FT new_dist = dist + (new_off*new_off - old_off*old_off); + return new_dist; + } - inline FT max_distance_to_rectangle(const Query_item& q, - const Kd_tree_rectangle& r) const { - FT distance=FT(0); - typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object(); - typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q), - qe = construct_it(q,1); - for(unsigned int i = 0;qit != qe; i++, qit++){ - if ((*qit) <= (r.min_coord(i)+r.max_coord(i))/FT(2.0)) - distance += (r.max_coord(i)-(*qit))*(r.max_coord(i)-(*qit)); - else - distance += ((*qit)-r.min_coord(i))*((*qit)-r.min_coord(i)); - }; - return distance; - } + inline FT transformed_distance(FT d) const { + return d*d; + } - inline FT max_distance_to_rectangle(const Query_item& q, - const Kd_tree_rectangle& r,std::vector& dists ) const { - FT distance=FT(0); - typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object(); - typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q), - qe = construct_it(q,1); - for(unsigned int i = 0;qit != qe; i++, qit++){ - if ((*qit) <= (r.min_coord(i)+r.max_coord(i))/FT(2.0)){ - dists[i] = (r.max_coord(i)-(*qit)); - distance += dists[i] * dists[i]; - } - else{ - dists[i] = ((*qit)-r.min_coord(i)); - distance += dists[i] * dists[i]; - } - }; - return distance; - } - - inline FT new_distance(FT dist, FT old_off, FT new_off, - int /* cutting_dimension */) const { - - FT new_dist = dist + (new_off*new_off - old_off*old_off); - return new_dist; - } - - inline FT transformed_distance(FT d) const { - return d*d; - } - - inline FT inverse_of_transformed_distance(FT d) const { - return CGAL::sqrt(d); - } + inline FT inverse_of_transformed_distance(FT d) const { + return CGAL::sqrt(d); + } }; // class Euclidean_distance diff --git a/Spatial_searching/include/CGAL/Fuzzy_iso_box.h b/Spatial_searching/include/CGAL/Fuzzy_iso_box.h index 547b93e8baa..35ddda7649d 100644 --- a/Spatial_searching/include/CGAL/Fuzzy_iso_box.h +++ b/Spatial_searching/include/CGAL/Fuzzy_iso_box.h @@ -120,6 +120,17 @@ namespace CGAL { return true; } + template + bool contains_point_given_as_coordinates(Coord_iterator it_coord_begin, Coord_iterator /*unused*/) const { + Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object(); + Cartesian_const_iterator_d minit= min_begin, maxit = max_begin; + for (unsigned int i = 0; i < dim; ++i, ++it_coord_begin, ++minit, ++maxit) { + if ( ((*it_coord_begin) < (*minit)) || ((*it_coord_begin) > (*maxit)) ) + return false; + } + return true; + } + bool inner_range_intersects(const Kd_tree_rectangle& rectangle) const { // test whether the box eroded by 'eps' intersects 'rectangle' Cartesian_const_iterator_d minit= min_begin, maxit = max_begin; @@ -131,7 +142,6 @@ namespace CGAL { return true; } - bool outer_range_contains(const Kd_tree_rectangle& rectangle) const { // test whether the box dilated by 'eps' contains 'rectangle' Cartesian_const_iterator_d minit= min_begin, maxit = max_begin; diff --git a/Spatial_searching/include/CGAL/Fuzzy_sphere.h b/Spatial_searching/include/CGAL/Fuzzy_sphere.h index 4588452a341..fd8bbb01bd1 100644 --- a/Spatial_searching/include/CGAL/Fuzzy_sphere.h +++ b/Spatial_searching/include/CGAL/Fuzzy_sphere.h @@ -72,6 +72,21 @@ public: return (distance <= sq_radius); } + template + bool contains_point_given_as_coordinates(Coord_iterator it_coord_begin, Coord_iterator /*unused*/) const { + // test whether the distance between c and p is less than the radius + FT distance = FT(0); + typename SearchTraits::Construct_cartesian_const_iterator_d construct_it = + traits.construct_cartesian_const_iterator_d_object(); + typename SearchTraits::Cartesian_const_iterator_d cit = construct_it(c), + end = construct_it(c, 0); + + for (; cit != end && (distance <= sq_radius); ++cit, ++it_coord_begin) + distance += ((*cit) - (*it_coord_begin))*((*cit) - (*it_coord_begin)); + + return (distance < sq_radius); + } + bool inner_range_intersects(const Kd_tree_rectangle& rectangle) const { // test whether the sphere with radius (r-eps) intersects 'rectangle', i.e. // if the minimal distance of c to 'rectangle' is less than r-eps diff --git a/Spatial_searching/include/CGAL/Incremental_neighbor_search.h b/Spatial_searching/include/CGAL/Incremental_neighbor_search.h index aa8e05f6420..a4e6608caa8 100644 --- a/Spatial_searching/include/CGAL/Incremental_neighbor_search.h +++ b/Spatial_searching/include/CGAL/Incremental_neighbor_search.h @@ -9,6 +9,7 @@ // // // Author(s) : Hans Tangelder () +// Clement Jamin (clement.jamin.pro@gmail.com) #ifndef CGAL_INCREMENTAL_NEIGHBOR_SEARCH_H #define CGAL_INCREMENTAL_NEIGHBOR_SEARCH_H @@ -16,21 +17,23 @@ #include #include +#include +#include +#include +#include #include #include #include #include -#include -#include -#include +#include // for std::distance namespace CGAL { template ::type, class Splitter_ = Sliding_midpoint, - class Tree_=Kd_tree > + class Tree_=Kd_tree > class Incremental_neighbor_search { public: @@ -88,7 +91,7 @@ namespace CGAL { Query_item m_query; Distance m_dist; FT m_Eps; - bool m_search_nearest; + bool m_search_nearest; public: @@ -264,6 +267,9 @@ namespace CGAL { FT rd; + internal::Distance_helper m_distance_helper; + int m_dim; + Tree const& m_tree; class Priority_higher { @@ -323,7 +329,9 @@ namespace CGAL { // constructor Iterator_implementation(const Tree& tree, const Query_item& q,const Distance& tr, FT Eps, bool search_nearest) - : query_point(q), search_nearest_neighbour(search_nearest), + : query_point(q), search_nearest_neighbour(search_nearest), + m_distance_helper(tr, tree.traits()), + m_tree(tree), PriorityQueue(Priority_higher(search_nearest)), Item_PriorityQueue(Distance_smaller(search_nearest)), distance(tr), reference_count(1), number_of_internal_nodes_visited(0), @@ -331,7 +339,11 @@ namespace CGAL { number_of_neighbours_computed(0) { if (tree.empty()) return; - + + typename SearchTraits::Construct_cartesian_const_iterator_d construct_it = + m_tree.traits().construct_cartesian_const_iterator_d_object(); + m_dim = static_cast(std::distance(construct_it(q), construct_it(q, 0))); + multiplication_factor= distance.transformed_distance(FT(1)+Eps); Node_box *bounding_box = new Node_box((tree.bounding_box())); @@ -422,6 +434,81 @@ namespace CGAL { delete The_item_top; } + + // With cache + bool search_in_leaf(typename Tree::Leaf_node_const_handle node, Tag_true, bool search_furthest) + { + typename Tree::iterator it_node_point = node->begin(), it_node_point_end = node->end(); + typename std::vector::const_iterator cache_point_begin = m_tree.cache_begin() + m_dim*(it_node_point - m_tree.begin()); + + for (; it_node_point != node->end(); ++it_node_point) + { + number_of_items_visited++; + FT distance_to_query_point = + m_distance_helper.transformed_distance_from_coordinates( + query_point, *it_node_point, cache_point_begin, cache_point_begin + m_dim); + + Point_with_transformed_distance *NN_Candidate = + new Point_with_transformed_distance(*it_node_point, distance_to_query_point); + Item_PriorityQueue.push(NN_Candidate); + + cache_point_begin += m_dim; + } + // old top of PriorityQueue has been processed, + // hence update rd + + bool next_neighbour_found; + if (!(PriorityQueue.empty())) + { + rd = PriorityQueue.top()->second; + next_neighbour_found = (search_furthest ? + multiplication_factor*rd < Item_PriorityQueue.top()->second + : multiplication_factor*rd > Item_PriorityQueue.top()->second); + } + else // priority queue empty => last neighbour found + { + next_neighbour_found = true; + } + + number_of_neighbours_computed++; + return next_neighbour_found; + } + + // Without cache + bool search_in_leaf(typename Tree::Leaf_node_const_handle node, Tag_false, bool search_furthest) + { + typename Tree::iterator it_node_point = node->begin(), it_node_point_end = node->end(); + + for (; it_node_point != it_node_point_end; ++it_node_point) + { + number_of_items_visited++; + FT distance_to_query_point = + distance.transformed_distance(query_point, *it_node_point); + + Point_with_transformed_distance *NN_Candidate = + new Point_with_transformed_distance(*it_node_point, distance_to_query_point); + Item_PriorityQueue.push(NN_Candidate); + } + // old top of PriorityQueue has been processed, + // hence update rd + + bool next_neighbour_found; + if (!(PriorityQueue.empty())) + { + rd = PriorityQueue.top()->second; + next_neighbour_found = (search_furthest ? + multiplication_factor*rd < Item_PriorityQueue.top()->second + : multiplication_factor*rd > Item_PriorityQueue.top()->second); + } + else // priority queue empty => last neighbour found + { + next_neighbour_found = true; + } + + number_of_neighbours_computed++; + return next_neighbour_found; + } + void Compute_the_next_nearest_neighbour() { @@ -501,36 +588,14 @@ namespace CGAL { } } delete B; - typename Tree::Leaf_node_const_handle node = + + // N is a leaf + typename Tree::Leaf_node_const_handle node = static_cast(N); number_of_leaf_nodes_visited++; if (node->size() > 0) { - for (typename Tree::iterator it = node->begin(); it != node->end(); it++) { - number_of_items_visited++; - FT distance_to_query_point= - distance.transformed_distance(query_point,*it); - Point_with_transformed_distance *NN_Candidate= - new Point_with_transformed_distance(*it,distance_to_query_point); - Item_PriorityQueue.push(NN_Candidate); - } - // old top of PriorityQueue has been processed, - // hence update rd - if (!PriorityQueue.empty()) { - rd = PriorityQueue.top()->second; - if (search_nearest_neighbour) - next_neighbour_found = - (multiplication_factor*rd > - Item_PriorityQueue.top()->second); - else - next_neighbour_found = - (multiplication_factor*rd < - Item_PriorityQueue.top()->second); - } - else // priority queue empty => last neighbour found - { - next_neighbour_found=true; - }; - number_of_neighbours_computed++; + typename internal::Has_points_cache::type::value>::type dummy; + next_neighbour_found = search_in_leaf(node, dummy, !search_nearest_neighbour); } } // next_neighbour_found or priority queue is empty // in the latter case also the item priority queue is empty diff --git a/Spatial_searching/include/CGAL/K_neighbor_search.h b/Spatial_searching/include/CGAL/K_neighbor_search.h index f3841ebe0f9..acf2953804c 100644 --- a/Spatial_searching/include/CGAL/K_neighbor_search.h +++ b/Spatial_searching/include/CGAL/K_neighbor_search.h @@ -8,7 +8,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Hans Tangelder () +// Author(s) : Hans Tangelder (), +// Clement Jamin (clement.jamin.pro@gmail.com) #ifndef CGAL_K_NEIGHBOR_SEARCH_H #define CGAL_K_NEIGHBOR_SEARCH_H @@ -19,8 +20,9 @@ #include #include +#include - +#include // for std::distance namespace CGAL { @@ -30,9 +32,11 @@ class K_neighbor_search; template ::type, class Splitter= Sliding_midpoint , - class Tree= Kd_tree > -class K_neighbor_search: public internal::K_neighbor_search { + class Tree= Kd_tree > +class K_neighbor_search: public internal::K_neighbor_search +{ typedef internal::K_neighbor_search Base; + typedef typename Tree::Point_d Point; public: typedef typename Base::FT FT; @@ -40,17 +44,23 @@ public: K_neighbor_search(const Tree& tree, const typename Base::Query_item& q, unsigned int k=1, FT Eps=FT(0.0), bool Search_nearest=true, const Distance& d=Distance(),bool sorted=true) - : Base(q,k,Eps,Search_nearest,d) + : Base(q,k,Eps,Search_nearest,d), + m_distance_helper(this->distance_instance, tree.traits()), + m_tree(tree) { if (tree.empty()) return; + compute_neighbors_general(tree.root(),tree.bounding_box()); - if (sorted) this->queue.sort(); + if (sorted) this->queue.sort(); }; private: typedef typename Base::Node_const_handle Node_const_handle; using Base::branch; + internal::Distance_helper m_distance_helper; + Tree const& m_tree; + void compute_neighbors_general(typename Base::Node_const_handle N, const Kd_tree_rectangle& r) { @@ -115,21 +125,129 @@ private: } else + { + // n is a leaf + typename Tree::Leaf_node_const_handle node = + static_cast(N); + this->number_of_leaf_nodes_visited++; + if (node->size() > 0) { - // n is a leaf - typename Tree::Leaf_node_const_handle node = - static_cast(N); - this->number_of_leaf_nodes_visited++; - if (node->size() > 0) - for (typename Tree::iterator it = node->begin(); it != node->end(); it++) { - this->number_of_items_visited++; - FT distance_to_query_object = - this->distance_instance.transformed_distance(this->query_object,*it); - this->queue.insert(std::make_pair(&(*it),distance_to_query_object)); - } + typename internal::Has_points_cache::type::value>::type dummy; + if (this->search_nearest) + search_nearest_in_leaf(node, dummy); + else + search_furthest_in_leaf(node, dummy); } + } } - + + // With cache + void search_nearest_in_leaf(typename Tree::Leaf_node_const_handle node, Tag_true) + { + typename Tree::iterator it_node_point = node->begin(), it_node_point_end = node->end(); + int dim = m_tree.dim(); + typename std::vector::const_iterator cache_point_begin = m_tree.cache_begin() + dim*(it_node_point - m_tree.begin()); + // As long as the queue is not full, the node is just inserted + for (; !this->queue.full() && it_node_point != it_node_point_end; ++it_node_point) + { + this->number_of_items_visited++; + + FT distance_to_query_object = + m_distance_helper.transformed_distance_from_coordinates( + this->query_object, *it_node_point, cache_point_begin, cache_point_begin + dim); + this->queue.insert(std::make_pair(&(*it_node_point), distance_to_query_object)); + + cache_point_begin += dim; + } + // Now that the queue is full, we can gain time by keeping track + // of the current worst distance to interrupt the distance computation earlier + FT worst_dist = this->queue.top().second; + for (; it_node_point != it_node_point_end; ++it_node_point) + { + this->number_of_items_visited++; + + FT distance_to_query_object = + m_distance_helper.interruptible_transformed_distance( + this->query_object, *it_node_point, cache_point_begin, cache_point_begin + dim, worst_dist); + + if (distance_to_query_object < worst_dist) + { + this->queue.insert(std::make_pair(&(*it_node_point), distance_to_query_object)); + worst_dist = this->queue.top().second; + } + + cache_point_begin += dim; + } + } + + // Without cache + void search_nearest_in_leaf(typename Tree::Leaf_node_const_handle node, Tag_false) + { + typename Tree::iterator it_node_point = node->begin(), it_node_point_end = node->end(); + // As long as the queue is not full, the node is just inserted + for (; !this->queue.full() && it_node_point != it_node_point_end; ++it_node_point) + { + this->number_of_items_visited++; + + FT distance_to_query_object = + this->distance_instance.transformed_distance(this->query_object, *it_node_point); + this->queue.insert(std::make_pair(&(*it_node_point), distance_to_query_object)); + } + // Now that the queue is full, we can gain time by keeping track + // of the current worst distance to interrupt the distance computation earlier + FT worst_dist = this->queue.top().second; + for (; it_node_point != it_node_point_end; ++it_node_point) + { + this->number_of_items_visited++; + + FT distance_to_query_object = + m_distance_helper.interruptible_transformed_distance( + this->query_object, *it_node_point, worst_dist); + + if (distance_to_query_object < worst_dist) + { + this->queue.insert(std::make_pair(&(*it_node_point), distance_to_query_object)); + worst_dist = this->queue.top().second; + } + } + } + + + // With cache + void search_furthest_in_leaf(typename Tree::Leaf_node_const_handle node, Tag_true) + { + typename Tree::iterator it_node_point = node->begin(), it_node_point_end = node->end(); + int dim = m_tree.dim(); + typename std::vector::const_iterator cache_point_begin = m_tree.cache_begin() + dim*(it_node_point - m_tree.begin()); + // In furthest search mode, the interruptible distance cannot be used to optimize + for (; it_node_point != it_node_point_end; ++it_node_point) + { + this->number_of_items_visited++; + + FT distance_to_query_object = + m_distance_helper.transformed_distance_from_coordinates( + this->query_object, *it_node_point, cache_point_begin, cache_point_begin + dim); + this->queue.insert(std::make_pair(&(*it_node_point), distance_to_query_object)); + + cache_point_begin += dim; + } + } + + // Without cache + void search_furthest_in_leaf(typename Tree::Leaf_node_const_handle node, Tag_false) + { + typename Tree::iterator it_node_point = node->begin(), it_node_point_end = node->end(); + // In furthest search mode, the interruptible distance cannot be used to optimize + for (; it_node_point != it_node_point_end; ++it_node_point) + { + this->number_of_items_visited++; + + FT distance_to_query_object = + this->distance_instance.transformed_distance(this->query_object, *it_node_point); + this->queue.insert(std::make_pair(&(*it_node_point), distance_to_query_object)); + } + } + }; // class } // namespace CGAL diff --git a/Spatial_searching/include/CGAL/Kd_tree.h b/Spatial_searching/include/CGAL/Kd_tree.h index 3c2f02a5a25..cdc17b4632a 100644 --- a/Spatial_searching/include/CGAL/Kd_tree.h +++ b/Spatial_searching/include/CGAL/Kd_tree.h @@ -8,7 +8,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Hans Tangelder (), -// : Waqar Khan +// : Waqar Khan , +// Clement Jamin (clement.jamin.pro@gmail.com) #ifndef CGAL_KD_TREE_H #define CGAL_KD_TREE_H @@ -37,7 +38,11 @@ namespace CGAL { //template , class UseExtendedNode = Tag_true > -template , class UseExtendedNode = Tag_true > +template < + class SearchTraits, + class Splitter_=Sliding_midpoint, + class UseExtendedNode = Tag_true, + class EnablePointsCache = Tag_false> class Kd_tree { public: @@ -47,11 +52,11 @@ public: typedef typename Splitter::Container Point_container; typedef typename SearchTraits::FT FT; - typedef Kd_tree_node Node; - typedef Kd_tree_leaf_node Leaf_node; - typedef Kd_tree_internal_node Internal_node; - typedef Kd_tree Tree; - typedef Kd_tree Self; + typedef Kd_tree_node Node; + typedef Kd_tree_leaf_node Leaf_node; + typedef Kd_tree_internal_node Internal_node; + typedef Kd_tree Tree; + typedef Kd_tree Self; typedef Node* Node_handle; typedef const Node* Node_const_handle; @@ -69,6 +74,8 @@ public: typedef typename internal::Get_dimension_tag::Dimension D; + typedef EnablePointsCache Enable_points_cache; + private: SearchTraits traits_; Splitter split; @@ -88,12 +95,18 @@ private: Kd_tree_rectangle* bbox; std::vector pts; + // Store a contiguous copy of the point coordinates + // for faster queries (reduce the number of cache misses) + std::vector points_cache; + // Instead of storing the points in arrays in the Kd_tree_node // we put all the data in a vector in the Kd_tree. // and we only store an iterator range in the Kd_tree_node. // std::vector data; + // Dimension of the points + int dim_; #ifdef CGAL_HAS_THREADS mutable CGAL_MUTEX building_mutex;//mutex used to protect const calls inducing build() @@ -103,7 +116,7 @@ private: // protected copy constructor Kd_tree(const Tree& tree) - : traits_(tree.traits_),built_(tree.built_) + : traits_(tree.traits_),built_(tree.built_),dim_(-1) {}; @@ -258,13 +271,13 @@ public: CGAL_assertion(!removed_); const Point_d& p = *pts.begin(); typename SearchTraits::Construct_cartesian_const_iterator_d ccci=traits_.construct_cartesian_const_iterator_d_object(); - int dim = static_cast(std::distance(ccci(p), ccci(p,0))); + dim_ = static_cast(std::distance(ccci(p), ccci(p,0))); data.reserve(pts.size()); for(unsigned int i = 0; i < pts.size(); i++){ data.push_back(&pts[i]); } - Point_container c(dim, data.begin(), data.end(),traits_); + Point_container c(dim_, data.begin(), data.end(),traits_); bbox = new Kd_tree_rectangle(c.bounding_box()); if (c.size() <= split.bucket_size()){ tree_root = create_leaf_node(c); @@ -275,9 +288,18 @@ public: //Reorder vector for spatial locality std::vector ptstmp; ptstmp.resize(pts.size()); - for (std::size_t i = 0; i < pts.size(); ++i){ + for (std::size_t i = 0; i < pts.size(); ++i) ptstmp[i] = *data[i]; + + // Cache? + if (Enable_points_cache::value) + { + typename SearchTraits::Construct_cartesian_const_iterator_d construct_it = traits_.construct_cartesian_const_iterator_d_object(); + points_cache.reserve(dim_ * pts.size()); + for (std::size_t i = 0; i < pts.size(); ++i) + points_cache.insert(points_cache.end(), construct_it(ptstmp[i]), construct_it(ptstmp[i], 0)); } + for(std::size_t i = 0; i < leaf_nodes.size(); ++i){ std::ptrdiff_t tmp = leaf_nodes[i].begin() - pts.begin(); leaf_nodes[i].data = ptstmp.begin() + tmp; @@ -289,6 +311,12 @@ public: built_ = true; } + // Only correct when build() has been called + int dim() const + { + return dim_; + } + private: //any call to this function is for the moment not threadsafe void const_build() const { @@ -463,7 +491,7 @@ public: const_build(); } Kd_tree_rectangle b(*bbox); - return tree_root->search(it,q,b); + return tree_root->search(it,q,b,begin(),cache_begin(),dim_); } return it; } @@ -479,7 +507,7 @@ public: const_build(); } Kd_tree_rectangle b(*bbox); - return tree_root->search_any_point(q,b); + return tree_root->search_any_point(q,b,begin(),cache_begin(),dim_); } return boost::none; } @@ -538,6 +566,13 @@ public: return *bbox; } + + typename std::vector::const_iterator + cache_begin() const + { + return points_cache.begin(); + } + const_iterator begin() const { diff --git a/Spatial_searching/include/CGAL/Kd_tree_node.h b/Spatial_searching/include/CGAL/Kd_tree_node.h index 83567b17e3b..a80c06ca6e1 100644 --- a/Spatial_searching/include/CGAL/Kd_tree_node.h +++ b/Spatial_searching/include/CGAL/Kd_tree_node.h @@ -19,31 +19,37 @@ #include #include +#include +#include #include namespace CGAL { - template + CGAL_GENERATE_MEMBER_DETECTOR(contains_point_given_as_coordinates); + + template class Kd_tree; - template < class TreeTraits, class Splitter, class UseExtendedNode > + template < class TreeTraits, class Splitter, class UseExtendedNode, class EnablePointsCache > class Kd_tree_node { - friend class Kd_tree; + friend class Kd_tree; - typedef typename Kd_tree::Node_handle Node_handle; - typedef typename Kd_tree::Node_const_handle Node_const_handle; - typedef typename Kd_tree::Internal_node_handle Internal_node_handle; - typedef typename Kd_tree::Internal_node_const_handle Internal_node_const_handle; - typedef typename Kd_tree::Leaf_node_handle Leaf_node_handle; - typedef typename Kd_tree::Leaf_node_const_handle Leaf_node_const_handle; + typedef Kd_tree Kdt; + + typedef typename Kdt::Node_handle Node_handle; + typedef typename Kdt::Node_const_handle Node_const_handle; + typedef typename Kdt::Internal_node_handle Internal_node_handle; + typedef typename Kdt::Internal_node_const_handle Internal_node_const_handle; + typedef typename Kdt::Leaf_node_handle Leaf_node_handle; + typedef typename Kdt::Leaf_node_const_handle Leaf_node_const_handle; typedef typename TreeTraits::Point_d Point_d; typedef typename TreeTraits::FT FT; - typedef typename Kd_tree::Separator Separator; - typedef typename Kd_tree::Point_d_iterator Point_d_iterator; - typedef typename Kd_tree::iterator iterator; - typedef typename Kd_tree::D D; + typedef typename Kdt::Separator Separator; + typedef typename Kdt::Point_d_iterator Point_d_iterator; + typedef typename Kdt::iterator iterator; + typedef typename Kdt::D D; bool leaf; @@ -183,15 +189,19 @@ namespace CGAL { template OutputIterator search(OutputIterator it, const FuzzyQueryItem& q, - Kd_tree_rectangle& b) const + Kd_tree_rectangle& b, + typename Kdt::const_iterator tree_points_begin, + typename std::vector::const_iterator cache_begin, + int dim) const { if (is_leaf()) { Leaf_node_const_handle node = static_cast(this); - if (node->size()>0) - for (iterator i=node->begin(); i != node->end(); i++) - if (q.contains(*i)) - {*it++=*i;} + if (node->size() > 0) + { + typename internal::Has_points_cache::type::value>::type dummy; + it = search_in_leaf(node, q, tree_points_begin, cache_begin, dim, it, dummy); + } } else { Internal_node_const_handle node = @@ -204,12 +214,12 @@ namespace CGAL { it=node->lower()->tree_items(it); else if (q.inner_range_intersects(b)) - it=node->lower()->search(it,q,b); + it=node->lower()->search(it,q,b,tree_points_begin,cache_begin,dim); if (q.outer_range_contains(b_upper)) it=node->upper()->tree_items(it); else if (q.inner_range_intersects(b_upper)) - it=node->upper()->search(it,q,b_upper); + it=node->upper()->search(it,q,b_upper,tree_points_begin,cache_begin,dim); }; return it; } @@ -218,16 +228,20 @@ namespace CGAL { template boost::optional search_any_point(const FuzzyQueryItem& q, - Kd_tree_rectangle& b) const + Kd_tree_rectangle& b, + typename Kdt::const_iterator tree_points_begin, + typename std::vector::const_iterator cache_begin, + int dim) const { boost::optional result = boost::none; if (is_leaf()) { Leaf_node_const_handle node = static_cast(this); - if (node->size()>0) - for (iterator i=node->begin(); i != node->end(); i++) - if (q.contains(*i)) - { result = *i; break; } + if (node->size()>0) + { + typename internal::Has_points_cache::type::value>::type dummy; + result = search_any_point_in_leaf(node, q, tree_points_begin, cache_begin, dim, dummy); + } } else { Internal_node_const_handle node = @@ -237,26 +251,138 @@ namespace CGAL { node->split_bbox(b, b_upper); if (q.inner_range_intersects(b)) { - result = node->lower()->search_any_point(q,b); + result = node->lower()->search_any_point(q,b,tree_points_begin,cache_begin,dim); if(result) return result; } if (q.inner_range_intersects(b_upper)) - result = node->upper()->search_any_point(q,b_upper); + result = node->upper()->search_any_point(q,b_upper,tree_points_begin,cache_begin,dim); } return result; } + private: + + // If contains_point_given_as_coordinates does not exist in `FuzzyQueryItem` + template + bool contains( + const FuzzyQueryItem& q, + Point_d const& p, + typename std::vector::const_iterator /*it_coord_begin*/, + typename std::vector::const_iterator /*it_coord_end*/, + Tag_false /*has_contains_point_given_as_coordinates*/) const + { + return q.contains(p); + } + // ... or if it exists + template + bool contains( + const FuzzyQueryItem& q, + Point_d const& /*p*/, + typename std::vector::const_iterator it_coord_begin, + typename std::vector::const_iterator it_coord_end, + Tag_true /*has_contains_point_given_as_coordinates*/) const + { + return q.contains_point_given_as_coordinates(it_coord_begin, it_coord_end); + } + + // With cache + template + OutputIterator search_in_leaf( + Leaf_node_const_handle node, + const FuzzyQueryItem &q, + typename Kdt::const_iterator tree_points_begin, + typename std::vector::const_iterator cache_begin, + int dim, + OutputIterator oit, + Tag_true /*has_points_cache*/) const + { + typename Kdt::iterator it_node_point = node->begin(), it_node_point_end = node->end(); + typename std::vector::const_iterator cache_point_it = cache_begin + dim*(it_node_point - tree_points_begin); + for (; it_node_point != it_node_point_end; ++it_node_point, cache_point_it += dim) + { + Boolean_tag::value> dummy; + if (contains(q, *it_node_point, cache_point_it, cache_point_it + dim, dummy)) + *oit++ = *it_node_point; + } + return oit; + } + + // Without cache + template + OutputIterator search_in_leaf( + Leaf_node_const_handle node, + const FuzzyQueryItem &q, + typename Kdt::const_iterator /*tree_points_begin*/, + typename std::vector::const_iterator /*cache_begin*/, + int /*dim*/, + OutputIterator oit, + Tag_false /*has_points_cache*/) const + { + for (iterator i = node->begin(); i != node->end(); ++i) + { + if (q.contains(*i)) + *oit++ = *i; + } + return oit; + } + + // With cache + template + boost::optional search_any_point_in_leaf( + Leaf_node_const_handle node, + const FuzzyQueryItem &q, + typename Kdt::const_iterator tree_points_begin, + typename std::vector::const_iterator cache_begin, + int dim, + Tag_true /*has_points_cache*/) const + { + boost::optional result = boost::none; + typename Kdt::iterator it_node_point = node->begin(), it_node_point_end = node->end(); + typename std::vector::const_iterator cache_point_it = cache_begin + dim*(it_node_point - tree_points_begin); + for (; it_node_point != it_node_point_end; ++it_node_point, cache_point_it += dim) + { + Boolean_tag::value> dummy; + if (contains(q, *it_node_point, cache_point_it, cache_point_it + dim, dummy)) + { + result = *it_node_point; + break; + } + } + return result; + } + + // Without cache + template + boost::optional search_any_point_in_leaf( + Leaf_node_const_handle node, + const FuzzyQueryItem &q, + typename Kdt::const_iterator /*tree_points_begin*/, + typename std::vector::const_iterator /*cache_begin*/, + int /*dim*/, + Tag_false /*has_points_cache*/) const + { + boost::optional result = boost::none; + for (iterator i = node->begin(); i != node->end(); ++i) + { + if (q.contains(*i)) + { + result = *i; + break; + } + } + return result; + } }; - template < class TreeTraits, class Splitter, class UseExtendedNode > - class Kd_tree_leaf_node : public Kd_tree_node< TreeTraits, Splitter, UseExtendedNode >{ + template < class TreeTraits, class Splitter, class UseExtendedNode, class EnablePointsCache > + class Kd_tree_leaf_node : public Kd_tree_node< TreeTraits, Splitter, UseExtendedNode, EnablePointsCache >{ - friend class Kd_tree; + friend class Kd_tree; - typedef typename Kd_tree::iterator iterator; - typedef Kd_tree_node< TreeTraits, Splitter, UseExtendedNode> Base; + typedef typename Kd_tree::iterator iterator; + typedef Kd_tree_node< TreeTraits, Splitter, UseExtendedNode, EnablePointsCache> Base; typedef typename TreeTraits::Point_d Point_d; private: @@ -315,18 +441,20 @@ namespace CGAL { - template < class TreeTraits, class Splitter, class UseExtendedNode> - class Kd_tree_internal_node : public Kd_tree_node< TreeTraits, Splitter, UseExtendedNode >{ + template < class TreeTraits, class Splitter, class UseExtendedNode, class EnablePointsCache> + class Kd_tree_internal_node : public Kd_tree_node< TreeTraits, Splitter, UseExtendedNode, EnablePointsCache >{ - friend class Kd_tree; + friend class Kd_tree; - typedef Kd_tree_node< TreeTraits, Splitter, UseExtendedNode> Base; - typedef typename Kd_tree::Node_handle Node_handle; - typedef typename Kd_tree::Node_const_handle Node_const_handle; + typedef Kd_tree Kdt; + + typedef Kd_tree_node< TreeTraits, Splitter, UseExtendedNode, EnablePointsCache> Base; + typedef typename Kdt::Node_handle Node_handle; + typedef typename Kdt::Node_const_handle Node_const_handle; typedef typename TreeTraits::FT FT; - typedef typename Kd_tree::Separator Separator; - typedef typename Kd_tree::D D; + typedef typename Kdt::Separator Separator; + typedef typename Kdt::D D; private: @@ -463,18 +591,21 @@ namespace CGAL { } };//internal node - template < class TreeTraits, class Splitter> - class Kd_tree_internal_node : public Kd_tree_node< TreeTraits, Splitter, Tag_false >{ + template < class TreeTraits, class Splitter, class EnablePointsCache> + class Kd_tree_internal_node + : public Kd_tree_node< TreeTraits, Splitter, Tag_false, EnablePointsCache > + { + friend class Kd_tree; + + typedef Kd_tree Kdt; - friend class Kd_tree; - - typedef Kd_tree_node< TreeTraits, Splitter, Tag_false> Base; - typedef typename Kd_tree::Node_handle Node_handle; - typedef typename Kd_tree::Node_const_handle Node_const_handle; + typedef Kd_tree_node< TreeTraits, Splitter, Tag_false, EnablePointsCache> Base; + typedef typename Kdt::Node_handle Node_handle; + typedef typename Kdt::Node_const_handle Node_const_handle; typedef typename TreeTraits::FT FT; - typedef typename Kd_tree::Separator Separator; - typedef typename Kd_tree::D D; + typedef typename Kdt::Separator Separator; + typedef typename Kdt::D D; private: diff --git a/Spatial_searching/include/CGAL/Orthogonal_incremental_neighbor_search.h b/Spatial_searching/include/CGAL/Orthogonal_incremental_neighbor_search.h index c90d16c50ff..6710af8c3d7 100644 --- a/Spatial_searching/include/CGAL/Orthogonal_incremental_neighbor_search.h +++ b/Spatial_searching/include/CGAL/Orthogonal_incremental_neighbor_search.h @@ -9,6 +9,7 @@ // // // Author(s) : Hans Tangelder () +// Clement Jamin (clement.jamin.pro@gmail.com) #ifndef CGAL_ORTHOGONAL_INCREMENTAL_NEIGHBOR_SEARCH #define CGAL_ORTHOGONAL_INCREMENTAL_NEIGHBOR_SEARCH @@ -16,21 +17,23 @@ #include #include +#include +#include +#include +#include #include #include #include #include -#include -#include -#include +#include // for std::distance namespace CGAL { template ::type, class Splitter_ = Sliding_midpoint, - class Tree_= Kd_tree > + class Tree_= Kd_tree > class Orthogonal_incremental_neighbor_search { public: @@ -72,7 +75,8 @@ namespace CGAL { Distance_vector dists; - Distance Orthogonal_distance_instance; + Distance orthogonal_distance_instance; + internal::Distance_helper m_distance_helper; FT multiplication_factor; @@ -84,6 +88,8 @@ namespace CGAL { FT rd; + int m_dim; + Tree const& m_tree; class Priority_higher { public: @@ -139,27 +145,30 @@ namespace CGAL { FT Eps=FT(0.0), bool search_nearest=true) : traits(tree.traits()),number_of_neighbours_computed(0), number_of_internal_nodes_visited(0), number_of_leaf_nodes_visited(0), number_of_items_visited(0), - Orthogonal_distance_instance(tr), multiplication_factor(Orthogonal_distance_instance.transformed_distance(FT(1.0)+Eps)), - query_point(q), search_nearest_neighbour(search_nearest), + orthogonal_distance_instance(tr), + m_distance_helper(orthogonal_distance_instance, traits), + multiplication_factor(orthogonal_distance_instance.transformed_distance(FT(1.0)+Eps)), + query_point(q), search_nearest_neighbour(search_nearest), + m_tree(tree), PriorityQueue(Priority_higher(search_nearest)), Item_PriorityQueue(Distance_smaller(search_nearest)), reference_count(1) { - if (tree.empty()) return; + if (m_tree.empty()) return; typename SearchTraits::Construct_cartesian_const_iterator_d ccci=traits.construct_cartesian_const_iterator_d_object(); - int dim = static_cast(std::distance(ccci(q), ccci(q,0))); + m_dim = static_cast(std::distance(ccci(q), ccci(q,0))); - dists.resize(dim); - for(int i=0 ; ibegin(), it_node_point_end = node->end(); + typename std::vector::const_iterator cache_point_begin = m_tree.cache_begin() + m_dim*(it_node_point - m_tree.begin()); + + for (; it_node_point != it_node_point_end; ++it_node_point) + { + number_of_items_visited++; + FT distance_to_query_point = + m_distance_helper.transformed_distance_from_coordinates( + query_point, *it_node_point, cache_point_begin, cache_point_begin + m_dim); + + Point_with_transformed_distance *NN_Candidate = + new Point_with_transformed_distance(*it_node_point, distance_to_query_point); + Item_PriorityQueue.push(NN_Candidate); + + cache_point_begin += m_dim; + } + // old top of PriorityQueue has been processed, + // hence update rd + + bool next_neighbour_found; + if (!(PriorityQueue.empty())) + { + rd = CGAL::cpp11::get<1>(*PriorityQueue.top()); + next_neighbour_found = (search_furthest ? + multiplication_factor*rd < Item_PriorityQueue.top()->second + : multiplication_factor*rd > Item_PriorityQueue.top()->second); + } + else // priority queue empty => last neighbour found + { + next_neighbour_found = true; + } + + number_of_neighbours_computed++; + return next_neighbour_found; + } + + // Without cache + bool search_in_leaf(typename Tree::Leaf_node_const_handle node, Tag_false, bool search_furthest) + { + typename Tree::iterator it_node_point = node->begin(), it_node_point_end = node->end(); + + for (; it_node_point != it_node_point_end; ++it_node_point) + { + number_of_items_visited++; + FT distance_to_query_point= + orthogonal_distance_instance.transformed_distance(query_point, *it_node_point); + + Point_with_transformed_distance *NN_Candidate = + new Point_with_transformed_distance(*it_node_point, distance_to_query_point); + Item_PriorityQueue.push(NN_Candidate); + } + // old top of PriorityQueue has been processed, + // hence update rd + + bool next_neighbour_found; + if (!(PriorityQueue.empty())) + { + rd = CGAL::cpp11::get<1>(*PriorityQueue.top()); + next_neighbour_found = (search_furthest ? + multiplication_factor*rd < Item_PriorityQueue.top()->second + : multiplication_factor*rd > Item_PriorityQueue.top()->second); + } + else // priority queue empty => last neighbour found + { + next_neighbour_found=true; + } + + number_of_neighbours_computed++; + return next_neighbour_found; + } + + void Compute_the_next_nearest_neighbour() { @@ -283,7 +369,7 @@ namespace CGAL { FT diff2 = val - node->lower_high_value(); if (diff1 + diff2 < FT(0.0)) { new_rd= - Orthogonal_distance_instance.new_distance(copy_rd,dst,diff1,new_cut_dim); + orthogonal_distance_instance.new_distance(copy_rd,dst,diff1,new_cut_dim); CGAL_assertion(new_rd >= copy_rd); dists[new_cut_dim] = diff1; @@ -295,7 +381,7 @@ namespace CGAL { } else { // compute new distance - new_rd=Orthogonal_distance_instance.new_distance(copy_rd,dst,diff2,new_cut_dim); + new_rd=orthogonal_distance_instance.new_distance(copy_rd,dst,diff2,new_cut_dim); CGAL_assertion(new_rd >= copy_rd); dists[new_cut_dim] = diff2; Node_with_distance *Lower_Child = @@ -309,31 +395,10 @@ namespace CGAL { typename Tree::Leaf_node_const_handle node = static_cast(N); number_of_leaf_nodes_visited++; - if (node->size() > 0) { - for (typename Tree::iterator it=node->begin(); it != node->end(); it++) { - number_of_items_visited++; - FT distance_to_query_point= - Orthogonal_distance_instance.transformed_distance(query_point,*it); - Point_with_transformed_distance *NN_Candidate= - new Point_with_transformed_distance(*it,distance_to_query_point); - Item_PriorityQueue.push(NN_Candidate); - } - // old top of PriorityQueue has been processed, - // hence update rd - - if (!(PriorityQueue.empty())) { - rd = std::get<1>(*PriorityQueue.top()); - next_neighbour_found = - (multiplication_factor*rd > - Item_PriorityQueue.top()->second); - } - else // priority queue empty => last neighbour found - { - next_neighbour_found=true; - } - - number_of_neighbours_computed++; - } + if (node->size() > 0) { + typename internal::Has_points_cache::type::value>::type dummy; + next_neighbour_found = search_in_leaf(node, dummy, false); + } } // next_neighbour_found or priority queue is empty // in the latter case also the item priority quee is empty } @@ -370,7 +435,7 @@ namespace CGAL { if (diff1 + diff2 < FT(0.0)) { diff1 = val - node->upper_high_value(); new_rd= - Orthogonal_distance_instance.new_distance(copy_rd,dst,diff1,new_cut_dim); + orthogonal_distance_instance.new_distance(copy_rd,dst,diff1,new_cut_dim); Node_with_distance *Lower_Child = new Node_with_distance(node->lower(), copy_rd, dists); PriorityQueue.push(Lower_Child); @@ -381,7 +446,7 @@ namespace CGAL { } else { // compute new distance diff2 = val - node->lower_low_value(); - new_rd=Orthogonal_distance_instance.new_distance(copy_rd,dst,diff2,new_cut_dim); + new_rd=orthogonal_distance_instance.new_distance(copy_rd,dst,diff2,new_cut_dim); Node_with_distance *Upper_Child = new Node_with_distance(node->upper(), copy_rd, dists); PriorityQueue.push(Upper_Child); @@ -395,30 +460,9 @@ namespace CGAL { static_cast(N); number_of_leaf_nodes_visited++; if (node->size() > 0) { - for (typename Tree::iterator it=node->begin(); it != node->end(); it++) { - number_of_items_visited++; - FT distance_to_query_point= - Orthogonal_distance_instance.transformed_distance(query_point,*it); - Point_with_transformed_distance *NN_Candidate= - new Point_with_transformed_distance(*it,distance_to_query_point); - Item_PriorityQueue.push(NN_Candidate); - } - // old top of PriorityQueue has been processed, - // hence update rd - - if (!(PriorityQueue.empty())) { - rd = std::get<1>(*PriorityQueue.top()); - next_neighbour_found = - (multiplication_factor*rd < - Item_PriorityQueue.top()->second); - } - else // priority queue empty => last neighbour found - { - next_neighbour_found=true; - } - - number_of_neighbours_computed++; - } + typename internal::Has_points_cache::type::value>::type dummy; + next_neighbour_found = search_in_leaf(node, dummy, true); + } } // next_neighbour_found or priority queue is empty // in the latter case also the item priority quee is empty } diff --git a/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h b/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h index a2d34c20392..5d5ea80f62e 100644 --- a/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h +++ b/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h @@ -8,7 +8,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Gael Guennebaud (gael.guennebaud@inria.fr), Hans Tangelder () +// Author(s) : Gael Guennebaud (gael.guennebaud@inria.fr), +// Hans Tangelder (), +// Clement Jamin (clement.jamin.pro@gmail.com) #ifndef CGAL_ORTHOGONAL_K_NEIGHBOR_SEARCH_H #define CGAL_ORTHOGONAL_K_NEIGHBOR_SEARCH_H @@ -18,36 +20,49 @@ #include #include +#include + +#include // for std::distance namespace CGAL { template ::type, class Splitter= Sliding_midpoint , - class Tree= Kd_tree > -class Orthogonal_k_neighbor_search: public internal::K_neighbor_search { - typedef internal::K_neighbor_search Base; + class Tree= Kd_tree > +class Orthogonal_k_neighbor_search: public internal::K_neighbor_search +{ + typedef internal::K_neighbor_search Base; + typedef typename Tree::Point_d Point; - typename SearchTraits::Cartesian_const_iterator_d query_object_it; - - std::vector dists; public: typedef typename Base::FT FT; +private: + typename SearchTraits::Cartesian_const_iterator_d query_object_it; + + internal::Distance_helper m_distance_helper; + std::vector dists; + int m_dim; + Tree const& m_tree; + +public: Orthogonal_k_neighbor_search(const Tree& tree, const typename Base::Query_item& q, unsigned int k=1, FT Eps=FT(0.0), bool Search_nearest=true, const Distance& d=Distance(),bool sorted=true) - : Base(q,k,Eps,Search_nearest,d) + : Base(q,k,Eps,Search_nearest,d), + m_distance_helper(this->distance_instance, tree.traits()), + m_tree(tree) { if (tree.empty()) return; typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=tree.traits().construct_cartesian_const_iterator_d_object(); query_object_it = construct_it(this->query_object); - int dim = static_cast(std::distance(query_object_it, construct_it(this->query_object,0))); + m_dim = static_cast(std::distance(query_object_it, construct_it(this->query_object,0))); - dists.resize(dim); - for(int i=0;iqueue.sort(); } private: + // With cache + void search_nearest_in_leaf(typename Tree::Leaf_node_const_handle node, Tag_true) + { + typename Tree::iterator it_node_point = node->begin(), it_node_point_end = node->end(); + typename std::vector::const_iterator cache_point_begin = m_tree.cache_begin() + m_dim*(it_node_point - m_tree.begin()); + // As long as the queue is not full, the node is just inserted + for (; !this->queue.full() && it_node_point != it_node_point_end; ++it_node_point) + { + this->number_of_items_visited++; + + FT distance_to_query_object = + m_distance_helper.transformed_distance_from_coordinates( + this->query_object, *it_node_point, cache_point_begin, cache_point_begin + m_dim); + this->queue.insert(std::make_pair(&(*it_node_point), distance_to_query_object)); + + cache_point_begin += m_dim; + } + // Now that the queue is full, we can gain time by keeping track + // of the current worst distance to interrupt the distance computation earlier + FT worst_dist = this->queue.top().second; + for (; it_node_point != it_node_point_end; ++it_node_point) + { + this->number_of_items_visited++; + + FT distance_to_query_object = + m_distance_helper.interruptible_transformed_distance( + this->query_object, *it_node_point, cache_point_begin, cache_point_begin + m_dim, worst_dist); + + if (distance_to_query_object < worst_dist) + { + this->queue.insert(std::make_pair(&(*it_node_point), distance_to_query_object)); + worst_dist = this->queue.top().second; + } + + cache_point_begin += m_dim; + } + } + + // Without cache + void search_nearest_in_leaf(typename Tree::Leaf_node_const_handle node, Tag_false) + { + typename Tree::iterator it_node_point = node->begin(), it_node_point_end = node->end(); + // As long as the queue is not full, the node is just inserted + for (; !this->queue.full() && it_node_point != it_node_point_end; ++it_node_point) + { + this->number_of_items_visited++; + + FT distance_to_query_object = + this->distance_instance.transformed_distance(this->query_object, *it_node_point); + this->queue.insert(std::make_pair(&(*it_node_point), distance_to_query_object)); + } + // Now that the queue is full, we can gain time by keeping track + // of the current worst distance to interrupt the distance computation earlier + FT worst_dist = this->queue.top().second; + for (; it_node_point != it_node_point_end; ++it_node_point) + { + this->number_of_items_visited++; + + FT distance_to_query_object = + m_distance_helper.interruptible_transformed_distance( + this->query_object, *it_node_point, worst_dist); + + if (distance_to_query_object < worst_dist) + { + this->queue.insert(std::make_pair(&(*it_node_point), distance_to_query_object)); + worst_dist = this->queue.top().second; + } + } + } + void compute_nearest_neighbors_orthogonally(typename Base::Node_const_handle N, FT rd) { - if (!(N->is_leaf())) - { - typename Tree::Internal_node_const_handle node = - static_cast(N); - this->number_of_internal_nodes_visited++; - int new_cut_dim=node->cutting_dimension(); - typename Base::Node_const_handle bestChild, otherChild; - FT new_off; - FT val = *(query_object_it + new_cut_dim); - FT diff1 = val - node->upper_low_value(); - FT diff2 = val - node->lower_high_value(); - if ( (diff1 + diff2 < FT(0.0)) ) - { - new_off = diff1; - bestChild = node->lower(); - otherChild = node->upper(); - } - else // compute new distance - { - new_off= diff2; - bestChild = node->upper(); - otherChild = node->lower(); - } - compute_nearest_neighbors_orthogonally(bestChild, rd); - FT dst=dists[new_cut_dim]; - FT new_rd = this->distance_instance.new_distance(rd,dst,new_off,new_cut_dim); - dists[new_cut_dim]=new_off; - if (this->branch_nearest(new_rd)) - { - compute_nearest_neighbors_orthogonally(otherChild, new_rd); - } - dists[new_cut_dim]=dst; - } - else + if (N->is_leaf()) { // n is a leaf typename Tree::Leaf_node_const_handle node = static_cast(N); this->number_of_leaf_nodes_visited++; - bool full = this->queue.full(); - FT worst_dist = this->queue.top().second; if (node->size() > 0) { - for (typename Tree::iterator it=node->begin(); it != node->end(); it++) - { - this->number_of_items_visited++; - FT distance_to_query_object= - this->distance_instance.transformed_distance(this->query_object,*it); - - if(!full || distance_to_query_object < worst_dist) - this->queue.insert(std::make_pair(&(*it),distance_to_query_object)); - } + typename internal::Has_points_cache::type::value>::type dummy; + search_nearest_in_leaf(node, dummy); } } + else + { + typename Tree::Internal_node_const_handle node = + static_cast(N); + this->number_of_internal_nodes_visited++; + int new_cut_dim = node->cutting_dimension(); + typename Base::Node_const_handle bestChild, otherChild; + FT new_off; + FT val = *(query_object_it + new_cut_dim); + FT diff1 = val - node->upper_low_value(); + FT diff2 = val - node->lower_high_value(); + if ((diff1 + diff2 < FT(0.0))) + { + new_off = diff1; + bestChild = node->lower(); + otherChild = node->upper(); + } + else // compute new distance + { + new_off = diff2; + bestChild = node->upper(); + otherChild = node->lower(); + } + compute_nearest_neighbors_orthogonally(bestChild, rd); + FT dst = dists[new_cut_dim]; + FT new_rd = this->distance_instance.new_distance(rd, dst, new_off, new_cut_dim); + dists[new_cut_dim] = new_off; + if (this->branch_nearest(new_rd)) + { + compute_nearest_neighbors_orthogonally(otherChild, new_rd); + } + dists[new_cut_dim] = dst; + } } - void compute_furthest_neighbors_orthogonally(typename Base::Node_const_handle N, FT rd) + // With cache + void search_furthest_in_leaf(typename Tree::Leaf_node_const_handle node, Tag_true) { - if (!(N->is_leaf())) + typename Tree::iterator it_node_point = node->begin(), it_node_point_end = node->end(); + typename std::vector::const_iterator cache_point_begin = m_tree.cache_begin() + m_dim*(it_node_point - m_tree.begin()); + // In furthest search mode, the interruptible distance cannot be used to optimize + for (; it_node_point != it_node_point_end; ++it_node_point) + { + this->number_of_items_visited++; + + FT distance_to_query_object = + m_distance_helper.transformed_distance_from_coordinates( + this->query_object, *it_node_point, cache_point_begin, cache_point_begin + m_dim); + this->queue.insert(std::make_pair(&(*it_node_point), distance_to_query_object)); + + cache_point_begin += m_dim; + } + } + + // Without cache + void search_furthest_in_leaf(typename Tree::Leaf_node_const_handle node, Tag_false) + { + typename Tree::iterator it_node_point = node->begin(), it_node_point_end = node->end(); + // In furthest search mode, the interruptible distance cannot be used to optimize + for (; it_node_point != it_node_point_end; ++it_node_point) + { + this->number_of_items_visited++; + + FT distance_to_query_object = + this->distance_instance.transformed_distance(this->query_object, *it_node_point); + this->queue.insert(std::make_pair(&(*it_node_point), distance_to_query_object)); + } + } + + void compute_furthest_neighbors_orthogonally(typename Base::Node_const_handle N, FT rd) + { + if (N->is_leaf()) + { + // n is a leaf + typename Tree::Leaf_node_const_handle node = + static_cast(N); + this->number_of_leaf_nodes_visited++; + if (node->size() > 0) + { + typename internal::Has_points_cache::type::value>::type dummy; + search_furthest_in_leaf(node, dummy); + } + } + else { typename Tree::Internal_node_const_handle node = static_cast(N); @@ -163,24 +281,7 @@ private: compute_furthest_neighbors_orthogonally(otherChild, new_rd); dists[new_cut_dim]=dst; } - else - { - // n is a leaf - typename Tree::Leaf_node_const_handle node = - static_cast(N); - this->number_of_leaf_nodes_visited++; - if (node->size() > 0) - { - for (typename Tree::iterator it=node->begin(); it != node->end(); it++) - { - this->number_of_items_visited++; - FT distance_to_query_object= - this->distance_instance.transformed_distance(this->query_object,*it); - this->queue.insert(std::make_pair(&(*it),distance_to_query_object)); - } - } - } - } + } }; // class diff --git a/Spatial_searching/include/CGAL/Search_traits_adapter.h b/Spatial_searching/include/CGAL/Search_traits_adapter.h index fb199aa4c5e..d7ac0549565 100644 --- a/Spatial_searching/include/CGAL/Search_traits_adapter.h +++ b/Spatial_searching/include/CGAL/Search_traits_adapter.h @@ -269,7 +269,6 @@ public: template class Distance_adapter : public Base_distance { PointPropertyMap ppmap; - typedef typename Base_distance::FT FT; public: @@ -278,7 +277,8 @@ public: ):Base_distance(distance),ppmap(ppmap_){} using Base_distance::transformed_distance; - + + typedef typename Base_distance::FT FT; typedef Point_with_info Point_d; typedef typename Base_distance::Query_item Query_item; diff --git a/Spatial_searching/include/CGAL/internal/Search_helpers.h b/Spatial_searching/include/CGAL/internal/Search_helpers.h new file mode 100644 index 00000000000..d63b2deedb7 --- /dev/null +++ b/Spatial_searching/include/CGAL/internal/Search_helpers.h @@ -0,0 +1,240 @@ +// Copyright (c) 2002,2011 Utrecht University (The Netherlands). +// 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) : Clement Jamin (clement.jamin.pro@gmail.com) + +#ifndef CGAL_INTERNAL_SEARCH_HELPERS_H +#define CGAL_INTERNAL_SEARCH_HELPERS_H + +#include + +#include + +#include + +namespace CGAL { +namespace internal { + +// Helper struct to know at compile-time if there is a cache of the points +// stored in the tree +template +struct Has_points_cache; + +template +struct Has_points_cache +{ + typedef typename Tree::Enable_points_cache type; + static const bool value = type::value; +}; + +template +struct Has_points_cache +{ + typedef Tag_false type; + static const bool value = false; +}; + +CGAL_GENERATE_MEMBER_DETECTOR(transformed_distance_from_coordinates); +CGAL_GENERATE_MEMBER_DETECTOR(interruptible_transformed_distance); +BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_Enable_points_cache, Enable_points_cache, false) + + + +// If transformed_distance_from_coordinates does not exist in `Distance` +template +class Transformed_distance_from_coordinates +{ + typedef typename Distance::FT FT; + typedef typename Distance::Point_d Point; + typedef typename Distance::Query_item Query_item; + +public: + Transformed_distance_from_coordinates(Distance const& distance) + : m_distance(distance) + {} + + FT operator() ( + const Query_item& q, + Point const& p, + typename std::vector::const_iterator /*it_coord_begin*/, + typename std::vector::const_iterator /*it_coord_end*/) const + { + return m_distance.transformed_distance(q, p); + } + +private: + Distance const& m_distance; +}; +// ... or if it exists +template +class Transformed_distance_from_coordinates +{ + typedef typename Distance::FT FT; + typedef typename Distance::Point_d Point; + typedef typename Distance::Query_item Query_item; + +public: + Transformed_distance_from_coordinates(Distance const& distance) + : m_distance(distance) + {} + + FT operator() ( + const Query_item& q, + Point const& /*p*/, + typename std::vector::const_iterator it_coord_begin, + typename std::vector::const_iterator it_coord_end) const + { + return m_distance.transformed_distance_from_coordinates(q, it_coord_begin, it_coord_end); + } + +private: + Distance const& m_distance; +}; + +// If interruptible_transformed_distance does not exist in `Distance` +template +class Interruptible_transformed_distance +{ + typedef typename Distance::FT FT; + typedef typename Distance::Point_d Point; + typedef typename Distance::Query_item Query_item; + +public: + typedef Transformed_distance_from_coordinates::value> Tdfc; + + Interruptible_transformed_distance( + SearchTraits const&, Distance const& distance, Tdfc const& tdfc) + : m_distance(distance), m_ref_to_tdfc(tdfc) + {} + + FT operator() ( + const Query_item& q, + Point const& p, + FT) const + { + return m_distance.transformed_distance(q, p); + } + + FT operator() ( + const Query_item& q, + Point const& p, + typename std::vector::const_iterator it_coord_begin, + typename std::vector::const_iterator it_coord_end, + FT) const + { + return m_ref_to_tdfc(q, p, it_coord_begin, it_coord_end); + } + +private: + Distance const& m_distance; + Tdfc const& m_ref_to_tdfc; +}; +// ... or if it exists +template +class Interruptible_transformed_distance +{ + typedef typename Distance::FT FT; + typedef typename Distance::Point_d Point; + typedef typename Distance::Query_item Query_item; + +public: + typedef Transformed_distance_from_coordinates::value> Tdfc; + + Interruptible_transformed_distance( + SearchTraits const& traits, Distance const& distance, Tdfc const&) + : m_traits(traits), m_distance(distance) + {} + + FT operator() ( + const Query_item& q, + Point const& p, + FT stop_if_geq_to_this) const + { + typename SearchTraits::Construct_cartesian_const_iterator_d construct_it = + m_traits.construct_cartesian_const_iterator_d_object(); + return m_distance.interruptible_transformed_distance( + q, construct_it(p), construct_it(p, 0), stop_if_geq_to_this); + } + + FT operator() ( + const Query_item& q, + Point const& /*p*/, + typename std::vector::const_iterator it_coord_begin, + typename std::vector::const_iterator it_coord_end, + FT stop_if_geq_to_this) const + { + return m_distance.interruptible_transformed_distance( + q, it_coord_begin, it_coord_end, stop_if_geq_to_this); + } + +private: + SearchTraits const& m_traits; + Distance const& m_distance; +}; + + + +template +class Distance_helper +{ + typedef typename Distance::FT FT; + typedef typename Distance::Point_d Point; + typedef typename Distance::Query_item Query_item; + +public: + + Distance_helper(Distance const& distance, SearchTraits const& traits) + : m_distance(distance), m_tdfc(m_distance), m_itd(traits, distance, m_tdfc) + {} + + FT + transformed_distance_from_coordinates( + const Query_item& q, + Point const& p, + typename std::vector::const_iterator it_coord_begin, + typename std::vector::const_iterator it_coord_end) + { + return m_tdfc(q, p, it_coord_begin, it_coord_end); + } + + FT + interruptible_transformed_distance( + const Query_item& q, + Point const& p, + FT stop_if_geq_to_this) + { + return m_itd(q, p, stop_if_geq_to_this); + } + + FT + interruptible_transformed_distance( + const Query_item& q, + Point const& p, + typename std::vector::const_iterator it_coord_begin, + typename std::vector::const_iterator it_coord_end, + FT stop_if_geq_to_this) + { + return m_itd(q, p, it_coord_begin, it_coord_end, stop_if_geq_to_this); + } + +private: + Distance const& m_distance; + Transformed_distance_from_coordinates::value> m_tdfc; + Interruptible_transformed_distance::value> m_itd; +}; // Distance_helper + + +}} // namespace CGAL::internal + +#endif // CGAL_INTERNAL_SEARCH_HELPERSS_H diff --git a/Spatial_searching/test/Spatial_searching/Distance.h b/Spatial_searching/test/Spatial_searching/Distance.h index b5cf20adfff..f8c02b846e5 100644 --- a/Spatial_searching/test/Spatial_searching/Distance.h +++ b/Spatial_searching/test/Spatial_searching/Distance.h @@ -1,4 +1,5 @@ struct Distance { + typedef Point Point_d; typedef Point Query_item; typedef double FT; diff --git a/Stream_support/examples/Stream_support/Linestring_WKT.cpp b/Stream_support/examples/Stream_support/Linestring_WKT.cpp index 5c95562620a..ebc863f9ee3 100644 --- a/Stream_support/examples/Stream_support/Linestring_WKT.cpp +++ b/Stream_support/examples/Stream_support/Linestring_WKT.cpp @@ -6,7 +6,6 @@ #include #include -#include //must be included before WKT for some reason #include #include #include @@ -27,7 +26,7 @@ int main(int argc, char* argv[]) CGAL::read_linestring_WKT(is, ls); is.close(); } - BOOST_FOREACH(Point p, ls) + for(Point p : ls) std::cout< #include -#include - #include //typedef CGAL::Simple_cartesian Kernel; @@ -26,7 +24,7 @@ int main(int argc, char* argv[]) std::ifstream is((argc>1)?argv[1]:"data/multipoint.wkt"); MultiPoint mp; CGAL::read_multi_point_WKT(is, mp); - BOOST_FOREACH(const Point& p, mp) + for(const Point& p : mp) { std::cout< #include -#include - #include #include @@ -35,7 +33,7 @@ int main(int argc, char* argv[]) if(!p.outer_boundary().is_empty()) polys.push_back(p); }while(is.good() && !is.eof()); - BOOST_FOREACH(Polygon p, polys) + for(Polygon p : polys) std::cout<2)?argv[2]:"data/multipolygon.wkt"); MultiPolygon mp; CGAL::read_multi_polygon_WKT(is, mp); - BOOST_FOREACH(Polygon p, mp) + for(Polygon p : mp) std::cout< #include -#include - #include //typedef CGAL::Simple_cartesian Kernel; @@ -35,12 +33,12 @@ int main(int argc, char* argv[]) MultiPolygon polygons; CGAL::read_WKT(is, points,polylines,polygons); - BOOST_FOREACH(Point p, points) + for(Point p : points) std::cout< m_data; + std::array m_data; public: @@ -159,21 +159,21 @@ public: /*! returns the array with rgba values. */ - const cpp11::array& to_rgba() const { return m_data; } + const std::array& to_rgba() const { return m_data; } /*! returns the array with rgb values. */ - const cpp11::array& to_rgb() const + const std::array& to_rgb() const { - return reinterpret_cast&>(m_data); + return reinterpret_cast&>(m_data); } /*! computes the hsv (hue, saturation, value) values and returns an array representing them as float values between 0 and 1. */ - cpp11::array to_hsv() const + std::array to_hsv() const { double r = (double)(m_data[0]) / 255.; double g = (double)(m_data[1]) / 255.; diff --git a/Stream_support/test/Stream_support/test_read_WKT.cpp b/Stream_support/test/Stream_support/test_read_WKT.cpp index 0b550d76f34..fa0bb9b2c08 100644 --- a/Stream_support/test/Stream_support/test_read_WKT.cpp +++ b/Stream_support/test/Stream_support/test_read_WKT.cpp @@ -9,8 +9,6 @@ #include #include -#include - #include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; diff --git a/Stream_support/test/Stream_support/test_write_WKT.cpp b/Stream_support/test/Stream_support/test_write_WKT.cpp index 9586021beb9..ac602a67a93 100644 --- a/Stream_support/test/Stream_support/test_write_WKT.cpp +++ b/Stream_support/test/Stream_support/test_write_WKT.cpp @@ -11,8 +11,6 @@ #include #include -#include - #include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; diff --git a/Surface_mesh/examples/Surface_mesh/sm_draw_small_faces.cpp b/Surface_mesh/examples/Surface_mesh/sm_draw_small_faces.cpp index 3ab87459e1d..5d07f8a2dfa 100644 --- a/Surface_mesh/examples/Surface_mesh/sm_draw_small_faces.cpp +++ b/Surface_mesh/examples/Surface_mesh/sm_draw_small_faces.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include "draw_surface_mesh_small_faces.h" typedef CGAL::Simple_cartesian K; @@ -26,7 +25,7 @@ int main(int argc, char* argv[]) boost::tie(faces_size, created)=sm.add_property_map("f:size",0.); CGAL_assertion(created); - BOOST_FOREACH(face_descriptor fd, sm.faces()) + for(face_descriptor fd : sm.faces()) { faces_size[fd]=CGAL::Polygon_mesh_processing::face_area(fd, sm); } draw_surface_mesh_with_small_faces(sm); diff --git a/Surface_mesh/include/CGAL/Surface_mesh/Properties.h b/Surface_mesh/include/CGAL/Surface_mesh/Properties.h index b7e7b465623..5a4f823e669 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/Properties.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/Properties.h @@ -477,6 +477,7 @@ public: void swap (Property_container& other) { this->parrays_.swap (other.parrays_); + std::swap(this->size_, other.size_); } private: diff --git a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h index 99ce029aa12..e6a397f9941 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h @@ -6,7 +6,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // @@ -80,21 +80,6 @@ namespace CGAL { return idx_ != inf; } - /// are two indices equal? - bool operator==(const T& _rhs) const { - return idx_ == _rhs.idx_; - } - - /// are two indices different? - bool operator!=(const T& _rhs) const { - return idx_ != _rhs.idx_; - } - - /// Comparison by index. - bool operator<(const T& _rhs) const { - return idx_ < _rhs.idx_; - } - // Compatibility with OpenMesh handle size_type idx() const { return idx_; @@ -120,7 +105,7 @@ namespace CGAL { SM_Index operator+=(std::ptrdiff_t n) { idx_ = size_type(std::ptrdiff_t(idx_) + n); return *this; } - private: + protected: size_type idx_; }; @@ -131,8 +116,8 @@ namespace CGAL { return ret; } - // Implementation for Surface_mesh::Vertex_index - + + // Implementation for Surface_mesh::Vertex_index class SM_Vertex_index : public SM_Index { @@ -142,6 +127,25 @@ namespace CGAL { explicit SM_Vertex_index(size_type _idx) : SM_Index(_idx) {} + template bool operator==(const T&) const = delete; + template bool operator!=(const T&) const = delete; + template bool operator<(const T&) const = delete; + + /// are two indices equal? + bool operator==(const SM_Vertex_index& _rhs) const { + return this->idx_ == _rhs.idx_; + } + + /// are two indices different? + bool operator!=(const SM_Vertex_index& _rhs) const { + return this->idx_ != _rhs.idx_; + } + + /// Comparison by index. + bool operator<(const SM_Vertex_index& _rhs) const { + return this->idx_ < _rhs.idx_; + } + friend std::ostream& operator<<(std::ostream& os, SM_Vertex_index const& v) { @@ -167,6 +171,25 @@ namespace CGAL { SM_Halfedge_index() : SM_Index((std::numeric_limits::max)()) {} explicit SM_Halfedge_index(size_type _idx) : SM_Index(_idx) {} + + template bool operator==(const T&) const = delete; + template bool operator!=(const T&) const = delete; + template bool operator<(const T&) const = delete; + + /// are two indices equal? + bool operator==(const SM_Halfedge_index& _rhs) const { + return this->idx_ == _rhs.idx_; + } + + /// are two indices different? + bool operator!=(const SM_Halfedge_index& _rhs) const { + return this->idx_ != _rhs.idx_; + } + + /// Comparison by index. + bool operator<(const SM_Halfedge_index& _rhs) const { + return this->idx_ < _rhs.idx_; + } friend std::ostream& operator<<(std::ostream& os, SM_Halfedge_index const& h) { @@ -183,7 +206,25 @@ namespace CGAL { SM_Face_index() : SM_Index((std::numeric_limits::max)()) {} explicit SM_Face_index(size_type _idx) : SM_Index(_idx) {} + + template bool operator==(const T&) const = delete; + template bool operator!=(const T&) const = delete; + template bool operator<(const T&) const = delete; + /// are two indices equal? + bool operator==(const SM_Face_index& _rhs) const { + return this->idx_ == _rhs.idx_; + } + + /// are two indices different? + bool operator!=(const SM_Face_index& _rhs) const { + return this->idx_ != _rhs.idx_; + } + + /// Comparison by index. + bool operator<(const SM_Face_index& _rhs) const { + return this->idx_ < _rhs.idx_; + } friend std::ostream& operator<<(std::ostream& os, SM_Face_index const& f) { @@ -218,6 +259,11 @@ namespace CGAL { // returns whether the index is valid, i.e., the index is not equal to std::numeric_limits::max(). bool is_valid() const { return halfedge_.is_valid(); } + + template bool operator==(const T&) const = delete; + template bool operator!=(const T&) const = delete; + template bool operator<(const T&) const = delete; + // Are two indices equal? bool operator==(const SM_Edge_index& other) const { return (size_type)(*this) == (size_type)other; } diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/MVC_post_processor_3.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/MVC_post_processor_3.h index 007a2092bd1..78d98885437 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/MVC_post_processor_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/MVC_post_processor_3.h @@ -128,17 +128,16 @@ private: // Types used for the convexification of the mesh // Each triangulation vertex is associated its corresponding vertex_descriptor - typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; - // Each triangultaion face is associated a color (inside/outside information) - typedef CGAL::Triangulation_face_base_with_info_2 Fb; - typedef CGAL::Constrained_triangulation_face_base_2 Cfb; - typedef CGAL::Triangulation_data_structure_2 TDS; - typedef CGAL::No_intersection_tag Itag; + typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; + // Each triangulation face is associated a color (inside/outside information) + typedef CGAL::Triangulation_face_base_with_info_2 Fb; + typedef CGAL::Constrained_triangulation_face_base_2 Cfb; + typedef CGAL::Triangulation_data_structure_2 TDS; + typedef CGAL::No_constraint_intersection_requiring_constructions_tag Itag; // Can choose either a triangulation or a Delaunay triangulation - typedef CGAL::Constrained_triangulation_2 CT; -// typedef CGAL::Constrained_Delaunay_triangulation_2 CT; + typedef CGAL::Constrained_triangulation_2 CT; +// typedef CGAL::Constrained_Delaunay_triangulation_2 CT; // Private fields private: diff --git a/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies b/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies index b5bfe486174..6365759ce7c 100644 --- a/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies +++ b/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies @@ -3,6 +3,7 @@ BGL Box_intersection_d Circulator Distance_2 +Distance_3 Filtered_kernel Hash_map Installation @@ -25,4 +26,3 @@ Stream_support Surface_mesh_parameterization TDS_2 Triangulation_2 -Distance_3 diff --git a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/SDF_calculation.h b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/SDF_calculation.h index 08cab7ca021..0e55c43f650 100644 --- a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/SDF_calculation.h +++ b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/SDF_calculation.h @@ -163,11 +163,10 @@ public: if(!test) tree.insert(Primitive(it, mesh, vertex_point_map)); } - tree.build(); - - if(build_kd_tree) { - tree.accelerate_distance_queries(); + if(!build_kd_tree) { + tree.do_not_accelerate_distance_queries(); } + tree.build(); if(use_diagonal) { CGAL::Bbox_3 bbox = tree.bbox(); diff --git a/Surface_mesh_segmentation/package_info/Surface_mesh_segmentation/dependencies b/Surface_mesh_segmentation/package_info/Surface_mesh_segmentation/dependencies index e22910d08fd..ea25e29aac6 100644 --- a/Surface_mesh_segmentation/package_info/Surface_mesh_segmentation/dependencies +++ b/Surface_mesh_segmentation/package_info/Surface_mesh_segmentation/dependencies @@ -4,6 +4,7 @@ BGL Cartesian_kernel Circulator Distance_2 +Distance_3 Installation Intersections_2 Intersections_3 @@ -18,4 +19,3 @@ STL_Extension Spatial_searching Stream_support Surface_mesh_segmentation -Distance_3 diff --git a/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/Surface_mesh_shortest_path.txt b/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/Surface_mesh_shortest_path.txt index b7af46bd906..cbc0cf43e9b 100644 --- a/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/Surface_mesh_shortest_path.txt +++ b/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/Surface_mesh_shortest_path.txt @@ -60,7 +60,18 @@ If the traits class used holds some local state, it must also be passed to the c The set of source points for shortest path queries can be populated one by one or using a range. A source point can be specified using either a vertex of the input surface mesh or a face of the input surface mesh with some barycentric coordinates. -Given a point \f$p\f$ that lies inside a triangle face \f$(A,B,C)\f$, its barycentric coordinates are a weight triple \f$(b_0,b_1,b_2)\f$ such that \f$p = b_0\cdot~A + b_1\cdot~B + b_2\cdot~C\f$, and \f$b_0 + b_1 + b_2 = 1\f$. +Given a point \f$p\f$ that lies inside a triangle face \f$(A,B,C)\f$, its barycentric coordinates +are a weight triple \f$(b_0,b_1,b_2)\f$ such that \f$p = b_0\cdot~A + b_1\cdot~B + b_2\cdot~C\f$, +and \f$b_0 + b_1 + b_2 = 1\f$. + +For convenience, a function `Surface_mesh_shortest_path::locate()` is provided to construct face locations from geometric +inputs: +- given a point `p` living in 3D space, this function computes the point closest to `p` on the surface, +and returns the face containing this point, as well as its barycentric coordinates; +- given a ray `r` living in 3D space, this function computes the intersection of the ray with the surface, +and (if an intersection exists) returns the face containing this point, as well as its barycentric coordinates; + +Usage of this function is illustrated in the example \ref Surface_mesh_shortest_path/shortest_path_with_locate.cpp. \subsubsection Surface_mesh_shortest_pathClassBuild Building the Internal Sequence Tree diff --git a/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/examples.txt b/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/examples.txt index bdb3f6e7aff..a13f2a8bde5 100644 --- a/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/examples.txt +++ b/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/examples.txt @@ -5,4 +5,5 @@ \example Surface_mesh_shortest_path/shortest_paths_OpenMesh.cpp \example Surface_mesh_shortest_path/shortest_paths_multiple_sources.cpp \example Surface_mesh_shortest_path/shortest_path_sequence.cpp +\example Surface_mesh_shortest_path/shortest_path_with_locate.cpp */ diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/CMakeLists.txt b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/CMakeLists.txt index 6b757a109e9..513007600bc 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/CMakeLists.txt +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/CMakeLists.txt @@ -17,6 +17,7 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "shortest_paths_no_id.cpp" ) create_single_source_cgal_program( "shortest_paths_with_id.cpp" ) create_single_source_cgal_program( "shortest_paths.cpp" ) + create_single_source_cgal_program( "shortest_path_with_locate.cpp" ) find_package( OpenMesh QUIET ) if ( OpenMesh_FOUND ) diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_with_locate.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_with_locate.cpp new file mode 100644 index 00000000000..de1ef93fb47 --- /dev/null +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_with_locate.cpp @@ -0,0 +1,78 @@ +#include + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef Kernel::Point_3 Point_3; +typedef Kernel::Ray_3 Ray_3; + +typedef CGAL::Surface_mesh Triangle_mesh; +typedef CGAL::Surface_mesh_shortest_path_traits Traits; +typedef CGAL::Surface_mesh_shortest_path Surface_mesh_shortest_path; + +typedef boost::graph_traits Graph_traits; +typedef Graph_traits::vertex_iterator vertex_iterator; +typedef Graph_traits::face_iterator face_iterator; + +typedef typename Surface_mesh_shortest_path::Barycentric_coordinates Barycentric_coordinates; +typedef typename Surface_mesh_shortest_path::Face_location Face_location; + +typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; +typedef CGAL::AABB_traits AABB_face_graph_traits; +typedef CGAL::AABB_tree AABB_tree; + +int main(int argc, char** argv) +{ + Triangle_mesh tmesh; + std::ifstream input((argc>1) ? argv[1] : "data/elephant.off"); + input >> tmesh; + + Surface_mesh_shortest_path shortest_paths(tmesh); + + // The source point is a 3D point. We must convert it to a face location (that is, + // a face ID and three barycentric coordinates) + const Point_3 source_pt(-0.06, -0.145, 0.182); + Face_location source_loc = shortest_paths.locate(source_pt); // this builds an AABB tree of the mesh + + // Add the source point + shortest_paths.add_source_point(source_loc.first, source_loc.second); + + // The target will be defined by the first intersection of the following ray with the input mesh + const Ray_3 ray(Point_3(0.126, 0.387, 0.324), Point_3(0.126, 0.387, 0.124)); + + // If you intend to call `locate` many times, you should cache the AABB tree + // that is used internally to avoid it being recomputed at each call, as follows: + AABB_tree tree; + shortest_paths.build_aabb_tree(tree); + Face_location target_loc = shortest_paths.locate(ray, tree); + + if(target_loc.first == boost::graph_traits::null_face()) + { + std::cerr << "They ray does not intersect the mesh!" << std::endl; + return EXIT_FAILURE; + } + + // Compute the shortest path between the source and the target + std::vector points; + shortest_paths.shortest_path_points_to_source_points(target_loc.first, target_loc.second, + std::back_inserter(points)); + + // Print the points + std::cout << points.size() << " "; + for (std::size_t i = 0; i < points.size(); ++i) + std::cout << " " << points[i]; + std::cout << std::endl; + + return EXIT_SUCCESS; +} 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 fa66c309161..dae71dc8929 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 @@ -1987,7 +1987,8 @@ private: for (boost::tie(current,end) = vertices(m_graph); current != end; ++current) { - std::cout << "Vertex#" << numVertices << ": p = " << get(m_vertexPointMap,*current) + std::cout << "Vertex#" << numVertices + << ": p = " << get(m_vertexPointMap,*current) << " , Saddle Vertex: " << (is_saddle_vertex(*current) ? "yes" : "no") << " , Boundary Vertex: " << (is_boundary_vertex(*current) ? "yes" : "no") << std::endl; ++numVertices; @@ -2100,7 +2101,8 @@ private: { std::cout << "PseudoSource Expansion: Parent = " << parent << " , Vertex = " << get(m_vertexIndexMap, event->m_parent->target_vertex()) - << " , Distance = " << event->m_distanceEstimate << " , Level = " << event->m_parent->level() + 1 << std::endl; + << " , Distance = " << event->m_distanceEstimate + << " , Level = " << event->m_parent->level() + 1 << std::endl; } expand_pseudo_source(parent); @@ -2111,7 +2113,8 @@ private: std::cout << "Left Expansion: Parent = " << parent << " Edge = (" << get(m_vertexIndexMap, source(event->m_parent->left_child_edge(), m_graph)) << "," << get(m_vertexIndexMap, target(event->m_parent->left_child_edge(), m_graph)) - << ") , Distance = " << event->m_distanceEstimate << " , Level = " << event->m_parent->level() + 1 << std::endl; + << ") , Distance = " << event->m_distanceEstimate + << " , Level = " << event->m_parent->level() + 1 << std::endl; } expand_left_child(parent, event->m_windowSegment); @@ -2122,7 +2125,8 @@ private: std::cout << "Right Expansion: Parent = " << parent << " , Edge = (" << get(m_vertexIndexMap, source(event->m_parent->right_child_edge(), m_graph)) << "," << get(m_vertexIndexMap, target(event->m_parent->right_child_edge(), m_graph)) - << ") , Distance = " << event->m_distanceEstimate << " , Level = " << event->m_parent->level() + 1 << std::endl; + << ") , Distance = " << event->m_distanceEstimate + << " , Level = " << event->m_parent->level() + 1 << std::endl; } expand_right_child(parent, event->m_windowSegment); @@ -2218,7 +2222,7 @@ public: \param traits Optional instance of the traits class to use. */ - Surface_mesh_shortest_path(Triangle_mesh& tm, + Surface_mesh_shortest_path(const Triangle_mesh& tm, Vertex_index_map vertexIndexMap, Halfedge_index_map halfedgeIndexMap, Face_index_map faceIndexMap, @@ -2824,8 +2828,7 @@ public: that accept a reference to an `AABB_tree` as input. \details The following static overload is also available: - - `static Face_location locate(const Point_3& p, const Triangle_mesh& tm, - Vertex_point_map vertexPointMap, const Traits& traits = Traits())` + - `static Face_location locate(const %Point_3& p, const Triangle_mesh& tm, Vertex_point_map vertexPointMap, const Traits& traits = Traits())` \tparam AABBTraits A model of `AABBTraits` used to define a \cgal `AABB_tree`. @@ -2856,8 +2859,7 @@ public: \brief Returns the face location nearest to the given point. \details The following static overload is also available: - - static Face_location locate(const Point_3& p, const AABB_tree& tree, const Triangle_mesh& tm, - Vertex_point_map vertexPointMap, const Traits& traits = Traits()) + - static Face_location locate(const %Point_3& p, const AABB_tree& tree, const Triangle_mesh& tm, Vertex_point_map vertexPointMap, const Traits& traits = Traits()) \tparam AABBTraits A model of `AABBTraits` used to define a \cgal `AABB_tree`. @@ -2898,7 +2900,7 @@ public: that accept a reference to an `AABB_tree` as input. \details The following static overload is also available: - - `static Face_location locate(const Ray_3& ray, const Triangle_mesh& tm, Vertex_point_map vertexPointMap, const Traits& traits = Traits())` + - `static Face_location locate(const %Ray_3& ray, const Triangle_mesh& tm, Vertex_point_map vertexPointMap, const Traits& traits = Traits())` \tparam AABBTraits A model of `AABBTraits` used to define an `AABB_tree`. @@ -2930,8 +2932,7 @@ public: its source point. \details The following static overload is also available: - - static Face_location locate(const Ray_3& ray, const AABB_tree& tree, const Triangle_mesh& tm, - Vertex_point_map vertexPointMap, const Traits& traits = Traits()) + - static Face_location locate(const %Ray_3& ray, const AABB_tree& tree, const Triangle_mesh& tm, Vertex_point_map vertexPointMap, const Traits& traits = Traits()) \tparam AABBTraits A model of `AABBTraits` used to define a \cgal `AABB_tree`. @@ -3004,9 +3005,7 @@ public: /// \endcond - /// @} - - /* + /*! \brief Creates an `AABB_tree` suitable for use with `locate`. \details The following static overload is also available: @@ -3022,6 +3021,8 @@ public: build_aabb_tree(m_graph, outTree, m_vertexPointMap); } + /// \cond + template void build_aabb_tree(AABB_tree& outTree, Vertex_point_map vertexPointMap) const @@ -3029,8 +3030,6 @@ public: build_aabb_tree(m_graph, outTree, vertexPointMap); } - /// \cond - template static void build_aabb_tree(const Triangle_mesh& tm, AABB_tree& outTree, @@ -3043,6 +3042,7 @@ public: } /// \endcond + /// @} }; } // namespace CGAL diff --git a/Surface_mesh_shortest_path/package_info/Surface_mesh_shortest_path/dependencies b/Surface_mesh_shortest_path/package_info/Surface_mesh_shortest_path/dependencies index a903992f736..0acb32e8813 100644 --- a/Surface_mesh_shortest_path/package_info/Surface_mesh_shortest_path/dependencies +++ b/Surface_mesh_shortest_path/package_info/Surface_mesh_shortest_path/dependencies @@ -4,6 +4,7 @@ BGL Cartesian_kernel Circulator Distance_2 +Distance_3 Installation Intersections_2 Intersections_3 @@ -18,4 +19,3 @@ STL_Extension Spatial_searching Stream_support Surface_mesh_shortest_path -Distance_3 diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Surface_sweep_2_impl.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Surface_sweep_2_impl.h index e0379d49771..79c4930a4e2 100644 --- a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Surface_sweep_2_impl.h +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Surface_sweep_2_impl.h @@ -280,7 +280,7 @@ void Surface_sweep_2::_handle_overlaps_in_right_curves() Subcurve_iterator next_after = this->m_currentEvent->get_curve_after_on_right(it->first); for (std::size_t i=0; isecond[i], *cpp11::prev(next_after), this->m_currentEvent); + _intersect(it->second[i], *std::prev(next_after), this->m_currentEvent); CGAL_assertion(it->second.size()==nbc); // make sure the container was not updated } } @@ -904,7 +904,7 @@ _create_overlapping_curve(const X_monotone_curve_2& overlap_cv, // Get the left end of overlap_cv. Event* left_event; - if (event_on_overlap!=nullptr) + if (event_on_overlap!=NULL) { CGAL_SS_PRINT_EVENT_INFO(event_on_overlap); CGAL_SS_PRINT_EOL(); diff --git a/TDS_2/doc/TDS_2/Concepts/TriangulationDataStructure_2.h b/TDS_2/doc/TDS_2/Concepts/TriangulationDataStructure_2.h index e193a21c460..4b025c1b7e4 100644 --- a/TDS_2/doc/TDS_2/Concepts/TriangulationDataStructure_2.h +++ b/TDS_2/doc/TDS_2/Concepts/TriangulationDataStructure_2.h @@ -68,7 +68,7 @@ for faces of maximal dimension instead of faces. \sa `TriangulationDataStructure_2::Face` \sa `TriangulationDataStructure_2::Vertex` -\sa `CGAL::Triangulation_2` +\sa `CGAL::Triangulation_2` */ diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index da8f7e0783d..e971ee6a7db 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,7 @@ #include #include +#include #include #include @@ -47,6 +49,7 @@ #include #include +#include #ifdef CGAL_LINKED_WITH_TBB # include @@ -173,6 +176,25 @@ public: typedef Triple Edge; typedef Triangulation_simplex_3 Simplex; + + typedef std::pair Vertex_pair; + typedef std::pair Local_facet; + + struct Small_pair_hash { + + std::size_t operator()(const Vertex_pair& k) const + { + std::size_t hf = boost::hash()(k.first); + std::size_t hs = boost::hash()(k.second); + + return hf ^ 419 * hs; + } + }; + + static const int maximal_nb_of_facets_of_small_hole = 128; + typedef Small_unordered_map Vertex_pair_facet_map; + //#ifndef CGAL_TDS_USE_RECURSIVE_CREATE_STAR_3 //internally used for create_star_3 (faster than a tuple) struct iAdjacency_info{ @@ -196,7 +218,7 @@ public: } }; //#endif - + public: Triangulation_data_structure_3() @@ -501,6 +523,57 @@ public: return insert_in_hole(cell_begin, cell_end, begin, i, create_vertex()); } + template + Vertex_handle _insert_in_small_hole(const Cells& cells, const Facets& facets) + { + CGAL_assertion(facets.size() < (std::numeric_limits::max)()); + CGAL_STATIC_THREAD_LOCAL_VARIABLE_0(Vertex_pair_facet_map, vertex_pair_facet_map); + Vertex_handle nv = create_vertex(); + std::array new_cells; + for (unsigned char local_facet_index = 0, end = static_cast(facets.size()); + local_facet_index < end; ++local_facet_index) { + const Facet f = mirror_facet(facets[local_facet_index]); + f.first->tds_data().clear(); // was on boundary + const Vertex_handle u = f.first->vertex(vertex_triple_index(f.second, 0)); + const Vertex_handle v = f.first->vertex(vertex_triple_index(f.second, 1)); + const Vertex_handle w = f.first->vertex(vertex_triple_index(f.second, 2)); + u->set_cell(f.first); + v->set_cell(f.first); + w->set_cell(f.first); + const Cell_handle nc = create_cell(v, u, w, nv); + new_cells[local_facet_index] = nc; + nv->set_cell(nc); + nc->set_neighbor(3, f.first); + f.first->set_neighbor(f.second, nc); + + vertex_pair_facet_map.set({u, v}, {local_facet_index, + static_cast(nc->index(w))}); + vertex_pair_facet_map.set({v, w}, {local_facet_index, + static_cast(nc->index(u))}); + vertex_pair_facet_map.set({w, u}, {local_facet_index, + static_cast(nc->index(v))}); + } + + for(auto it = vertex_pair_facet_map.begin(); it != vertex_pair_facet_map.end(); ++it){ + const std::pair& ef = *it; + if(ef.first.first < ef.first.second){ + const Facet f = Facet{new_cells[ef.second.first], ef.second.second}; + vertex_pair_facet_map.clear(it); + const auto p = vertex_pair_facet_map.get_and_erase(std::make_pair(ef.first.second, ef.first.first)); + const Facet n = Facet{new_cells[p.first], p.second}; + f.first->set_neighbor(f.second, n.first); + n.first->set_neighbor(n.second, f.first); + } + } + for(Cell_handle c : cells){ + c->tds_data().clear(); // was in conflict + } + delete_cells(cells.begin(), cells.end()); + vertex_pair_facet_map.clear(); + return nv; + } + + //INSERTION // Create a finite cell with v1, v2, v3 and v4 @@ -1443,6 +1516,11 @@ public: Vertex_range & vertices() const { return const_cast(this)->_vertices; } + bool is_small_hole(std::size_t s) + { + return s <= maximal_nb_of_facets_of_small_hole; + } + private: // Change the orientation of the cell by swapping indices 0 and 1. diff --git a/Three/include/CGAL/Three/Viewer_interface.h b/Three/include/CGAL/Three/Viewer_interface.h index 26b0778098e..0a4ceea06fb 100644 --- a/Three/include/CGAL/Three/Viewer_interface.h +++ b/Three/include/CGAL/Three/Viewer_interface.h @@ -238,6 +238,9 @@ public Q_SLOTS: //! If b is true, faces will be ligted from both internal and external side. //! If b is false, only the side that is exposed to the light source will be lighted. virtual void setTwoSides(bool b) = 0; + //! If b is true, then a special color mask is applied to points and meshes to differenciate + //! front-faced and back-faced elements. + virtual void setBackFrontShading(bool b) =0; //! \brief Sets the fast drawing mode //! @see inFastDrawing() virtual void setFastDrawing(bool b) = 0; diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_Delaunay_triangulation_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_Delaunay_triangulation_2.h index 85295f0243f..311210184b8 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_Delaunay_triangulation_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_Delaunay_triangulation_2.h @@ -34,11 +34,16 @@ and has then to be also a model of the concept \tparam Tds must be a model of `TriangulationDataStructure_2`or `Default`. \tparam Itag allows to select if intersecting constraints are supported and how they are handled. -- `No_intersection_tag` if intersections of -input constraints are disallowed, +- `No_constraint_intersection_tag` if intersections of +input constraints are disallowed, except for the configuration of a single common extremity; +- `No_constraint_intersection_requiring_constructions_tag` if intersections of +input constraints are disallowed, except if no actual construction is needed to represent the intersection. +For example, if two constraints intersect in a 'T'-like junction, the intersection point is one of +the constraints' extremity and as such, no construction is in fact needed. Other similar configurations include +overlapping segments, common extremities, or equal constraints. - `Exact_predicates_tag` allows intersections between input constraints and is to be used when the traits class provides exact -predicates but approximate constructions of the intersection points, +predicates but approximate constructions of the intersection points; - `Exact_intersections_tag` allows intersections between input constraints and is to be used in conjunction with an exact arithmetic type. @@ -71,7 +76,7 @@ the default for and the default for the triangulation data structure parameter is the class `Triangulation_data_structure_2< CGAL::Triangulation_vertex_base_2, Constrained_triangulation_face_base_2 >`. -The default intersection tag is `No_intersection_tag`. +The default intersection tag is `No_constraint_intersection_requiring_constructions_tag`. \cgalHeading{Types} diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h index 181dc976ff6..47f4a38c217 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h @@ -6,9 +6,33 @@ namespace CGAL { \ingroup PkgTriangulation2TriangulationClasses Intersection tag for constrained triangulations, when input constraints do not intersect. + +\deprecated This class is deprecated since \cgal 5.1 as it was ambiguous. Users should instead +use the tags `No_constraint_intersection_tag` and `No_constraint_intersection_requiring_constructions_tag`, +depending on their needs. */ struct No_intersection_tag{}; +/*! +\ingroup PkgTriangulation2TriangulationClasses + +Intersection tag for constrained triangulations, when input constraints are not allowed to intersect +except at a single common extremity. +*/ +struct No_constraint_intersection_tag{}; + +/*! +\ingroup PkgTriangulation2TriangulationClasses + +Intersection tag for constrained triangulations, when input constraints are not allowed to intersect +except if the intersection does not require any new point construction. + +This for example allows configurations such as two segments intersecting in a 'T', or overlapping (and +even identical) segments. + +This is the default tag. +*/ +struct No_constraint_intersection_requiring_constructions_tag{}; /*! \ingroup PkgTriangulation2TriangulationClasses @@ -81,7 +105,6 @@ as it avoids the cascading of intersection computations. \image html constraints.png \image latex constraints.png - \tparam Traits is a geometric traits class and must be a model of the concept `TriangulationTraits_2`. When intersection of input constraints are supported, @@ -91,46 +114,33 @@ to compute the intersection of two segments. It has then to be a model of the concept `ConstrainedTriangulationTraits_2`. +\tparam Tds must be a model of the concept `TriangulationDataStructure_2` or `Default`. +The information about constrained edges is stored in the faces of the triangulation. Thus the nested `Face` +type of a constrained triangulation offers additional functionalities to deal with this information. +These additional functionalities induce additional requirements on the face base class +plugged into the triangulation data structure of a constrained Delaunay triangulation. +The face base of a constrained Delaunay triangulation has to be a model of the concept +`ConstrainedTriangulationFaceBase_2`. -\tparam Tds must be a model -of the concept `TriangulationDataStructure_2` or `Default`. +\tparam Itag is the intersection tag +which serves to choose between the different +strategies to deal with constraints intersections. +\cgal provides three valid types for this parameter: +- `No_constraint_intersection_tag` disallows intersections of input constraints +except for the case of a single common extremity; +- `No_constraint_intersection_requiring_constructions_tag` (default value) disallows intersections +of input constraints except for configurations where the intersection can be represented +without requiring the construction of a new point such as overlapping constraints; +- `Exact_predicates_tag` is to be used when the traits class +provides exact predicates but approximate constructions of the +intersection points; +- `Exact_intersections_tag` is to be used in conjunction +with an exact arithmetic type. -\tparam Itag is the intersection tag -which serves to choose between the different -strategies to deal with constraints intersections. -\cgal provides three valid types for this parameter: -- `No_intersection_tag` disallows intersections of -input constraints, -- `Exact_predicates_tag` is to be used when the traits -class -provides exact predicates but approximate constructions of the -intersection points. -- `Exact_intersections_tag` is to be used in conjunction -with an exact arithmetic type. - -The information about constrained edges is stored in the -faces of the triangulation. Thus the nested `Face` -type of a constrained triangulation offers -additional functionalities to deal with this information. -These additional functionalities -induce additional requirements on the face base class -plugged into the triangulation data structure of -a constrained Delaunay triangulation. -The face base of a constrained Delaunay triangulation -has to be a model of the concept -`ConstrainedTriangulationFaceBase_2`. - -\cgal provides default instantiations for the template parameters -`Tds` and `Itag`, and for the `ConstrainedTriangulationFaceBase_2`. -If `Gt` is the geometric traits class -parameter, -the default for -`ConstrainedTriangulationFaceBase_2` is the class -`Constrained_triangulation_face_base_2` -and the default for the -triangulation data structure parameter is the class -`Triangulation_data_structure_2 < Triangulation_vertex_base_2, Constrained_triangulation_face_base_2 >`. -The default intersection tag is `No_intersection_tag`. +\cgal provides default instantiations for the template parameters `Tds` and `Itag`. +If `Gt` is the geometric traits class parameter, the default triangulation data structure +is the class is the class `Triangulation_data_structure_2, Constrained_triangulation_face_base_2 >`. +The default intersection tag is `No_constraint_intersection_requiring_constructions_tag`. \sa `CGAL::Triangulation_2` \sa `TriangulationDataStructure_2` @@ -344,8 +354,8 @@ template std::istream& operator>>(std::istream& is,Constrained_triangulation_2 Ct& ct); /*! Exception used by constrained triangulations configured with -the tag `No_intersection_tag`. It is thrown upon insertion of a constraint -that is intersecting an already inserted constraint in its interior. +the tags `No_constraint_intersection_tag` or `No_constraint_intersection_requiring_constructions_tag` +when the insertion of a new constraint would break the respective conditions associated to each tag. */ class Intersection_of_constraints_exception; } /* end namespace CGAL */ diff --git a/Triangulation_2/doc/Triangulation_2/Concepts/ConstrainedTriangulationTraits_2.h b/Triangulation_2/doc/Triangulation_2/Concepts/ConstrainedTriangulationTraits_2.h index 4d871fe8008..da8d135cbe4 100644 --- a/Triangulation_2/doc/Triangulation_2/Concepts/ConstrainedTriangulationTraits_2.h +++ b/Triangulation_2/doc/Triangulation_2/Concepts/ConstrainedTriangulationTraits_2.h @@ -82,8 +82,8 @@ typedef unspecified_type Compute_squared_distance_2; A function object whose `operator()` computes the bounding box of a point. -`unspecified_type operator()(Point_2 p);` Returns the bounding box of `p`. -The result type is either `Bbox_2` or `Bbox_3` (for projection traits classes). +CGAL::Bbox_2 operator()(Point_2 p);` Returns the bounding box of `p`. +The result type is `CGAL::Bbox_2` (even for projection traits classes). */ typedef unspecified_type Compute_bounding_box_2; diff --git a/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt b/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt index 742ea922347..9451f88be77 100644 --- a/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt +++ b/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt @@ -842,10 +842,15 @@ The third parameter `Itag` is the intersection tag which serves to choose how intersecting constraints are dealt with. This parameter has to be instantiated by one of the following classes: -- `No_intersection_tag` when input constraints do not -intersect +- `No_constraint_intersection_tag` if intersections of +input constraints are disallowed, except for the configuration of a single common extremity; +- `No_constraint_intersection_requiring_constructions_tag` if intersections of +input constraints are disallowed, except if no actual construction is needed to represent the intersection. +For example, if two constraints intersect in a 'T'-like junction, the intersection point is one of +the constraints' extremity and as such, no construction is in fact needed. Other similar configurations include +overlapping segments, common extremities, or equal constraints; - `Exact_predicates_tag` if the geometric traits class provides -exact predicates but approximate constructions +exact predicates but approximate constructions; - `Exact_intersections_tag` when exact predicates and exact constructions are provided. @@ -941,9 +946,8 @@ As in the case of constrained triangulations, the third parameter `Itag` is the intersection tag and serves to choose how intersecting constraints are dealt with. It can be instantiated with one of the following -classes: `No_intersection_tag`, -`Exact_predicates_tag`, -`Exact_intersections_tag` +classes: `No_constraint_intersection_tag`, `No_constraint_intersection_requiring_constructions_tag`, +`Exact_predicates_tag`, or `Exact_intersections_tag` (see Section \ref Section_2D_Triangulations_Constrained). A constrained Delaunay triangulation is not a Delaunay diff --git a/Triangulation_2/examples/Triangulation_2/CMakeLists.txt b/Triangulation_2/examples/Triangulation_2/CMakeLists.txt index 4911f1d9872..fe3f5a7f849 100644 --- a/Triangulation_2/examples/Triangulation_2/CMakeLists.txt +++ b/Triangulation_2/examples/Triangulation_2/CMakeLists.txt @@ -31,6 +31,8 @@ if ( CGAL_FOUND ) if(CGAL_Qt5_FOUND) target_link_libraries(draw_triangulation_2 PUBLIC CGAL::CGAL_Qt5) + else() + message(STATUS "NOTICE: The example draw_triangulation_2 requires Qt and will not be compiled.") endif() else() diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_2.h index d586170614f..63217b459d4 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_2.h @@ -34,13 +34,21 @@ #include #include +#include namespace CGAL { -struct No_intersection_tag{}; +struct No_constraint_intersection_tag{}; +struct No_constraint_intersection_requiring_constructions_tag{}; struct Exact_intersections_tag{}; // to be used with an exact number type struct Exact_predicates_tag{}; // to be used with filtered exact number +// This was deprecated and replaced by ` No_constraint_intersection_tag` and `No_constraint_intersection_requiring_constructions_tag` +// due to an inconsistency between the code and the documenation. +struct CGAL_DEPRECATED No_intersection_tag : + public No_constraint_intersection_requiring_constructions_tag +{ }; + namespace internal { template @@ -67,7 +75,7 @@ public: Triangulation_vertex_base_2, Constrained_triangulation_face_base_2 > >::type Tds; - typedef typename Default::Get::type Itag; + typedef typename Default::Get::type Itag; typedef Triangulation_2 Triangulation; typedef Constrained_triangulation_2 Constrained_triangulation; @@ -103,7 +111,7 @@ public: { const char* what() const throw () { - return "Intersection of constraints while using No_intersection_tag"; + return "Unauthorized intersections of constraints"; } }; @@ -300,7 +308,21 @@ insert_constraint(Vertex_handle vaa, Vertex_handle vbb, OutputIterator out) Face_handle fr; int i; - if(includes_edge(vaa,vbb,vi,fr,i)) { + if(includes_edge(vaa,vbb,vi,fr,i)) + { + // if the segment (or a subpart of the segment) that we are trying to constraint is already + // present in the triangulation and is already marked as constrained, + // then this is an intersection + if(boost::is_same::value) { + if(dimension() == 1) { + if(fr->is_constrained(2)) + throw Intersection_of_constraints_exception(); + } else { + if(fr->is_constrained(i)) + throw Intersection_of_constraints_exception(); + } + } + mark_constraint(fr,i); if (vi != vbb) { insert_constraint(vi,vbb,out); @@ -448,21 +470,25 @@ protected: void mark_constraint(Face_handle fr, int i); - virtual Vertex_handle intersect(Face_handle f, int i, - Vertex_handle vaa, - Vertex_handle vbb); - Vertex_handle intersect(Face_handle f, int i, - Vertex_handle vaa, - Vertex_handle vbb, - No_intersection_tag); - Vertex_handle intersect(Face_handle f, int i, - Vertex_handle vaa, - Vertex_handle vbb, - Exact_intersections_tag); - Vertex_handle intersect(Face_handle f, int i, - Vertex_handle vaa, - Vertex_handle vbb, - Exact_predicates_tag); + virtual Vertex_handle intersect(Face_handle f, int i, + Vertex_handle vaa, + Vertex_handle vbb); + Vertex_handle intersect(Face_handle f, int i, + Vertex_handle vaa, + Vertex_handle vbb, + No_constraint_intersection_tag); + Vertex_handle intersect(Face_handle f, int i, + Vertex_handle vaa, + Vertex_handle vbb, + No_constraint_intersection_requiring_constructions_tag); + Vertex_handle intersect(Face_handle f, int i, + Vertex_handle vaa, + Vertex_handle vbb, + Exact_intersections_tag); + Vertex_handle intersect(Face_handle f, int i, + Vertex_handle vaa, + Vertex_handle vbb, + Exact_predicates_tag); private: //made private to avoid using the Triangulation_2 version Vertex_handle move(Vertex_handle v, const Point &) @@ -649,16 +675,26 @@ insert(const Point& a, Locate_type lt, Face_handle loc, int li) Vertex_handle v1, v2; bool insert_in_constrained_edge = false; - if ( lt == Triangulation::EDGE && loc->is_constrained(li) ){ + if ( lt == Triangulation::EDGE && loc->is_constrained(li) ) + { + if(boost::is_same::value) + throw Intersection_of_constraints_exception(); + insert_in_constrained_edge = true; v1=loc->vertex(ccw(li)); //endpoint of the constraint v2=loc->vertex(cw(li)); // endpoint of the constraint } va = Triangulation::insert(a,lt,loc,li); - if (insert_in_constrained_edge) update_constraints_incident(va, v1,v2); - else if(lt != Triangulation::VERTEX) clear_constraints_incident(va); - if (dimension() == 2) update_constraints_opposite(va); + + if (insert_in_constrained_edge) + update_constraints_incident(va, v1,v2); + else if(lt != Triangulation::VERTEX) + clear_constraints_incident(va); + + if (dimension() == 2) + update_constraints_opposite(va); + return va; } @@ -719,7 +755,21 @@ insert_constraint(Vertex_handle vaa, Vertex_handle vbb) Face_handle fr; int i; - if(includes_edge(vaa,vbb,vi,fr,i)) { + if(includes_edge(vaa,vbb,vi,fr,i)) + { + // if the segment (or a subpart of the segment) that we are trying to constraint is already + // present in the triangulation and is already marked as constrained, + // then this is an intersection + if(boost::is_same::value) { + if(dimension() == 1) { + if(fr->is_constrained(2)) + throw Intersection_of_constraints_exception(); + } else { + if(fr->is_constrained(i)) + throw Intersection_of_constraints_exception(); + } + } + mark_constraint(fr,i); if (vi != vbb) { stack.push(std::make_pair(vi,vbb)); @@ -729,7 +779,6 @@ insert_constraint(Vertex_handle vaa, Vertex_handle vbb) List_faces intersected_faces; List_edges conflict_boundary_ab, conflict_boundary_ba; - bool intersection = find_intersected_faces( vaa, vbb, intersected_faces, conflict_boundary_ab, @@ -871,9 +920,20 @@ Constrained_triangulation_2:: intersect(Face_handle , int , Vertex_handle , Vertex_handle , - No_intersection_tag) + No_constraint_intersection_tag) { + throw Intersection_of_constraints_exception(); + return Vertex_handle() ; +} +template +typename Constrained_triangulation_2::Vertex_handle +Constrained_triangulation_2:: +intersect(Face_handle , int , + Vertex_handle , + Vertex_handle , + No_constraint_intersection_requiring_constructions_tag) +{ throw Intersection_of_constraints_exception(); return Vertex_handle() ; } @@ -898,7 +958,7 @@ intersect(Face_handle f, int i, "would avoid cascading intersection computation\n" " and be much more efficient\n" "This message is shown only if CGAL_NO_CDT_2_WARNING" - "is not defined.\n"); + " is not defined.\n"); #endif const Point& pa = vaa->point(); const Point& pb = vbb->point(); @@ -1411,16 +1471,29 @@ operator>>(std::istream& is, template bool intersection(const Gt& , - const typename Gt::Point_2& , - const typename Gt::Point_2& , - const typename Gt::Point_2& , - const typename Gt::Point_2& , - typename Gt::Point_2& , - No_intersection_tag) + const typename Gt::Point_2& , + const typename Gt::Point_2& , + const typename Gt::Point_2& , + const typename Gt::Point_2& , + typename Gt::Point_2& , + No_constraint_intersection_tag) { return false; } - + +template +bool +intersection(const Gt& , + const typename Gt::Point_2& , + const typename Gt::Point_2& , + const typename Gt::Point_2& , + const typename Gt::Point_2& , + typename Gt::Point_2& , + No_constraint_intersection_requiring_constructions_tag) +{ + return false; +} + template bool intersection(const Gt& gt, @@ -1531,11 +1604,23 @@ compute_intersection(const Gt& gt, template int limit_intersection(const Gt& , - const typename Gt::Point_2& , - const typename Gt::Point_2& , - const typename Gt::Point_2& , - const typename Gt::Point_2& , - No_intersection_tag) + const typename Gt::Point_2& , + const typename Gt::Point_2& , + const typename Gt::Point_2& , + const typename Gt::Point_2& , + No_constraint_intersection_tag) +{ + return 0; +} + +template +int +limit_intersection(const Gt& , + const typename Gt::Point_2& , + const typename Gt::Point_2& , + const typename Gt::Point_2& , + const typename Gt::Point_2& , + No_constraint_intersection_requiring_constructions_tag) { return 0; } diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h index dae5e8c0440..b9c2ef0d4f7 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -676,21 +677,25 @@ public: return cid; } - virtual Vertex_handle intersect(Face_handle f, int i, - Vertex_handle vaa, - Vertex_handle vbb); - Vertex_handle intersect(Face_handle f, int i, - Vertex_handle vaa, - Vertex_handle vbb, - No_intersection_tag); - Vertex_handle intersect(Face_handle f, int i, - Vertex_handle vaa, - Vertex_handle vbb, - Exact_intersections_tag); - Vertex_handle intersect(Face_handle f, int i, - Vertex_handle vaa, - Vertex_handle vbb, - Exact_predicates_tag); + virtual Vertex_handle intersect(Face_handle f, int i, + Vertex_handle vaa, + Vertex_handle vbb); + Vertex_handle intersect(Face_handle f, int i, + Vertex_handle vaa, + Vertex_handle vbb, + No_constraint_intersection_tag); + Vertex_handle intersect(Face_handle f, int i, + Vertex_handle vaa, + Vertex_handle vbb, + No_constraint_intersection_requiring_constructions_tag); + Vertex_handle intersect(Face_handle f, int i, + Vertex_handle vaa, + Vertex_handle vbb, + Exact_intersections_tag); + Vertex_handle intersect(Face_handle f, int i, + Vertex_handle vaa, + Vertex_handle vbb, + Exact_predicates_tag); // REMOVAL @@ -1018,11 +1023,16 @@ insert(const Point& a, Locate_type lt, Face_handle loc, int li) Vertex_handle v1, v2; bool insert_in_constrained_edge = false; - if ( lt == Triangulation::EDGE && loc->is_constrained(li) ){ + if ( lt == Triangulation::EDGE && loc->is_constrained(li) ) + { + if(boost::is_same::value) + throw typename Tr::Intersection_of_constraints_exception(); + insert_in_constrained_edge = true; v1=loc->vertex(ccw(li)); //endpoint of the constraint v2=loc->vertex(cw(li)); // endpoint of the constraint } + Vertex_handle va = Triangulation::insert(a,lt,loc,li); // update the hierarchy if (insert_in_constrained_edge) { @@ -1044,16 +1054,24 @@ intersect(Face_handle f, int i, template typename Constrained_triangulation_plus_2
    :: Vertex_handle Constrained_triangulation_plus_2:: - -intersect(Face_handle , int , - Vertex_handle , - Vertex_handle , - No_intersection_tag) +intersect(Face_handle, int, + Vertex_handle, + Vertex_handle, + No_constraint_intersection_tag) { - std::cerr << " sorry, this triangulation does not deal with" - << std::endl - << " intersecting constraints" << std::endl; - CGAL_triangulation_assertion(false); + throw typename Tr::Intersection_of_constraints_exception(); + return Vertex_handle(); +} + +template +typename Constrained_triangulation_plus_2:: Vertex_handle +Constrained_triangulation_plus_2:: +intersect(Face_handle, int, + Vertex_handle, + Vertex_handle, + No_constraint_intersection_requiring_constructions_tag) +{ + throw typename Tr::Intersection_of_constraints_exception(); return Vertex_handle(); } diff --git a/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h b/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h index 1b490a1427d..91d58c4b9dc 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h @@ -28,12 +28,11 @@ namespace CGAL { // T is expected to be Vertex_handle // Compare is a comparison operator for type T -// Data is intended to store info on a Vertex -template +// Point the point type of vertices +template class Polyline_constraint_hierarchy_2 { public: - typedef Data Point; typedef T Vertex_handle; typedef std::pair Edge; typedef std::pair Constraint; @@ -43,14 +42,12 @@ private: class Node { public: explicit Node(Vertex_handle vh, bool input = false) - : vertex_(vh), point_(vh->point()), id(-1), input(input) + : vertex_(vh), id(-1), input(input) {} - Point& point() { return point_; } - const Point& point() const { return point_; } + const Point& point() const { return vertex_->point(); } Vertex_handle vertex() const { return vertex_; } private: Vertex_handle vertex_; - Point point_; public: int id; bool input; @@ -65,7 +62,7 @@ public: : public boost::iterator_adaptor< Point_it , typename Vertex_list::all_iterator - , Point + , const Point > { public: @@ -73,7 +70,7 @@ public: Point_it(typename Vertex_list::all_iterator it) : Point_it::iterator_adaptor_(it) {} private: friend class boost::iterator_core_access; - Point& dereference() const { return this->base()->point(); } + const Point& dereference() const { return this->base()->point(); } }; // only nodes with a vertex_handle that is still in the triangulation @@ -150,7 +147,7 @@ public: }; class Context { - friend class Polyline_constraint_hierarchy_2; + friend class Polyline_constraint_hierarchy_2; private: Vertex_list* enclosing; Vertex_it pos; @@ -284,8 +281,8 @@ public: void print() const; }; -template -Polyline_constraint_hierarchy_2:: +template +Polyline_constraint_hierarchy_2:: Polyline_constraint_hierarchy_2(const Polyline_constraint_hierarchy_2& ch) : comp(ch.comp) , sc_to_c_map(Pair_compare(comp)) @@ -293,17 +290,17 @@ Polyline_constraint_hierarchy_2(const Polyline_constraint_hierarchy_2& ch) copy(ch); } -template -Polyline_constraint_hierarchy_2& -Polyline_constraint_hierarchy_2:: +template +Polyline_constraint_hierarchy_2& +Polyline_constraint_hierarchy_2:: operator=(const Polyline_constraint_hierarchy_2& ch){ copy(ch); return *this; } -template +template void -Polyline_constraint_hierarchy_2:: +Polyline_constraint_hierarchy_2:: copy(const Polyline_constraint_hierarchy_2& ch1) { // create a identity transfer vertex map @@ -318,9 +315,9 @@ copy(const Polyline_constraint_hierarchy_2& ch1) copy(ch1, vmap); } -template +template void -Polyline_constraint_hierarchy_2:: +Polyline_constraint_hierarchy_2:: copy(const Polyline_constraint_hierarchy_2& ch1, std::map& vmap) // copy with a transfer vertex map { @@ -365,9 +362,9 @@ copy(const Polyline_constraint_hierarchy_2& ch1, std::map +template void -Polyline_constraint_hierarchy_2:: +Polyline_constraint_hierarchy_2:: swap(Polyline_constraint_hierarchy_2& ch) { constraint_set.swap(ch.constraint_set); @@ -376,16 +373,16 @@ swap(Polyline_constraint_hierarchy_2& ch) /* -template -bool Polyline_constraint_hierarchy_2:: +template +bool Polyline_constraint_hierarchy_2:: is_constrained_edge(T va, T vb) const { return( c_to_sc_map.find(make_edge(va, vb)) != c_to_sc_map.end() ); } */ -template -bool Polyline_constraint_hierarchy_2:: +template +bool Polyline_constraint_hierarchy_2:: is_subconstrained_edge(T va, T vb) const { return( sc_to_c_map.find(make_edge(va, vb)) != sc_to_c_map.end() ); @@ -393,8 +390,8 @@ is_subconstrained_edge(T va, T vb) const // af: obsolete -template -bool Polyline_constraint_hierarchy_2:: +template +bool Polyline_constraint_hierarchy_2:: enclosing_constraint(Edge he, Constraint& hc) const { Context_iterator hcit, past; @@ -405,8 +402,8 @@ enclosing_constraint(Edge he, Constraint& hc) const // used by Constrained_triangulation_plus_2::intersect with Exact_intersection_tag -template -bool Polyline_constraint_hierarchy_2:: +template +bool Polyline_constraint_hierarchy_2:: enclosing_constraint(T vaa, T vbb, T& va, T& vb) const { Context_iterator hcit, past; @@ -433,8 +430,8 @@ enclosing_constraint(T vaa, T vbb, T& va, T& vb) const } // af: obsolete -template -bool Polyline_constraint_hierarchy_2:: +template +bool Polyline_constraint_hierarchy_2:: enclosing_constraints(T vaa, T vbb , Constraint_list& hcl) const { Context_iterator hcit, past; @@ -446,9 +443,9 @@ enclosing_constraints(T vaa, T vbb , Constraint_list& hcl) const return true; } -template -typename Polyline_constraint_hierarchy_2::Context -Polyline_constraint_hierarchy_2:: +template +typename Polyline_constraint_hierarchy_2::Context +Polyline_constraint_hierarchy_2:: context(T va, T vb) { Context_iterator hcit, past; @@ -456,9 +453,9 @@ context(T va, T vb) return *hcit; } -template +template std::size_t -Polyline_constraint_hierarchy_2:: +Polyline_constraint_hierarchy_2:: number_of_enclosing_constraints(T va, T vb) const { Context_list* hcl = nullptr; @@ -467,9 +464,9 @@ number_of_enclosing_constraints(T va, T vb) const return hcl->size(); } -template -typename Polyline_constraint_hierarchy_2::Context_iterator -Polyline_constraint_hierarchy_2:: +template +typename Polyline_constraint_hierarchy_2::Context_iterator +Polyline_constraint_hierarchy_2:: contexts_begin(T va, T vb) const { Context_iterator first, last; @@ -477,9 +474,9 @@ contexts_begin(T va, T vb) const return first; } -template -typename Polyline_constraint_hierarchy_2::Context_iterator -Polyline_constraint_hierarchy_2:: +template +typename Polyline_constraint_hierarchy_2::Context_iterator +Polyline_constraint_hierarchy_2:: contexts_end(T va, T vb) const { Context_iterator first, last; @@ -487,9 +484,9 @@ contexts_end(T va, T vb) const return last; } -template +template void -Polyline_constraint_hierarchy_2:: +Polyline_constraint_hierarchy_2:: swap(Constraint_id first, Constraint_id second){ // We have to look at all subconstraints for(Vertex_it it = first.vl_ptr()->skip_begin(), succ = it, end = first.vl_ptr()->skip_end(); @@ -543,9 +540,9 @@ swap(Constraint_id first, Constraint_id second){ } -template +template void -Polyline_constraint_hierarchy_2:: +Polyline_constraint_hierarchy_2:: remove_constraint(Constraint_id cid){ constraint_set.erase(cid); @@ -580,8 +577,8 @@ remove_constraint(Constraint_id cid){ // This function removes vertex v from the polyline constraint // It only works for one polyline passing through v // and for the case that the constrained edge u,w has no intersections -template -void Polyline_constraint_hierarchy_2::simplify(Vertex_it uc, +template +void Polyline_constraint_hierarchy_2::simplify(Vertex_it uc, Vertex_it vc, Vertex_it wc) @@ -628,9 +625,9 @@ void Polyline_constraint_hierarchy_2::simplify(Vertex_it uc, } -template +template std::size_t -Polyline_constraint_hierarchy_2::remove_points_without_corresponding_vertex(Constraint_id cid) +Polyline_constraint_hierarchy_2::remove_points_without_corresponding_vertex(Constraint_id cid) { std::size_t n = 0; for(Point_it it = points_in_constraint_begin(cid); @@ -643,9 +640,9 @@ Polyline_constraint_hierarchy_2::remove_points_without_correspon return n; } -template +template std::size_t -Polyline_constraint_hierarchy_2::remove_points_without_corresponding_vertex() +Polyline_constraint_hierarchy_2::remove_points_without_corresponding_vertex() { std::size_t n = 0; for(C_iterator it = constraint_set.begin(); it!= constraint_set.end(); ++it){ @@ -655,9 +652,9 @@ Polyline_constraint_hierarchy_2::remove_points_without_correspon } -template -typename Polyline_constraint_hierarchy_2::Constraint_id -Polyline_constraint_hierarchy_2::concatenate(Constraint_id first, Constraint_id second) +template +typename Polyline_constraint_hierarchy_2::Constraint_id +Polyline_constraint_hierarchy_2::concatenate(Constraint_id first, Constraint_id second) { constraint_set.erase(first); constraint_set.erase(second); @@ -708,9 +705,9 @@ Polyline_constraint_hierarchy_2::concatenate(Constraint_id first return first; } -template -typename Polyline_constraint_hierarchy_2::Constraint_id -Polyline_constraint_hierarchy_2::concatenate2(Constraint_id first, Constraint_id second) +template +typename Polyline_constraint_hierarchy_2::Constraint_id +Polyline_constraint_hierarchy_2::concatenate2(Constraint_id first, Constraint_id second) { constraint_set.erase(first); constraint_set.erase(second); @@ -764,9 +761,9 @@ Polyline_constraint_hierarchy_2::concatenate2(Constraint_id firs // split a constraint in two constraints, so that vcit becomes the first // vertex of the new constraint // returns the new constraint -template -typename Polyline_constraint_hierarchy_2::Constraint_id -Polyline_constraint_hierarchy_2::split(Constraint_id first, Vertex_it vcit) +template +typename Polyline_constraint_hierarchy_2::Constraint_id +Polyline_constraint_hierarchy_2::split(Constraint_id first, Vertex_it vcit) { constraint_set.erase(first); Vertex_list* second = new Vertex_list; @@ -798,9 +795,9 @@ Polyline_constraint_hierarchy_2::split(Constraint_id first, Vert return second; } -template -typename Polyline_constraint_hierarchy_2::Constraint_id -Polyline_constraint_hierarchy_2::split2(Constraint_id first, Vertex_it vcit) +template +typename Polyline_constraint_hierarchy_2::Constraint_id +Polyline_constraint_hierarchy_2::split2(Constraint_id first, Vertex_it vcit) { constraint_set.erase(first); Vertex_list* second = new Vertex_list; @@ -837,9 +834,9 @@ Polyline_constraint_hierarchy_2::split2(Constraint_id first, Ver when a constraint is inserted, it is, at first, both a constraint and a subconstraint */ -template -typename Polyline_constraint_hierarchy_2::Vertex_list* -Polyline_constraint_hierarchy_2:: +template +typename Polyline_constraint_hierarchy_2::Vertex_list* +Polyline_constraint_hierarchy_2:: insert_constraint(T va, T vb){ Edge he = make_edge(va, vb); Vertex_list* children = new Vertex_list; @@ -865,9 +862,9 @@ insert_constraint(T va, T vb){ } -template -typename Polyline_constraint_hierarchy_2::Vertex_list* -Polyline_constraint_hierarchy_2:: +template +typename Polyline_constraint_hierarchy_2::Vertex_list* +Polyline_constraint_hierarchy_2:: insert_constraint_old_API(T va, T vb){ Edge he = make_edge(va, vb); @@ -894,9 +891,9 @@ insert_constraint_old_API(T va, T vb){ } -template +template void -Polyline_constraint_hierarchy_2:: +Polyline_constraint_hierarchy_2:: append_constraint(Constraint_id cid, T va, T vb){ Edge he = make_edge(va, vb); Context_list* fathers; @@ -919,8 +916,8 @@ append_constraint(Constraint_id cid, T va, T vb){ } -template -void Polyline_constraint_hierarchy_2:: +template +void Polyline_constraint_hierarchy_2:: clear() { C_iterator cit; @@ -940,8 +937,8 @@ clear() } -template -bool Polyline_constraint_hierarchy_2:: +template +bool Polyline_constraint_hierarchy_2:: next_along_sc(T va, T vb, T& w) const { // find the next vertex after vb along any enclosing constrained @@ -969,8 +966,8 @@ next_along_sc(T va, T vb, T& w) const Attention, le point v DOIT etre un point de Steiner, et les segments va,v et v,vb sont des sous contraintes. */ -template -void Polyline_constraint_hierarchy_2:: +template +void Polyline_constraint_hierarchy_2:: remove_Steiner(T v, T va, T vb) { // remove a Steiner point @@ -1001,16 +998,16 @@ remove_Steiner(T v, T va, T vb) same as add_Steiner precondition : va,vb est une souscontrainte. */ -template -void Polyline_constraint_hierarchy_2:: +template +void Polyline_constraint_hierarchy_2:: split_constraint(T va, T vb, T vc){ add_Steiner(va, vb, vc); } -template +template void -Polyline_constraint_hierarchy_2:: +Polyline_constraint_hierarchy_2:: add_Steiner(T va, T vb, T vc){ Context_list* hcl=nullptr; if(!get_contexts(va,vb,hcl)) CGAL_triangulation_assertion(false); @@ -1061,19 +1058,19 @@ add_Steiner(T va, T vb, T vc){ } -template +template inline -typename Polyline_constraint_hierarchy_2::Edge -Polyline_constraint_hierarchy_2:: +typename Polyline_constraint_hierarchy_2::Edge +Polyline_constraint_hierarchy_2:: make_edge(T va, T vb) const { return comp(va, vb) ? Edge(va,vb) : Edge(vb,va); } -template +template inline bool -Polyline_constraint_hierarchy_2:: +Polyline_constraint_hierarchy_2:: get_contexts(T va, T vb, Context_list* & hcl) const { Sc_iterator sc_iter = sc_to_c_map.find(make_edge(va,vb)); @@ -1082,10 +1079,10 @@ get_contexts(T va, T vb, Context_list* & hcl) const return true; } -template +template inline bool -Polyline_constraint_hierarchy_2:: +Polyline_constraint_hierarchy_2:: get_contexts(T va, T vb, Context_iterator& ctxt, Context_iterator& past) const @@ -1099,19 +1096,19 @@ get_contexts(T va, T vb, -template +template inline -typename Polyline_constraint_hierarchy_2::Vertex_it -Polyline_constraint_hierarchy_2:: +typename Polyline_constraint_hierarchy_2::Vertex_it +Polyline_constraint_hierarchy_2:: get_pos(T va, T vb) const //return pos in the first context { return (*sc_to_c_map.find(make_edge(va,vb))).second->begin().pos; } -template +template void -Polyline_constraint_hierarchy_2:: +Polyline_constraint_hierarchy_2:: oriented_end(T va, T vb, T& vc) const { Context_iterator ctxt, past; @@ -1123,9 +1120,9 @@ oriented_end(T va, T vb, T& vc) const } -template +template void -Polyline_constraint_hierarchy_2:: +Polyline_constraint_hierarchy_2:: print() const { C_iterator hcit; diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h index 4c937317dba..eaa9e936e1c 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h @@ -24,6 +24,69 @@ #include #include +#include + +enum Intersection_type { + NO_INTERSECTION = 0, + INTERSECTION_WITHOUT_CONSTRUCTION, + INTERSECTION +}; + +template +void +_test_cdt_throwing(const Pt& p0, const Pt& p1, const Pt& p2, const Pt& p3, + const Intersection_type& intersection_type) +{ + std::cout << "test_cdt_throwing [" << p0 << "] - [" << p1 << "] || [" << p2 << "] - [" << p3 << "]" << std::endl; + + try + { + Triang tr; + tr.insert_constraint(p0, p1); + tr.insert_constraint(p2, p3); + } + catch (typename Triang::Intersection_of_constraints_exception& /*e*/) + { + std::cout << "threw, expected: " << intersection_type << std::endl; + + // There must have been an intersection + assert(intersection_type != NO_INTERSECTION); + + // If the intersection requires no construction, then only 'No_constraint_intersection_tag' throws + if(intersection_type == INTERSECTION_WITHOUT_CONSTRUCTION) + { + assert((boost::is_same::value)); + } + else // threw and it's not a construction-less intersection ---> real intersection + { + assert(intersection_type == INTERSECTION); +#if !defined(CGAL_NO_DEPRECATED_CODE) && defined(CGAL_NO_DEPRECATION_WARNINGS) + assert((boost::is_same::value) || + (boost::is_same::value) || + (boost::is_same::value)); +#else + assert((boost::is_same::value) || + (boost::is_same::value)); +#endif + } + + return; + } + + if(intersection_type == INTERSECTION_WITHOUT_CONSTRUCTION) + { + // Even with an intersection without construction, 'No_constraint_intersection_tag' should have thrown + assert(!(boost::is_same::value)); + } + else if(intersection_type == INTERSECTION) + { + assert(!(boost::is_same::value) && + !(boost::is_same::value)); +#if !defined(CGAL_NO_DEPRECATED_CODE) && defined(CGAL_NO_DEPRECATION_WARNINGS) + assert(!(boost::is_same::value)); +#endif + } +} template void @@ -134,7 +197,7 @@ _test_cls_constrained_triangulation(const Triang &) // between constrained and Constrained Delaunay Triang T2_5; for (int j=0; j < 20; j++) T2_5.insert(lpt[j]); - T2_5.insert( Point(1,0.5), Point(2.5, 3.5)); + T2_5.insert_constraint( Point(1,0.5), Point(2.5, 3.5)); T2_5.is_valid(); @@ -220,8 +283,9 @@ _test_cls_constrained_triangulation(const Triang &) assert(T1_2.is_edge(vha,vhb, fh, ih)); assert(fh->is_constrained(ih)); T1_2.remove_constrained_edge(fh,ih); + assert(!fh->is_constrained(ih)); assert(T1_2.is_valid()); - T1_2.insert(Point(0,0),Point(3,2)); + T1_2.insert_constraint(Point(0,0),Point(3,2)); fh = T1_2.locate(Point(3,2),lt,li); assert( lt == Triang::VERTEX ); vhb = fh->vertex(li); assert(T1_2.are_there_incident_constraints(vhb)); @@ -241,7 +305,6 @@ _test_cls_constrained_triangulation(const Triang &) assert(ic_edges.size() == 1); T1_2.remove(vha); assert(T1_2.is_valid()); - // remove_constraint and remove 2 dim std::cout << "remove_constrained_edge and remove 2-dim " << std::endl; @@ -290,4 +353,28 @@ _test_cls_constrained_triangulation(const Triang &) T2_6.insert_constraint(Point(1,0.1), Point(2,0.2)); assert(std::distance(T2_6.constrained_edges_begin(), T2_6.constrained_edges_end()) == 1); + + // test throwing/not throwing on intersecting constraints + _test_cdt_throwing(Point(0, 0), Point(1, 1), Point(2, 2), Point(2, 3), NO_INTERSECTION); + _test_cdt_throwing(Point(0, 0), Point(1, 1), Point(1, 1), Point(2, 2), NO_INTERSECTION); // common point + _test_cdt_throwing(Point(2, 2), Point(0, 0), Point(2, 2), Point(3, 3), NO_INTERSECTION); // ^ + _test_cdt_throwing(Point(0, 0), Point(2, 2), Point(1, 1), Point(3, 3), INTERSECTION_WITHOUT_CONSTRUCTION); // overlapping + _test_cdt_throwing(Point(2, 2), Point(0, 0), Point(1, 1), Point(3, 3), INTERSECTION_WITHOUT_CONSTRUCTION); // ^ + _test_cdt_throwing(Point(2, 2), Point(0, 0), Point(0, 0), Point(3, 3), INTERSECTION_WITHOUT_CONSTRUCTION); // ^ + _test_cdt_throwing(Point(2, 2), Point(0, 0), Point(3, 3), Point(0, 0), INTERSECTION_WITHOUT_CONSTRUCTION); // ^ + _test_cdt_throwing(Point(0, 0), Point(3, 3), Point(1, 1), Point(2, 2), INTERSECTION_WITHOUT_CONSTRUCTION); // contains + _test_cdt_throwing(Point(3, 3), Point(0, 0), Point(1, 1), Point(2, 2), INTERSECTION_WITHOUT_CONSTRUCTION); // ^ + _test_cdt_throwing(Point(1, 1), Point(2, 2), Point(3, 3), Point(0, 0), INTERSECTION_WITHOUT_CONSTRUCTION); // ^ + _test_cdt_throwing(Point(2, 2), Point(1, 1), Point(3, 3), Point(0, 0), INTERSECTION_WITHOUT_CONSTRUCTION); // ^ + _test_cdt_throwing(Point(3, 3), Point(0, 0), Point(0, 0), Point(3, 3), INTERSECTION_WITHOUT_CONSTRUCTION); // same constraint + _test_cdt_throwing(Point(3, 3), Point(0, 0), Point(1, 1), Point(1, 1), INTERSECTION_WITHOUT_CONSTRUCTION); // degenerate entry + _test_cdt_throwing(Point(0, 0), Point(0, 0), Point(0, 0), Point(0, 0), NO_INTERSECTION); // degenerate same entry + + // extremity on the interior of another segment + _test_cdt_throwing(Point(0, 0), Point(2, 0), Point(1, 0), Point(1, 4), INTERSECTION_WITHOUT_CONSTRUCTION); + + // non aligned + _test_cdt_throwing(Point(0, 0), Point(3, 3), Point(1, 0), Point(4, 0), NO_INTERSECTION); + _test_cdt_throwing(Point(0, 2), Point(2, 2), Point(1, 0), Point(1, 3), INTERSECTION); // generic intersection + _test_cdt_throwing(Point(0, 0), Point(2, 2), Point(1, 3), Point(1, 0), INTERSECTION); } diff --git a/Triangulation_2/test/Triangulation_2/issue_4405.cpp b/Triangulation_2/test/Triangulation_2/issue_4405.cpp new file mode 100644 index 00000000000..142ceaaa348 --- /dev/null +++ b/Triangulation_2/test/Triangulation_2/issue_4405.cpp @@ -0,0 +1,39 @@ +#define CGAL_CDT_2_DEBUG_INTERSECTIONS 1 +#include +#include +#include +#include +#include + +typedef CGAL::Epick Kernel; +typedef Kernel::FT FieldNumberType; +typedef Kernel::Point_2 Point2; +typedef Kernel::Point_3 Point3; +struct FaceInfo2 +{ + unsigned long long m_id; +}; +typedef CGAL::Projection_traits_xy_3 TriangulationTraits; +typedef CGAL::Triangulation_vertex_base_with_id_2 VertexBaseWithId; +typedef CGAL::Triangulation_vertex_base_2 VertexBase; +typedef CGAL::Triangulation_face_base_with_info_2 FaceBaseWithInfo; +typedef CGAL::Constrained_triangulation_face_base_2 FaceBase; +typedef CGAL::Triangulation_data_structure_2 TriangulationData; +typedef CGAL::Constrained_Delaunay_triangulation_2 ConstrainedTriangulation; + typedef CGAL::Constrained_triangulation_plus_2 CDT; + +int main() +{ + CDT cdt; + const Point3 A(539.5294108288881, 332.45151278002265, 109.660400390625); + const Point3 B(538.779296875, 329.10546875, 109.707275390625); + const Point3 C(539.74609375, 332.431640625, 109.660400390625); + const Point3 D(539.68266371486789, 333.13513011783971, 109.649658203125); + const Point3 E(539.52898179930912, 332.45155212665065, 109.660400390625); + + cdt.insert_constraint(A, B); + cdt.insert_constraint(C, A); + cdt.insert_constraint(D, B); + cdt.insert_constraint(C, E); + return 0; +} diff --git a/Triangulation_2/test/Triangulation_2/test_cdt_2_projection_traits_special_case.cpp b/Triangulation_2/test/Triangulation_2/test_cdt_2_projection_traits_special_case.cpp index f37eb4174a1..26693b95a28 100644 --- a/Triangulation_2/test/Triangulation_2/test_cdt_2_projection_traits_special_case.cpp +++ b/Triangulation_2/test/Triangulation_2/test_cdt_2_projection_traits_special_case.cpp @@ -29,10 +29,10 @@ bool test(std::string test_name) std::cerr << "Testing " << test_name << std::endl; const unsigned nb_input_points = sizeof(input)/sizeof(vec); - typedef CGAL::Constrained_triangulation_face_base_2 CDT_2_fb; - typedef CGAL::Triangulation_vertex_base_2 CDT_2_vb; - typedef CGAL::Triangulation_data_structure_2 CDT_2_tds; - typedef CGAL::No_intersection_tag CDT_2_itag; + typedef CGAL::Constrained_triangulation_face_base_2 CDT_2_fb; + typedef CGAL::Triangulation_vertex_base_2 CDT_2_vb; + typedef CGAL::Triangulation_data_structure_2 CDT_2_tds; + typedef CGAL::No_constraint_intersection_requiring_constructions_tag CDT_2_itag; typedef CGAL::Constrained_Delaunay_triangulation_2 CDT_2; diff --git a/Triangulation_2/test/Triangulation_2/test_const_del_triangulation_2.cpp b/Triangulation_2/test/Triangulation_2/test_const_del_triangulation_2.cpp index 2ef4cd90a17..3f1c18b5d73 100644 --- a/Triangulation_2/test/Triangulation_2/test_const_del_triangulation_2.cpp +++ b/Triangulation_2/test/Triangulation_2/test_const_del_triangulation_2.cpp @@ -30,9 +30,8 @@ template class CGAL::Constrained_Delaunay_triangulation_2; int main() { - std::cout << "Testing constrained_Delaunay_triangulation "<< std::endl; - std::cout << " with No_intersection_tag : " << std::endl; + std::cout << " with No_constraint_intersection_requiring_constructions_tag : " << std::endl; typedef CGAL::Constrained_Delaunay_triangulation_2 CDt2; _test_cls_const_Del_triangulation(CDt2()); diff --git a/Triangulation_2/test/Triangulation_2/test_constrained_triangulation_2.cpp b/Triangulation_2/test/Triangulation_2/test_constrained_triangulation_2.cpp index 592b3239a05..18746efd090 100644 --- a/Triangulation_2/test/Triangulation_2/test_constrained_triangulation_2.cpp +++ b/Triangulation_2/test/Triangulation_2/test_constrained_triangulation_2.cpp @@ -20,6 +20,11 @@ // coordinator : INRIA Sophia-Antipolis // ============================================================================ +#include + +// Don't want to be warned about using CDT_2 (and not CDT_2+) with an exact number type +#define CGAL_NO_CDT_2_WARNING + #include #include @@ -31,8 +36,20 @@ template class CGAL::Constrained_triangulation_2; int main() { std::cout << "Testing constrained_triangulation "<< std::endl; - std::cout << " with No_intersection_tag : " << std::endl; - typedef CGAL::Constrained_triangulation_2 Ct; + std::cout << " with No_constraint_intersection_tag : " << std::endl; + typedef CGAL::No_constraint_intersection_tag CItag; + typedef CGAL::Constrained_triangulation_2 Ctwoc; + _test_cls_constrained_triangulation(Ctwoc()); + + std::cout << "Testing constrained_triangulation "<< std::endl; + std::cout << " with No_constraint_intersection_requiring_constructions_tag (default): " << std::endl; + +#ifndef CGAL_NO_DEPRECATED_CODE + typedef CGAL::No_intersection_tag CDItag; + typedef CGAL::Constrained_triangulation_2 Ct; +#else + typedef CGAL::Constrained_triangulation_2 Ct; +#endif _test_cls_constrained_triangulation(Ct()); std::cout << "Testing constrained_triangulation "<< std::endl; diff --git a/Triangulation_3/benchmark/Triangulation_3/CMakeLists.txt b/Triangulation_3/benchmark/Triangulation_3/CMakeLists.txt new file mode 100644 index 00000000000..c6892abd08e --- /dev/null +++ b/Triangulation_3/benchmark/Triangulation_3/CMakeLists.txt @@ -0,0 +1,62 @@ +# Created by the script cgal_create_CMakeLists +# This is the CMake script for compiling a set of CGAL applications. + +cmake_minimum_required(VERSION 3.1...3.15) + +project( Triangulation_3 ) + + +# CGAL and its components +find_package( CGAL QUIET COMPONENTS ) + +if ( NOT CGAL_FOUND ) + + message(STATUS "This project requires the CGAL library, and will not be compiled.") + return() + +endif() + + +# Boost and its components +find_package( Boost REQUIRED ) + +if ( NOT Boost_FOUND ) + + message(STATUS "This project requires the Boost library, and will not be compiled.") + + return() + +endif() + +# include for local directory + +# include for local package + + +# Creating entries for all C++ files with "main" routine +# ########################################################## + + +create_single_source_cgal_program( "incident_edges.cpp" ) + +create_single_source_cgal_program( "simple_2.cpp" ) + +create_single_source_cgal_program( "simple.cpp" ) + +create_single_source_cgal_program( "Triangulation_benchmark_3.cpp" ) + +find_package(benchmark) + +if(TARGET benchmark::benchmark) + find_package(TBB REQUIRED) + include( CGAL_target_use_TBB ) + + create_single_source_cgal_program( "DT3_benchmark_with_TBB.cpp" ) + CGAL_target_use_TBB(DT3_benchmark_with_TBB) + target_link_libraries(DT3_benchmark_with_TBB PRIVATE benchmark::benchmark) + + add_executable(DT3_benchmark_with_TBB_CCC_approximate_size DT3_benchmark_with_TBB.cpp) + CGAL_target_use_TBB(DT3_benchmark_with_TBB_CCC_approximate_size) + target_compile_definitions(DT3_benchmark_with_TBB_CCC_approximate_size PRIVATE CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE) + target_link_libraries(DT3_benchmark_with_TBB_CCC_approximate_size PRIVATE CGAL::CGAL benchmark::benchmark) +endif() diff --git a/Triangulation_3/benchmark/Triangulation_3/DT3_benchmark_with_TBB.cpp b/Triangulation_3/benchmark/Triangulation_3/DT3_benchmark_with_TBB.cpp new file mode 100644 index 00000000000..dad2b3c1871 --- /dev/null +++ b/Triangulation_3/benchmark/Triangulation_3/DT3_benchmark_with_TBB.cpp @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include + +#include +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef K::Point_3 Point_3; + +typedef CGAL::Triangulation_data_structure_3< + CGAL::Triangulation_vertex_base_3, + CGAL::Triangulation_cell_base_3, + CGAL::Parallel_tag> Tds; +typedef CGAL::Delaunay_triangulation_3 PDT; + +// global variables used by bench_dt3 +int argc; +char** argv; + + + +void bench_dt3(benchmark::State& state) { + CGAL::get_default_random() = CGAL::Random(0); + + std::vector points; + Point_3 p; + + std::ifstream in(argv[1]); + while(in >> p) + points.push_back(p); + + for(auto _ : state) { + CGAL::Bbox_3 bb = CGAL::bounding_box(points.begin(), points.end()).bbox(); + PDT::Lock_data_structure locking_ds(bb, 50); + + PDT pdt(points.begin(), points.end(), &locking_ds); + } + return; +} +BENCHMARK(bench_dt3)->Unit(benchmark::kMillisecond);; + + +int main(int argc, char* argv[]) +{ + benchmark::Initialize(&argc, argv); + ::argc = argc; + ::argv = argv; + benchmark::RunSpecifiedBenchmarks(); +} diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index 6f2f1f6807f..6941c6c8acf 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -58,6 +59,7 @@ #include #include #include +#include #ifndef CGAL_TRIANGULATION_3_DONT_INSERT_RANGE_OF_POINTS_WITH_INFO #include @@ -1266,6 +1268,17 @@ public: return v; } + // Internal function, cells should already be marked. + template + Vertex_handle _insert_in_small_hole(const Point& p, + const Cells& cells, + const Facets& facets ) + { + Vertex_handle v = _tds._insert_in_small_hole(cells, facets); + v->set_point(p); + return v; + } + // Internal function, cells should already be marked. template Vertex_handle _insert_in_hole(const Point& p, @@ -1320,7 +1333,10 @@ protected: CGAL_triangulation_precondition(tester(d)); // To store the boundary cells, in case we need to rollback - std::stack cell_stack; + typedef boost::container::small_vector SV; + SV sv; + std::stack cell_stack(sv); + cell_stack.push(d); d->tds_data().mark_in_conflict(); @@ -3742,15 +3758,14 @@ insert_in_conflict(const Point& p, // Ok, we really insert the point now. // First, find the conflict region. - std::vector cells; - cells.reserve(32); + boost::container::small_vector cells; Facet facet; + boost::container::small_vector facets; + // Parallel if(could_lock_zone) { - std::vector facets; - facets.reserve(32); find_conflicts(c, tester, @@ -3772,28 +3787,30 @@ insert_in_conflict(const Point& p, } return Vertex_handle(); } - - facet = facets.back(); } // Sequential else { - cells.reserve(32); find_conflicts(c, tester, make_triple( - Oneset_iterator(facet), + std::back_inserter(facets), std::back_inserter(cells), Emptyset_iterator())); } + facet = facets.back(); + // Remember the points that are hidden by the conflicting cells, // as they will be deleted during the insertion. hider.process_cells_in_conflict(cells.begin(), cells.end()); - Vertex_handle v = _insert_in_hole(p, - cells.begin(), cells.end(), - facet.first, facet.second); + Vertex_handle v = + tds().is_small_hole(facets.size()) ? + _insert_in_small_hole(p, cells, facets) : + _insert_in_hole(p, + cells.begin(), cells.end(), + facet.first, facet.second); // Store the hidden points in their new cells. hider.reinsert_vertices(v); diff --git a/Visibility_2/include/CGAL/Triangular_expansion_visibility_2.h b/Visibility_2/include/CGAL/Triangular_expansion_visibility_2.h index aa8423fa01c..12a9580ecef 100644 --- a/Visibility_2/include/CGAL/Triangular_expansion_visibility_2.h +++ b/Visibility_2/include/CGAL/Triangular_expansion_visibility_2.h @@ -66,13 +66,13 @@ public: typedef CGAL::Tag_true Supports_simple_polygon_category; private: - typedef CGAL::Triangulation_vertex_base_2 Vb; - typedef CGAL::Constrained_triangulation_face_base_2 Fb; - typedef CGAL::Triangulation_data_structure_2 TDS; - typedef CGAL::No_intersection_tag Itag; - typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; + typedef CGAL::Triangulation_vertex_base_2 Vb; + typedef CGAL::Constrained_triangulation_face_base_2 Fb; + typedef CGAL::Triangulation_data_structure_2 TDS; + typedef CGAL::No_constraint_intersection_requiring_constructions_tag Itag; + typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; - typedef std::pair Constraint; + typedef std::pair Constraint; // Functor to create edge constraints for the CDT out of Halfedges struct Make_constraint diff --git a/Visibility_2/package_info/Visibility_2/dependencies b/Visibility_2/package_info/Visibility_2/dependencies index df17db35a32..bdaf92f883b 100644 --- a/Visibility_2/package_info/Visibility_2/dependencies +++ b/Visibility_2/package_info/Visibility_2/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arrangement_on_surface_2 Circulator Distance_2 +Distance_3 Filtered_kernel HalfedgeDS Hash_map @@ -23,4 +24,3 @@ Surface_sweep_2 TDS_2 Triangulation_2 Visibility_2 -Distance_3 diff --git a/Voronoi_diagram_2/doc/Voronoi_diagram_2/CGAL/draw_voronoi_diagram_2.h b/Voronoi_diagram_2/doc/Voronoi_diagram_2/CGAL/draw_voronoi_diagram_2.h new file mode 100644 index 00000000000..ef273cb1734 --- /dev/null +++ b/Voronoi_diagram_2/doc/Voronoi_diagram_2/CGAL/draw_voronoi_diagram_2.h @@ -0,0 +1,17 @@ +namespace CGAL { + +/*! +\ingroup PkgDrawVoronoiDiagram2 + +opens a new window and draws `av2`, the `Voronoi_diagram_2` constructed from a Delaunay Graph which is a model of `DelaunayGraph_2` concept. +The class `Voronoi_diagram_2` provides an adaptor to view a triangulated Delaunay graph as their dual subdivision, the +Voronoi diagram. A call to this function is blocking, that is the program continues as soon as the user closes the window. + This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time. +\tparam V2 a model of the `AdaptationTraits_2` concept. +\param av2 the voronoi diagram to draw. + +*/ +template +void draw(const V2& av2); + +} /* namespace CGAL */ diff --git a/Voronoi_diagram_2/doc/Voronoi_diagram_2/PackageDescription.txt b/Voronoi_diagram_2/doc/Voronoi_diagram_2/PackageDescription.txt index 379a9b01b4e..a173d3af29b 100644 --- a/Voronoi_diagram_2/doc/Voronoi_diagram_2/PackageDescription.txt +++ b/Voronoi_diagram_2/doc/Voronoi_diagram_2/PackageDescription.txt @@ -12,6 +12,14 @@ /// \defgroup PkgVoronoiDiagram2Disks Voronoi Diagram of Disks /// \ingroup PkgVoronoiDiagram2Ref +/*! + \code + #include + \endcode +*/ +/// \defgroup PkgDrawVoronoiDiagram2 Draw a 2D Voronoi Diagram +/// \ingroup PkgVoronoiDiagram2Ref + /*! \addtogroup PkgVoronoiDiagram2Ref \todo check generated documentation @@ -81,5 +89,9 @@ performing this adaptation. - `CGAL::Segment_Delaunay_graph_degeneracy_removal_policy_2` - `CGAL::Segment_Delaunay_graph_caching_degeneracy_removal_policy_2` +\cgalCRPSection{Draw Voronoi Diagram} + +- \link PkgDrawVoronoiDiagram2 CGAL::draw() \endlink + */ diff --git a/Voronoi_diagram_2/doc/Voronoi_diagram_2/Voronoi_diagram_2.txt b/Voronoi_diagram_2/doc/Voronoi_diagram_2/Voronoi_diagram_2.txt index 163719da3aa..41b3f9828cf 100644 --- a/Voronoi_diagram_2/doc/Voronoi_diagram_2/Voronoi_diagram_2.txt +++ b/Voronoi_diagram_2/doc/Voronoi_diagram_2/Voronoi_diagram_2.txt @@ -488,6 +488,20 @@ location queries. \cgalExample{Voronoi_diagram_2/vd_2_point_location.cpp} +\section secvda2drawvoronoi Draw a Voronoi Diagram + +A 2D Voronoi Diagram can be visualized by calling the \link PkgDrawVoronoiDiagram2 CGAL::draw() \endlink function as +shown in the following example. This function opens a new window showing the Voronoi Diagram of the given input sites/vertix locations. A call to this function is blocking, that is the program continues as soon as the user closes the window. + +This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time. + +\cgalExample{Voronoi_diagram_2/draw_voronoi_diagram_2.cpp} + +\cgalFigureBegin{draw_voronoi_diagram, draw_voronoi_diagram.png} +Result of the draw_voronoi_diagram_2 program. A window shows the Voronoi vertices and edges. +The window allows navigation through the 2D scene. +\cgalFigureEnd + */ } /* namespace CGAL */ diff --git a/Voronoi_diagram_2/doc/Voronoi_diagram_2/dependencies b/Voronoi_diagram_2/doc/Voronoi_diagram_2/dependencies index 8cd9d01cbec..e89d9d8be77 100644 --- a/Voronoi_diagram_2/doc/Voronoi_diagram_2/dependencies +++ b/Voronoi_diagram_2/doc/Voronoi_diagram_2/dependencies @@ -7,3 +7,4 @@ Stream_support Triangulation_2 Segment_Delaunay_graph_2 Apollonius_graph_2 +GraphicsView diff --git a/Voronoi_diagram_2/doc/Voronoi_diagram_2/examples.txt b/Voronoi_diagram_2/doc/Voronoi_diagram_2/examples.txt index 059a4823bc2..2c2e063da4c 100644 --- a/Voronoi_diagram_2/doc/Voronoi_diagram_2/examples.txt +++ b/Voronoi_diagram_2/doc/Voronoi_diagram_2/examples.txt @@ -1,4 +1,5 @@ /*! \example Voronoi_diagram_2/vd_2_point_location.cpp \example Voronoi_diagram_2/vd_2_point_location_sdg_linf.cpp +\example Voronoi_diagram_2/draw_voronoi_diagram_2.cpp */ diff --git a/Voronoi_diagram_2/doc/Voronoi_diagram_2/fig/draw_voronoi_diagram.png b/Voronoi_diagram_2/doc/Voronoi_diagram_2/fig/draw_voronoi_diagram.png new file mode 100644 index 00000000000..b48e63207a5 Binary files /dev/null and b/Voronoi_diagram_2/doc/Voronoi_diagram_2/fig/draw_voronoi_diagram.png differ diff --git a/Voronoi_diagram_2/examples/Voronoi_diagram_2/CMakeLists.txt b/Voronoi_diagram_2/examples/Voronoi_diagram_2/CMakeLists.txt index 2741d391aec..775a3faf64c 100644 --- a/Voronoi_diagram_2/examples/Voronoi_diagram_2/CMakeLists.txt +++ b/Voronoi_diagram_2/examples/Voronoi_diagram_2/CMakeLists.txt @@ -6,7 +6,11 @@ cmake_minimum_required(VERSION 3.1...3.15) project( Voronoi_diagram_2_Examples ) -find_package(CGAL QUIET) +find_package(CGAL COMPONENTS Qt5) + +if(CGAL_Qt5_FOUND) + add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS) +endif() if ( CGAL_FOUND ) @@ -16,6 +20,11 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "${cppfile}" ) endforeach() + if(CGAL_Qt5_FOUND ) + target_link_libraries(draw_voronoi_diagram_2 PUBLIC CGAL::CGAL_Qt5) + endif() + + else() message(STATUS "This program requires the CGAL library, and will not be compiled.") diff --git a/Voronoi_diagram_2/examples/Voronoi_diagram_2/data/data4.dt.cin b/Voronoi_diagram_2/examples/Voronoi_diagram_2/data/data4.dt.cin new file mode 100644 index 00000000000..4f0d7b4565e --- /dev/null +++ b/Voronoi_diagram_2/examples/Voronoi_diagram_2/data/data4.dt.cin @@ -0,0 +1,10 @@ +0 0 +100 0 +100 100 +0 100 +200 0 +300 0 +350 0 +150 150 +100 150 +300 325 diff --git a/Voronoi_diagram_2/examples/Voronoi_diagram_2/draw_voronoi_diagram_2.cpp b/Voronoi_diagram_2/examples/Voronoi_diagram_2/draw_voronoi_diagram_2.cpp new file mode 100644 index 00000000000..faa24a70034 --- /dev/null +++ b/Voronoi_diagram_2/examples/Voronoi_diagram_2/draw_voronoi_diagram_2.cpp @@ -0,0 +1,37 @@ +// standard includes +#include + +// includes for drawing the Voronoi Diagram +#include +#include +#include +#include +#include +#include + +// typedefs for defining the adaptor +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Delaunay_triangulation_2 DT; +typedef CGAL::Delaunay_triangulation_adaptation_traits_2
    AT; +typedef CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2
    AP; +typedef CGAL::Voronoi_diagram_2 VD; + +// typedef for the result type of the point location +typedef AT::Site_2 Site_2; + +int main() +{ + VD vd; + std::ifstream ifs("data/data4.dt.cin"); + assert(ifs); + + Site_2 t; + while ( ifs >> t ) { vd.insert(t); } + ifs.close(); + + assert( vd.is_valid() ); + + CGAL::draw(vd); + + return EXIT_SUCCESS; +} diff --git a/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h b/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h new file mode 100644 index 00000000000..5e32e12d3d4 --- /dev/null +++ b/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h @@ -0,0 +1,335 @@ +// Copyright(c) 2019 Foundation for Research and Technology-Hellas (Greece). +// 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) : Jasmeet Singh + +#ifndef CGAL_DRAW_VORONOI_DIAGRAM_2_H +#define CGAL_DRAW_VORONOI_DIAGRAM_2_H + +#include +#include + +#ifdef CGAL_USE_BASIC_VIEWER + +#include +#include +#include +#include +#include +#include +#include + +namespace CGAL { + +// Default color functor; user can change it to have its own face color +struct DefaultColorFunctorV2 +{ + template + static CGAL::Color run(const V2 &, const typename V2::Face_iterator /*fh*/) { + //CGAL::Random random((unsigned int)(std::size_t)(&*fh)); + //return get_random_color(random); + return CGAL::Color(73, 250, 117); + } +}; + +// Viewer for Voronoi diagram +template +class SimpleVoronoiDiagram2ViewerQt : public Basic_viewer_qt +{ + typedef Basic_viewer_qt Base; + typedef typename V2::Vertex_iterator Vertex_const_handle; + typedef typename V2::Delaunay_vertex_handle Delaunay_vertex_const_handle; + typedef typename V2::Delaunay_graph::Finite_vertices_iterator Dual_vertices_iterator; + + typedef typename V2::Halfedge_iterator Halfedge_const_handle; + typedef typename V2::Ccb_halfedge_circulator Ccb_halfedge_circulator; + typedef typename V2::Halfedge_handle Halfedge_handle; + + typedef typename V2::Face_iterator Face_const_handle; + + typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; + +public: + /// Construct the viewer. + /// @param av2 the voronoi diagram to view + /// @param title the title of the window + /// @param anofaces if true, do not draw faces (faces are not computed; this + /// can be useful for very big object where this time could be long) + SimpleVoronoiDiagram2ViewerQt(QWidget *parent, const V2 &av2, + const char *title = "Basic Voronoi Viewer", + bool anofaces = false, + bool draw_voronoi_vertices = true, + bool draw_delaunay_vertices = true, + const ColorFunctor &fcolor = ColorFunctor()) + : // First draw: vertices; half-edges; faces; multi-color; no inverse + // normal + Base(parent, title, true, true, true, false, false, true, true), + v2(av2), m_nofaces(anofaces), + m_draw_voronoi_vertices(draw_voronoi_vertices), + m_draw_dual_vertices(draw_delaunay_vertices), m_fcolor(fcolor) { + // Add custom key description (see keyPressEvent) + setKeyDescription(::Qt::Key_R, "Toggles rays display"); + setKeyDescription(::Qt::Key_D, "Toggles dual vertices display"); + setKeyDescription(::Qt::Key_V, "Toggles voronoi vertices display"); + + compute_elements(); + } + +protected: + + void compute_vertex(Vertex_const_handle vh) { add_point(vh->point()); } + + void compute_dual_vertex(Dual_vertices_iterator vi) + { + add_point(vi->point(), CGAL::Color(50, 100, 180)); + } + + void add_segments_and_update_bounding_box(Halfedge_handle he) + { + if (he->is_segment()) { + add_segment(he->source()->point(), he->target()->point()); + } else { + Delaunay_vertex_const_handle v1 = he->up(); + Delaunay_vertex_const_handle v2 = he->down(); + + Kernel::Vector_2 direction(v1->point().y() - v2->point().y(), + v2->point().x() - v1->point().x()); + if (he->is_ray()) { + Kernel::Point_2 end_point; + if (he->has_source()) { + end_point = he->source()->point(); + update_bounding_box_for_ray(end_point, direction); + } + } else if (he->is_bisector()) { + Kernel::Point_2 pointOnLine((v1->point().x() + v2->point().x()) / 2, + (v1->point().y() + v2->point().y()) / 2); + Kernel::Vector_2 perpendicularDirection( + v2->point().x() - v1->point().x(), + v2->point().y() - v1->point().y()); + update_bounding_box_for_line(pointOnLine, direction, + perpendicularDirection); + } + } + } + + Local_kernel::Point_2 get_second_point(Halfedge_handle ray) + { + Delaunay_vertex_const_handle v1 = ray->up(); + Delaunay_vertex_const_handle v2 = ray->down(); + + // calculate direction of ray and its inverse + Kernel::Vector_2 v(v1->point().y() - v2->point().y(), + v2->point().x() - v1->point().x()); + Local_kernel::Vector_2 inv(1 / v.x(), 1 / v.y()); + + // origin of the ray + Kernel::Point_2 p; + if (ray->has_source()) { + p = ray->source()->point(); + } else { + p = ray->target()->point(); + } + + // get the bounding box of the viewer + Local_kernel::Vector_2 boundsMin(m_bounding_box.xmin(), + m_bounding_box.zmin()); + Local_kernel::Vector_2 boundsMax(m_bounding_box.xmax(), + m_bounding_box.zmax()); + // calculate intersection + double txmax, txmin, tymax, tymin; + + if (inv.x() >= 0) { + txmax = (boundsMax.x() - p.x()) * inv.x(); + txmin = (boundsMin.x() - p.x()) * inv.x(); + } else { + txmax = (boundsMin.x() - p.x()) * inv.x(); + txmin = (boundsMax.x() - p.x()) * inv.x(); + } + + if (inv.y() >= 0) { + tymax = (boundsMax.y() - p.y()) * inv.y(); + tymin = (boundsMin.y() - p.y()) * inv.y(); + } else { + tymax = (boundsMin.y() - p.y()) * inv.y(); + tymin = (boundsMax.y() - p.y()) * inv.y(); + } + + if (tymin > txmin) + txmin = tymin; + if (tymax < txmax) + txmax = tymax; + + Local_kernel::Point_2 p1; + if (v.x() == 0) { + p1 = Local_kernel::Point_2(p.x(), p.y() + tymax * v.y()); + } else if (v.y() == 0) { + p1 = Local_kernel::Point_2(p.x() + txmax * v.x(), p.y()); + } else { + p1 = Local_kernel::Point_2(p.x() + txmax * v.x(), p.y() + tymax * v.y()); + } + return p1; + } + + void compute_rays_and_bisectors(Halfedge_const_handle he) + { + Delaunay_vertex_const_handle v1 = he->up(); + Delaunay_vertex_const_handle v2 = he->down(); + + Kernel::Vector_2 direction(v1->point().y() - v2->point().y(), + v2->point().x() - v1->point().x()); + if (he->is_ray()) { + if (he->has_source()) { + // add_ray_segment(he->source()->point(), get_second_point(he)); + add_ray(he->source()->point(), direction, CGAL::Color(100, 0, 0)); + } + } else if (he->is_bisector()) { + Kernel::Point_2 pointOnLine((v1->point().x() + v2->point().x()) / 2, + (v1->point().y() + v2->point().y()) / 2); + add_line(pointOnLine, direction); + } + } + + void compute_face(Face_const_handle fh) + { + CGAL::Color c = m_fcolor.run(v2, fh); + + Ccb_halfedge_circulator ec_start = fh->ccb(); + Ccb_halfedge_circulator ec = ec_start; + + if (!fh->is_unbounded()) { + face_begin(c); + do { + add_point_in_face(ec->source()->point()); + } while (++ec != ec_start); + face_end(); + } + // Test: for unbounded faces + // else { + // do{ + // if( ec->has_source() ){ + // add_point_in_face(ec->source()->point()); + // } + // else{ + // add_point_in_face(get_second_point(ec->twin())); + // } + // } while(++ec != ec_start); + // } + } + + void compute_elements() + { + clear(); + + // Draw the voronoi vertices + if (m_draw_voronoi_vertices) { + for (typename V2::Vertex_iterator it = v2.vertices_begin(); + it != v2.vertices_end(); ++it) { + compute_vertex(it); + } + } + + // Draw the dual vertices + if (m_draw_dual_vertices) { + for (Dual_vertices_iterator it = v2.dual().finite_vertices_begin(); + it != v2.dual().finite_vertices_end(); ++it) { + compute_dual_vertex(it); + } + } + + // Add segments and update bounding box + for (typename V2::Halfedge_iterator it = v2.halfedges_begin(); + it != v2.halfedges_end(); ++it) { + add_segments_and_update_bounding_box(it); + } + + for (typename V2::Halfedge_iterator it = v2.halfedges_begin(); + it != v2.halfedges_end(); ++it) { + compute_rays_and_bisectors(it); + } + + if (!m_nofaces) { + for (typename V2::Face_iterator it = v2.faces_begin(); + it != v2.faces_end(); ++it) { + compute_face(it); + } + } + } + + virtual void keyPressEvent(QKeyEvent *e) + { + /// [Keypress] + const ::Qt::KeyboardModifiers modifiers = e->modifiers(); + if ((e->key() == ::Qt::Key_R) && (modifiers == ::Qt::NoButton)) { + m_draw_rays = !m_draw_rays; + displayMessage( + QString("Draw rays=%1.").arg(m_draw_rays ? "true" : "false")); + update(); + } else if ((e->key() == ::Qt::Key_V) && (modifiers == ::Qt::NoButton)) { + m_draw_voronoi_vertices = !m_draw_voronoi_vertices; + displayMessage( + QString("Voronoi vertices=%1.").arg(m_draw_voronoi_vertices? "true" : "false")); + compute_elements(); + redraw(); + } else if ((e->key() == ::Qt::Key_D) && (modifiers == ::Qt::NoButton)) { + m_draw_dual_vertices = !m_draw_dual_vertices; + displayMessage(QString("Dual vertices=%1.") + .arg(m_draw_dual_vertices ? "true" : "false")); + compute_elements(); + redraw(); + } else { + // Call the base method to process others/classicals key + Base::keyPressEvent(e); + } + /// [Keypress] + } + +protected: + const V2 &v2; + bool m_nofaces; + bool m_draw_voronoi_vertices; + bool m_draw_dual_vertices; + const ColorFunctor &m_fcolor; +}; + +// Specialization of draw function. +#define CGAL_VORONOI_TYPE CGAL::Voronoi_diagram_2 + +template +void draw(const CGAL_VORONOI_TYPE &av2, + const char *title="2D Voronoi Diagram Basic Viewer", + bool nofill = false, + bool draw_voronoi_vertices = true, + bool draw_dual_vertices = true) +{ +#if defined(CGAL_TEST_SUITE) + bool cgal_test_suite = true; +#else + bool cgal_test_suite = qEnvironmentVariableIsSet("CGAL_TEST_SUITE"); +#endif + + if (!cgal_test_suite) { + int argc = 1; + const char *argv[2] = {"voronoi_2_viewer", "\0"}; + QApplication app(argc, const_cast(argv)); + DefaultColorFunctorV2 fcolor; + SimpleVoronoiDiagram2ViewerQt + mainwindow(app.activeWindow(), av2, title, nofill, + draw_voronoi_vertices, draw_dual_vertices, fcolor); + mainwindow.show(); + app.exec(); + } +} + +} // End namespace CGAL + +#endif // CGAL_USE_BASIC_VIEWER + +#endif // CGAL_DRAW_VORONOI_DIAGRAM_2_H diff --git a/Voronoi_diagram_2/package_info/Voronoi_diagram_2/dependencies b/Voronoi_diagram_2/package_info/Voronoi_diagram_2/dependencies index 59ff755db76..47ba473b701 100644 --- a/Voronoi_diagram_2/package_info/Voronoi_diagram_2/dependencies +++ b/Voronoi_diagram_2/package_info/Voronoi_diagram_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Apollonius_graph_2 Circulator +GraphicsView Hash_map Installation Interval_support