diff --git a/.github/workflows/build_doc.yml b/.github/workflows/build_doc.yml index 8657f56e4a0..687dc754a40 100644 --- a/.github/workflows/build_doc.yml +++ b/.github/workflows/build_doc.yml @@ -96,6 +96,7 @@ jobs: cd .. git clone https://CGAL:${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }}@github.com/CGAL/cgal.github.io.git mkdir -p cgal.github.io/${PR_NUMBER}/$ROUND + rm cgal.github.io/${PR_NUMBER}/$ROUND/* -rf for f in $LIST_OF_PKGS do if [ -d ./build_doc/doc_output/$f ]; then diff --git a/AABB_tree/test/AABB_tree/aabb_test_all_intersected_primitives_tree.cpp b/AABB_tree/test/AABB_tree/aabb_test_all_intersected_primitives_tree.cpp index 5cf50bc0b96..c0c7d160fd0 100644 --- a/AABB_tree/test/AABB_tree/aabb_test_all_intersected_primitives_tree.cpp +++ b/AABB_tree/test/AABB_tree/aabb_test_all_intersected_primitives_tree.cpp @@ -1,7 +1,6 @@ #include #include - -#include +#include #include @@ -59,11 +58,11 @@ int main() std::list t_primitives; std::list s_primitives; cube_tree.all_intersected_primitives(tet_tree,std::back_inserter(t_primitives)); - CGAL_assertion(t_primitives.size() == 6); + assert(t_primitives.size() == 6); tet_tree.all_intersected_primitives(cube_tree,std::back_inserter(s_primitives)); - CGAL_assertion(s_primitives.size() == 6); - CGAL_assertion(tet_tree.do_intersect(cube_tree)); - CGAL_assertion(cube_tree.do_intersect(tet_tree)); + assert(s_primitives.size() == 6); + assert(tet_tree.do_intersect(cube_tree)); + assert(cube_tree.do_intersect(tet_tree)); std::vector all_primitives; cube_tree.all_intersected_primitives(tet_tree, std::back_inserter(all_primitives)); @@ -73,7 +72,7 @@ int main() if((int)prim.first == 5) found_f5 = true; } - CGAL_assertion(found_f5); - CGAL_USE(found_f5); + assert(found_f5); + return 0; } diff --git a/AABB_tree/test/AABB_tree/aabb_test_move_constructor.cpp b/AABB_tree/test/AABB_tree/aabb_test_move_constructor.cpp index 0eed3df343a..7f61faf6b7c 100644 --- a/AABB_tree/test/AABB_tree/aabb_test_move_constructor.cpp +++ b/AABB_tree/test/AABB_tree/aabb_test_move_constructor.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -149,12 +150,12 @@ public: std::list s_primitives; cube_tree.all_intersected_primitives(tet_tree, std::back_inserter(t_primitives)); - CGAL_assertion(t_primitives.size() == 6); + assert(t_primitives.size() == 6); tet_tree.all_intersected_primitives(cube_tree, std::back_inserter(s_primitives)); - CGAL_assertion(s_primitives.size() == 6); - CGAL_assertion(tet_tree.do_intersect(cube_tree)); - CGAL_assertion(cube_tree.do_intersect(tet_tree)); + assert(s_primitives.size() == 6); + assert(tet_tree.do_intersect(cube_tree)); + assert(cube_tree.do_intersect(tet_tree)); std::vector all_primitives; cube_tree.all_intersected_primitives(tet_tree, @@ -164,8 +165,8 @@ public: if ((int)prim.first == 5) found_f5 = true; } - CGAL_assertion(found_f5); - CGAL_USE(found_f5); + assert(found_f5); + return true; } }; diff --git a/AABB_tree/test/AABB_tree/aabb_test_multi_mesh.cpp b/AABB_tree/test/AABB_tree/aabb_test_multi_mesh.cpp index b6d2858ece5..5b78ff33016 100644 --- a/AABB_tree/test/AABB_tree/aabb_test_multi_mesh.cpp +++ b/AABB_tree/test/AABB_tree/aabb_test_multi_mesh.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include #include diff --git a/AABB_tree/test/AABB_tree/aabb_test_ray_intersection.cpp b/AABB_tree/test/AABB_tree/aabb_test_ray_intersection.cpp index debf7e25522..4e86ed22d7f 100644 --- a/AABB_tree/test/AABB_tree/aabb_test_ray_intersection.cpp +++ b/AABB_tree/test/AABB_tree/aabb_test_ray_intersection.cpp @@ -138,9 +138,8 @@ int main() for(std::vector::iterator it = rays.begin(); it != rays.end(); ++it) { primitives2.push_back(tree.first_intersection(*it)); } - CGAL_assertion_msg(primitives1.size() == primitives2.size(), "Different amount of primitives intersected."); - CGAL_assertion_msg(std::equal(primitives1.begin(), primitives1.end(), primitives2.begin()), - "Primitives mismatch."); + assert(primitives1.size() == primitives2.size()); // Different amount of primitives intersected + assert(std::equal(primitives1.begin(), primitives1.end(), primitives2.begin())); // Primitives mismatch std::size_t c = primitives1.size() - std::count(primitives1.begin(), primitives1.end(), boost::none); std::cout << "Intersected " << c << " primitives with " << NB_RAYS << " rays" << std::endl; std::cout << "Primitive method had to sort " << accum/NB_RAYS diff --git a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_surface_mesh.cpp b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_surface_mesh.cpp index bbce3a1bdb2..e4fbdfafb3b 100644 --- a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_surface_mesh.cpp +++ b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_surface_mesh.cpp @@ -53,7 +53,6 @@ int main(int argc, char* argv[]) { std::ifstream in((argc>1)?argv[1]:CGAL::data_file_path("points_3/half.xyz")); std::vector points; - std::vector facets; Mesh m; std::copy(std::istream_iterator(in), 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 59d1c4a5ac7..3e4d8ba7df9 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 @@ -191,7 +191,7 @@ namespace CGAL { \tparam P must be a functor offering \code - FT operator()(Advancing_front_surface_reconstruction,Cell_handle,int) + FT operator()(Advancing_front_surface_reconstruction::Cell_handle,int) \endcode returning the priority of the facet `(Cell_handle,int)`. This functor enables the user to choose how candidate triangles are prioritized. If a facet should not appear in the output, @@ -394,7 +394,7 @@ namespace CGAL { bool deal_with_2d; Priority priority; int max_connected_component; - double K_init, K_step; + coord_type K_init, K_step; std::list interior_edges; std::list< Incidence_request_elt > incidence_requests; typename std::list< Incidence_request_elt >::iterator sentinel; @@ -2581,18 +2581,18 @@ namespace CGAL { be convertible to `Exact_predicates_inexact_constructions_kernel::Point_3` with the `Cartesian_converter`. \tparam IndicesOutputIterator must be an output iterator to which `std::array` can be assigned. - \tparam Priority must be a functor with `double operator()(Advancing_front_surface_reconstruction,Cell_handle,int)` returning the + \tparam Priority must be a functor with `double operator()(Advancing_front_surface_reconstruction::Cell_handle,int)` returning the priority of the facet `(Cell_handle,int)`. \param b iterator on the first point of the sequence \param e past the end iterator of the point sequence \param out output iterator + \param priority enables the user to choose how candidate triangles are prioritized. \param radius_ratio_bound candidates incident to surface triangles which are not in the beta-wedge are discarded, if the ratio of their radius and the radius of the surface triangle is larger than `radius_ratio_bound`. Described in Section \ref AFSR_Boundaries \param beta half the angle of the wedge in which only the radius of triangles counts for the plausibility of candidates. Described in Section \ref AFSR_Selection - \param priority allows the user to choose how candidate triangles are prioritized. */ template diff --git a/Algebraic_foundations/test/Algebraic_foundations/Chinese_remainder_traits.cpp b/Algebraic_foundations/test/Algebraic_foundations/Chinese_remainder_traits.cpp index d1a8b19c9f4..fa756716fcb 100644 --- a/Algebraic_foundations/test/Algebraic_foundations/Chinese_remainder_traits.cpp +++ b/Algebraic_foundations/test/Algebraic_foundations/Chinese_remainder_traits.cpp @@ -103,7 +103,7 @@ void test_CR_for(const NT& f){ // try chinese remainder do{ // chinese remainder failed if q > 2*max_coeff(f) - CGAL_postcondition_msg(pq < p*(2*max_coeff), " chinese remainder failed "); + assert(pq < p*(2*max_coeff)); prime_index++; if(prime_index < 1000){ diff --git a/Algebraic_kernel_d/test/Algebraic_kernel_d/include/CGAL/_test_algebraic_kernel_1.h b/Algebraic_kernel_d/test/Algebraic_kernel_d/include/CGAL/_test_algebraic_kernel_1.h index ac9ea88f5e5..c12be717c2d 100644 --- a/Algebraic_kernel_d/test/Algebraic_kernel_d/include/CGAL/_test_algebraic_kernel_1.h +++ b/Algebraic_kernel_d/test/Algebraic_kernel_d/include/CGAL/_test_algebraic_kernel_1.h @@ -409,9 +409,9 @@ void test_algebraic_kernel_1(const AlgebraicKernel_d_1& ak_1){ #define CGAL_TEST_ALGEBRAIC_REAL_IO(_f) \ alg1=_f; \ ss<>CGAL::IO::iformat(alg2); \ - CGAL_assertion(!ss.fail()); \ + assert(ss.good()); \ + ss>>CGAL::IO::iformat(alg2); \ + assert(!ss.fail()); \ ss.clear(); \ assert(alg1==alg2) // Note: after the reading ss>>CGAL::IO::iformat(alg2) the state of ss can diff --git a/Alpha_shapes_2/examples/Alpha_shapes_2/ex_alpha_shapes_2.cpp b/Alpha_shapes_2/examples/Alpha_shapes_2/ex_alpha_shapes_2.cpp index 28c8bea6915..1892df87e98 100644 --- a/Alpha_shapes_2/examples/Alpha_shapes_2/ex_alpha_shapes_2.cpp +++ b/Alpha_shapes_2/examples/Alpha_shapes_2/ex_alpha_shapes_2.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include diff --git a/Alpha_shapes_3/doc/Alpha_shapes_3/Alpha_shapes_3.txt b/Alpha_shapes_3/doc/Alpha_shapes_3/Alpha_shapes_3.txt index 350721768f9..ffa6e25a3fe 100644 --- a/Alpha_shapes_3/doc/Alpha_shapes_3/Alpha_shapes_3.txt +++ b/Alpha_shapes_3/doc/Alpha_shapes_3/Alpha_shapes_3.txt @@ -193,7 +193,7 @@ the vertices, edges, facets and cells of the different types `INTERIOR`). \subsection AlphaShape3DIO Input/Output -It is possible to export a 3D alpha shape to a `std::ostream` or to a `Geomview_stream` +It is possible to export a 3D alpha shape to a `std::ostream` using the `operator<<`, see the documentation of the class `Alpha_shape_3` for more information. \section AlphaShape3D_ConceptAndModels Concepts and Models @@ -352,4 +352,3 @@ results will suffer from round-off problems. */ } /* namespace CGAL */ - 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 ee64a63db65..1a90836e601 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 @@ -480,15 +480,6 @@ Defined in `CGAL/IO/io.h` std::ostream& operator<<(std::ostream& os, const Alpha_shape_3& A); -/*! -Inserts the alpha shape `A` for the current alpha value into the Geomview stream `W`. -\pre The insert operator must be defined for `GT::Point` and `GT::Triangle`. -Defined in `CGAL/IO/Geomview_stream.h` and `CGAL/IO/alpha_shape_geomview_ostream_3.h` - -\relates Alpha_shape_3 -*/ -Geomview_stream& operator<<(Geomview_stream& W, -const Alpha_shape_3& A); } /* end namespace CGAL */ diff --git a/Alpha_shapes_3/doc/Alpha_shapes_3/dependencies b/Alpha_shapes_3/doc/Alpha_shapes_3/dependencies index 4fb2fed26dd..e49655e07b9 100644 --- a/Alpha_shapes_3/doc/Alpha_shapes_3/dependencies +++ b/Alpha_shapes_3/doc/Alpha_shapes_3/dependencies @@ -5,7 +5,6 @@ Algebraic_foundations Circulator Stream_support Triangulation_3 -Geomview Periodic_3_triangulation_3 Number_types Alpha_shapes_2 diff --git a/Alpha_shapes_3/examples/Alpha_shapes_3/visible_alpha_shape_facets_to_OFF.cpp b/Alpha_shapes_3/examples/Alpha_shapes_3/visible_alpha_shape_facets_to_OFF.cpp index f12c5233acb..675024cd831 100644 --- a/Alpha_shapes_3/examples/Alpha_shapes_3/visible_alpha_shape_facets_to_OFF.cpp +++ b/Alpha_shapes_3/examples/Alpha_shapes_3/visible_alpha_shape_facets_to_OFF.cpp @@ -8,8 +8,8 @@ #include #include -#include -#include +#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Gt; @@ -48,7 +48,7 @@ int main() // collect alpha-shape facets accessible from the infinity // marks the cells that are in the same component as the infinite vertex by flooding - boost::unordered_set< Alpha_shape_3::Cell_handle > marked_cells; + std::unordered_set< Alpha_shape_3::Cell_handle > marked_cells; std::vector< Alpha_shape_3::Cell_handle > queue; queue.push_back( as.infinite_cell() ); @@ -86,7 +86,7 @@ int main() // dump into OFF format // assign an id per vertex - boost::unordered_map< Alpha_shape_3::Vertex_handle, std::size_t> vids; + std::unordered_map< Alpha_shape_3::Vertex_handle, std::size_t> vids; points.clear(); for(Alpha_shape_3::Facet f : filtered_regular_facets) diff --git a/Alpha_shapes_3/include/CGAL/Alpha_shape_3.h b/Alpha_shapes_3/include/CGAL/Alpha_shape_3.h index 88e3fa36079..0df8cc2cd53 100644 --- a/Alpha_shapes_3/include/CGAL/Alpha_shape_3.h +++ b/Alpha_shapes_3/include/CGAL/Alpha_shape_3.h @@ -24,9 +24,6 @@ #include #include #include -#ifdef CGAL_USE_GEOMVIEW -#include // TBC -#endif #include #include @@ -786,11 +783,6 @@ private: //--------------------------------------------------------------------- public: -#ifdef CGAL_USE_GEOMVIEW - void show_triangulation_edges(Geomview_stream &gv) const; - void show_alpha_shape_faces(Geomview_stream &gv) const; -#endif - // to Debug void print_maps() const; @@ -1950,8 +1942,5 @@ Alpha_shape_3::print_alpha_status(const Alpha_status& as) const } //namespace CGAL -#ifdef CGAL_USE_GEOMVIEW -#include -#endif #endif //CGAL_ALPHA_SHAPE_3_H diff --git a/Alpha_shapes_3/include/CGAL/Fixed_alpha_shape_3.h b/Alpha_shapes_3/include/CGAL/Fixed_alpha_shape_3.h index d06be11b76a..ea15aa9ffb6 100644 --- a/Alpha_shapes_3/include/CGAL/Fixed_alpha_shape_3.h +++ b/Alpha_shapes_3/include/CGAL/Fixed_alpha_shape_3.h @@ -32,9 +32,6 @@ #include #include #include -#ifdef CGAL_USE_GEOMVIEW -#include // TBC -#endif #include @@ -727,10 +724,6 @@ private: //--------------------------------------------------------------------- public: -#ifdef CGAL_USE_GEOMVIEW - void show_alpha_shape_faces(Geomview_stream &gv) const; -#endif - //Iterators diff --git a/Alpha_shapes_3/include/CGAL/IO/Alpha_shape_3_VRML_2_ostream.h b/Alpha_shapes_3/include/CGAL/IO/Alpha_shape_3_VRML_2_ostream.h deleted file mode 100644 index 59e031b9668..00000000000 --- a/Alpha_shapes_3/include/CGAL/IO/Alpha_shape_3_VRML_2_ostream.h +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) 1997 -// Utrecht University (The Netherlands), -// ETH Zurich (Switzerland), -// INRIA Sophia-Antipolis (France), -// Max-Planck-Institute Saarbruecken (Germany), -// and Tel-Aviv University (Israel). 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) : Andreas Fabri - -#ifndef CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H -#define CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H - -#include - -#include -#include -#include - -namespace CGAL { - -template -VRML_2_ostream& -operator<<(VRML_2_ostream& os, - Alpha_shape_3
&as) -{ - // Finite vertices coordinates. - Alpha_shape_3
::Alpha_shape_vertices_iterator Vlist_it, - Vlist_begin = as.alpha_shape_vertices_begin(), - Vlist_end = as.alpha_shape_vertices_end(); - - std::map::Vertex_handle, int> V; - int number_of_vertex = 0; - for( Vlist_it = Vlist_begin; Vlist_it != Vlist_end; Vlist_it++) { - V[*Vlist_it] = number_of_vertex++; - } - - typename Alpha_shape_3
::Alpha_shape_facets_iterator Flist_it, - Flist_begin = as.alpha_shape_facets_begin(), - Flist_end = as.alpha_shape_facets_end(); - - std::map::Facet, int> F; - int number_of_facets = 0; - for( Flist_it = Flist_begin; Flist_it != Flist_end; Flist_it++) { - F[*Flist_it] = number_of_facets++; - } - - const char *Indent = " "; - os << " Group {\n" - " children [\n" - " Shape {\n" - " appearance USE A1\n" - " geometry\n" - " IndexedFaceSet {\n" - " coord Coordinate {\n" - " point [ \n" - << Indent << " "; - for( Vlist_it = Vlist_begin; Vlist_it != Vlist_end; Vlist_it++) { - os << CGAL::to_double((*Vlist_it)->point().x()) << " "; - os << CGAL::to_double((*Vlist_it)->point().y()) << " "; - os << CGAL::to_double((*Vlist_it)->point().z()) << ",\n" << Indent << " "; - } - os << "\n ]\n" - " } # coord\n" - " solid FALSE\n" - << Indent << "coordIndex [\n"; - // Finite facets indices. - for( Flist_it = Flist_begin; Flist_it != Flist_end; Flist_it++){ - os << Indent << " "; - for (int i=0; i<4; i++) - if (i != (*Flist_it).second){ - os << V[(*Flist_it).first->vertex(i)]; - os << ", "; - } - if (Flist_it != Flist_end) - os << "-1,\n"; - else - os << "-1 \n"; - } - os << Indent << "]\n"; - " } #IndexedFaceSet\n" - " } #Shape\n" - " ] #children\n" - " } #Group\n"; - - return os; -} - -} //namespace CGAL - -#endif // CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H diff --git a/Alpha_shapes_3/include/CGAL/IO/alpha_shape_geomview_ostream_3.h b/Alpha_shapes_3/include/CGAL/IO/alpha_shape_geomview_ostream_3.h deleted file mode 100644 index 0d0efa9f9e1..00000000000 --- a/Alpha_shapes_3/include/CGAL/IO/alpha_shape_geomview_ostream_3.h +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright (c) 1997 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) : Tran Kai Frank DA -// Mael Rouxel-Labbé - -#ifndef CGAL_IO_ALPHA_SHAPE_GEOMVIEW_OSTREAM_3_H -#define CGAL_IO_ALPHA_SHAPE_GEOMVIEW_OSTREAM_3_H - -#include - -#include -#include - -#include -#include - -// TODO : -// - Check the correctness when dimension < 3. -// - Use the stream color instead of built-in constant/random. -// - If interfaces were more similar, we could think of sharing 2d and 3d ? - -//------------------------------------------------------------------- -namespace CGAL { -//------------------------------------------------------------------- - -template -void -Alpha_shape_3:: -show_triangulation_edges(Geomview_stream &gv) const -{ - // To become unordered when CGAL's Point_3/Weighted_point_3 has a hash function - typedef typename std::map PMap; - - // Used to keep the insertion order in memory - typedef typename std::vector PMapIterVector; - - PMap P; - PMapIterVector PIV; - int number_of_points = 0; - - for(Finite_edges_iterator eit=finite_edges_begin(); eit!=finite_edges_end(); ++eit) - { - Point p = point(eit->first, eit->second); - Point q = point(eit->first, eit->third); - - std::pair is_p_insert_successful = - P.insert(std::make_pair(p, number_of_points)); - - if(is_p_insert_successful.second) - { - ++number_of_points; - PIV.push_back(is_p_insert_successful.first); - } - - std::pair is_q_insert_successful = - P.insert(std::make_pair(q, number_of_points)); - - if(is_q_insert_successful.second) - { - ++number_of_points; - PIV.push_back(is_q_insert_successful.first); - } - } - - // Header - gv.set_ascii_mode(); - gv << "(geometry " << gv.get_new_id("triangulation_edges") - << " {appearance {}{ SKEL \n" - << number_of_points << this->number_of_finite_edges() << "\n"; - - // Vertices - typename PMapIterVector::iterator Pit, Pbegin = PIV.begin(), Pend = PIV.end(); - for(Pit = Pbegin; Pit != Pend; ++Pit) - gv << this->geom_traits().construct_point_3_object()((*Pit)->first); - - // Finite edges indices - for(Finite_edges_iterator eit=finite_edges_begin(); eit!=finite_edges_end(); ++eit) { - gv << 2 - << P[point(eit->first, eit->second)] - << P[point(eit->first, eit->third)] - << "\n"; // without color - // << 4 << drand48() << drand48() << drand48() << 1.0; // random color - } -} - -//------------------------------------------------------------------- -// This function outputs the facets. -template -void -Alpha_shape_3:: -show_alpha_shape_faces(Geomview_stream &gv) const -{ - // To become unordered when CGAL's Point_3/Weighted_point_3 has a hash function - typedef typename std::map PMap; - - // Used to keep the insertion order in memory - typedef typename std::vector PMapIterVector; - - typename Alpha_shape_3::Alpha_shape_facets_iterator Flist_it, - Flist_begin = Alpha_shape_facets_begin(), - Flist_end = Alpha_shape_facets_end(); - - PMap P; - PMapIterVector PIV; - int number_of_points = 0; - int number_of_facets = std::distance(Flist_begin, Flist_end); - - for(Flist_it = Flist_begin; Flist_it != Flist_end; Flist_it++) - { - // Collect the points - // Note that we cannot simply loop over the vertices using e.g. - // Alpha_shape_vertices_begin() because v->point() might not always - // be the correct point position (see periodic triangulations for example); - // we must instead use tr.point(c,i) - for(int i=0; i<4; i++) - { - if(i != Flist_it->second) - { - Point p = point(Flist_it->first, i); - std::pair is_insert_successful = - P.insert(std::make_pair(p, number_of_points)); - - if(is_insert_successful.second) - { - ++number_of_points; - PIV.push_back(is_insert_successful.first); - } - } - } - } - - // Header - gv.set_binary_mode(); - gv << "(geometry " << gv.get_new_id("alpha_shape") - << " {appearance {}{ OFF BINARY\n" - << number_of_points << number_of_facets << 0; - - std::cout << number_of_points << " " << number_of_facets << std::endl; - - // Vertices - typename PMapIterVector::iterator Pit, Pbegin = PIV.begin(), Pend = PIV.end(); - for(Pit = Pbegin; Pit != Pend; ++Pit) - gv << this->geom_traits().construct_point_3_object()((*Pit)->first); - - // Finite facets indices - for(Flist_it = Flist_begin; Flist_it != Flist_end; Flist_it++) - { - gv << 3; - for(int i=0; i<4; i++) - if(i != Flist_it->second) - gv << P[point(Flist_it->first, i)]; - gv << 0; // without color -// gv << 4 << drand48() << drand48() << drand48() << 1.0; // random color - } -} - -//------------------------------------------------------------------- - -template < class Dt,class EACT > -Geomview_stream& -operator<<(Geomview_stream &gv, Alpha_shape_3& A) -{ - bool ascii_bak = gv.get_ascii_mode(); - bool raw_bak = gv.set_raw(true); - - if(gv.get_wired()) - A.show_triangulation_edges(gv); - else - A.show_alpha_shape_faces(gv); - - // Footer - gv << "}})"; - - gv.set_raw(raw_bak); - gv.set_ascii_mode(ascii_bak); - return gv; -} - -//------------------------------------------------------------------- -} //namespace CGAL -//------------------------------------------------------------------- - -#endif // CGAL_IO_ALPHA_SHAPE_GEOMVIEW_OSTREAM_3_H diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveParser.cpp b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveParser.cpp index 19d3405bb9b..009eede6a79 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveParser.cpp +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveParser.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include "AlgebraicCurveParser.h" diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Arrangement_on_surface_2.txt b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Arrangement_on_surface_2.txt index dcb52051c82..5c6c5522fc4 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Arrangement_on_surface_2.txt +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Arrangement_on_surface_2.txt @@ -2213,11 +2213,9 @@ vertex and the remaining one is vertical. \cgalFigureBegin{aos_fig-bounded_vd,bounded_vertical_decomposition.png} An arrangement of four line segments and its vertical decomposition into pseudo trapezoids, as constructed in \ref -Arrangement_on_surface_2/bounded_vertical_decomposition.cpp. The -segments of \f$\mathcal{S}_1\f$ are drawn in solid lines and the -segments of \f$\mathcal{S}_2\f$ are drawn in dark dashed lines. Note -that the segment \f$ s\f$ (light dashed line) overlaps one of the -segments in \f$\mathcal{S}_1\f$. +Arrangement_on_surface_2/bounded_vertical_decomposition.cpp. The +segments of the arrangement are drawn in solid blue lines and the +segments of the vertical decomposition are drawn in dark dotted lines. \cgalFigureEnd @@ -3529,6 +3527,29 @@ an \f$x\f$-monotone curve connecting \f$p_1\f$ and \f$p_2\f$. Most traits classes model the `ArrangementTraits_2` concept, and some also model the `ArrangementLandmarkTraits_2` concept. + +\subsubsection aos_sssec-tr_additional_concepts The Construct Curve Concept + + +The concept `ArrangementConstructCurveTraits_2` refines the concept +`ArrangementTraits_2`. A model of the +`ArrangementConstructCurveTraits_2` concept must support the operation +below (in addition to fulfilling the requirements listed by the +`ArrangementTraits_2` concept). + +
+
\link ArrangementConstructCurveTraits_2::Construct_curve_2 `Construct_curve_2`\endlink: +
Given two points \f$p_1\f$ and \f$p_2\f$, construct +a curve connecting \f$p_1\f$ and \f$p_2\f$. +
+ +The `Arr_polyline_traits_2` class template handles +polylines; see Section ~\ref arr_sssectr_polylines. +The type that substitutes the template parameter `SubcurveTraits_2` +when `Arr_polyline_traits_2` is instantiated must be +a geometry-traits class that models the concept `ArrangementConstructCurveTraits_2` +to enable the construction of polylines from a sequence of two or more points. + \subsubsection aos_ssec-traits-curved Supporting Unbounded Curves or Curved Surfaces @@ -4208,18 +4229,19 @@ arr_sssectr_polycurves. The `Arr_polyline_traits_2` class template handles -polylines. It models the following three concepts: +polylines. It models the following four concepts: - `ArrangementTraits_2`, -- `ArrangementDirectionalXMonotoneTraits_2`, and +- `ArrangementDirectionalXMonotoneTraits_2` -- `ArrangementConstructXMonotoneCurveTraits_2`; see Package \ref -PkgBooleanSetOperations2Ref. +- `ArrangementConstructXMonotoneCurveTraits_2`, and + +- `ArrangementConstructCurveTraits_2`. The type that substitutes the template parameter `SubcurveTraits_2` when `Arr_polyline_traits_2` is instantiated must be -a geometry-traits class that models the same three concepts. We refer +a geometry-traits class that models the same four concepts. We refer to the type that substitutes the template parameter `SubcurveTraits_2` as the subcurve traits hereafter. If, in addition, the subcurve traits also models the concept @@ -4383,7 +4405,6 @@ typedef CGAL::Arrangement_2 Arrangement; \paragraph arr_sssectr_polycurves The Polycurve Traits Class - \subsubsection arr_ssectr_algebraic Traits Classes for Algebraic Curves diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_polycurve_traits_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_polycurve_traits_2.h index cf464eb6b8c..f75223432f4 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_polycurve_traits_2.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_polycurve_traits_2.h @@ -448,8 +448,6 @@ namespace CGAL { /*! \deprecated * Add a new point to the polycurvs, which becomes the new target point * of `pi`. - * \pre SubcurveTraits_2 is a model of - * ArrangementConstructXMonotoneCurveTraits_2. */ void push_back(const Point_2 & p); diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_polyline_traits_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_polyline_traits_2.h index 7d1ba9335f3..ee3c7e5a16f 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_polyline_traits_2.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_polyline_traits_2.h @@ -32,7 +32,8 @@ namespace CGAL { * of the concepts * - `ArrangementTraits_2`, * - `ArrangementDirectionalXMonotoneTraits_2`, - * - `ArrangementConstructXMonotoneCurveTraits_2`. + * - `ArrangementConstructXMonotoneCurveTraits_2`, + * - `ArrangementConstructCurveTraits_2`. * * If, in addition, the GeometryTraits_2 models the concept * `ArrangementApproximateTraits_2` then `Arr_polycurve_traits_2` models @@ -79,6 +80,7 @@ namespace CGAL { * \cgalModels `ArrangementTraits_2` * \cgalModels `ArrangementDirectionalXMonotoneTraits_2` * \cgalModels `ArrangementConstructXMonotoneCurveTraits_2` + * \cgalModels `ArrangementConstructCurveTraits_2` * \cgalModels `ArrangementApproximateTraits_2` (if the type that substitutes * the template parameter `SegmentTraits_2` models the concept as well) * diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrTraits--ConstructCurve_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrTraits--ConstructCurve_2.h new file mode 100644 index 00000000000..68c708c27af --- /dev/null +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrTraits--ConstructCurve_2.h @@ -0,0 +1,26 @@ +namespace ArrTraits { + +/*! \ingroup PkgArrangementOnSurface2ConceptsFunctionObjects + * \cgalConcept + * + * \cgalRefines Functor + * + * \cgalHasModel ArrangementConstructCurveTraits_2::Construct_curve_2 + */ +class ConstructCurve_2 { +public: + + /// \name Operations + /// A model of this concept must provide: + /// @{ + + /*! returns a curve connecting `p1` and `p2` (i.e., the + * two input points are its endpoints). + */ + ArrTraits::Curve_2 operator()(ArrTraits::Point_2 p1, ArrTraits::Point_2 p2); + + /// @} + +}; /* end ArrTraits::ConstructCurve_2 */ + +} diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementConstructCurveTraits_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementConstructCurveTraits_2.h new file mode 100644 index 00000000000..c2b074cbe21 --- /dev/null +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementConstructCurveTraits_2.h @@ -0,0 +1,40 @@ +/*! \ingroup PkgArrangementOnSurface2ConceptsTraits + * \cgalConcept + * + * The concept `ArrangementConstructCurveTraits_2` refines the basic + * traits concept `ArrangementBasicTraits_2`. A model of this concept is able + * to construct a curve from two points. + * + * \cgalRefines `ArrangementTraits_2` + * + * \cgalHasModel `CGAL::Arr_conic_traits_2` + * \cgalHasModel `CGAL::Arr_geodesic_arc_on_sphere_traits_2` + * \cgalHasModel `CGAL::Arr_linear_traits_2` + * \cgalHasModel `CGAL::Arr_non_caching_segment_traits_2` + * \cgalHasModel `CGAL::Arr_segment_traits_2` + * \cgalHasModel `CGAL::Arr_polyline_traits_2` + * \cgalHasModel `CGAL::Arr_rational_function_traits_2` + * + * \sa `ArrangementConstructXMonotoneCurveTraits_2`, and + * `ArrangementTraits_2` + */ +class ArrangementConstructCurveTraits_2 { +public: + /// \name Functor Types + /// @{ + + /*! models the concept `ArrTraits::ConstructCurve_2`. + */ + typedef unspecified_type Construct_curve_2; + + /// @} + + /// \name Accessing Functor Objects + /// @{ + + /*! + */ + Construct_curve_2 construct_curve_2_object() const; + + /// @} +}; diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementConstructXMonotoneCurveTraits_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementConstructXMonotoneCurveTraits_2.h index fb2c1f53798..dc7998ec0af 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementConstructXMonotoneCurveTraits_2.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementConstructXMonotoneCurveTraits_2.h @@ -16,8 +16,9 @@ * \cgalHasModel `CGAL::Arr_rational_function_traits_2` * * \sa `ArrangementApproximateTraits_2`, - * `ArrangementXMonotoneTraits_2`, and - * `ArrangementTraits_2` + * `ArrangementXMonotoneTraits_2` + * `ArrangementTraits_2`, and + * `ArrangementConstructCurveTraits_2`. */ class ArrangementConstructXMonotoneCurveTraits_2 { public: diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/PackageDescription.txt b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/PackageDescription.txt index 6bbc3363430..8e5a61aac0a 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/PackageDescription.txt +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/PackageDescription.txt @@ -117,6 +117,7 @@ implemented as peripheral classes or as free (global) functions. - `ArrangementBasicTopologyTraits` - `ArrangementBasicTraits_2` - `ArrangementConstructXMonotoneCurveTraits_2` +- `ArrangementConstructCurveTraits_2` - `ArrangementLandmarkTraits_2` - `ArrangementXMonotoneTraits_2` - `ArrangementTraits_2` @@ -183,6 +184,7 @@ implemented as peripheral classes or as free (global) functions. - `ArrTraits::MakeXMonotone_2` - `ArrTraits::Approximate_2` - `ArrTraits::ConstructXMonotoneCurve_2` +- `ArrTraits::ConstructCurve_2` \cgalCRPSection{Classes} diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/algebraic_segments.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/algebraic_segments.cpp index a546f9c16ae..95eb729bb66 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/algebraic_segments.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/algebraic_segments.cpp @@ -2,6 +2,7 @@ // Constructing an arrangement of algebraic segments. #include +#include #include #if (!CGAL_USE_CORE) && (!CGAL_USE_LEDA) && (!(CGAL_USE_GMP && CGAL_USE_MPFI)) @@ -52,7 +53,7 @@ int main() { std::vector segs; for(size_t i = 0; i < pre_segs.size(); ++i) { auto* curr_p = boost::get(&pre_segs[i]); - CGAL_assertion(curr_p); + assert(curr_p); segs.push_back(*curr_p); } // Construct an ellipse (C2) with the equation 2*x^2+5*y^2-7=0. diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/conics.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/conics.cpp index f01501c054a..a8688f55a98 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/conics.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/conics.cpp @@ -29,7 +29,7 @@ int main() { // with (-3, 4) and (4, 3) as its endpoints. We want the arc to be // clockwise-oriented, so it passes through (0, 5) as well. Conic_arc c4(Rat_point(-3, 4), Rat_point(0, 5), Rat_point(4, 3)); - CGAL_assertion(c4.is_valid()); + insert(arr, c4); // Insert a full unit circle (C5) that is centered at (0, 4). @@ -46,7 +46,7 @@ int main() { 0, 0, 0, 0, 1, 3, // the line: y = -3. Point(1.41, -2), // approximation of the target. 0, 0, 0, 0, 1, 2); // the line: y = -2. - CGAL_assertion(c6.is_valid()); + insert(arr, c6); // Insert the right half of the circle centered at (4, 2.5) whose radius diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/dual_lines.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/dual_lines.cpp index b6b4304c1a0..36a5cbb3b5b 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/dual_lines.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/dual_lines.cpp @@ -3,6 +3,7 @@ // using the arrangement of the dual lines. #include +#include #include "arr_linear.h" #include "read_objects.h" @@ -74,7 +75,7 @@ int main(int argc, char* argv[]) { break; } } - CGAL_assertion(found_collinear); + assert(found_collinear); return (0); } diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/edge_manipulation_curve_history.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/edge_manipulation_curve_history.cpp index 59c36abf614..e89d8b57d89 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/edge_manipulation_curve_history.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/edge_manipulation_curve_history.cpp @@ -46,7 +46,6 @@ int main() { const Point q{_7_halves, 7}; Point_location::result_type obj = pl.locate(q); auto* e = boost::get(&obj); - CGAL_assertion(e); // Split the edge e to two edges e1 and e2; auto e1 = arr.split_edge(arr.non_const_handle(*e), q); diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/face_extension_overlay.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/face_extension_overlay.cpp index c5fbb593f25..7eda7deea85 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/face_extension_overlay.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/face_extension_overlay.cpp @@ -1,6 +1,8 @@ //! \file examples/Arrangement_on_surface_2/face_extension_overlay.cpp // A face overlay of two arrangements with extended face records. +#include + #include #include #include @@ -21,7 +23,8 @@ int main() { insert_non_intersecting_curve(arr1, Segment(Point(6, 2), Point(6, 6))); insert_non_intersecting_curve(arr1, Segment(Point(6, 6), Point(2, 6))); insert_non_intersecting_curve(arr1, Segment(Point(2, 6), Point(2, 2))); - CGAL_assertion(arr1.number_of_faces() == 2); + // 2 because the bounded and the unbounded one + assert(arr1.number_of_faces() == 2); // Mark just the bounded face. for (auto fit = arr1.faces_begin(); fit != arr1.faces_end(); ++fit) @@ -33,7 +36,6 @@ int main() { insert_non_intersecting_curve(arr2, Segment(Point(7, 4), Point(4, 7))); insert_non_intersecting_curve(arr2, Segment(Point(4, 7), Point(1, 4))); insert_non_intersecting_curve(arr2, Segment(Point(1, 4), Point(4, 1))); - CGAL_assertion(arr2.number_of_faces() == 2); for (auto fit = arr2.faces_begin(); fit != arr2.faces_end(); ++fit) fit->set_data(fit != arr2.unbounded_face()); // mark the bounded face. diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/incremental_insertion.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/incremental_insertion.cpp index 7f6e63e1661..51112be6c50 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/incremental_insertion.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/incremental_insertion.cpp @@ -33,7 +33,7 @@ int main() { Point q(4, 1); auto obj = pl.locate(q); auto* f = boost::get(&obj); - CGAL_assertion(f != nullptr); + std::cout << "The query point (" << q << ") is located in: "; print_face(*f); diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/overlay_color.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/overlay_color.cpp index 0a1e106681d..6cb7f17f477 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/overlay_color.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/overlay_color.cpp @@ -1,6 +1,8 @@ //! \file examples/Arrangement_on_surface_2/overlay_color.cpp // The overlay of two arrangement with extended dcel structures +#include + #include #include #include @@ -25,7 +27,7 @@ int main() { insert(arr1, Segment(Point(0, 0), Point(0, 4))); insert(arr1, Segment(Point(2, 0), Point(2, 4))); insert(arr1, Segment(Point(4, 0), Point(4, 4))); - CGAL_assertion(arr1.number_of_faces() == 5); + assert(arr1.number_of_faces() == 5); for (auto vit = arr1.vertices_begin(); vit != arr1.vertices_end(); ++vit) vit->set_data(vcol1); for (auto hit = arr1.halfedges_begin(); hit != arr1.halfedges_end(); ++hit) @@ -41,7 +43,7 @@ int main() { insert(arr2, Segment(Point(0, 0), Point(0, 6))); insert(arr2, Segment(Point(3, 0), Point(3, 6))); insert(arr2, Segment(Point(6, 0), Point(6, 6))); - CGAL_assertion(arr2.number_of_faces() == 5); + assert(arr2.number_of_faces() == 5); for (auto vit = arr2.vertices_begin(); vit != arr2.vertices_end(); ++vit) vit->set_data(vcol2); for (auto hit = arr2.halfedges_begin(); hit != arr2.halfedges_end(); ++hit) diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/point_location_utils.h b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/point_location_utils.h index 556b75113e3..70bc38bce3f 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/point_location_utils.h +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/point_location_utils.h @@ -1,3 +1,4 @@ +#include #include //----------------------------------------------------------------------------- @@ -106,7 +107,7 @@ void shoot_vertical_ray(const VerticalRayShooting& vrs, else if ((e = boost::get(&obj)) ) // hit an edge std::cout << "an edge: " << (*e)->curve() << std::endl; else if ((f = boost::get(&obj))) { // hit nothing - CGAL_assertion((*f)->is_unbounded()); + assert((*f)->is_unbounded()); std::cout << "nothing." << std::endl; } else CGAL_error_msg("Invalid object."); diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/polycurve_bezier.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/polycurve_bezier.cpp index 020320acb89..287fd51786a 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/polycurve_bezier.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/polycurve_bezier.cpp @@ -59,7 +59,6 @@ int main() { std::vector obj_vector; bezier_traits.make_x_monotone_2_object()(B, std::back_inserter(obj_vector)); auto* x_seg_p = boost::get(&obj_vector[0]); - CGAL_assertion(x_seg_p); x_curves.push_back(*x_seg_p); } diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/spherical_degenerate_sweep.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/spherical_degenerate_sweep.cpp index 4646b0cda36..8c6f46dfeb6 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/spherical_degenerate_sweep.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/spherical_degenerate_sweep.cpp @@ -5,6 +5,7 @@ // #define CGAL_ARRANGEMENT_ON_SURFACE_INSERT_VERBOSE 1 // #define CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE 1 +#include #include #include @@ -57,26 +58,26 @@ int main() { X_monotone_curve_2 xcv_sp1 = ctr_xcv(sp, p1); X_monotone_curve_2 xcv_sp2 = ctr_xcv(sp, p2); X_monotone_curve_2 xcv_sp3 = ctr_xcv(sp, p3); - CGAL_assertion(xcv_sp1.is_vertical()); - CGAL_assertion(xcv_sp2.is_vertical()); - CGAL_assertion(xcv_sp3.is_vertical()); + assert(xcv_sp1.is_vertical()); + assert(xcv_sp2.is_vertical()); + assert(xcv_sp3.is_vertical()); xcvs.push_back(xcv_sp1); // 0 xcvs.push_back(xcv_sp2); // 1 xcvs.push_back(xcv_sp3); // 2 X_monotone_curve_2 xcv_12 = ctr_xcv(p1, p2); X_monotone_curve_2 xcv_23 = ctr_xcv(p2, p3); - CGAL_assertion(!xcv_12.is_vertical()); - CGAL_assertion(!xcv_23.is_vertical()); + assert(!xcv_12.is_vertical()); + assert(!xcv_23.is_vertical()); xcvs.push_back(xcv_12); // 3 xcvs.push_back(xcv_23); // 4 X_monotone_curve_2 xcv_np1 = ctr_xcv(np, p1); X_monotone_curve_2 xcv_np2 = ctr_xcv(np, p2); X_monotone_curve_2 xcv_np3 = ctr_xcv(np, p3); - CGAL_assertion(xcv_np1.is_vertical()); - CGAL_assertion(xcv_np2.is_vertical()); - CGAL_assertion(xcv_np3.is_vertical()); + assert(xcv_np1.is_vertical()); + assert(xcv_np2.is_vertical()); + assert(xcv_np3.is_vertical()); xcvs.push_back(xcv_np1); // 5 xcvs.push_back(xcv_np2); // 6 xcvs.push_back(xcv_np3); // 7 diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/spherical_is_in_x_range.h b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/spherical_is_in_x_range.h index 8e25bff3b3a..21eac95bb4b 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/spherical_is_in_x_range.h +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/spherical_is_in_x_range.h @@ -1,13 +1,15 @@ #ifndef IS_IN_X_RANGE_H #define IS_IN_X_RANGE_H +#include + // Check whether the given point is in the x-range of the given curve that // represents a great-circle arc. template bool is_in_x_range(const typename GeometryTraits::X_monotone_curve_2& c, const typename GeometryTraits::Point_2& p, const GeometryTraits& traits) { - CGAL_assertion(! traits.is_on_y_identification_2_object()(p)); + assert(! traits.is_on_y_identification_2_object()(p)); if (traits.is_on_y_identification_2_object()(c)) return false; diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/unb_planar_vertical_decomposition.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/unb_planar_vertical_decomposition.cpp index 72dc3469703..831e0e44395 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/unb_planar_vertical_decomposition.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/unb_planar_vertical_decomposition.cpp @@ -45,7 +45,6 @@ int main() { if (vh) std::cout << '(' << (*vh)->point() << ')'; else { auto* hh = boost::get(&*(curr.first)); - CGAL_assertion(hh); if (! (*hh)->is_fictitious()) std::cout << '[' << (*hh)->curve() << ']'; else std::cout << "NONE"; @@ -59,7 +58,6 @@ int main() { if (vh) std::cout << '(' << (*vh)->point() << ")\n"; else { auto* hh = boost::get(&*(curr.second)); - CGAL_assertion(hh); if (! (*hh)->is_fictitious()) std::cout << '[' << (*hh)->curve() << "]\n"; else std::cout << "NONE\n"; diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/unbounded_non_intersecting.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/unbounded_non_intersecting.cpp index 159d66a6184..7de9d0981d6 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/unbounded_non_intersecting.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/unbounded_non_intersecting.cpp @@ -2,6 +2,8 @@ // Constructing an arrangement of unbounded linear objects using the insertion // function for non-intersecting curves. +#include + #include "arr_linear.h" #include "arr_print.h" @@ -13,7 +15,7 @@ int main() { X_monotone_curve c1 = Line(Point(-1, 0), Point(1, 0)); arr.insert_in_face_interior(c1, arr.unbounded_face()); Vertex_handle v = insert_point(arr, Point(0,0)); - CGAL_assertion(! v->is_at_open_boundary()); + assert(! v->is_at_open_boundary()); // Add two more rays using the specialized insertion functions. arr.insert_from_right_vertex(Ray(Point(0, 0), Point(-1, 1)), v); // c2 diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h index 4b4fea69c74..f926dca65f0 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h @@ -723,29 +723,39 @@ public: return Approximate_2(); } - class Construct_x_monotone_curve_2 - { + //! Functor + class Construct_x_monotone_curve_2 { public: - - /*! - * Return an x-monotone curve connecting the two given endpoints. + /*! Return an x-monotone curve connecting the two given endpoints. * \param p The first point. * \param q The second point. * \pre p and q must not be the same. * \return A segment connecting p and q. */ - X_monotone_curve_2 operator() (const Point_2& p, - const Point_2& q) const - { - return (X_monotone_curve_2 (p, q)); - } + X_monotone_curve_2 operator()(const Point_2& p, const Point_2& q) const + { return (X_monotone_curve_2(p, q)); } }; /*! Get a Construct_x_monotone_curve_2 functor object. */ Construct_x_monotone_curve_2 construct_x_monotone_curve_2_object () const - { - return Construct_x_monotone_curve_2(); - } + { return Construct_x_monotone_curve_2(); } + + //! Functor + class Construct_curve_2 { + public: + /*! Return a curve connecting the two given endpoints. + * \param p The first point. + * \param q The second point. + * \pre p and q must not be the same. + * \return A segment connecting p and q. + */ + Curve_2 operator()(const Point_2& p, const Point_2& q) const + { return (Curve_2(p, q)); } + }; + + /*! Get a Construct_curve_2 functor object. */ + Construct_curve_2 construct_curve_2_object () const + { return Construct_curve_2(); } //@} /// \name Functor definitions for the Boolean set-operation traits. diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geodesic_arc_on_sphere_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geodesic_arc_on_sphere_traits_2.h index e19fb8337c0..fad8aabc754 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_geodesic_arc_on_sphere_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_geodesic_arc_on_sphere_traits_2.h @@ -1663,7 +1663,8 @@ public: * Once we do a better dispatching of the functors (LR-ident + TB-contraction), * an implementation of this signature becomes obsolete. */ - Comparison_result operator()(const Point_2& p1, const Point_2& p2) const + Comparison_result operator()(const Point_2& /* p1 */, + const Point_2& /* p2 */) const { CGAL_error(); return EQUAL; } @@ -3106,40 +3107,6 @@ public: return (*this); } - /*! Construct the minor arc from two endpoint directions. The minor arc - * is the one with the smaller angle among the two geodesic arcs with - * the given endpoints. - * 1. Find out whether the arc is x-monotone. - * 2. If it is x-monotone, - * 2.1 Find out whether it is vertical, and - * 2.2 whether the target is larger than the source (directed right). - * The arc is vertical, iff - * 1. one of its endpoint direction pierces a pole, or - * 2. the projections onto the xy-plane coincide. - * \param source the source point. - * \param target the target point. - * \pre the source and target cannot be equal. - * \pre the source and target cannot be antipodal. - */ - Arr_x_monotone_geodesic_arc_on_sphere_3 - (const Arr_extended_direction_3& source, - const Arr_extended_direction_3& target) : - m_source(source), - m_target(target), - m_is_full(false), - m_is_degenerate(false), - m_is_empty(false) - { - // MSVC 10 complains when the casting below is not present probably due - // to a bug (in MSVC 10). - CGAL_precondition_code(Kernel kernel); - CGAL_precondition(!kernel.equal_3_object() - (kernel.construct_opposite_direction_3_object()(m_source), - (const typename Kernel::Direction_3&)(m_target))); - m_normal = construct_normal_3(m_source, m_target); - init(); - } - /*! Initialize a spherical_arc given that the two endpoint directions * have been set. It is assumed that the arc is the one with the smaller * angle among the two. @@ -3530,109 +3497,6 @@ public: CGAL_precondition(this->has_on(trg)); } - /*! Construct a spherical_arc from two endpoint directions. It is assumed - * that the arc is the one with the smaller angle among the two. - * 1. Find out whether the arc is x-monotone. - * 2. If it is x-monotone, - * 2.1 Find out whether it is vertical, and - * 2.2 whether the target is larger than the source (directed right). - * The arc is vertical, iff - * 1. one of its endpoint direction pierces a pole, or - * 2. the projections onto the xy-plane coincide. - * \param source the source point. - * \param target the target point. - * \pre the source and target cannot be equal. - * \pre the source and target cannot be the opoosite of each other. - */ - Arr_geodesic_arc_on_sphere_3(const Arr_extended_direction_3& source, - const Arr_extended_direction_3& target) - { - this->set_source(source); - this->set_target(target); - this->set_is_full(false); - this->set_is_degenerate(false); - this->set_is_empty(false); - - typedef Arr_geodesic_arc_on_sphere_traits_2 Traits; - typedef typename Kernel::Direction_2 Direction_2; - typedef typename Kernel::Direction_3 Direction_3; - - Kernel kernel; - CGAL_precondition(!kernel.equal_3_object()(Direction_3(source), - Direction_3(target))); - CGAL_precondition(!kernel.equal_3_object() - (kernel.construct_opposite_direction_3_object()(source), - static_cast(target))); - this->m_normal = this->construct_normal_3(source, target); - - // Check whether one of the endpoints coincides with a pole: */ - if (source.is_max_boundary()) { - this->set_is_vertical(true); - this->set_is_directed_right(false); - set_is_x_monotone(true); - return; - } - if (source.is_min_boundary()) { - this->set_is_vertical(true); - this->set_is_directed_right(true); - set_is_x_monotone(true); - return; - } - if (target.is_max_boundary()) { - this->set_is_vertical(true); - this->set_is_directed_right(true); - set_is_x_monotone(true); - return; - } - if (target.is_min_boundary()) { - this->set_is_vertical(true); - this->set_is_directed_right(false); - set_is_x_monotone(true); - return; - } - - // None of the enpoints coincide with a pole: - Direction_3 normal = this->m_normal; - if (z_sign(normal) == ZERO) { - // The arc is vertical - this->set_is_vertical(true); - bool s_is_positive, t_is_positive, plane_is_positive; - CGAL::Sign xsign = x_sign(normal); - if (xsign == ZERO) { - s_is_positive = x_sign(source) == POSITIVE; - t_is_positive = x_sign(target) == POSITIVE; - plane_is_positive = y_sign(normal) == NEGATIVE; - } else { - s_is_positive = y_sign(source) == POSITIVE; - t_is_positive = y_sign(target) == POSITIVE; - plane_is_positive = xsign == POSITIVE; - } - set_is_x_monotone(s_is_positive == t_is_positive); - bool ccw = ((plane_is_positive && s_is_positive) || - (!plane_is_positive && !s_is_positive)); - this->set_is_directed_right(ccw); - return; - } - - // The arc is not vertical! - this->set_is_vertical(false); - Direction_2 s = Traits::project_xy(source); - Direction_2 t = Traits::project_xy(target); - Orientation orient = Traits::orientation(s, t); - - const Direction_2& d = Traits::identification_xy(); - if (orient == LEFT_TURN) { - this->set_is_directed_right(true); - set_is_x_monotone(!kernel.counterclockwise_in_between_2_object()(d, s, t)); - return; - } - - // (orient == RIGHT_TURN) - this->set_is_directed_right(false); - set_is_x_monotone(!kernel.counterclockwise_in_between_2_object()(d, t, s)); - return; - } - /*! Construct a spherical_arc from two endpoint directions contained * in a plane. * \param plane the containing plane. diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h index 96dee434f9a..15bee1cd34b 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h @@ -199,6 +199,35 @@ public: _set (rat_coeffs); } + /*! Construct a segment conic arc from two endpoints. + * \param source the source point with rational coordinates. + */ + _Conic_arc_2(const Point_2& source, const Point_2& target) : + _orient (COLLINEAR), + _info(static_cast(IS_VALID)), + _source(source), + _target(target), + _extra_data_P(nullptr) + { + CGAL_precondition(Alg_kernel().compare_xy_2_object()(_source, _target) != + EQUAL); + + // Compose the equation of the underlying line. + const Algebraic x1 = source.x(); + const Algebraic y1 = source.y(); + const Algebraic x2 = target.x(); + const Algebraic y2 = target.y(); + + // The supporting line is A*x + B*y + C = 0, where: + // A = y2 - y1, B = x1 - x2, C = x2*y1 - x1*y2 + // We use the extra data field to store the equation of this line. + _extra_data_P = new Extra_data; + _extra_data_P->a = y2 - y1; + _extra_data_P->b = x1 - x2; + _extra_data_P->c = x2*y1 - x1*y2; + _extra_data_P->side = ZERO; + } + /*! * Construct a conic arc from the given line segment. * \param seg The line segment with rational endpoints. @@ -325,7 +354,7 @@ public: // and it squared radius is R^2, that its equation is: // x^2 + y^2 - 2*x0*x - 2*y0*y + (x0^2 + y0^2 - R^2) = 0 // Since this equation describes a curve with a negative (clockwise) - // orientation, we multiply it by -1 if necessary to obtain a positive + // orientation, we multiply it by -1 if nece_Conic_arc_2 ssary to obtain a positive // (counterclockwise) orientation. const Rational _zero (0); Rational rat_coeffs[6]; diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_x_monotone_arc_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_x_monotone_arc_2.h index ec70376642b..ad13fe00427 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_x_monotone_arc_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_x_monotone_arc_2.h @@ -177,58 +177,27 @@ public: _set(); } - /*! - * Construct a special segment connecting to given endpoints (for the usage + /*! Construct a special segment connecting to given endpoints (for the usage * of the landmarks point-location strategy). * \param source The source point. * \param target The target point. */ _Conic_x_monotone_arc_2(const Point_2& source, const Point_2& target) : - Base() + Base(source, target) { - // Set the basic properties and clear the _info bits. - this->_source = source; - this->_target = target; - this->_orient = COLLINEAR; - this->_info = 0; + this->_info |= static_cast(DEGREE_1); - // Check if the arc is directed right (the target is lexicographically - // greater than the source point), or to the left. Alg_kernel ker; - Comparison_result dir_res = - ker.compare_xy_2_object()(this->_source, this->_target); - - CGAL_precondition (dir_res != EQUAL); - // Invalid arc: - if (dir_res == EQUAL) return; - - this->_info = (static_cast(Conic_arc_2::IS_VALID) | static_cast(DEGREE_1)); - if (dir_res == SMALLER) - this->_info = (this->_info | IS_DIRECTED_RIGHT); - - // Compose the equation of the underlying line. - const Algebraic x1 = source.x(), y1 = source.y(); - const Algebraic x2 = target.x(), y2 = target.y(); - - // The supporting line is A*x + B*y + C = 0, where: - // - // A = y2 - y1, B = x1 - x2, C = x2*y1 - x1*y2 - // - // We use the extra data field to store the equation of this line. - this->_extra_data_P = new typename Base::Extra_data; - this->_extra_data_P->a = y2 - y1; - this->_extra_data_P->b = x1 - x2; - this->_extra_data_P->c = x2*y1 - x1*y2; - this->_extra_data_P->side = ZERO; + auto cmp_xy = ker.compare_xy_2_object(); + Comparison_result dir_res = cmp_xy(this->_source, this->_target); + if (dir_res == SMALLER) this->_info |= IS_DIRECTED_RIGHT; // Check if the segment is vertical. - if (CGAL::sign (this->_extra_data_P->b) == ZERO) - this->_info = (this->_info | IS_VERTICAL_SEGMENT); + if (CGAL::sign(this->_extra_data_P->b) == ZERO) + this->_info |= IS_VERTICAL_SEGMENT; // Mark that this is a special segment. - this->_info = (this->_info | IS_SPECIAL_SEGMENT); - - return; + this->_info |= IS_SPECIAL_SEGMENT; } /*! @@ -608,7 +577,7 @@ public: if (_has_same_supporting_conic (arc)) { if ((this->_info & FACING_UP) != 0 && (arc._info & FACING_DOWN) != 0) return LARGER; - else if ((this->_info & FACING_DOWN)!= 0 && (arc._info & FACING_UP) != 0) + else if ((this->_info & FACING_DOWN) != 0 && (arc._info & FACING_UP) != 0) return SMALLER; // In this case the two arcs overlap. @@ -680,7 +649,7 @@ public: // comparison result is trivial. if ((this->_info & FACING_UP) != 0 && (arc._info & FACING_DOWN) != 0) return (LARGER); - else if ((this->_info & FACING_DOWN)!= 0 && (arc._info & FACING_UP)!= 0) + else if ((this->_info & FACING_DOWN) != 0 && (arc._info & FACING_UP) != 0) return SMALLER; // Compute the second-order derivative by y and act according to it. @@ -729,7 +698,7 @@ public: if (_has_same_supporting_conic (arc)) { if ((this->_info & FACING_UP) != 0 && (arc._info & FACING_DOWN) != 0) return LARGER; - else if ((this->_info & FACING_DOWN)!= 0 && (arc._info & FACING_UP)!= 0) + else if ((this->_info & FACING_DOWN) != 0 && (arc._info & FACING_UP) != 0) return SMALLER; // In this case the two arcs overlap. @@ -801,7 +770,7 @@ public: // comparison result is trivial. if ((this->_info & FACING_UP) != 0 && (arc._info & FACING_DOWN) != 0) return LARGER; - else if ((this->_info & FACING_DOWN)!= 0 && (arc._info & FACING_UP)!= 0) + else if ((this->_info & FACING_DOWN) != 0 && (arc._info & FACING_UP) != 0) return SMALLER; // Compute the second-order derivative by y and act according to it. diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_linear_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_linear_traits_2.h index 5ad1960f6b7..8a71028c8b4 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_linear_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_linear_traits_2.h @@ -1535,6 +1535,7 @@ public: /*! Obtain an Approximate_2 functor object. */ Approximate_2 approximate_2_object() const { return Approximate_2(); } + //! Functor class Construct_x_monotone_curve_2 { public: /*! Obtain an x-monotone curve connecting the two given endpoints. @@ -1556,6 +1557,17 @@ public: Construct_x_monotone_curve_2 construct_x_monotone_curve_2_object() const { return Construct_x_monotone_curve_2(); } //@} + + /// \name Functor definitions for polylines. + //@{ + + //! Functor + typedef Construct_x_monotone_curve_2 Construct_curve_2; + + /*! Obtain a Construct_curve_2 functor object. */ + Construct_curve_2 construct_curve_2_object() const + { return Construct_x_monotone_curve_2(*this); } + //@} }; /*! diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_non_caching_segment_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_non_caching_segment_traits_2.h index 81852fe41ea..3a6ab1538b8 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_non_caching_segment_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_non_caching_segment_traits_2.h @@ -403,6 +403,18 @@ public: Compare_endpoints_xy_2 compare_endpoints_xy_2_object() const { return Compare_endpoints_xy_2(); } //@} + + //! \name Functor definitions for constructions. + //@{ + + //! Functor + typedef typename Kernel::Construct_segment_2 Construct_curve_2; + + /*! Obtain a Construct_curve_2 functor object. */ + Construct_curve_2 construct_curve_2_object() const + { return this->construct_segment_2_object(); } + + //@} }; } //namespace CGAL diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h index 323ec092056..9477afe821c 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h @@ -163,8 +163,7 @@ public: // { Base::Push_back_2::operator()(xcv, seg); } /* Append a point `p` to an existing polyline `cv` at the back. */ - void operator()(Curve_2& cv, const Point_2& p) const - { + void operator()(Curve_2& cv, const Point_2& p) const { typedef typename Curve_2::size_type size_type; size_type num_seg = cv.number_of_subcurves(); CGAL_precondition(num_seg > 0); @@ -172,8 +171,8 @@ public: const Segment_traits_2* seg_traits = this->m_poly_traits.subcurve_traits_2(); - typename Segment_traits_2::Compare_endpoints_xy_2 cmp_seg_endpts = - seg_traits->compare_endpoints_xy_2_object(); + auto cmp_seg_endpts = seg_traits->compare_endpoints_xy_2_object(); + auto ctr = seg_traits->construct_curve_2_object(); /* Since it is desired to maintain `cv` well-oriented, we have * to append the segment [cv[last_seg].target(),p]. The @@ -181,14 +180,12 @@ public: * the target, i.e. the actual end of `cv`. */ if (cmp_seg_endpts(cv[last_seg]) == SMALLER) { - typename Segment_traits_2::Construct_max_vertex_2 get_max_v = - seg_traits->construct_max_vertex_2_object(); - cv.push_back(Subcurve_2(get_max_v(cv[last_seg]), p)); + auto get_max_v = seg_traits->construct_max_vertex_2_object(); + cv.push_back(ctr(get_max_v(cv[last_seg]), p)); } else { - typename Segment_traits_2::Construct_min_vertex_2 get_min_v = - seg_traits->construct_min_vertex_2_object(); - cv.push_back(Subcurve_2(get_min_v(cv[last_seg]), p)); + auto get_min_v = seg_traits->construct_min_vertex_2_object(); + cv.push_back(ctr(get_min_v(cv[last_seg]), p)); } } @@ -276,8 +273,7 @@ public: // { Base::Push_front_2::operator()(xcv, seg); } /* Append a point `p` to an existing polyline `cv` at the front. */ - void operator()(Curve_2& cv, const Point_2& p) const - { + void operator()(Curve_2& cv, const Point_2& p) const { CGAL_precondition_code ( typedef typename Curve_2::size_type size_type; @@ -287,18 +283,16 @@ public: const Segment_traits_2* geom_traits = this->m_poly_traits.subcurve_traits_2(); - typename Segment_traits_2::Compare_endpoints_xy_2 cmp_seg_endpts = - geom_traits->compare_endpoints_xy_2_object(); + auto cmp_seg_endpts = geom_traits->compare_endpoints_xy_2_object(); + auto ctr = geom_traits->construct_curve_2_object(); if (cmp_seg_endpts(cv[0]) == SMALLER) { - typename Segment_traits_2::Construct_min_vertex_2 get_min_v = - geom_traits->construct_min_vertex_2_object(); - cv.push_front(Subcurve_2(p, get_min_v(cv[0]))); + auto get_min_v = geom_traits->construct_min_vertex_2_object(); + cv.push_front(ctr(p, get_min_v(cv[0]))); } else { - typename Segment_traits_2::Construct_max_vertex_2 get_max_v = - geom_traits->construct_max_vertex_2_object(); - cv.push_front(Subcurve_2(p, get_max_v(cv[0]))); + auto get_max_v = geom_traits->construct_max_vertex_2_object(); + cv.push_front(ctr(p, get_max_v(cv[0]))); } } @@ -369,8 +363,11 @@ public: /* Obtain an polyline connecting two given endpoints. */ - Curve_2 operator()(const Point_2& p, const Point_2& q) const - { return Curve_2(Subcurve_2(p, q)); } + Curve_2 operator()(const Point_2& p, const Point_2& q) const { + const Segment_traits_2* seg_traits = + this->m_poly_traits.subcurve_traits_2(); + return seg_traits->construct_curve_2_object()(p, q); + } /* Obtain a polyline consists of one given segment. */ @@ -433,7 +430,9 @@ public: auto point_pair_to_segment = [&](const Zip_iterator_ref& t)->Subcurve_2 { CGAL_precondition_msg(! equal(boost::get<0>(t), boost::get<1>(t)), "Cannot construct a degenerated segment"); - return Subcurve_2(boost::get<0>(t), boost::get<1>(t)); + const Segment_traits_2* seg_traits = + this->m_poly_traits.subcurve_traits_2(); + return seg_traits->construct_curve_2_object()(boost::get<0>(t), boost::get<1>(t)); }; auto begin_next = std::next(begin); auto end_prev = std::prev(end); 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 6ce3ad5edbf..ee7fe0ac5aa 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 @@ -900,6 +900,7 @@ public: /*! Obtain an Approximate_2 functor object. */ Approximate_2 approximate_2_object() const { return Approximate_2(); } + //! Functor class Construct_x_monotone_curve_2 { protected: typedef Arr_segment_traits_2 Traits; @@ -994,6 +995,17 @@ public: { return Construct_x_monotone_curve_2(*this); } //@} + /// \name Functor definitions for polylines. + //@{ + + //! Functor + typedef Construct_x_monotone_curve_2 Construct_curve_2; + + /*! Obtain a Construct_curve_2 functor object. */ + Construct_curve_2 construct_curve_2_object() const + { return Construct_x_monotone_curve_2(*this); } + //@} + /// \name Functor definitions for the Boolean set-operation traits. //@{ diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_spherical_gaussian_map_3/Arr_spherical_gaussian_map_3.h b/Arrangement_on_surface_2/include/CGAL/Arr_spherical_gaussian_map_3/Arr_spherical_gaussian_map_3.h index 43ba2d947c1..3dfd56071ca 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_spherical_gaussian_map_3/Arr_spherical_gaussian_map_3.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_spherical_gaussian_map_3/Arr_spherical_gaussian_map_3.h @@ -134,8 +134,7 @@ public: OutputIterator oi) { const Geometry_traits_2* traits = this->m_sgm.geometry_traits(); - typename Traits::Construct_point_2 ctr_point = - traits->construct_point_2_object(); + auto ctr_point = traits->construct_point_2_object(); Curve_2 cv = traits->construct_curve_2_object()(ctr_point(normal1.direction()), ctr_point(normal2.direction())); diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_insertion_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_insertion_helper.h index 1c2af52f340..10abb5f19ea 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_insertion_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_insertion_helper.h @@ -143,7 +143,7 @@ before_handle_event(Event* event) */ template void Arr_spherical_insertion_helper:: -before_handle_event_imp(Event* event, Arr_all_sides_oblivious_tag) +before_handle_event_imp(Event* /* event */, Arr_all_sides_oblivious_tag) { return; } /* A notification invoked before the surface-sweep starts handling a given diff --git a/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_ss_visitor.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_ss_visitor.h index 01514fe37cf..87d723501ae 100644 --- a/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_ss_visitor.h +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_ss_visitor.h @@ -24,9 +24,10 @@ #include #include -#include #include +#include + #include #include #include @@ -114,7 +115,7 @@ protected: Halfedge_map; typedef std::pair Handle_info; - typedef boost::unordered_map + typedef std::unordered_map Vertex_map; // Side categoties: diff --git a/Arrangement_on_surface_2/include/CGAL/graph_traits_Arrangement_2.h b/Arrangement_on_surface_2/include/CGAL/graph_traits_Arrangement_2.h index 751414b5d44..77f75138a73 100644 --- a/Arrangement_on_surface_2/include/CGAL/graph_traits_Arrangement_2.h +++ b/Arrangement_on_surface_2/include/CGAL/graph_traits_Arrangement_2.h @@ -24,7 +24,7 @@ */ // include this to avoid a VC15 warning -#include +#include #include #include diff --git a/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_2.h b/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_2.h index cc29b262092..0ff6b278841 100644 --- a/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_2.h +++ b/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_2.h @@ -25,7 +25,7 @@ */ // include this to avoid a VC15 warning -#include +#include #include #include diff --git a/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_on_surface_2.h b/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_on_surface_2.h index 8e23fd7d388..de13e81f559 100644 --- a/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_on_surface_2.h +++ b/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_on_surface_2.h @@ -25,7 +25,7 @@ */ // include this to avoid a VC15 warning -#include +#include #include #include diff --git a/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_on_surface_with_history_2.h b/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_on_surface_with_history_2.h index 06ef9a064c6..dd47b011f46 100644 --- a/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_on_surface_with_history_2.h +++ b/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_on_surface_with_history_2.h @@ -26,7 +26,7 @@ */ // include this to avoid a VC15 warning -#include +#include #include #include diff --git a/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_with_history_2.h b/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_with_history_2.h index 65d95f4e51f..ea9ccdf78f4 100644 --- a/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_with_history_2.h +++ b/Arrangement_on_surface_2/include/CGAL/graph_traits_dual_arrangement_with_history_2.h @@ -26,7 +26,7 @@ */ // include this to avoid a VC15 warning -#include +#include #include #include diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_polycurve_intersection.cpp b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_polycurve_intersection.cpp index 7e3bfe81659..2c0a68510c7 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_polycurve_intersection.cpp +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_polycurve_intersection.cpp @@ -6,6 +6,7 @@ #include #include +#include typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef CGAL::Arr_segment_traits_2 Segment_traits_2; @@ -29,7 +30,7 @@ struct Test_functor { const X_monotone_polyline* poly = CGAL::object_cast(&obj); - CGAL_assertion_msg (poly != nullptr, "Intersection is not a polyline"); + assert(poly != nullptr); // Intersection is not a polyline typename X_monotone_polyline::Point_const_iterator itref = reference->points_begin(), @@ -38,7 +39,7 @@ struct Test_functor for (; itref != reference->points_end() && itpoly != poly->points_end(); ++ itref, ++ itpoly) - CGAL_assertion (*itref == *itpoly); + assert(*itref == *itpoly); } }; diff --git a/BGL/doc/BGL/Doxyfile.in b/BGL/doc/BGL/Doxyfile.in index eef73a0d564..970bf3ffa8b 100644 --- a/BGL/doc/BGL/Doxyfile.in +++ b/BGL/doc/BGL/Doxyfile.in @@ -35,13 +35,6 @@ EXTRACT_ALL=NO HIDE_UNDOC_MEMBERS = YES HIDE_UNDOC_CLASSES = YES -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = YES -EXPAND_AS_DEFINED = CGAL_BGL_NP_TEMPLATE_PARAMETERS \ - CGAL_BGL_NP_CLASS \ - CGAL_DEPRECATED - - # macros to be used inside the code ALIASES += "cgalAssociatedTypesBegin=
Associated Types
" ALIASES += "cgalAssociatedTypesEnd=
" diff --git a/BGL/doc/BGL/NamedParameters.txt b/BGL/doc/BGL/NamedParameters.txt index 70a9e8a8029..8fad0e16910 100644 --- a/BGL/doc/BGL/NamedParameters.txt +++ b/BGL/doc/BGL/NamedParameters.txt @@ -24,7 +24,7 @@ The named parameters in the snippet use the tags `predecessor_map` and `distance and they are concatenated using the dot operator.
A similar mechanism was introduced in \cgal, with the small difference that the named parameters -tag live in the `CGAL::parameters::` namespace and `CGAL::parameters::all_default()` can be used to indicate +tag live in the `CGAL::parameters::` namespace and `CGAL::parameters::default_values()` can be used to indicate that default values of optional named parameters must be used. As in the \bgl, named parameters in \cgal are also concatenated using the dot operator, and a typical usage is thus: @@ -40,7 +40,9 @@ CGAL::copy_face_graph(g1, g2); CGAL::copy_face_graph(g1, g2, CGAL::parameters::vertex_point_map(vpm) //parameter for g1 .vertex_to_vertex_map(v2v), //other parameter for g1 - CGAL::parameters::all_default()); //parameter for g2 + CGAL::parameters::default_values()); //parameter for g2 \endcode */ + + ˛ diff --git a/BGL/doc/BGL/PackageDescription.txt b/BGL/doc/BGL/PackageDescription.txt index d74834a3c19..22d3836facb 100644 --- a/BGL/doc/BGL/PackageDescription.txt +++ b/BGL/doc/BGL/PackageDescription.txt @@ -683,6 +683,8 @@ user might encounter. - `CGAL::set_triangulation_ids()` +- `CGAL::parameters::default_values()` + \cgalCRPSection{Iterators} - `CGAL::Halfedge_around_source_iterator` - `CGAL::Halfedge_around_target_iterator` diff --git a/BGL/examples/BGL_LCC/copy_lcc.cpp b/BGL/examples/BGL_LCC/copy_lcc.cpp index 57a12a5ddb6..6495bcf57d1 100644 --- a/BGL/examples/BGL_LCC/copy_lcc.cpp +++ b/BGL/examples/BGL_LCC/copy_lcc.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; @@ -50,8 +50,8 @@ int main(int argc, char* argv[]) typedef boost::graph_traits::vertex_descriptor tm_vertex_descriptor; typedef boost::graph_traits::halfedge_descriptor tm_halfedge_descriptor; - boost::unordered_map v2v; - boost::unordered_map h2h; + std::unordered_map v2v; + std::unordered_map h2h; CGAL::copy_face_graph(T1, S, CGAL::parameters::vertex_to_vertex_output_iterator(std::inserter(v2v, v2v.end())) .halfedge_to_halfedge_output_iterator(std::inserter(h2h, h2h.end()))); diff --git a/BGL/examples/BGL_graphcut/face_selection_borders_regularization_example.cpp b/BGL/examples/BGL_graphcut/face_selection_borders_regularization_example.cpp index 1868da6145c..c9671dd408e 100644 --- a/BGL/examples/BGL_graphcut/face_selection_borders_regularization_example.cpp +++ b/BGL/examples/BGL_graphcut/face_selection_borders_regularization_example.cpp @@ -23,7 +23,7 @@ int main(int argc, char** argv) Mesh mesh; CGAL::IO::read_OFF (in, mesh); - boost::unordered_map is_selected_map; + std::unordered_map is_selected_map; // randomly select 1/3 of faces std::size_t nb_selected_before = 0; diff --git a/BGL/examples/BGL_polyhedron_3/copy_polyhedron.cpp b/BGL/examples/BGL_polyhedron_3/copy_polyhedron.cpp index 7840c805a7e..660f9179bdd 100644 --- a/BGL/examples/BGL_polyhedron_3/copy_polyhedron.cpp +++ b/BGL/examples/BGL_polyhedron_3/copy_polyhedron.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; @@ -56,9 +56,9 @@ int main(int argc, char* argv[]) typedef boost::graph_traits::face_descriptor tm_face_descriptor; // Use an unordered_map to keep track of elements. - boost::unordered_map v2v; - boost::unordered_map h2h; - boost::unordered_map f2f; + std::unordered_map v2v; + std::unordered_map h2h; + std::unordered_map f2f; CGAL::copy_face_graph(S, T2, CGAL::parameters::vertex_to_vertex_output_iterator(std::inserter(v2v, v2v.end())) .halfedge_to_halfedge_output_iterator(std::inserter(h2h, h2h.end())) @@ -83,9 +83,9 @@ int main(int argc, char* argv[]) typedef boost::graph_traits::face_descriptor tm_face_descriptor; - boost::unordered_map v2v; - boost::unordered_map h2h; - boost::unordered_map f2f; + std::unordered_map v2v; + std::unordered_map h2h; + std::unordered_map f2f; CGAL::copy_face_graph(T1, S, CGAL::parameters::vertex_to_vertex_map(boost::make_assoc_property_map(v2v)) .halfedge_to_halfedge_output_iterator(std::inserter(h2h, h2h.end())) .face_to_face_map(boost::make_assoc_property_map(f2f))); diff --git a/BGL/examples/BGL_surface_mesh/surface_mesh_partition.cpp b/BGL/examples/BGL_surface_mesh/surface_mesh_partition.cpp index 50ec6b0affa..57c96a907d8 100644 --- a/BGL/examples/BGL_surface_mesh/surface_mesh_partition.cpp +++ b/BGL/examples/BGL_surface_mesh/surface_mesh_partition.cpp @@ -7,6 +7,7 @@ #include #include +#include typedef CGAL::Simple_cartesian K; typedef CGAL::Surface_mesh SM; @@ -39,7 +40,7 @@ int main(int argc, char** argv) // Extract the part n°0 of the partition into a new, independent mesh typedef CGAL::Face_filtered_graph Filtered_graph; Filtered_graph filtered_sm(sm, 0 /*id of th part*/, face_pid_map); - CGAL_assertion(filtered_sm.is_selection_valid()); + assert(filtered_sm.is_selection_valid()); SM part_sm; CGAL::copy_face_graph(filtered_sm, part_sm); diff --git a/BGL/include/CGAL/boost/graph/Face_filtered_graph.h b/BGL/include/CGAL/boost/graph/Face_filtered_graph.h index e957754d03c..6647245fab7 100644 --- a/BGL/include/CGAL/boost/graph/Face_filtered_graph.h +++ b/BGL/include/CGAL/boost/graph/Face_filtered_graph.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -26,17 +26,12 @@ #include #include #include -#include +#include #include #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { /*! @@ -152,9 +147,9 @@ struct Face_filtered_graph * \cgalParamNEnd * \cgalNamedParamsEnd */ - template + template Face_filtered_graph(const Graph& graph, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) : _graph(const_cast(graph)) , fimap(CGAL::get_initialized_face_index_map(graph, np)) , vimap(CGAL::get_initialized_vertex_index_map(graph, np)) @@ -164,10 +159,6 @@ struct Face_filtered_graph , selected_halfedges(num_halfedges(graph), 0) {} - Face_filtered_graph(const Graph& graph) - :Face_filtered_graph(graph, parameters::all_default()) - {} - /*! * \brief Constructor where the set of selected faces is specified as a range of patch ids. * @@ -217,11 +208,11 @@ struct Face_filtered_graph * \cgalParamNEnd * \cgalNamedParamsEnd */ - template + template Face_filtered_graph(const Graph& graph, const FacePatchIndexRange& selected_face_patch_indices, FacePatchIndexMap face_patch_index_map, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np #ifndef DOXYGEN_RUNNING , typename boost::enable_if< typename boost::has_range_const_iterator::type @@ -299,11 +290,11 @@ struct Face_filtered_graph * \cgalParamNEnd * \cgalNamedParamsEnd */ - template + template Face_filtered_graph(const Graph& graph, typename boost::property_traits::value_type selected_face_patch_index, FacePatchIndexMap face_patch_index_map, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) : _graph(const_cast(graph)), fimap(CGAL::get_initialized_face_index_map(graph, np)), vimap(CGAL::get_initialized_vertex_index_map(graph, np)), @@ -369,10 +360,10 @@ struct Face_filtered_graph * \cgalParamNEnd * \cgalNamedParamsEnd */ - template + template Face_filtered_graph(const Graph& graph, const FaceRange& selected_faces, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) : _graph(const_cast(graph)), fimap(CGAL::get_initialized_face_index_map(graph, np)), vimap(CGAL::get_initialized_vertex_index_map(graph, np)), @@ -446,7 +437,7 @@ struct Face_filtered_graph initialize_halfedge_indices(); } - ///change the set of selected faces using a patch id + /// changes the set of selected faces using a patch id. template void set_selected_faces(typename boost::property_traits::value_type face_patch_id, FacePatchIndexMap face_patch_index_map) @@ -475,7 +466,7 @@ struct Face_filtered_graph reset_indices(); } - /// change the set of selected faces using a range of patch ids + /// changes the set of selected faces using a range of patch ids template void set_selected_faces(const FacePatchIndexRange& selected_face_patch_indices, FacePatchIndexMap face_patch_index_map @@ -495,8 +486,8 @@ struct Face_filtered_graph selected_halfedges.reset(); typedef typename boost::property_traits::value_type Patch_index; - boost::unordered_set pids(boost::begin(selected_face_patch_indices), - boost::end(selected_face_patch_indices)); + std::unordered_set pids(boost::begin(selected_face_patch_indices), + boost::end(selected_face_patch_indices)); for(face_descriptor fd : faces(_graph) ) { @@ -515,7 +506,7 @@ struct Face_filtered_graph reset_indices(); } - /// change the set of selected faces using a range of face descriptors + /// changes the set of selected faces using a range of face descriptors. template void set_selected_faces(const FaceRange& selection) { @@ -578,18 +569,21 @@ struct Face_filtered_graph { return selected_halfedges[get(himap, halfedge(e,_graph))]; } - ///returns the number of selected faces - size_type number_of_faces()const + + /// returns the number of selected faces. + size_type number_of_faces() const { return selected_faces.count(); } -///returns the number of selected vertices. - size_type number_of_vertices()const + + /// returns the number of selected vertices. + size_type number_of_vertices() const { return selected_vertices.count(); } -///returns the number of selected halfedges. - size_type number_of_halfedges()const + + /// returns the number of selected halfedges. + size_type number_of_halfedges() const { return selected_halfedges.count(); } @@ -621,21 +615,18 @@ struct Face_filtered_graph return bind_property_maps(himap, make_property_map(halfedge_indices) ); } - /// returns `true` if around any vertex of a selected face, - /// there is at most one connected set of selected faces. + /// returns `true` if around any vertex of a selected face there is at most a single umbrella bool is_selection_valid() const { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - // Non-manifoldness can appear either: - // - if 'pm' is pinched at a vertex. While traversing the incoming halfedges at this vertex, - // we will meet strictly more than one border halfedge. - // - if there are multiple umbrellas around a vertex. In that case, we will find a non-visited - // halfedge that has for target a vertex that is already visited. + // Non-manifoldness can appear if there are multiple umbrellas around a vertex. + // In that case, we will find a non-visited halfedge that has for target a vertex + // that is already visited. - boost::unordered_set vertices_visited; - boost::unordered_set halfedges_handled; + std::unordered_set vertices_visited; + std::unordered_set halfedges_handled; for(halfedge_descriptor hd : halfedges(*this)) { @@ -652,15 +643,11 @@ struct Face_filtered_graph if(!vertices_visited.insert(vd).second) return false; - std::size_t border_halfedge_counter = 0; - - // Can't simply call halfedges_around_target(vd, *this) because 'halfedge(vd)' is not necessarily 'hd' + // Can't call halfedges_around_target(vd, *this) because 'halfedge(vd)' is not necessarily 'hd' halfedge_descriptor ihd = hd; do { halfedges_handled.insert(ihd); - if(is_border(ihd, *this)) - ++border_halfedge_counter; do { @@ -669,14 +656,32 @@ struct Face_filtered_graph while(!is_in_cc(ihd) && ihd != hd); } while(ihd != hd); - - if(border_halfedge_counter > 1) - return false; } return true; } + /// inverts the selected status of faces. + void invert_selection() + { + selected_faces=~selected_faces; + selected_halfedges.reset(); + selected_vertices.reset(); + + for(face_descriptor fd : faces(_graph)) + { + if (!selected_faces.test(get(fimap, fd))) continue; + for(halfedge_descriptor hd : halfedges_around_face(halfedge(fd, _graph), _graph)) + { + selected_halfedges.set(get(himap, hd)); + selected_halfedges.set(get(himap, opposite(hd, _graph))); + selected_vertices.set(get(vimap, target(hd, _graph))); + } + } + + reset_indices(); + } + private: Graph& _graph; FIM fimap; @@ -1059,7 +1064,8 @@ typename boost::graph_traits< Face_filtered_graph >: next(typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor h, const Face_filtered_graph & w) { - CGAL_assertion(w.is_in_cc(h)); + CGAL_precondition(w.is_in_cc(h)); + if(w.is_in_cc(next(h, w.graph()))) return next(h, w.graph()); @@ -1083,8 +1089,8 @@ typename boost::graph_traits< Face_filtered_graph >: prev(typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor h, const Face_filtered_graph & w) { + CGAL_precondition(w.is_in_cc(h)); - CGAL_assertion(w.is_in_cc(h)); if(w.is_in_cc(prev(h, w.graph()))) return prev(h, w.graph()); diff --git a/BGL/include/CGAL/boost/graph/IO/GOCAD.h b/BGL/include/CGAL/boost/graph/IO/GOCAD.h index a3d8b48cf88..b273394ae84 100644 --- a/BGL/include/CGAL/boost/graph/IO/GOCAD.h +++ b/BGL/include/CGAL/boost/graph/IO/GOCAD.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include @@ -25,11 +25,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -113,17 +108,17 @@ public: /// \returns `true` if reading was successful and the resulting mesh is valid, `false` otherwise. /// template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_GOCAD(std::istream& is, std::pair& name_and_color, Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif ) { - typedef typename CGAL::GetVertexPointMap::type VPM; + typedef typename CGAL::GetVertexPointMap::type VPM; typedef typename boost::property_traits::value_type Point; internal::GOCAD_builder builder(is); @@ -138,27 +133,14 @@ bool read_GOCAD(std::istream& is, /// \cond SKIP_IN_MANUAL -template -bool read_GOCAD(std::istream& is, std::pair& name_and_color, Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return read_GOCAD(is, name_and_color, g, parameters::all_default()); -} - -template -bool read_GOCAD(std::istream& is, Graph& g, const CGAL_BGL_NP_CLASS& np, +template +bool read_GOCAD(std::istream& is, Graph& g, const CGAL_NP_CLASS& np = parameters::default_values(), typename boost::disable_if >::type* = nullptr) { std::pair dummy; return read_GOCAD(is, dummy, g, np); } -template -bool read_GOCAD(std::istream& is, Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return read_GOCAD(is, g, parameters::all_default()); -} /// \endcond @@ -200,11 +182,11 @@ bool read_GOCAD(std::istream& is, Graph& g, /// \returns `true` if reading was successful and the resulting mesh is valid, `false` otherwise. /// template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_GOCAD(const std::string& fname, std::pair& name_and_color, Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -217,28 +199,14 @@ bool read_GOCAD(const std::string& fname, /// \cond SKIP_IN_MANUAL -template -bool read_GOCAD(const std::string& fname, std::pair& name_and_color, Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return read_GOCAD(fname, name_and_color, g, parameters::all_default()); -} - -template -bool read_GOCAD(const std::string& fname, Graph& g, const CGAL_BGL_NP_CLASS& np, +template +bool read_GOCAD(const std::string& fname, Graph& g, const CGAL_NP_CLASS& np = parameters::default_values(), typename boost::disable_if >::type* = nullptr) { std::pair dummy; return read_GOCAD(fname, dummy, g, np); } -template -bool read_GOCAD(const std::string& fname, Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return read_GOCAD(fname, g, parameters::all_default()); -} - /// \endcond //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -277,11 +245,11 @@ bool read_GOCAD(const std::string& fname, Graph& g, /// \returns `true` if writing was successful, `false` otherwise. /// template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_GOCAD(std::ostream& os, const char* name, const Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -295,7 +263,7 @@ bool write_GOCAD(std::ostream& os, using parameters::choose_parameter; using parameters::get_parameter; - typename CGAL::GetVertexPointMap::const_type + typename CGAL::GetVertexPointMap::const_type vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(CGAL::vertex_point, g)); @@ -341,17 +309,6 @@ bool write_GOCAD(std::ostream& os, return os.good(); } -/// \cond SKIP_IN_MANUAL - -template -bool write_GOCAD(std::ostream& os, const char* name, const Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return write_GOCAD(os, name, g, parameters::all_default()); -} - -/// \endcond - /// \ingroup PkgBGLIoFuncsGOCAD /// /// \brief writes the graph `g` in the \ref IOStreamGocad into `os`. @@ -385,10 +342,10 @@ bool write_GOCAD(std::ostream& os, const char* name, const Graph& g, /// \returns `true` if writing was successful, `false` otherwise. /// template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_GOCAD(std::ostream& os, const Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -397,17 +354,6 @@ bool write_GOCAD(std::ostream& os, return write_GOCAD(os, "anonymous", g, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_GOCAD(std::ostream& os, const Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return write_GOCAD(os, g, parameters::all_default()); -} - -/// \endcond - /// \ingroup PkgBGLIoFuncsGOCAD /// /// \brief writes the graph `g` into a file named `fname`, using the \ref IOStreamGocad. @@ -441,10 +387,10 @@ bool write_GOCAD(std::ostream& os, const Graph& g, /// \sa Overloads of this function for specific models of the concept `FaceGraph`. /// template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_GOCAD(const std::string& fname, const Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -456,17 +402,6 @@ bool write_GOCAD(const std::string& fname, return write_GOCAD(os, fname.c_str(), g, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_GOCAD(const std::string& fname, const Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return write_GOCAD(fname, g, parameters::all_default()); -} - -/// \endcond - }} // namespace CGAL::IO #endif // CGAL_BGL_IO_GOCAD_H diff --git a/BGL/include/CGAL/boost/graph/IO/Generic_facegraph_builder.h b/BGL/include/CGAL/boost/graph/IO/Generic_facegraph_builder.h index b78d97f5af8..76b3e48836b 100644 --- a/BGL/include/CGAL/boost/graph/IO/Generic_facegraph_builder.h +++ b/BGL/include/CGAL/boost/graph/IO/Generic_facegraph_builder.h @@ -38,8 +38,8 @@ protected: public: Generic_facegraph_builder(std::istream& in_) : m_is(in_) { } - template - bool operator()(Graph& g, const NamedParameters& np) + template + bool operator()(Graph& g, const NamedParameters& np = parameters::default_values()) { typedef typename GetK::Kernel Kernel; typedef typename Kernel::Vector_3 Vector; @@ -76,10 +76,10 @@ public: using parameters::is_default_parameter; using parameters::get_parameter; - const bool is_vnm_requested = !(is_default_parameter(get_parameter(np, internal_np::vertex_normal_map))); - const bool is_vcm_requested = !(is_default_parameter(get_parameter(np, internal_np::vertex_color_map))); - const bool is_vtm_requested = !(is_default_parameter(get_parameter(np, internal_np::vertex_texture_map))); - const bool is_fcm_requested = !(is_default_parameter(get_parameter(np, internal_np::face_color_map))); + const bool is_vnm_requested = !(is_default_parameter()); + const bool is_vcm_requested = !(is_default_parameter()); + const bool is_vtm_requested = !(is_default_parameter()); + const bool is_fcm_requested = !(is_default_parameter()); std::vector vertex_normals; std::vector vertex_colors; @@ -154,8 +154,6 @@ public: return is_valid(g); } - bool operator()(Graph& g) { return operator()(g, parameters::all_default()); } - protected: std::istream& m_is; diff --git a/BGL/include/CGAL/boost/graph/IO/Generic_facegraph_printer.h b/BGL/include/CGAL/boost/graph/IO/Generic_facegraph_printer.h index c78861a855d..de848713e89 100644 --- a/BGL/include/CGAL/boost/graph/IO/Generic_facegraph_printer.h +++ b/BGL/include/CGAL/boost/graph/IO/Generic_facegraph_printer.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include @@ -88,9 +88,9 @@ public: Generic_facegraph_printer(Stream& os) : m_os(os) { } Generic_facegraph_printer(Stream& os, FileWriter writer) : m_os(os), m_writer(writer) { } - template + template bool operator()(const Graph& g, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename GetVertexPointMap::const_type VPM; typedef typename boost::property_traits::reference Point_ref; @@ -122,10 +122,10 @@ public: VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(CGAL::vertex_point, g)); - const bool has_vertex_normals = !(is_default_parameter(get_parameter(np, internal_np::vertex_normal_map))); - const bool has_vertex_colors = !(is_default_parameter(get_parameter(np, internal_np::vertex_color_map))); - const bool has_vertex_textures = !(is_default_parameter(get_parameter(np, internal_np::vertex_texture_map))); - const bool has_face_colors = !(is_default_parameter(get_parameter(np, internal_np::face_color_map))); + const bool has_vertex_normals = !(is_default_parameter()); + const bool has_vertex_colors = !(is_default_parameter()); + const bool has_vertex_textures = !(is_default_parameter()); + const bool has_face_colors = !(is_default_parameter()); VNM vnm = get_parameter(np, internal_np::vertex_normal_map); VTM vtm = get_parameter(np, internal_np::vertex_texture_map); @@ -193,8 +193,6 @@ public: return m_os.good(); } - bool operator()(const Graph& g) { return operator()(g, parameters::all_default()); } - protected: Stream& m_os; FileWriter m_writer; diff --git a/BGL/include/CGAL/boost/graph/IO/INP.h b/BGL/include/CGAL/boost/graph/IO/INP.h index 9194174dd9b..eec6986e16f 100644 --- a/BGL/include/CGAL/boost/graph/IO/INP.h +++ b/BGL/include/CGAL/boost/graph/IO/INP.h @@ -13,7 +13,7 @@ #define CGAL_BGL_IO_INP_H #include -#include +#include #include #include @@ -27,18 +27,18 @@ namespace IO { /// \cond SKIP_IN_MANUAL -template +template bool write_INP(std::ostream& os, const std::string& name, const std::string& type, const Graph& g, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef typename boost::graph_traits::vertices_size_type vertices_size_type; - typedef typename CGAL::GetVertexPointMap::const_type VPM; + typedef typename CGAL::GetVertexPointMap::const_type VPM; typedef typename boost::property_traits::reference Point_ref; using parameters::choose_parameter; @@ -76,46 +76,26 @@ bool write_INP(std::ostream& os, return os.good(); } -template +template bool write_INP(const std::string& fname, const std::string& type, const Graph& g, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values() ) { std::ofstream os(fname); return write_INP(os, fname, type, g, np); } -template -bool write_INP(std::ostream& os, const std::string& name, const std::string& type, const Graph& g) -{ - return write_INP(os, name, type, g, parameters::all_default()); -} - -template -bool write_INP(const std::string& fname, const std::string& type, const Graph& g) -{ - return write_INP(fname, type, g, parameters::all_default()); -} - #ifndef CGAL_NO_DEPRECATED_CODE -template +template CGAL_DEPRECATED bool write_inp(std::ostream& os, const FaceGraph& g, std::string name, std::string type, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { return write_INP(os, name, type, g, np); } -template -CGAL_DEPRECATED bool write_inp(std::ostream& os, - const FaceGraph& g, - std::string name, - std::string type) -{ - return write_INP(os, name, type, g, parameters::all_default()); -} #endif /// \endcond diff --git a/BGL/include/CGAL/boost/graph/IO/OBJ.h b/BGL/include/CGAL/boost/graph/IO/OBJ.h index ba09a85e6da..16e779bf9ba 100644 --- a/BGL/include/CGAL/boost/graph/IO/OBJ.h +++ b/BGL/include/CGAL/boost/graph/IO/OBJ.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -28,11 +28,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -109,33 +104,22 @@ public: \sa Overloads of this function for specific models of the concept `FaceGraph`. */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_OBJ(std::istream& is, Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif ) { - typedef typename CGAL::GetVertexPointMap::type VPM; + typedef typename CGAL::GetVertexPointMap::type VPM; typedef typename boost::property_traits::value_type Point; internal::OBJ_builder builder(is); return builder(g, np); } -/// \cond SKIP_IN_MANUAL - -template -bool read_OBJ(std::istream& is, Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return read_OBJ(is, g, parameters::all_default()); -} - -/// \endcond - /*! \ingroup PkgBGLIoFuncsOBJ @@ -176,10 +160,10 @@ bool read_OBJ(std::istream& is, Graph& g, \sa Overloads of this function for specific models of the concept `FaceGraph`. */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_OBJ(const std::string& fname, Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -190,17 +174,6 @@ bool read_OBJ(const std::string& fname, return read_OBJ(is, g, np); } -/// \cond SKIP_IN_MANUAL - -template -bool read_OBJ(const std::string& fname, Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return read_OBJ(fname, g, parameters::all_default()); -} - -/// \endcond - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // Write @@ -239,10 +212,10 @@ bool read_OBJ(const std::string& fname, Graph& g, \sa Overloads of this function for specific models of the concept `FaceGraph`. */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_OBJ(std::ostream& os, const Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -252,17 +225,6 @@ bool write_OBJ(std::ostream& os, return printer(g, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_OBJ(std::ostream& os, const Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return write_OBJ(os, g, parameters::all_default()); -} - -/// \endcond - /*! \ingroup PkgBGLIoFuncsOBJ @@ -296,10 +258,10 @@ bool write_OBJ(std::ostream& os, const Graph& g, \sa Overloads of this function for specific models of the concept `FaceGraph`. */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_OBJ(const std::string& fname, const Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -310,17 +272,6 @@ bool write_OBJ(const std::string& fname, return write_OBJ(os, g, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_OBJ(const std::string& fname, const Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return write_OBJ(fname, g, parameters::all_default()); -} - -/// \endcond - }} // namespace CGAL::IO #endif // CGAL_BGL_IO_OBJ_H diff --git a/BGL/include/CGAL/boost/graph/IO/OFF.h b/BGL/include/CGAL/boost/graph/IO/OFF.h index 03e7dd1c7dc..0d1b242be5e 100644 --- a/BGL/include/CGAL/boost/graph/IO/OFF.h +++ b/BGL/include/CGAL/boost/graph/IO/OFF.h @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include @@ -28,12 +28,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -70,12 +64,12 @@ public: // Because some packages can provide overloads with the same signature to automatically initialize // property maps (see Surface_mesh/IO/ for example) -template +template bool read_OFF_BGL(std::istream& is, Graph& g, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) { - typedef typename CGAL::GetVertexPointMap::type VPM; + typedef typename CGAL::GetVertexPointMap::type VPM; typedef typename boost::property_traits::value_type Point; internal::OFF_builder builder(is); @@ -156,10 +150,10 @@ bool read_OFF_BGL(std::istream& is, \sa Overloads of this function for specific models of the concept `FaceGraph`. */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_OFF(std::istream& is, Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -168,17 +162,6 @@ bool read_OFF(std::istream& is, return internal::read_OFF_BGL(is, g, np); } -/// \cond SKIP_IN_MANUAL - -template -bool read_OFF(std::istream& is, Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return read_OFF(is, g, parameters::all_default()); -} - -/// \endcond - /*! \ingroup PkgBGLIoFuncsOFF @@ -251,10 +234,10 @@ bool read_OFF(std::istream& is, Graph& g, \sa Overloads of this function for specific models of the concept `FaceGraph`. */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_OFF(const std::string& fname, Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -264,17 +247,6 @@ bool read_OFF(const std::string& fname, return read_OFF(is, g, np); } -/// \cond SKIP_IN_MANUAL - -template -bool read_OFF(const std::string& fname, Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return read_OFF(fname, g, parameters::all_default()); -} - -/// \endcond - } // namespace IO #ifndef CGAL_NO_DEPRECATED_CODE @@ -284,8 +256,8 @@ bool read_OFF(const std::string& fname, Graph& g, \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::read_OFF()` should be used instead. */ -template -CGAL_DEPRECATED bool read_off(std::istream& is, Graph& g, const CGAL_BGL_NP_CLASS& np) +template +CGAL_DEPRECATED bool read_off(std::istream& is, Graph& g, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::read_OFF(is, g, np); } @@ -295,28 +267,15 @@ CGAL_DEPRECATED bool read_off(std::istream& is, Graph& g, const CGAL_BGL_NP_CLAS \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::read_OFF()` should be used instead. */ -template -CGAL_DEPRECATED bool read_off(const char* fname, Graph& g, const CGAL_BGL_NP_CLASS& np) +template +CGAL_DEPRECATED bool read_off(const char* fname, Graph& g, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::read_OFF(fname, g, np); } - -template -CGAL_DEPRECATED bool read_off(std::istream& is, Graph& g) -{ - return read_off(is, g, parameters::all_default()); -} - -template -CGAL_DEPRECATED bool read_off(const char* fname, Graph& g) -{ - return read_off(fname, g, parameters::all_default()); -} - template CGAL_DEPRECATED bool read_off(const std::string& fname, Graph& g) { - return read_off(fname.c_str(), g, parameters::all_default()); + return read_off(fname.c_str(), g, parameters::default_values()); } #endif // CGAL_NO_DEPRECATED_CODE @@ -328,10 +287,10 @@ CGAL_DEPRECATED bool read_off(const std::string& fname, Graph& g) namespace IO { namespace internal { -template +template bool write_OFF_BGL(std::ostream& os, const Graph& g, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) { internal::Generic_facegraph_printer printer(os); return printer(g, np); @@ -401,10 +360,10 @@ bool write_OFF_BGL(std::ostream& os, \sa Overloads of this function for specific models of the concept `FaceGraph`. */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_OFF(std::ostream& os, const Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -413,17 +372,6 @@ bool write_OFF(std::ostream& os, return internal::write_OFF_BGL(os, g, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_OFF(std::ostream& os, const Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return write_OFF(os, g, parameters::all_default()); -} - -/// \endcond - /*! \ingroup PkgBGLIoFuncsOFF @@ -486,10 +434,10 @@ bool write_OFF(std::ostream& os, const Graph& g, \sa Overloads of this function for specific models of the concept `FaceGraph`. */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_OFF(const std::string& fname, const Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -505,17 +453,6 @@ bool write_OFF(const std::string& fname, return write_OFF(os, g, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_OFF(const std::string& fname, const Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return write_OFF(fname, g, parameters::all_default()); -} - -/// \endcond - } // namespace IO #ifndef CGAL_NO_DEPRECATED_CODE @@ -525,33 +462,23 @@ bool write_OFF(const std::string& fname, const Graph& g, \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::write_OFF()` should be used instead. */ -template -CGAL_DEPRECATED bool write_off(std::ostream& os, const Graph& g, const CGAL_BGL_NP_CLASS& np) +template +CGAL_DEPRECATED bool write_off(std::ostream& os, const Graph& g, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::write_OFF(os, g, np); } -template -CGAL_DEPRECATED bool write_off(std::ostream& os, const Graph& g) -{ - return write_off(os, g, CGAL::parameters::all_default()); -} /*! \ingroup PkgBGLIOFctDeprecated \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::write_OFF()` should be used instead. */ -template -CGAL_DEPRECATED bool write_off(const char* fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) +template +CGAL_DEPRECATED bool write_off(const char* fname, const Graph& g, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::write_OFF(fname, g, np); } -template -CGAL_DEPRECATED bool write_off(const char* fname, const Graph& g) -{ - return write_off(fname, g, parameters::all_default()); -} #endif // CGAL_NO_DEPRECATED_CODE } // namespace CGAL diff --git a/BGL/include/CGAL/boost/graph/IO/PLY.h b/BGL/include/CGAL/boost/graph/IO/PLY.h index 6cf64f5dd1f..df8345258fc 100644 --- a/BGL/include/CGAL/boost/graph/IO/PLY.h +++ b/BGL/include/CGAL/boost/graph/IO/PLY.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include @@ -24,11 +24,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -63,12 +58,12 @@ public: } }; -template +template bool read_PLY_BGL(std::istream& is, Graph& g, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { - typedef typename CGAL::GetVertexPointMap::type VPM; + typedef typename CGAL::GetVertexPointMap::type VPM; typedef typename boost::property_traits::value_type Point; internal::PLY_builder builder(is); @@ -136,10 +131,10 @@ bool read_PLY_BGL(std::istream& is, \sa Overloads of this function for specific models of the concept `FaceGraph`. */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_PLY(std::istream& is, Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -148,17 +143,6 @@ bool read_PLY(std::istream& is, return internal::read_PLY_BGL(is, g, np); } -/// \cond SKIP_IN_MANUAL - -template -bool read_PLY(std::istream& is, Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return internal::read_PLY_BGL(is, g, parameters::all_default()); -} - -/// \endcond - /*! \ingroup PkgBGLIoFuncsPLY @@ -222,10 +206,10 @@ bool read_PLY(std::istream& is, Graph& g, \sa Overloads of this function for specific models of the concept `FaceGraph`. */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_PLY(const std::string& fname, Graph& g, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -246,17 +230,6 @@ bool read_PLY(const std::string& fname, } } -/// \cond SKIP_IN_MANUAL - -template -bool read_PLY(const std::string& fname, Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return read_PLY(fname, g, parameters::all_default()); -} - -/// \endcond - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // Write @@ -319,11 +292,11 @@ bool read_PLY(const std::string& fname, Graph& g, \returns `true` if writing was successful, `false` otherwise. */ -template +template bool write_PLY(std::ostream& os, const Graph& g, const std::string& comments, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -333,17 +306,17 @@ bool write_PLY(std::ostream& os, typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename CGAL::GetInitializedVertexIndexMap::const_type VIMap; - typedef typename GetVertexPointMap::const_type Vpm; + typedef typename CGAL::GetInitializedVertexIndexMap::const_type VIMap; + typedef typename GetVertexPointMap::const_type Vpm; typedef typename boost::property_traits::value_type Point_3; typedef CGAL::IO::Color Color; typedef typename internal_np::Lookup_named_param_def< internal_np::vertex_color_map_t, - CGAL_BGL_NP_CLASS, + CGAL_NP_CLASS, Constant_property_map >::type VCM; typedef typename internal_np::Lookup_named_param_def< internal_np::face_color_map_t, - CGAL_BGL_NP_CLASS, + CGAL_NP_CLASS, Constant_property_map >::type FCM; using parameters::choose_parameter; @@ -353,8 +326,8 @@ bool write_PLY(std::ostream& os, VCM vcm = choose_parameter(get_parameter(np, internal_np::vertex_color_map), VCM()); FCM fcm = choose_parameter(get_parameter(np, internal_np::face_color_map), FCM()); - bool has_vcolor = !is_default_parameter(get_parameter(np, internal_np::vertex_color_map)); - bool has_fcolor = !is_default_parameter(get_parameter(np, internal_np::face_color_map)); + bool has_vcolor = !is_default_parameter(); + bool has_fcolor = !is_default_parameter(); VIMap vim = CGAL::get_initialized_vertex_index_map(g, np); Vpm vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(boost::vertex_point, g)); @@ -446,27 +419,13 @@ bool write_PLY(std::ostream& os, /// \cond SKIP_IN_MANUAL -template -bool write_PLY(std::ostream& os, const Graph& g, const std::string& comments, - typename boost::disable_if >::type* = nullptr) -{ - return write_PLY(os, g, comments, parameters::all_default()); -} - -template -bool write_PLY(std::ostream& os, const Graph& g, const CGAL_BGL_NP_CLASS& np, +template +bool write_PLY(std::ostream& os, const Graph& g, const CGAL_NP_CLASS& np = parameters::default_values(), typename boost::disable_if >::type* = nullptr) { return write_PLY(os, g, std::string(), np); } -template -bool write_PLY(std::ostream& os, const Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return write_PLY(os, g, std::string(), parameters::all_default()); -} - /// \endcond /*! @@ -529,11 +488,11 @@ bool write_PLY(std::ostream& os, const Graph& g, \returns `true` if writing was successful, `false` otherwise. */ -template +template bool write_PLY(const std::string& fname, const Graph& g, const std::string& comments, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if >::type* = nullptr #endif @@ -557,27 +516,13 @@ bool write_PLY(const std::string& fname, /// \cond SKIP_IN_MANUAL -template -bool write_PLY(const std::string& fname, const Graph& g, const std::string comments, - typename boost::disable_if >::type* = nullptr) -{ - return write_PLY(fname, g, comments, parameters::all_default()); -} - -template -bool write_PLY(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np, +template +bool write_PLY(const std::string& fname, const Graph& g, const CGAL_NP_CLASS& np = parameters::default_values(), typename boost::disable_if >::type* = nullptr) { return write_PLY(fname, g, std::string(), np); } -template -bool write_PLY(const std::string& fname, const Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return write_PLY(fname, g, std::string(), parameters::all_default()); -} - /// \endcond } } // namespace CGAL::IO diff --git a/BGL/include/CGAL/boost/graph/IO/STL.h b/BGL/include/CGAL/boost/graph/IO/STL.h index 1a1c05e082c..d2090bfa052 100644 --- a/BGL/include/CGAL/boost/graph/IO/STL.h +++ b/BGL/include/CGAL/boost/graph/IO/STL.h @@ -23,11 +23,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -103,12 +98,12 @@ public: \sa Overloads of this function for specific models of the concept `FaceGraph`. */ -template +template bool read_STL(std::istream& is, Graph& g, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) { - typedef typename CGAL::GetVertexPointMap::type VPM; + typedef typename CGAL::GetVertexPointMap::type VPM; typedef typename boost::property_traits::value_type Point; if(!is.good()) return false; @@ -160,10 +155,10 @@ bool read_STL(std::istream& is, \sa Overloads of this function for specific models of the concept `FaceGraph`. */ -template +template bool read_STL(const std::string& fname, Graph& g, const - CGAL_BGL_NP_CLASS& np) + CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -182,7 +177,7 @@ bool read_STL(const std::string& fname, std::ifstream is(fname); CGAL::IO::set_mode(is, CGAL::IO::ASCII); - typedef typename CGAL::GetVertexPointMap::type VPM; + typedef typename CGAL::GetVertexPointMap::type VPM; VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(CGAL::vertex_point, g)); bool v = choose_parameter(get_parameter(np, internal_np::verbose), @@ -193,9 +188,7 @@ bool read_STL(const std::string& fname, /// \cond SKIP_IN_MANUAL template -bool read_STL(std::istream& is, Graph& g) { return read_STL(is, g, parameters::all_default()); } -template -bool read_STL(const std::string& fname, Graph& g) { return read_STL(fname, g, parameters::all_default()); } +bool read_STL(std::istream& is, Graph& g) { return read_STL(is, g, parameters::default_values()); } /// \endcond @@ -241,15 +234,15 @@ bool read_STL(const std::string& fname, Graph& g) { return read_STL(fname, g, pa \returns `true` if writing was successful, `false` otherwise. */ -template +template bool write_STL(std::ostream& os, const Graph& g, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename CGAL::GetVertexPointMap::const_type VPM; + typedef typename CGAL::GetVertexPointMap::const_type VPM; typedef typename boost::property_traits::reference Point_ref; typedef typename boost::property_traits::value_type Point; typedef typename Kernel_traits::Kernel::Vector_3 Vector; @@ -358,8 +351,8 @@ bool write_STL(std::ostream& os, \sa Overloads of this function for specific models of the concept `FaceGraph`. */ -template -bool write_STL(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) +template +bool write_STL(const std::string& fname, const Graph& g, const CGAL_NP_CLASS& np = parameters::default_values()) { const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true); if(binary) @@ -377,15 +370,6 @@ bool write_STL(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS } } -/// \cond SKIP_IN_MANUAL - -template -bool write_STL(std::ostream& os, const Graph& g) { return write_STL(os, g, parameters::all_default()); } -template -bool write_STL(const std::string& fname, const Graph& g) { return write_STL(fname, g, parameters::all_default()); } - -/// \endcond - }} // namespace CGAL::IO #endif // CGAL_BGL_IO_STL_H diff --git a/BGL/include/CGAL/boost/graph/IO/VTK.h b/BGL/include/CGAL/boost/graph/IO/VTK.h index 58cf152f21c..931c744765e 100644 --- a/BGL/include/CGAL/boost/graph/IO/VTK.h +++ b/BGL/include/CGAL/boost/graph/IO/VTK.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include @@ -32,12 +32,6 @@ #if defined(CGAL_USE_VTK) || defined(DOXYGEN_RUNNING) -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -146,10 +140,10 @@ bool vtkPointSet_to_polygon_mesh(vtkPointSet* poly_data, * \returns `true` if reading was successful, `false` otherwise. */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_VTP(const std::string& fname, Graph& g, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { std::ifstream test(fname); if(!test.good()) @@ -168,13 +162,6 @@ bool read_VTP(const std::string& fname, return internal::vtkPointSet_to_polygon_mesh(data, g, np); } -/// \cond SKIP_IN_MANUAL - -template -bool read_VTP(const std::string& fname, Graph& g) { return read_VTP(fname, g, parameters::all_default()); } - -/// \endcond - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // Write @@ -425,10 +412,10 @@ void write_polys_points(std::ostream& os, * * \returns `true` if writing was successful, `false` otherwise. */ -template +template bool write_VTP(std::ostream& os, const Graph& g, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::get_parameter; using parameters::choose_parameter; @@ -524,8 +511,8 @@ bool write_VTP(std::ostream& os, * * \returns `true` if writing was successful, `false` otherwise. */ -template -bool write_VTP(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) +template +bool write_VTP(const std::string& fname, const Graph& g, const CGAL_NP_CLASS& np = parameters::default_values()) { const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true); std::ofstream os; @@ -539,14 +526,6 @@ bool write_VTP(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS return write_VTP(os, g, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_VTP(std::ostream& os, const Graph& g) { return write_VTP(os, g, CGAL::parameters::all_default()); } -template -bool write_VTP(const std::string& fname, const Graph& g) { return write_VTP(fname, g, parameters::all_default()); } - -/// \endcond } // namespace IO @@ -557,18 +536,12 @@ bool write_VTP(const std::string& fname, const Graph& g) { return write_VTP(fnam \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::write_VTP()` should be used instead. */ -template -CGAL_DEPRECATED bool write_vtp(std::ostream& os, const Graph& g, const CGAL_BGL_NP_CLASS& np) +template +CGAL_DEPRECATED bool write_vtp(std::ostream& os, const Graph& g, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::write_VTP(os, g, np); } -template -CGAL_DEPRECATED bool write_vtp(std::ostream& os, const Graph& g) -{ - return write_vtp(os, g, parameters::all_default()); -} - #endif // CGAL_NO_DEPRECATED_CODE } // namespace CGAL diff --git a/BGL/include/CGAL/boost/graph/IO/WRL.h b/BGL/include/CGAL/boost/graph/IO/WRL.h index b149c35c149..b92429a193b 100644 --- a/BGL/include/CGAL/boost/graph/IO/WRL.h +++ b/BGL/include/CGAL/boost/graph/IO/WRL.h @@ -16,18 +16,12 @@ #include -#include +#include #include #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { namespace IO { @@ -67,10 +61,10 @@ namespace IO { \returns `true` if writing was successful, `false` otherwise. */ -template +template bool write_WRL(std::ostream& os, const Graph& g, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { CGAL::VRML_2_ostream vos(os); internal::Generic_facegraph_printer printer(vos); @@ -108,18 +102,13 @@ bool write_WRL(std::ostream& os, \returns `true` if writing was successful, `false` otherwise. */ -template -bool write_WRL(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) +template +bool write_WRL(const std::string& fname, const Graph& g, const CGAL_NP_CLASS& np = parameters::default_values()) { std::ofstream os(fname); return write_WRL(os, g, np); } -template -bool write_WRL(std::ostream& os, const Graph& g) { return write_WRL(os, g, parameters::all_default()); } -template -bool write_WRL(const std::string& fname, const Graph& g) { return write_WRL(fname, g, parameters::all_default()); } - } // namespace IO #ifndef CGAL_NO_DEPRECATED_CODE @@ -129,18 +118,12 @@ bool write_WRL(const std::string& fname, const Graph& g) { return write_WRL(fnam \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::write_WRL()` should be used instead. */ -template -CGAL_DEPRECATED bool write_wrl(std::ostream& os, const Graph& g, const CGAL_BGL_NP_CLASS& np) +template +CGAL_DEPRECATED bool write_wrl(std::ostream& os, const Graph& g, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::write_WRL(os, g, np); } -template -CGAL_DEPRECATED bool write_wrl(std::ostream& os, const Graph& g) -{ - return write_wrl(os, g, parameters::all_default()); -} - #endif // CGAL_NO_DEPRECATED_CODE } // namespace CGAL diff --git a/BGL/include/CGAL/boost/graph/IO/polygon_mesh_io.h b/BGL/include/CGAL/boost/graph/IO/polygon_mesh_io.h index 958982f28b0..6c156266172 100644 --- a/BGL/include/CGAL/boost/graph/IO/polygon_mesh_io.h +++ b/BGL/include/CGAL/boost/graph/IO/polygon_mesh_io.h @@ -36,10 +36,10 @@ namespace IO { //not for now : some readers will return "ok" despite not managing to read anything /* -template +template bool read_polygon_mesh(std::istream& is, Graph& g, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { bool ok = false; ok = read_OFF(is, g, np, false); @@ -70,12 +70,6 @@ bool read_polygon_mesh(std::istream& is, return ok; } -template -bool read_polygon_mesh(std::istream& is, - Graph& g) -{ - return read_polygon_mesh(is, g, parameters::all_default()); -} */ /*! @@ -125,10 +119,10 @@ bool read_polygon_mesh(std::istream& is, * * \sa \link PMP_IO_grp `CGAL::Polygon_mesh_processing::IO::read_polygon_mesh()`\endlink if the data is not 2-manifold */ -template +template bool read_polygon_mesh(const std::string& fname, Graph& g, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false); @@ -164,16 +158,6 @@ bool read_polygon_mesh(const std::string& fname, return false; } -/// \cond SKIP_IN_MANUAL - -template -bool read_polygon_mesh(const std::string& fname, Graph& g) -{ - return read_polygon_mesh(fname, g, parameters::all_default()); -} - -/// \endcond - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // Write @@ -228,10 +212,10 @@ bool read_polygon_mesh(const std::string& fname, Graph& g) * * \return `true` if writing was successful, `false` otherwise. */ -template +template bool write_polygon_mesh(const std::string& fname, Graph& g, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false); @@ -267,16 +251,6 @@ bool write_polygon_mesh(const std::string& fname, return false; } -/// \cond SKIP_IN_MANUAL - -template -bool write_polygon_mesh(const std::string& fname, Graph& g) -{ - return write_polygon_mesh(fname, g, parameters::all_default()); -} - -/// \endcond - }} // namespace CGAL::IO #endif // CGAL_BOOST_GRAPH_POLYGON_MESH_IO_H diff --git a/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h b/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h index 69e31c2eb95..72be6347a71 100644 --- a/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h +++ b/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include @@ -184,20 +184,14 @@ void partition_dual_graph(const TriangleMesh& tm, int nparts, /// /// \pre `tm` is a pure triangular surface mesh: there are no edges /// without at least one incident face -template -void partition_dual_graph(const TriangleMesh& tm, int nparts, const NamedParameters& np) +template +void partition_dual_graph(const TriangleMesh& tm, int nparts, const NamedParameters& np = parameters::default_values()) { using parameters::get_parameter; return partition_dual_graph(tm, nparts, get_parameter(np, internal_np::METIS_options), np); } -template -void partition_dual_graph(const TriangleMesh& tm, const int nparts) -{ - return partition_dual_graph(tm, nparts, CGAL::parameters::all_default()); -} - } // end namespace METIS } // end namespace CGAL diff --git a/BGL/include/CGAL/boost/graph/METIS/partition_graph.h b/BGL/include/CGAL/boost/graph/METIS/partition_graph.h index ae1058c3917..e1054f84837 100644 --- a/BGL/include/CGAL/boost/graph/METIS/partition_graph.h +++ b/BGL/include/CGAL/boost/graph/METIS/partition_graph.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include @@ -217,20 +217,14 @@ void partition_graph(const TriangleMesh& tm, int nparts, /// /// \pre `tm` is a pure triangular surface mesh: there are no edges /// without at least one incident face -template -void partition_graph(const TriangleMesh& tm, int nparts, const NamedParameters& np) +template +void partition_graph(const TriangleMesh& tm, int nparts, const NamedParameters& np = parameters::default_values()) { using parameters::get_parameter; return partition_graph(tm, nparts, get_parameter(np, internal_np::METIS_options), np); } -template -void partition_graph(const TriangleMesh& tm, const int nparts) -{ - return partition_graph(tm, nparts, CGAL::parameters::all_default()); -} - } // end namespace METIS } // end namespace CGAL diff --git a/BGL/include/CGAL/boost/graph/Seam_mesh.h b/BGL/include/CGAL/boost/graph/Seam_mesh.h index c74accc8586..5971942b17b 100644 --- a/BGL/include/CGAL/boost/graph/Seam_mesh.h +++ b/BGL/include/CGAL/boost/graph/Seam_mesh.h @@ -19,10 +19,11 @@ #include #include +#include #include -#include +#include #include #include #include @@ -934,7 +935,7 @@ public: void build_TM_vertices_vector(std::vector& tm_vds) const { - assert(tm_vds.empty()); + CGAL_precondition(tm_vds.empty()); // If the input is a list of integers, we need to build a correspondence // between vertices and integers. @@ -1008,7 +1009,7 @@ public: TM_halfedge_descriptor add_seams(InputIterator first, InputIterator last) { // must have an even number of input vertices - assert(std::distance(first, last) % 2 == 0); + CGAL_precondition(std::distance(first, last) % 2 == 0); TM_halfedge_descriptor tmhd = boost::graph_traits::null_halfedge(); InputIterator it = first; diff --git a/BGL/include/CGAL/boost/graph/alpha_expansion_graphcut.h b/BGL/include/CGAL/boost/graph/alpha_expansion_graphcut.h index 308da82f6d0..c76e7b9ec3e 100644 --- a/BGL/include/CGAL/boost/graph/alpha_expansion_graphcut.h +++ b/BGL/include/CGAL/boost/graph/alpha_expansion_graphcut.h @@ -20,7 +20,7 @@ #endif #include -#include +#include #include #include @@ -508,12 +508,12 @@ template + typename NamedParameters = parameters::Default_named_parameters> double alpha_expansion_graphcut (const InputGraph& input_graph, EdgeCostMap edge_cost_map, VertexLabelCostMap vertex_label_cost_map, VertexLabelMap vertex_label_map, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -660,22 +660,7 @@ double alpha_expansion_graphcut (const InputGraph& input_graph, return min_cut; } - /// \cond SKIP_IN_MANUAL -// variant with default NP -template -double alpha_expansion_graphcut (const InputGraph& input_graph, - EdgeCostMap edge_cost_map, - VertexLabelCostMap vertex_label_cost_map, - VertexLabelMap vertex_label_map) -{ - return alpha_expansion_graphcut (input_graph, edge_cost_map, - vertex_label_cost_map, vertex_label_map, - CGAL::parameters::all_default()); -} // Old API inline double alpha_expansion_graphcut (const std::vector >& edges, diff --git a/BGL/include/CGAL/boost/graph/copy_face_graph.h b/BGL/include/CGAL/boost/graph/copy_face_graph.h index 19755ac8e46..2a4850647ce 100644 --- a/BGL/include/CGAL/boost/graph/copy_face_graph.h +++ b/BGL/include/CGAL/boost/graph/copy_face_graph.h @@ -20,13 +20,14 @@ #include #include #include -#include +#include #include #include -#include #include #include +#include + namespace CGAL { namespace internal { @@ -351,21 +352,12 @@ inline Emptyset_iterator make_functor(const internal_np::Param_not_found&) Other properties are not copied. */ template void copy_face_graph(const SourceMesh& sm, TargetMesh& tm, - #ifndef DOXYGEN_RUNNING - const CGAL::Named_function_parameters& np1, - const CGAL::Named_function_parameters& np2 - #else - const NamedParameters1& np1, - const NamedParameters2& np2 - #endif + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values() ) { using parameters::choose_parameter; @@ -384,55 +376,6 @@ void copy_face_graph(const SourceMesh& sm, TargetMesh& tm, get(vertex_point, tm))); } -template -void copy_face_graph(const SourceMesh& sm, TargetMesh& tm) -{ - copy_face_graph(sm, tm, parameters::all_default(), parameters::all_default()); -} - -template -void copy_face_graph(const SourceMesh& sm, TargetMesh& tm, - const CGAL::Named_function_parameters& np) -{ - copy_face_graph(sm, tm, np, parameters::all_default()); -} - -#if !defined(DOXYGEN_RUNNING) && !defined(CGAL_NO_DEPRECATED_CODE) -template -void copy_face_graph(const SourceMesh& sm, TargetMesh& tm, - V2V v2v, H2H h2h, F2F f2f, - Src_vpm sm_vpm, Tgt_vpm tm_vpm ) -{ - internal::copy_face_graph_impl(sm, tm, - v2v, h2h, f2f, - sm_vpm, tm_vpm); -} - - -template -void copy_face_graph(const SourceMesh& sm, TargetMesh& tm, V2V v2v) -{ copy_face_graph(sm, tm, v2v, Emptyset_iterator(), Emptyset_iterator(), - get(vertex_point, sm), get(vertex_point, tm)); } - -template -void copy_face_graph(const SourceMesh& sm, TargetMesh& tm, V2V v2v, H2H h2h) -{ copy_face_graph(sm, tm, v2v, h2h, Emptyset_iterator(), - get(vertex_point, sm), get(vertex_point, tm)); } - -template -void copy_face_graph(const SourceMesh& sm, TargetMesh& tm, V2V v2v, H2H h2h, F2F f2f) -{ copy_face_graph(sm, tm, v2v, h2h, f2f, - get(vertex_point, sm), get(vertex_point, tm)); } - -template -void copy_face_graph(const SourceMesh& sm, TargetMesh& tm, V2V v2v, H2H h2h, F2F f2f, Src_vpm sm_vpm) -{ copy_face_graph(sm, tm, v2v, h2h, f2f, - sm_vpm, get(vertex_point, tm)); } -#endif - } // namespace CGAL #endif // CGAL_BOOST_GRAPH_COPY_FACE_GRAPH_H diff --git a/BGL/include/CGAL/boost/graph/dijkstra_shortest_paths.h b/BGL/include/CGAL/boost/graph/dijkstra_shortest_paths.h index 9ac84628c7b..e9fb0c317d4 100644 --- a/BGL/include/CGAL/boost/graph/dijkstra_shortest_paths.h +++ b/BGL/include/CGAL/boost/graph/dijkstra_shortest_paths.h @@ -14,7 +14,7 @@ #define CGAL_BOOST_GRAPH_DIJKSTRA_SHORTEST_PATHS_H // This will push/pop a VC15 warning -#include +#include #include #endif // CGAL_BOOST_GRAPH_DIJKSTRA_SHORTEST_PATHS_H diff --git a/BGL/include/CGAL/boost/graph/generators.h b/BGL/include/CGAL/boost/graph/generators.h index dd9cb32b393..d49a53fd814 100644 --- a/BGL/include/CGAL/boost/graph/generators.h +++ b/BGL/include/CGAL/boost/graph/generators.h @@ -19,6 +19,10 @@ #include #include +#include +#include +#include + namespace CGAL { namespace Euler { @@ -640,8 +644,9 @@ template typename boost::graph_traits::halfedge_descriptor make_icosahedron(Graph& g, const P& center = P(0,0,0), - typename CGAL::Kernel_traits

::Kernel::FT radius = 1.0) + typename CGAL::Kernel_traits

::Kernel::FT radius = 1) { + typedef typename CGAL::Kernel_traits

::Kernel::FT FT; typedef typename boost::property_map::type Point_property_map; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; Point_property_map vpmap = get(CGAL::vertex_point, g); @@ -652,70 +657,71 @@ make_icosahedron(Graph& g, for(int i=0; i<12; ++i) v_vertices[i] = add_vertex(g); - typename CGAL::Kernel_traits

::Kernel::FT t = radius * (1.0 + CGAL::approximate_sqrt(5.0)) / 2.0; + const FT phi = (FT(1) + CGAL::approximate_sqrt(FT(5))) / FT(2); + const FT t = radius / CGAL::approximate_sqrt(1 + square(phi)); + const FT t_phi = t * phi; - put(vpmap, v_vertices[0], P(-radius + center.x(), t + center.y(), 0.0 + center.z())); - put(vpmap, v_vertices[1], P( radius + center.x(), t + center.y(), 0.0 + center.z())); - put(vpmap, v_vertices[2], P(-radius + center.x(), -t + center.y(), 0.0 + center.z())); - put(vpmap, v_vertices[3], P( radius + center.x(), -t + center.y(), 0.0 + center.z())); + put(vpmap, v_vertices[0], P(center.x(), center.y() + t, center.z() + t_phi)); + put(vpmap, v_vertices[1], P(center.x(), center.y() + t, center.z() - t_phi)); + put(vpmap, v_vertices[2], P(center.x(), center.y() - t, center.z() + t_phi)); + put(vpmap, v_vertices[3], P(center.x(), center.y() - t, center.z() - t_phi)); - put(vpmap, v_vertices[4], P( 0.0 + center.x(), -radius + center.y(), t + center.z())); - put(vpmap, v_vertices[5], P( 0.0 + center.x(), radius + center.y(), t + center.z())); - put(vpmap, v_vertices[6], P( 0.0 + center.x(), -radius + center.y(), -t + center.z())); - put(vpmap, v_vertices[7], P( 0.0 + center.x(), radius + center.y(), -t + center.z())); + put(vpmap, v_vertices[4], P(center.x() + t, center.y() + t_phi, center.z())); + put(vpmap, v_vertices[5], P(center.x() + t, center.y() - t_phi, center.z())); + put(vpmap, v_vertices[6], P(center.x() - t, center.y() + t_phi, center.z())); + put(vpmap, v_vertices[7], P(center.x() - t, center.y() - t_phi, center.z())); - put(vpmap, v_vertices[8], P( t + center.x(), 0.0 + center.y(), -radius + center.z())); - put(vpmap, v_vertices[9], P( t + center.x(), 0.0 + center.y(), radius + center.z())); - put(vpmap, v_vertices[10], P(-t + center.x(), 0.0 + center.y(), -radius + center.z())); - put(vpmap, v_vertices[11], P(-t + center.x(), 0.0 + center.y(), radius + center.z())); + put(vpmap, v_vertices[8], P(center.x() + t_phi, center.y(), center.z() + t)); + put(vpmap, v_vertices[9], P(center.x() + t_phi, center.y(), center.z() - t)); + put(vpmap, v_vertices[10], P(center.x() - t_phi, center.y(), center.z() + t)); + put(vpmap, v_vertices[11], P(center.x() - t_phi, center.y(), center.z() - t)); - std::vector face; - face.resize(3); - face[1] = v_vertices[0]; face[0] = v_vertices[5]; face[2] = v_vertices[11]; + std::array face; + face[0] = v_vertices[0]; face[1] = v_vertices[2]; face[2] = v_vertices[8]; Euler::add_face(face, g); - face[1] = v_vertices[0]; face[0] = v_vertices[1]; face[2] = v_vertices[5]; + face[0] = v_vertices[0]; face[1] = v_vertices[8]; face[2] = v_vertices[4]; Euler::add_face(face, g); - face[1] = v_vertices[0]; face[0] = v_vertices[7]; face[2] = v_vertices[1]; + face[0] = v_vertices[0]; face[1] = v_vertices[4]; face[2] = v_vertices[6]; Euler::add_face(face, g); - face[1] = v_vertices[0]; face[0] = v_vertices[10]; face[2] = v_vertices[7]; + face[0] = v_vertices[0]; face[1] = v_vertices[6]; face[2] = v_vertices[10]; Euler::add_face(face, g); - face[1] = v_vertices[0]; face[0] = v_vertices[11]; face[2] = v_vertices[10]; + face[0] = v_vertices[0]; face[1] = v_vertices[10]; face[2] = v_vertices[2]; Euler::add_face(face, g); - face[1] = v_vertices[1]; face[0] = v_vertices[9]; face[2] = v_vertices[5]; + face[0] = v_vertices[1]; face[1] = v_vertices[9]; face[2] = v_vertices[3]; Euler::add_face(face, g); - face[1] = v_vertices[5]; face[0] = v_vertices[4]; face[2] = v_vertices[11]; + face[0] = v_vertices[1]; face[1] = v_vertices[3]; face[2] = v_vertices[11]; Euler::add_face(face, g); - face[1] = v_vertices[11]; face[0] = v_vertices[2]; face[2] = v_vertices[10]; + face[0] = v_vertices[1]; face[1] = v_vertices[11]; face[2] = v_vertices[6]; Euler::add_face(face, g); - face[1] = v_vertices[10]; face[0] = v_vertices[6]; face[2] = v_vertices[7]; + face[0] = v_vertices[1]; face[1] = v_vertices[6]; face[2] = v_vertices[4]; Euler::add_face(face, g); - face[1] = v_vertices[7]; face[0] = v_vertices[8]; face[2] = v_vertices[1]; + face[0] = v_vertices[1]; face[1] = v_vertices[4]; face[2] = v_vertices[9]; Euler::add_face(face, g); - face[1] = v_vertices[3]; face[0] = v_vertices[4]; face[2] = v_vertices[9]; + face[0] = v_vertices[5]; face[1] = v_vertices[8]; face[2] = v_vertices[2]; Euler::add_face(face, g); - face[1] = v_vertices[3]; face[0] = v_vertices[2]; face[2] = v_vertices[4]; + face[0] = v_vertices[5]; face[1] = v_vertices[2]; face[2] = v_vertices[7]; Euler::add_face(face, g); - face[1] = v_vertices[3]; face[0] = v_vertices[6]; face[2] = v_vertices[2]; + face[0] = v_vertices[5]; face[1] = v_vertices[7]; face[2] = v_vertices[3]; Euler::add_face(face, g); - face[1] = v_vertices[3]; face[0] = v_vertices[8]; face[2] = v_vertices[6]; + face[0] = v_vertices[5]; face[1] = v_vertices[3]; face[2] = v_vertices[9]; Euler::add_face(face, g); - face[1] = v_vertices[3]; face[0] = v_vertices[9]; face[2] = v_vertices[8]; + face[0] = v_vertices[5]; face[1] = v_vertices[9]; face[2] = v_vertices[8]; Euler::add_face(face, g); - face[1] = v_vertices[4]; face[0] = v_vertices[5]; face[2] = v_vertices[9]; + face[0] = v_vertices[8]; face[1] = v_vertices[9]; face[2] = v_vertices[4]; Euler::add_face(face, g); - face[1] = v_vertices[2]; face[0] = v_vertices[11]; face[2] = v_vertices[4]; + face[0] = v_vertices[3]; face[1] = v_vertices[7]; face[2] = v_vertices[11]; Euler::add_face(face, g); - face[1] = v_vertices[6]; face[0] = v_vertices[10]; face[2] = v_vertices[2]; + face[0] = v_vertices[11]; face[1] = v_vertices[7]; face[2] = v_vertices[10]; Euler::add_face(face, g); - face[1] = v_vertices[8]; face[0] = v_vertices[7]; face[2] = v_vertices[6]; + face[0] = v_vertices[10]; face[1] = v_vertices[7]; face[2] = v_vertices[2]; Euler::add_face(face, g); - face[1] = v_vertices[9]; face[0] = v_vertices[1]; face[2] = v_vertices[8]; + face[0] = v_vertices[6]; face[1] = v_vertices[11]; face[2] = v_vertices[10]; Euler::add_face(face, g); - return halfedge(v_vertices[1], v_vertices[0], g).first; + return halfedge(v_vertices[5], v_vertices[0], g).first; } /*! diff --git a/BGL/include/CGAL/boost/graph/graph_traits_OpenMesh.h b/BGL/include/CGAL/boost/graph/graph_traits_OpenMesh.h index 19bf533ce22..0783b2f8ee3 100644 --- a/BGL/include/CGAL/boost/graph/graph_traits_OpenMesh.h +++ b/BGL/include/CGAL/boost/graph/graph_traits_OpenMesh.h @@ -10,7 +10,7 @@ // Author(s) : Andreas Fabri, Philipp Moeller // include this to avoid a VC15 warning -#include +#include #include #include diff --git a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h index a1842b8148a..2d85e38d35c 100644 --- a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h +++ b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h @@ -13,7 +13,7 @@ #define CGAL_BOOST_GRAPH_INITIALIZED_INTERNAL_INDEX_MAPS_HELPERS #include -#include +#include #include #include #include @@ -271,7 +271,7 @@ get_initialized_index_map(CGAL::internal_np::Param_not_found, template > + typename NamedParameters = parameters::Default_named_parameters > class GetInitializedIndexMap { public: diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 0d8ca71e7d6..0cc6eb0e638 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -10,7 +10,7 @@ #define CGAL_BOOST_GRAPH_NAMED_PARAMETERS_HELPERS_H #include -#include +#include #include #include #include @@ -122,7 +122,7 @@ namespace CGAL { }; template > + typename NamedParameters = parameters::Default_named_parameters > class GetVertexPointMap { typedef typename property_map_selector::const_type @@ -153,7 +153,7 @@ namespace CGAL { }; template, + typename NamedParametersGT = parameters::Default_named_parameters, typename NamedParametersVPM = NamedParametersGT > class GetGeomTraits { @@ -189,8 +189,7 @@ namespace CGAL { #define CGAL_DEF_GET_INDEX_TYPE(CTYPE, DTYPE, STYPE) \ template > \ + typename NamedParameters = parameters::Default_named_parameters> \ struct GetInitialized##CTYPE##IndexMap \ : public BGL::internal::GetInitializedIndexMap::faces_s #define CGAL_DEF_GET_INITIALIZED_INDEX_MAP(DTYPE, STYPE) \ template \ + typename NamedParameters = parameters::Default_named_parameters> \ typename BGL::internal::GetInitializedIndexMap, \ Graph, NamedParameters>::const_type \ get_initialized_##DTYPE##_index_map(const Graph& g, \ - const NamedParameters& np) \ + const NamedParameters& np = parameters::default_values()) \ { \ typedef BGL::internal::GetInitializedIndexMap Index_map_getter; \ return Index_map_getter::get_const(CGAL::internal_np::DTYPE##_index_t{}, g, np); \ } \ -template \ -typename BGL::internal::GetInitializedIndexMap, \ - Graph>::const_type \ -get_initialized_##DTYPE##_index_map(const Graph& g) \ -{ \ - return get_initialized_##DTYPE##_index_map(g, CGAL::parameters::all_default()); \ -} \ /* same as above, non-const version*/ \ template ::type>::value, int> = 0> \ @@ -253,7 +243,7 @@ typename BGL::internal::GetInitializedIndexMap, \ Graph, NamedParameters>::type \ get_initialized_##DTYPE##_index_map(Graph& g, \ - const NamedParameters& np) \ + const NamedParameters& np = parameters::default_values()) \ { \ typedef BGL::internal::GetInitializedIndexMap Index_map_getter; \ return Index_map_getter::get(CGAL::internal_np::DTYPE##_index_t{}, g, np); \ } \ -template ::type>::value, int> = 0> \ -typename BGL::internal::GetInitializedIndexMap, \ - Graph>::type \ -get_initialized_##DTYPE##_index_map(Graph& g) \ -{ \ - return get_initialized_##DTYPE##_index_map(g, CGAL::parameters::all_default()); \ -} CGAL_DEF_GET_INITIALIZED_INDEX_MAP(vertex, typename boost::graph_traits::vertices_size_type) CGAL_DEF_GET_INITIALIZED_INDEX_MAP(halfedge, typename boost::graph_traits::halfedges_size_type) @@ -280,35 +259,12 @@ CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face, typename boost::graph_traits::fa #undef CGAL_DEF_GET_INITIALIZED_INDEX_MAP - template - class GetFaceNormalMap - { - struct DummyNormalPmap - { - typedef typename boost::graph_traits::face_descriptor key_type; - typedef typename GetGeomTraits::type::Vector_3 value_type; - typedef value_type reference; - typedef boost::readable_property_map_tag category; - - typedef DummyNormalPmap Self; - friend value_type get(const Self&, const key_type&) { return CGAL::NULL_VECTOR; } - }; - - public: - typedef DummyNormalPmap NoMap; - typedef typename internal_np::Lookup_named_param_def < - internal_np::face_normal_t, - NamedParameters, - DummyNormalPmap//default - > ::type type; - }; - namespace internal { BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_nested_type_iterator, iterator, false) } template, + typename NamedParameters = parameters::Default_named_parameters, bool has_nested_iterator = internal::Has_nested_type_iterator::value, typename NP_TAG = internal_np::point_t > @@ -342,8 +298,75 @@ CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face, typename boost::graph_traits::fa typedef typename CGAL::Identity_property_map const_type; }; - namespace Point_set_processing_3 { + template + struct Point_set_processing_3_np_helper + { + typedef typename std::iterator_traits::value_type Value_type; + typedef CGAL::Identity_property_map DefaultPMap; + typedef CGAL::Identity_property_map DefaultConstPMap; + typedef typename internal_np::Lookup_named_param_def ::type Point_map; // public + typedef typename internal_np::Lookup_named_param_def ::type Const_point_map; // public + + typedef typename boost::property_traits::value_type Point; + typedef typename Kernel_traits::Kernel Default_geom_traits; + + typedef typename internal_np::Lookup_named_param_def < + internal_np::geom_traits_t, + NamedParameters, + Default_geom_traits + > ::type Geom_traits; // public + + typedef typename Geom_traits::FT FT; // public + + typedef Constant_property_map DummyNormalMap; + + typedef typename internal_np::Lookup_named_param_def< + internal_np::normal_t, + NamedParameters, + DummyNormalMap + > ::type Normal_map; // public + + static Point_map get_point_map(PointRange&, const NamedParameters& np) + { + return parameters::choose_parameter(parameters::get_parameter(np, internal_np::point_map)); + } + + static Point_map get_point_map(const NamedParameters& np) + { + return parameters::choose_parameter(parameters::get_parameter(np, internal_np::point_map)); + } + + static Const_point_map get_const_point_map(const PointRange&, const NamedParameters& np) + { + return parameters::choose_parameter(parameters::get_parameter(np, internal_np::point_map)); + } + + static Normal_map get_normal_map(const PointRange&, const NamedParameters& np) + { + return parameters::choose_parameter(parameters::get_parameter(np, internal_np::normal_map)); + } + + static Normal_map get_normal_map(const NamedParameters& np) + { + return parameters::choose_parameter(parameters::get_parameter(np, internal_np::normal_map)); + } + + static Geom_traits get_geom_traits(const PointRange&, const NamedParameters& np) + { + return parameters::choose_parameter(parameters::get_parameter(np, internal_np::geom_traits)); + } + + static constexpr bool has_normal_map() + { + return !boost::is_same< typename internal_np::Get_param::type, + internal_np::Param_not_found> ::value; + } + }; + + namespace Point_set_processing_3 { template struct Fake_point_range { @@ -357,67 +380,6 @@ CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face, typename boost::graph_traits::fa }; }; - namespace parameters - { - template - Named_function_parameters - inline all_default(const PointRange&) - { - return CGAL::parameters::all_default(); - } - } - - template - class GetFT - { - public: - typedef typename Kernel_traits< - typename std::iterator_traits< - typename PointRange::iterator - >::value_type - >::Kernel::FT type; - }; - - template - class GetK - { - typedef typename GetPointMap::type Vpm; - typedef typename Kernel_traits< - typename boost::property_traits::value_type - >::Kernel Default_kernel; - - public: - typedef typename internal_np::Lookup_named_param_def < - internal_np::geom_traits_t, - NamedParameters, - Default_kernel - > ::type Kernel; - }; - - template - class GetNormalMap - { - struct DummyNormalMap - { - typedef typename std::iterator_traits::value_type key_type; - typedef typename GetK::Kernel::Vector_3 value_type; - typedef value_type reference; - typedef boost::read_write_property_map_tag category; - - typedef DummyNormalMap Self; - friend value_type get(const Self&, const key_type&) { return CGAL::NULL_VECTOR; } - friend void put(const Self&, const key_type&, const value_type&) { } - }; - - public: - typedef DummyNormalMap NoMap; - typedef typename internal_np::Lookup_named_param_def < - internal_np::normal_t, - NamedParameters, - DummyNormalMap//default - > ::type type; - }; - template class GetPlaneMap { @@ -442,19 +404,8 @@ CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face, typename boost::graph_traits::fa template class GetPlaneIndexMap { - struct DummyPlaneIndexMap - { - typedef std::size_t key_type; - typedef int value_type; - typedef value_type reference; - typedef boost::readable_property_map_tag category; - - typedef DummyPlaneIndexMap Self; - friend value_type get(const Self&, const key_type&) { return -1; } - }; - + typedef Constant_property_map DummyPlaneIndexMap; public: - typedef DummyPlaneIndexMap NoMap; typedef typename internal_np::Lookup_named_param_def < internal_np::plane_index_t, NamedParameters, @@ -465,23 +416,14 @@ CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face, typename boost::graph_traits::fa template class GetIsConstrainedMap { - struct DummyConstrainedMap - { - typedef typename std::iterator_traits::value_type key_type; - typedef bool value_type; - typedef value_type reference; - typedef boost::readable_property_map_tag category; - - typedef DummyConstrainedMap Self; - friend value_type get(const Self&, const key_type&) { return false; } - }; - + typedef Static_boolean_property_map< + typename std::iterator_traits::value_type, + false> Default_map; public: - typedef DummyConstrainedMap NoMap; typedef typename internal_np::Lookup_named_param_def < internal_np::point_is_constrained_t, NamedParameters, - DummyConstrainedMap //default + Default_map //default > ::type type; }; @@ -566,7 +508,7 @@ CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face, typename boost::graph_traits::fa using parameters::choose_parameter; using parameters::is_default_parameter; - if(!is_default_parameter(get_parameter(np, internal_np::stream_precision))) + if(!is_default_parameter()) { const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision)); diff --git a/BGL/include/CGAL/boost/graph/selection.h b/BGL/include/CGAL/boost/graph/selection.h index b63bb387efe..2604e4cf223 100644 --- a/BGL/include/CGAL/boost/graph/selection.h +++ b/BGL/include/CGAL/boost/graph/selection.h @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -22,6 +21,9 @@ #include #include +#include + +#include namespace CGAL { @@ -498,13 +500,13 @@ reduce_face_selection( \cgalParamNEnd \cgalNamedParamsEnd */ -template +template void regularize_face_selection_borders( TriangleMesh& mesh, IsSelectedMap is_selected, double weight, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -546,20 +548,6 @@ regularize_face_selection_borders( put(is_selected, fd, graph.labels[get(face_index_map,fd)]); } -/// \cond SKIP_IN_MANUAL -// variant with default np -template -void -regularize_face_selection_borders( - TriangleMesh& fg, - IsSelectedMap is_selected, - double weight) -{ - regularize_face_selection_borders (fg, is_selected, weight, - CGAL::parameters::all_default()); -} -/// \endcond - /// \cond SKIP_IN_MANUAL namespace experimental { @@ -1051,7 +1039,7 @@ void expand_face_selection_for_removal(const FaceRange& faces_to_be_deleted, typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - boost::unordered_set vertices_queue; + std::unordered_set vertices_queue; // collect vertices belonging to at least a triangle that will be removed for(face_descriptor fd : faces_to_be_deleted) @@ -1126,7 +1114,7 @@ void expand_face_selection_for_removal(const FaceRange& faces_to_be_deleted, for(halfedge_descriptor f_hd : faces_traversed) { - assert(target(f_hd, tm) == vd); + CGAL_assertion(target(f_hd, tm) == vd); put(is_selected, face(f_hd, tm), true); vertices_queue.insert( target( next(f_hd, tm), tm) ); vertices_queue.insert( source(f_hd, tm) ); @@ -1144,8 +1132,8 @@ int euler_characteristic_of_selection(const FaceRange& face_selection, typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::edge_descriptor edge_descriptor; - boost::unordered_set sel_vertices; - boost::unordered_set sel_edges; + std::unordered_set sel_vertices; + std::unordered_set sel_edges; for(face_descriptor f : face_selection) { for(halfedge_descriptor h : halfedges_around_face(halfedge(f, pm), pm)) diff --git a/BGL/test/BGL/CMakeLists.txt b/BGL/test/BGL/CMakeLists.txt index 2b799b0e2de..5644ffee425 100644 --- a/BGL/test/BGL/CMakeLists.txt +++ b/BGL/test/BGL/CMakeLists.txt @@ -71,8 +71,6 @@ create_single_source_cgal_program("test_Has_member_clear.cpp") create_single_source_cgal_program("test_Has_member_id.cpp") -create_single_source_cgal_program("test_cgal_bgl_named_params.cpp") - create_single_source_cgal_program("test_bgl_read_write.cpp") create_single_source_cgal_program("graph_concept_Face_filtered_graph.cpp") diff --git a/BGL/test/BGL/test_Collapse_edge_with_constraints.cpp b/BGL/test/BGL/test_Collapse_edge_with_constraints.cpp index 931149dbbbf..a8f84f6e654 100644 --- a/BGL/test/BGL/test_Collapse_edge_with_constraints.cpp +++ b/BGL/test/BGL/test_Collapse_edge_with_constraints.cpp @@ -26,9 +26,10 @@ int main() // ---------------------------------------------- // // two faces incident to the edge to be collapsed // // ---------------------------------------------- // + Point_3 p1(0,0,0), p2(1,0,0), p3(0,1,0); { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); /* ECM ecm = */m.add_property_map("ecm", false); bool res = test(h2c, m); @@ -36,7 +37,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); ECM ecm = m.add_property_map("ecm", false).first; put(ecm, edge(prev(h2c,m), m), true); @@ -46,7 +47,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); ECM ecm = m.add_property_map("ecm", false).first; put(ecm, edge(next(h2c,m), m), true); @@ -56,7 +57,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); ECM ecm = m.add_property_map("ecm", false).first; put(ecm, edge(prev(h2c,m), m), true); @@ -67,7 +68,7 @@ int main() // duplicate block + add one border (1) { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); Mesh::Halfedge_index hb1 = opposite(prev(h2c, m), m); assert(is_border(hb1, m)); @@ -78,7 +79,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); Mesh::Halfedge_index hb1 = opposite(prev(h2c, m), m); assert(is_border(hb1, m)); @@ -91,7 +92,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); Mesh::Halfedge_index hb1 = opposite(prev(h2c, m), m); assert(is_border(hb1, m)); @@ -104,7 +105,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); Mesh::Halfedge_index hb1 = opposite(prev(h2c, m), m); assert(is_border(hb1, m)); @@ -118,7 +119,7 @@ int main() // duplicate block + add one border (2) { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); Mesh::Halfedge_index hb2 = opposite(next(opposite(h2c,m), m), m); assert(is_border(hb2, m)); @@ -129,7 +130,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); Mesh::Halfedge_index hb2 = opposite(next(opposite(h2c,m), m), m); assert(is_border(hb2, m)); @@ -142,7 +143,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); Mesh::Halfedge_index hb2 = opposite(next(opposite(h2c,m), m), m); assert(is_border(hb2, m)); @@ -155,7 +156,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); Mesh::Halfedge_index hb2 = opposite(next(opposite(h2c,m), m), m); assert(is_border(hb2, m)); @@ -169,7 +170,7 @@ int main() // duplicate block + add one border (1) { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); Mesh::Halfedge_index hb1 = opposite(prev(h2c, m), m); assert(is_border(hb1, m)); @@ -183,7 +184,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); Mesh::Halfedge_index hb1 = opposite(prev(h2c, m), m); assert(is_border(hb1, m)); @@ -199,7 +200,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); Mesh::Halfedge_index hb1 = opposite(prev(h2c, m), m); assert(is_border(hb1, m)); @@ -215,7 +216,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index h2c = CGAL::Euler::add_center_vertex(h, m); Mesh::Halfedge_index hb1 = opposite(prev(h2c, m), m); assert(is_border(hb1, m)); @@ -235,7 +236,7 @@ int main() // center triangle with 2 border edges (1) { Mesh m; - Mesh::Halfedge_index h2c = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h2c = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index hb1=opposite(next(h2c,m),m); CGAL::Euler::add_vertex_and_face_to_border(prev(hb1, m), hb1, m); /* ECM ecm = */m.add_property_map("ecm", false); @@ -244,7 +245,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h2c = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h2c = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index hb1=opposite(next(h2c,m),m); CGAL::Euler::add_vertex_and_face_to_border(prev(hb1, m), hb1, m); ECM ecm = m.add_property_map("ecm", false).first; @@ -254,7 +255,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h2c = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h2c = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index hb1=opposite(next(h2c,m),m); CGAL::Euler::add_vertex_and_face_to_border(prev(hb1, m), hb1, m); ECM ecm = m.add_property_map("ecm", false).first; @@ -265,7 +266,7 @@ int main() // center triangle with 2 border edges (2) { Mesh m; - Mesh::Halfedge_index h2c = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h2c = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index hb2=opposite(prev(h2c,m),m); CGAL::Euler::add_vertex_and_face_to_border(prev(hb2, m), hb2, m); /* ECM ecm = */m.add_property_map("ecm", false); @@ -274,7 +275,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h2c = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h2c = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index hb2=opposite(prev(h2c,m),m); CGAL::Euler::add_vertex_and_face_to_border(prev(hb2, m), hb2, m); ECM ecm = m.add_property_map("ecm", false).first; @@ -284,7 +285,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h2c = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h2c = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index hb2=opposite(prev(h2c,m),m); CGAL::Euler::add_vertex_and_face_to_border(prev(hb2, m), hb2, m); ECM ecm = m.add_property_map("ecm", false).first; @@ -295,7 +296,7 @@ int main() // center triangle with 1 border edges { Mesh m; - Mesh::Halfedge_index h2c = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h2c = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index hb1=opposite(next(h2c,m),m); CGAL::Euler::add_vertex_and_face_to_border(prev(hb1, m), hb1, m); Mesh::Halfedge_index hb2=opposite(prev(h2c,m),m); @@ -306,7 +307,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h2c = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h2c = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index hb1=opposite(next(h2c,m),m); CGAL::Euler::add_vertex_and_face_to_border(prev(hb1, m), hb1, m); Mesh::Halfedge_index hb2=opposite(prev(h2c,m),m); @@ -318,7 +319,7 @@ int main() } { Mesh m; - Mesh::Halfedge_index h2c = CGAL::make_triangle(Point_3(),Point_3(),Point_3(),m); + Mesh::Halfedge_index h2c = CGAL::make_triangle(p1,p2,p3,m); Mesh::Halfedge_index hb1=opposite(next(h2c,m),m); CGAL::Euler::add_vertex_and_face_to_border(prev(hb1, m), hb1, m); Mesh::Halfedge_index hb2=opposite(prev(h2c,m),m); diff --git a/BGL/test/BGL/test_Euler_operations.cpp b/BGL/test/BGL/test_Euler_operations.cpp index 8aaed89d530..4c2ade85ea1 100644 --- a/BGL/test/BGL/test_Euler_operations.cpp +++ b/BGL/test/BGL/test_Euler_operations.cpp @@ -14,7 +14,7 @@ test_copy_face_graph_nm_umbrella() CGAL_GRAPH_TRAITS_MEMBERS(T); T g; - Kernel::Point_3 p; + Kernel::Point_3 p(0,0,0); CGAL::make_tetrahedron(p, p, p, p, g); CGAL::make_tetrahedron(p, p, p, p, g); @@ -39,8 +39,7 @@ template void test_copy_face_graph_isolated_vertices() { - typedef Kernel::Point_3 Point_3; - + Kernel::Point_3 p(0,0,0); { T s, t; add_vertex(s); @@ -55,7 +54,7 @@ test_copy_face_graph_isolated_vertices() { T s, t; - CGAL::make_triangle(Point_3(), Point_3(), Point_3(), s); + CGAL::make_triangle(p, p, p, s); add_vertex(s); t=s; CGAL::copy_face_graph(s, t); @@ -63,7 +62,7 @@ test_copy_face_graph_isolated_vertices() { T s, t; - CGAL::make_triangle(Point_3(), Point_3(), Point_3(), s); + CGAL::make_triangle(p, p, p, s); add_vertex(s); add_vertex(t); CGAL::copy_face_graph(s, t); @@ -71,7 +70,7 @@ test_copy_face_graph_isolated_vertices() { T s, t; - CGAL::make_tetrahedron(Point_3(), Point_3(), Point_3(), Point_3(), s); + CGAL::make_tetrahedron(p, p, p, p, s); add_vertex(s); t=s; CGAL::copy_face_graph(s, t); @@ -79,7 +78,7 @@ test_copy_face_graph_isolated_vertices() { T s, t; - CGAL::make_tetrahedron(Point_3(), Point_3(), Point_3(), Point_3(), s); + CGAL::make_tetrahedron(p, p, p, p, s); add_vertex(s); add_vertex(t); CGAL::copy_face_graph(s, t); @@ -480,7 +479,7 @@ test_swap_edges() halfedge_descriptor h1 = *std::next(boost::begin(halfedges(g)), i); halfedge_descriptor h2 = *std::next(boost::begin(halfedges(g)), j); CGAL::internal::swap_edges(h1, h2, g); - CGAL_assertion(CGAL::is_valid_polygon_mesh(g)); + assert(CGAL::is_valid_polygon_mesh(g)); } } } diff --git a/BGL/test/BGL/test_Face_filtered_graph.cpp b/BGL/test/BGL/test_Face_filtered_graph.cpp index 2da2f3ed205..2bab2e1d83c 100644 --- a/BGL/test/BGL/test_Face_filtered_graph.cpp +++ b/BGL/test/BGL/test_Face_filtered_graph.cpp @@ -6,15 +6,16 @@ #include "test_Prefix.h" #include -#include -#include +#include +#include #include #include #include #include +#include -typedef boost::unordered_set id_map; +typedef std::unordered_set id_map; namespace PMP = CGAL::Polygon_mesh_processing; @@ -24,8 +25,8 @@ void test_halfedge_around_vertex_iterator(const Graph& g) typedef typename boost::graph_traits::face_descriptor g_face_descriptor; typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); - boost::unordered_map map(num_faces(g)); - PMP::connected_components(g, boost::make_assoc_property_map(map), CGAL::parameters::all_default()); + std::unordered_map map(num_faces(g)); + PMP::connected_components(g, boost::make_assoc_property_map(map)); Adapter fg(g, 0, boost::make_assoc_property_map(map)); typename boost::graph_traits::vertex_iterator vit, vend; @@ -52,7 +53,7 @@ void test_halfedge_around_face_iterator(const Graph& g) typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; - PMP::connected_components(g, boost::make_assoc_property_map(map), CGAL::parameters::all_default()); + PMP::connected_components(g, boost::make_assoc_property_map(map)); Adapter fg(g, 0, boost::make_assoc_property_map(map)); face_iterator fit, fend; @@ -73,7 +74,7 @@ void test_edge_iterators(const Graph& g) typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; - PMP::connected_components(g, boost::make_assoc_property_map(map), CGAL::parameters::all_default()); + PMP::connected_components(g, boost::make_assoc_property_map(map)); Adapter fg(g, 0, boost::make_assoc_property_map(map)); // do we iterate as many as that? @@ -99,7 +100,7 @@ void test_vertex_iterators(Graph& g) typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; - PMP::connected_components(g, boost::make_assoc_property_map(map), CGAL::parameters::all_default()); + PMP::connected_components(g, boost::make_assoc_property_map(map)); Adapter fg(g, 0, boost::make_assoc_property_map(map)); vertex_iterator vb, ve; std::size_t count = 0; @@ -129,7 +130,7 @@ void test_out_edges(const Graph& g) typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; - PMP::connected_components(g, boost::make_assoc_property_map(map), CGAL::parameters::all_default()); + PMP::connected_components(g, boost::make_assoc_property_map(map)); Adapter fg(g, 0, boost::make_assoc_property_map(map)); vertex_iterator vb, ve; @@ -158,7 +159,7 @@ void test_in_edges(const Graph& g) typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; - PMP::connected_components(g, boost::make_assoc_property_map(map), CGAL::parameters::all_default()); + PMP::connected_components(g, boost::make_assoc_property_map(map)); Adapter fg(g, 0, boost::make_assoc_property_map(map)); vertex_iterator vb, ve; @@ -185,7 +186,7 @@ void test_in_out_edges(const Graph& g) typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; - PMP::connected_components(g, boost::make_assoc_property_map(map), CGAL::parameters::all_default()); + PMP::connected_components(g, boost::make_assoc_property_map(map)); Adapter fg(g, 0, boost::make_assoc_property_map(map)); // check that the sets of in out edges are the same @@ -227,7 +228,7 @@ void test_edge_find(const Graph& g) typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; - PMP::connected_components(g, boost::make_assoc_property_map(map), CGAL::parameters::all_default()); + PMP::connected_components(g, boost::make_assoc_property_map(map)); Adapter fg(g, 0, boost::make_assoc_property_map(map)); typedef std::pair ret; @@ -251,7 +252,7 @@ void test_faces(const Graph& g) typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; - PMP::connected_components(g, boost::make_assoc_property_map(map), CGAL::parameters::all_default()); + PMP::connected_components(g, boost::make_assoc_property_map(map)); Adapter fg(g, 0, boost::make_assoc_property_map(map)); unsigned int count = 0; @@ -278,7 +279,7 @@ void test_index_property_maps(const Graph& g) typedef typename boost::graph_traits::face_descriptor g_face_descriptor; std::map map; - PMP::connected_components(g, boost::make_assoc_property_map(map), CGAL::parameters::all_default()); + PMP::connected_components(g, boost::make_assoc_property_map(map), CGAL::parameters::default_values()); Adapter fg(g, -1, boost::make_assoc_property_map(map)); assert(is_empty(fg)); @@ -325,7 +326,7 @@ void test_read(const Graph& g) CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; - PMP::connected_components(g, boost::make_assoc_property_map(map), CGAL::parameters::all_default()); + PMP::connected_components(g, boost::make_assoc_property_map(map)); Adapter fg(g, 0, boost::make_assoc_property_map(map)); assert(fg.is_selection_valid()); assert(CGAL::is_valid_polygon_mesh(fg)); @@ -416,29 +417,29 @@ void test_mesh(Adapter fga) { CGAL_GRAPH_TRAITS_MEMBERS(Adapter); //check that there is the right number of simplices in fga - CGAL_assertion(CGAL::is_valid_polygon_mesh(fga)); - CGAL_assertion(num_faces(fga) == 2); - CGAL_assertion(num_edges(fga) == 5); - CGAL_assertion(num_halfedges(fga) == 10); - CGAL_assertion(num_vertices(fga) == 4); + assert(CGAL::is_valid_polygon_mesh(fga)); + assert(num_faces(fga) == 2); + assert(num_edges(fga) == 5); + assert(num_halfedges(fga) == 10); + assert(num_vertices(fga) == 4); halfedge_descriptor h = halfedge(*faces(fga).first, fga); - CGAL_assertion_code( vertex_descriptor v = source(h, fga)); + vertex_descriptor v = source(h, fga); //check that next() works inside the patch - CGAL_assertion(next(next(next(h, fga), fga), fga) == h); + assert(next(next(next(h, fga), fga), fga) == h); //check that next() works on bordure of the patch h = opposite(h, fga); - CGAL_assertion(next(next(next(next(h, fga), fga), fga), fga) == h); + assert(next(next(next(next(h, fga), fga), fga), fga) == h); //check that prev() works inside the patch h = halfedge(*faces(fga).first, fga); - CGAL_assertion(prev(prev(prev(h, fga), fga), fga) == h); + assert(prev(prev(prev(h, fga), fga), fga) == h); //check that prev() works on bordure of the patch h = opposite(h, fga); - CGAL_assertion(prev(prev(prev(prev(h, fga), fga), fga), fga) == h); + assert(prev(prev(prev(prev(h, fga), fga), fga), fga) == h); //check degree - CGAL_assertion(degree(v, fga) == 3); + assert(degree(v, fga) == 3); //check in_edges and out_edges - CGAL_assertion(std::distance(in_edges(v, fga).first ,in_edges(v, fga).second) == 3); - CGAL_assertion(std::distance(out_edges(v, fga).first ,out_edges(v, fga).second) == 3); + assert(std::distance(in_edges(v, fga).first ,in_edges(v, fga).second) == 3); + assert(std::distance(out_edges(v, fga).first ,out_edges(v, fga).second) == 3); Mesh copy; CGAL::copy_face_graph(fga, copy); @@ -484,8 +485,8 @@ void test_invalid_selections() face_range.push_back(SM::Face_index(2)); face_range.push_back(SM::Face_index(3)); - CGAL::Face_filtered_graph bad_fg(mesh, face_range); - assert(!bad_fg.is_selection_valid()); + CGAL::Face_filtered_graph pinched_fg(mesh, face_range); + assert(pinched_fg.is_selection_valid()); // this creates a non-manifold vertex (multiple umbrellas) clear(mesh); @@ -495,8 +496,8 @@ void test_invalid_selections() face_range.clear(); merge_vertices(SM::Vertex_index(1337), SM::Vertex_index(87), face_range, mesh); - CGAL::Face_filtered_graph bad_fg_2(mesh, face_range); - assert(!bad_fg_2.is_selection_valid()); + CGAL::Face_filtered_graph many_umbrellas_fg(mesh, face_range); + assert(!many_umbrellas_fg.is_selection_valid()); } int main() @@ -525,7 +526,7 @@ int main() *sm, fccmap, CGAL::parameters::edge_is_constrained_map(Constraint::vertex_descriptor, SM::Point> >(*sm, positions))); - boost::unordered_set pids; + std::unordered_set pids; pids.insert(0); pids.insert(2); SM_Adapter sm_adapter(*sm, pids, fccmap); diff --git a/BGL/test/BGL/test_Manifold_face_removal.cpp b/BGL/test/BGL/test_Manifold_face_removal.cpp index a8628394071..1b021e678c8 100644 --- a/BGL/test/BGL/test_Manifold_face_removal.cpp +++ b/BGL/test/BGL/test_Manifold_face_removal.cpp @@ -2,12 +2,14 @@ #include #include -#include + #include #include #include #include +#include + #include #include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; @@ -83,7 +85,7 @@ int main() input >> sm; // define my selection of faces to remove - boost::unordered_map is_selected_map; + std::unordered_map is_selected_map; const int selection_indices[30] = {652,18,328,698,322,212,808,353,706,869,646,352,788,696,714,796,937,2892,374,697,227,501,786,794,345,16,21,581,347,723}; std::set index_set(&selection_indices[0], &selection_indices[0]+30); diff --git a/BGL/test/BGL/test_Properties.cpp b/BGL/test/BGL/test_Properties.cpp index d840c837e48..ca63a2f7803 100644 --- a/BGL/test/BGL/test_Properties.cpp +++ b/BGL/test/BGL/test_Properties.cpp @@ -2,7 +2,7 @@ #include -#include +#include // #define CGAL_TEST_PROPERTIES_DEBUG @@ -72,7 +72,7 @@ void test_uniqueness(const Graph&, begin2 = boost::begin(range), end = boost::end(range); - typedef boost::unordered_set id_map; + typedef std::unordered_set id_map; typedef std::pair resultp; id_map m; @@ -217,7 +217,8 @@ void test_initialized_index_maps_const(const Graph& g) // Writable pmap typedef typename boost::graph_traits::edge_descriptor edge_descriptor; - typedef boost::unordered_map EdgeIndexMap; + typedef std::unordered_map> EdgeIndexMap; typedef CGAL::RW_property_map EdgeIdPropertyMap; EdgeIndexMap eim; @@ -321,7 +322,8 @@ void test_initialized_index_maps(Graph& g) // Writable pmap typedef typename boost::graph_traits::edge_descriptor edge_descriptor; - typedef boost::unordered_map EdgeIndexMap; + typedef std::unordered_map> + EdgeIndexMap; typedef CGAL::RW_property_map EdgeIdPropertyMap; EdgeIndexMap eim; diff --git a/BGL/test/BGL/test_Regularize_face_selection_borders.cpp b/BGL/test/BGL/test_Regularize_face_selection_borders.cpp index 512670b5555..c0cdbb0565e 100644 --- a/BGL/test/BGL/test_Regularize_face_selection_borders.cpp +++ b/BGL/test/BGL/test_Regularize_face_selection_borders.cpp @@ -1,14 +1,15 @@ #include #include #include +#include -#include #include #include #include #include -#include +#include + typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Surface_mesh SM; @@ -21,7 +22,7 @@ int main() input >> sm; // define my selection of faces to remove - boost::unordered_map is_selected_map; + std::unordered_map is_selected_map; const int selection_indices[30] = {652,18,328,698,322,212,808,353,706,869,646,352,788,696,714,796,937,2892,374,697,227,501,786,794,345,16,21,581,347,723}; std::set index_set(&selection_indices[0], &selection_indices[0]+30); diff --git a/BGL/test/BGL/test_graph_traits.cpp b/BGL/test/BGL/test_graph_traits.cpp index cc2559752d4..3d71af5a7c2 100644 --- a/BGL/test/BGL/test_graph_traits.cpp +++ b/BGL/test/BGL/test_graph_traits.cpp @@ -3,9 +3,9 @@ #include #include -#include +#include -typedef boost::unordered_set id_map; +typedef std::unordered_set id_map; template void test_isolated_vertex() diff --git a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/Concepts/BarycentricTraits_2.h b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/Concepts/BarycentricTraits_2.h index df9b650b7c7..1fe3c8fc2bd 100644 --- a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/Concepts/BarycentricTraits_2.h +++ b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/Concepts/BarycentricTraits_2.h @@ -11,6 +11,7 @@ coordinates from the namespace `CGAL::Barycentric_coordinates`. \cgalHasModel - All models of `Kernel` +- `CGAL::Projection_traits_3` - `CGAL::Projection_traits_xy_3` - `CGAL::Projection_traits_yz_3` - `CGAL::Projection_traits_xz_3` diff --git a/Boolean_set_operations_2/doc/Boolean_set_operations_2/CGAL/Boolean_set_operations_2.h b/Boolean_set_operations_2/doc/Boolean_set_operations_2/CGAL/Boolean_set_operations_2.h index b69e5757375..9b35c3ed574 100644 --- a/Boolean_set_operations_2/doc/Boolean_set_operations_2/CGAL/Boolean_set_operations_2.h +++ b/Boolean_set_operations_2/doc/Boolean_set_operations_2/CGAL/Boolean_set_operations_2.h @@ -650,7 +650,7 @@ OutputIterator difference(const General_polygon_with_holes_2& pgn1, // CGAL/Boolean_set_operations_2/do_intersect.h namespace CGAL { -/*! \addtogroup boolean_do_intersect Intersection Testing Functions +/*! \addtogroup boolean_do_intersect Polygon Intersection Testing Functions * \ingroup PkgBooleanSetOperations2Ref * \anchor ref_bso_do_intersect * @@ -1160,7 +1160,7 @@ bool do_intersect(InputIterator1 begin1, InputIterator1 end1, // CGAL/Boolean_set_operations_2/intersection.h namespace CGAL { -/*! \addtogroup boolean_intersection Intersection Functions +/*! \addtogroup boolean_intersection Polygon Intersection Functions * \ingroup PkgBooleanSetOperations2Ref * \anchor ref_bso_intersection * diff --git a/Boolean_set_operations_2/examples/Boolean_set_operations_2/circle_segment.cpp b/Boolean_set_operations_2/examples/Boolean_set_operations_2/circle_segment.cpp index 523f1961907..7cf3ec3dc7b 100644 --- a/Boolean_set_operations_2/examples/Boolean_set_operations_2/circle_segment.cpp +++ b/Boolean_set_operations_2/examples/Boolean_set_operations_2/circle_segment.cpp @@ -8,6 +8,7 @@ #include #include +#include typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef Kernel::Point_2 Point_2; @@ -28,7 +29,7 @@ Polygon_2 construct_polygon (const Circle_2& circle) Curve_2 curve (circle); std::list objects; traits.make_x_monotone_2_object() (curve, std::back_inserter(objects)); - CGAL_assertion (objects.size() == 2); + assert(objects.size() == 2); // Construct the polygon. Polygon_2 pgn; diff --git a/Boolean_set_operations_2/examples/Boolean_set_operations_2/set_union.cpp b/Boolean_set_operations_2/examples/Boolean_set_operations_2/set_union.cpp index a6d2e2e3dd6..cecacc9a107 100644 --- a/Boolean_set_operations_2/examples/Boolean_set_operations_2/set_union.cpp +++ b/Boolean_set_operations_2/examples/Boolean_set_operations_2/set_union.cpp @@ -10,6 +10,7 @@ #include #include #include +#include typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef Kernel::Point_2 Point_2; @@ -29,7 +30,7 @@ Polygon_2 construct_polygon (const Circle_2& circle) Curve_2 curve (circle); std::list objects; traits.make_x_monotone_2_object() (curve, std::back_inserter(objects)); - CGAL_assertion (objects.size() == 2); + assert(objects.size() == 2); // Construct the polygon. Polygon_2 pgn; diff --git a/Bounding_volumes/examples/Min_sphere_of_spheres_d/min_sphere_of_spheres_d_2.cpp b/Bounding_volumes/examples/Min_sphere_of_spheres_d/min_sphere_of_spheres_d_2.cpp index 2d133ddba86..81562b974fd 100644 --- a/Bounding_volumes/examples/Min_sphere_of_spheres_d/min_sphere_of_spheres_d_2.cpp +++ b/Bounding_volumes/examples/Min_sphere_of_spheres_d/min_sphere_of_spheres_d_2.cpp @@ -5,6 +5,7 @@ #include #include #include +#include const int N = 1000; // number of spheres const int LOW = 0, HIGH = 10000; // range of coordinates and radii @@ -29,5 +30,5 @@ int main () { } Min_sphere ms(S.begin(),S.end()); // check in the spheres - CGAL_assertion(ms.is_valid()); + assert(ms.is_valid()); } diff --git a/Bounding_volumes/examples/Min_sphere_of_spheres_d/min_sphere_of_spheres_d_3.cpp b/Bounding_volumes/examples/Min_sphere_of_spheres_d/min_sphere_of_spheres_d_3.cpp index c0b8b978e0c..a8a998a991f 100644 --- a/Bounding_volumes/examples/Min_sphere_of_spheres_d/min_sphere_of_spheres_d_3.cpp +++ b/Bounding_volumes/examples/Min_sphere_of_spheres_d/min_sphere_of_spheres_d_3.cpp @@ -5,6 +5,7 @@ #include #include #include +#include const int N = 1000; // number of spheres const int LOW = 0, HIGH = 10000; // range of coordinates and radii @@ -30,5 +31,5 @@ int main () { } Min_sphere ms(S.begin(),S.end()); // check in the spheres - CGAL_assertion(ms.is_valid()); + assert(ms.is_valid()); } diff --git a/Bounding_volumes/examples/Min_sphere_of_spheres_d/min_sphere_of_spheres_d_d.cpp b/Bounding_volumes/examples/Min_sphere_of_spheres_d/min_sphere_of_spheres_d_d.cpp index 0ddbe825fba..984ce89e8e5 100644 --- a/Bounding_volumes/examples/Min_sphere_of_spheres_d/min_sphere_of_spheres_d_d.cpp +++ b/Bounding_volumes/examples/Min_sphere_of_spheres_d/min_sphere_of_spheres_d_d.cpp @@ -5,6 +5,7 @@ #include #include #include +#include const int N = 1000; // number of spheres const int D = 3; // dimension of points @@ -31,5 +32,5 @@ int main () { } Min_sphere ms(S.begin(),S.end()); // check in the spheres - CGAL_assertion(ms.is_valid()); + assert(ms.is_valid()); } diff --git a/Bounding_volumes/test/Bounding_volumes/min_sphere_test.cpp b/Bounding_volumes/test/Bounding_volumes/min_sphere_test.cpp index 82b71269443..ff82ea1bdb0 100644 --- a/Bounding_volumes/test/Bounding_volumes/min_sphere_test.cpp +++ b/Bounding_volumes/test/Bounding_volumes/min_sphere_test.cpp @@ -33,10 +33,12 @@ #include #include #include -#include -#include #include #include +#include + +#include +#include using namespace CGAL; diff --git a/Box_intersection_d/include/CGAL/Box_intersection_d/segment_tree.h b/Box_intersection_d/include/CGAL/Box_intersection_d/segment_tree.h index 8e18301f9f7..c810c98b3af 100644 --- a/Box_intersection_d/include/CGAL/Box_intersection_d/segment_tree.h +++ b/Box_intersection_d/include/CGAL/Box_intersection_d/segment_tree.h @@ -207,24 +207,19 @@ median_of_three( RandomAccessIter a, RandomAccessIter b, RandomAccessIter c, } -template< class RandomAccessIter, class Predicate_traits > +template< class RandomAccessIter, class Predicate_traits, class Generator> class Iterative_radon { RandomAccessIter begin; - std::ptrdiff_t size; Predicate_traits traits; int dim; - - boost::rand48 rng; - boost::uniform_int dist; - boost::variate_generator > generator; + Generator& generator; public: -Iterative_radon( RandomAccessIter begin, RandomAccessIter end, - Predicate_traits traits, int dim, int /*num_levels*/ ) - : begin(begin), size(end-begin), traits(traits), dim(dim), - rng(), dist(0,size-1), generator(rng,dist) + Iterative_radon( const RandomAccessIter& begin_, const Predicate_traits& traits_, + int dim_, Generator& generator_) + : begin(begin_), traits(traits_), dim(dim_), generator(generator_) {} RandomAccessIter @@ -247,7 +242,10 @@ RandomAccessIter iterative_radon( RandomAccessIter begin, RandomAccessIter end, Predicate_traits traits, int dim, int num_levels ) { - Iterative_radon IR(begin,end,traits,dim,num_levels); + typedef typename boost::variate_generator > Generator; + boost::rand48 rng; + Generator generator(rng, boost::uniform_int(0, (end-begin)-1)); + Iterative_radon IR(begin, traits, dim, generator); return IR(num_levels); } diff --git a/CGAL_ImageIO/include/CGAL/Image_3.h b/CGAL_ImageIO/include/CGAL/Image_3.h index 8f2a2ea4b4a..f6b186ef36c 100644 --- a/CGAL_ImageIO/include/CGAL/Image_3.h +++ b/CGAL_ImageIO/include/CGAL/Image_3.h @@ -21,7 +21,6 @@ #include #include -#include #include #include diff --git a/CGAL_ImageIO/include/CGAL/SEP_header.h b/CGAL_ImageIO/include/CGAL/SEP_header.h index db5b2fe752a..e6ffe0b13f4 100644 --- a/CGAL_ImageIO/include/CGAL/SEP_header.h +++ b/CGAL_ImageIO/include/CGAL/SEP_header.h @@ -22,11 +22,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #ifdef CGAL_SEP_READER_DEBUG diff --git a/CGAL_ImageIO/test/CGAL_ImageIO/test_trilinear_interpolation.cpp b/CGAL_ImageIO/test/CGAL_ImageIO/test_trilinear_interpolation.cpp index f4bdb80a1cb..818632ce0e5 100644 --- a/CGAL_ImageIO/test/CGAL_ImageIO/test_trilinear_interpolation.cpp +++ b/CGAL_ImageIO/test/CGAL_ImageIO/test_trilinear_interpolation.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -183,6 +184,7 @@ int main() { 0.f); } timer_old_implementation.stop(); + CGAL_USE(sum); } std::cerr << "max difference = " << max_diff << "\n" << "timer new implementation: " << timer_new_implementation.time() @@ -253,5 +255,3 @@ int main() { } std::cerr << counter << " tests. OK."; } - - diff --git a/Cartesian_kernel/include/CGAL/Cartesian_converter.h b/Cartesian_kernel/include/CGAL/Cartesian_converter.h index 65a68c612fb..946dc51ce4b 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian_converter.h +++ b/Cartesian_kernel/include/CGAL/Cartesian_converter.h @@ -39,6 +39,8 @@ #include #include +#include + namespace CGAL { // Guess which compiler needs this work around ? @@ -82,8 +84,7 @@ struct Converting_visitor : boost::static_visitor<> { } // namespace internal template < class K1, class K2, -// class Converter = NT_converter > - class Converter> + class Converter /*= typename internal::Default_converter::Type*/> class Cartesian_converter : public Enum_converter { typedef Enum_converter Base; @@ -96,24 +97,24 @@ public: using Base::operator(); Origin - operator()(const Origin& o) const + operator()(Origin o) const { return o; } Null_vector - operator()(const Null_vector& n) const + operator()(Null_vector n) const { return n; } - Bbox_2 + const Bbox_2& operator()(const Bbox_2& b) const { return b; } - Bbox_3 + const Bbox_3& operator()(const Bbox_3& b) const { return b; @@ -125,6 +126,14 @@ public: return c(a); } + template + T + operator()(const T t, + typename std::enable_if::value>::type* = nullptr) const + { + return t; + } + // drop the boost::detail::variant::void_ generated by the macros // from the sequence, transform with the type mapper and throw the // new list into a variant @@ -384,24 +393,25 @@ public: return std::make_pair(operator()(pp.first), operator()(pp.second)); } - typename K2::Aff_transformation_3 - operator()(const typename K1::Aff_transformation_3 &a) const + typename K2::Aff_transformation_2 + operator()(const typename K1::Aff_transformation_2& a) const { - typedef typename K2::Aff_transformation_3 Aff_transformation_3; - typename K2::FT t[12]; - for(int i=0; i< 3; ++i) - { - for(int j=0; j<4; ++j) - { - t[i*4+j] = a.m(i,j); - } - } - return Aff_transformation_3( - t[0],t[1],t[2],t[3], - t[4],t[5],t[6],t[7], - t[8],t[9],t[10],t[11], - a.m(3,3)); + typedef typename K2::Aff_transformation_2 Aff_transformation_2; + return Aff_transformation_2(c(a.m(0,0)), c(a.m(0,1)), c(a.m(0,2)), + c(a.m(1,0)), c(a.m(1,1)), c(a.m(1,2)), + c(a.m(2,2))); } + + typename K2::Aff_transformation_3 + operator()(const typename K1::Aff_transformation_3& a) const + { + typedef typename K2::Aff_transformation_3 Aff_transformation_3; + return Aff_transformation_3(c(a.m(0,0)), c(a.m(0,1)), c(a.m(0,2)), c(a.m(0,3)), + c(a.m(1,0)), c(a.m(1,1)), c(a.m(1,2)), c(a.m(1,3)), + c(a.m(2,0)), c(a.m(2,1)), c(a.m(2,2)), c(a.m(2,3)), + c(a.m(3,3))); + } + private: Converter c; K2 k; diff --git a/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/common-libraries.hpp b/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/common-libraries.hpp index 2815ecbf232..c20b9b7155f 100644 --- a/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/common-libraries.hpp +++ b/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/common-libraries.hpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include @@ -63,7 +63,7 @@ inline void init_feature_class_data(FeatureClassDataFloat& /*data*/, int /*n_cla { // data.resize(n_samples); } -typedef boost::unordered_set FeatureSet; +typedef std::unordered_set FeatureSet; #if BOOST_VERSION >= 104700 typedef boost::random::uniform_int_distribution<> UniformIntDist; diff --git a/Classification/include/CGAL/Classification/Label_set.h b/Classification/include/CGAL/Classification/Label_set.h index 8af0f5e935b..7f626cde305 100644 --- a/Classification/include/CGAL/Classification/Label_set.h +++ b/Classification/include/CGAL/Classification/Label_set.h @@ -205,7 +205,6 @@ public: // else return add (name, found->second.second, found->second.first); } - /// \endcond /*! \brief removes a label. diff --git a/Combinatorial_map/doc/Combinatorial_map/CGAL/Combinatorial_map.h b/Combinatorial_map/doc/Combinatorial_map/CGAL/Combinatorial_map.h index c7175837df6..bfd19667879 100644 --- a/Combinatorial_map/doc/Combinatorial_map/CGAL/Combinatorial_map.h +++ b/Combinatorial_map/doc/Combinatorial_map/CGAL/Combinatorial_map.h @@ -34,8 +34,6 @@ Other methods have all a constant time complexity. \sa `GenericMapItems` -\deprecated Before CGAL 4.9, `Items` had to define the type of dart used, and the default class was `Combinatorial_map_min_items`. This is now deprecated, the `Dart` type is no more defined in the item class, but replaced by the `Dart_info` type. `CGAL_CMAP_DART_DEPRECATED` can be defined to keep the old behavior. - */ template< unsigned int d, typename Items, typename Alloc > class Combinatorial_map { diff --git a/Combinatorial_map/doc/Combinatorial_map/CGAL/Combinatorial_map_constructors.h b/Combinatorial_map/doc/Combinatorial_map/CGAL/Combinatorial_map_constructors.h deleted file mode 100644 index c40c726cc30..00000000000 --- a/Combinatorial_map/doc/Combinatorial_map/CGAL/Combinatorial_map_constructors.h +++ /dev/null @@ -1,48 +0,0 @@ -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsConstructions - -\deprecated Creates a combinatorial hexahedron. Deprecated. Use `cm.make_combinatorial_hexahedron()` instead. -*/ -template < class CMap > -typename CMap::Dart_handle make_combinatorial_hexahedron(CMap& cm); - -} /* namespace CGAL */ - -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsConstructions - -\deprecated Creates a combinatorial polygon of length `lg`. Deprecated. Use `cm.make_combinatorial_polygon()` instead. -*/ -template < class CMap > typename CMap::Dart_handle -make_combinatorial_polygon(CMap& cm, unsigned int lg); - -} /* namespace CGAL */ - -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsConstructions - -\deprecated Creates a combinatorial tetrahedron. Deprecated. Use `cm.make_combinatorial_tetrahedron()` instead. -*/ -template < class CMap > -typename CMap::Dart_handle make_combinatorial_tetrahedron(CMap& cm); - -} /* namespace CGAL */ - -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsConstructions - -\deprecated Creates an isolated edge. Deprecated. Use `cm.make_edge()` instead. -*/ -template < class CMap > -typename CMap::Dart_handle make_edge(CMap& cm); - -} /* namespace CGAL */ - diff --git a/Combinatorial_map/doc/Combinatorial_map/CGAL/Combinatorial_map_min_items.h b/Combinatorial_map/doc/Combinatorial_map/CGAL/Combinatorial_map_min_items.h deleted file mode 100644 index 067f94c3bec..00000000000 --- a/Combinatorial_map/doc/Combinatorial_map/CGAL/Combinatorial_map_min_items.h +++ /dev/null @@ -1,37 +0,0 @@ - -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsClasses - -The class `Combinatorial_map_min_items` defines the type of darts which is a `Dart`. The `Combinatorial_map_min_items` has a template argument for the dimension of the combinatorial map. In this class, no attribute is enabled. - -\tparam d the dimension of the combinatorial map. - -\deprecated This class is deprecated since CGAL 4.9. Users are required to use class `Generic_map_min_items` instead, where the `Dart` type is no more defined, but replaced by the `Dart_info` type. `CGAL_CMAP_DART_DEPRECATED` can be defined to keep the old behavior. - -\cgalHeading{Example} - -The following example shows the implementation of the `Combinatorial_map_min_items` class. - -\code{.cpp} -template -struct Combinatorial_map_min_items -{ - template - struct Dart_wrapper - { - typedef CGAL::Dart Dart; - typedef std::tuple<> Attributes; - }; -}; -\endcode - -\sa `Generic_map_items` - -*/ -template< unsigned int d > -struct Combinatorial_map_min_items { - -}; /* end Combinatorial_map_min_items */ -} /* end namespace CGAL */ diff --git a/Combinatorial_map/doc/Combinatorial_map/CGAL/Combinatorial_map_operations.h b/Combinatorial_map/doc/Combinatorial_map/CGAL/Combinatorial_map_operations.h deleted file mode 100644 index e61f4a9d901..00000000000 --- a/Combinatorial_map/doc/Combinatorial_map/CGAL/Combinatorial_map_operations.h +++ /dev/null @@ -1,118 +0,0 @@ -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsOperations - -\deprecated Inserts a 0-cell in the 1-cell containing `dh`. Deprecated. Use `cm.insert_cell_0_in_cell_1()` instead. -*/ -template < class CMap > -typename CMap::Dart_handle insert_cell_0_in_cell_1(CMap& cm, -typename CMap::Dart_handle dh); - -} /* namespace CGAL */ - -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsOperations - -\deprecated Inserts a 0-cell in the 2-cell containing `dh`. Deprecated. Use `cm.insert_cell_0_in_cell_2()` instead. -*/ -template -typename CMap::Dart_handle insert_cell_0_in_cell_2(CMap & cm, -typename CMap::Dart_handle dh); - -} /* namespace CGAL */ - -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsOperations - -\deprecated Inserts a 1-cell in the 2-cell containing `dh1` and `dh2`. Deprecated. Use `cm.insert_cell_1_in_cell_2()` instead. -*/ -template < class CMap > -typename CMap::Dart_handle insert_cell_1_in_cell_2(CMap& cm, -typename CMap::Dart_handle dh1,typename CMap::Dart_handle dh2); - -} /* namespace CGAL */ - -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsOperations - -\deprecated Inserts a 2-cell along the path of 1-cells containing darts given by the range `[afirst,alast)`. Deprecated. Use `cm.insert_cell_2_in_cell_3()` instead. -*/ -template -typename CMap::Dart_handle insert_cell_2_in_cell_3(CMap & cm, -InputIterator afirst, InputIterator alast); - -} /* namespace CGAL */ - -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsOperations - -\deprecated Inserts a 1-cell in a the 2-cell containing `dh`, the 1-cell -being attached only by one of its extremity to the 0-cell containing `dh`. Deprecated. Use `cm.insert_dangling_cell_1_in_cell_2()` instead. -*/ -template < class CMap > -typename CMap::Dart_handle insert_dangling_cell_1_in_cell_2(CMap& cm, -typename CMap::Dart_handle dh); - -} /* namespace CGAL */ - -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsOperations - -\deprecated Returns true iff it is possible to insert a 1-cell in `cm` between `dh1` and `dh2`. Deprecated. Use `cm.is_insertable_cell_1_in_cell_2()` instead. -*/ -template < class CMap > -bool is_insertable_cell_1_in_cell_2(const CMap & cm, -typename CMap::Dart_const_handle dh1, -typename CMap::Dart_const_handle dh2); - -} /* namespace CGAL */ - -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsOperations - -\deprecated Returns true iff it is possible to insert a 2-cell in `cm` along the path -of darts given by the range `[afirst,alast)`. Deprecated. Use `cm.is_insertable_cell_2_in_cell_3()` instead. -*/ -template -bool is_insertable_cell_2_in_cell_3(const CMap & cm, -InputIterator afirst, InputIterator alast); - -} /* namespace CGAL */ - -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsOperations - -\deprecated Returns true iff the i-cell containing `dh` can be removed. Deprecated. Use `cm.is_removable()` instead. -*/ -template -bool is_removable(const CMap& cm, typename CMap::Dart_const_handle dh); - -} /* namespace CGAL */ - -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsOperations - -\deprecated Removes the i-cell containing `dh`. Deprecated. Use `cm.remove_cell()` instead. -*/ -template -typename CMap::size_type remove_cell(CMap& cm, typename CMap::Dart_handle dh); - -} /* namespace CGAL */ - diff --git a/Combinatorial_map/doc/Combinatorial_map/CGAL/Dart.h b/Combinatorial_map/doc/Combinatorial_map/CGAL/Dart.h deleted file mode 100644 index d7559f2251b..00000000000 --- a/Combinatorial_map/doc/Combinatorial_map/CGAL/Dart.h +++ /dev/null @@ -1,61 +0,0 @@ - -namespace CGAL { - -/*! -\ingroup PkgCombinatorialMapsClasses - -The class `Dart` represents a dD dart in a combinatorial map. - -\deprecated This class is deprecated since CGAL 4.9. Dart is now a type defined internally; users can now only define the information associated with darts. All functions defined in this class are now defined as methods of a combinatorial map taking a `Dart_handle` as first parameter. `CGAL_CMAP_DART_DEPRECATED` can be defined to keep the old behavior. - -*/ -template< typename d, typename CMap > -struct Dart { -/*! - -*/ -typedef CMap::Dart_handle Dart_handle; - -/*! - -*/ -typedef CMap::Dart_const_handle Dart_const_handle; - -/*! - -*/ -template -using Attribute_handle = CMap::Attribute_handle; - -/*! - -*/ -template -using Attribute_const_handle = CMap::Attribute_const_handle; - -/*! -Returns \f$ \beta_i\f$(`*this`). -\pre 0 \f$ \leq \f$ i \f$ \leq \f$ dimension. -*/ -Dart_handle beta(unsigned int i); - -/*! -Returns \f$ \beta_i\f$(`*this`) when the dart is const. -\pre 0 \f$ \leq \f$ i \f$ \leq \f$ dimension. -*/ -Dart_const_handle beta(unsigned int i) const; - -/*! -Returns \f$ \beta_i^{-1}\f$(`*this`). -\pre 0 \f$ \leq \f$ i \f$ \leq \f$ dimension. -*/ -Dart_handle beta_inv(unsigned int i); - -/*! -Returns \f$ \beta_i^{-1}\f$(`*this`) when the dart is const. -\pre 0 \f$ \leq \f$ i \f$ \leq \f$ dimension. -*/ -Dart_const_handle beta_inv(unsigned int i) const; - -}; /* end Dart */ -} /* end namespace CGAL */ diff --git a/Combinatorial_map/doc/Combinatorial_map/PackageDescription.txt b/Combinatorial_map/doc/Combinatorial_map/PackageDescription.txt index f4f74a7b2ec..202866c0046 100644 --- a/Combinatorial_map/doc/Combinatorial_map/PackageDescription.txt +++ b/Combinatorial_map/doc/Combinatorial_map/PackageDescription.txt @@ -6,23 +6,6 @@ /// \defgroup PkgCombinatorialMapsClasses Classes /// \ingroup PkgCombinatorialMapsRef -/*! Basic constructions. - \code - #include - \endcode -*/ -/// \defgroup PkgCombinatorialMapsConstructions Constructions -/// \ingroup PkgCombinatorialMapsRef - -/*! High-level operations. - \code - #include - \endcode -*/ -/// \defgroup PkgCombinatorialMapsOperations Operations -/// \ingroup PkgCombinatorialMapsRef - - /*! \addtogroup PkgCombinatorialMapsRef \cgalPkgDescriptionBegin{Combinatorial Maps,PkgCombinatorialMaps} @@ -53,23 +36,5 @@ - `CGAL::Cell_attribute_with_id` - `CGAL::Generic_map_min_items` -\cgalCRPSection{Global Functions} -\cgalCRPSubsection{Constructions for Combinatorial Maps} -- `CGAL::make_edge` -- `CGAL::make_combinatorial_polygon` -- `CGAL::make_combinatorial_tetrahedron` -- `CGAL::make_combinatorial_hexahedron` - -\cgalCRPSubsection{Operations for Combinatorial Maps} -- `CGAL::is_removable` -- `CGAL::remove_cell` -- `CGAL::is_insertable_cell_1_in_cell_2` -- `CGAL::is_insertable_cell_2_in_cell_3` -- `CGAL::insert_cell_0_in_cell_1` -- `CGAL::insert_cell_0_in_cell_2` -- `CGAL::insert_cell_1_in_cell_2` -- `CGAL::insert_dangling_cell_1_in_cell_2` -- `CGAL::insert_cell_2_in_cell_3` - */ diff --git a/Combinatorial_map/examples/Combinatorial_map/map_3_foreach.cpp b/Combinatorial_map/examples/Combinatorial_map/map_3_foreach.cpp index 347c2b0d9bd..62e0b9d0ea9 100644 --- a/Combinatorial_map/examples/Combinatorial_map/map_3_foreach.cpp +++ b/Combinatorial_map/examples/Combinatorial_map/map_3_foreach.cpp @@ -1,5 +1,4 @@ #include -#include #include #include diff --git a/Combinatorial_map/examples/Combinatorial_map/map_3_operations.cpp b/Combinatorial_map/examples/Combinatorial_map/map_3_operations.cpp index cf96103b56a..83217577d5d 100644 --- a/Combinatorial_map/examples/Combinatorial_map/map_3_operations.cpp +++ b/Combinatorial_map/examples/Combinatorial_map/map_3_operations.cpp @@ -1,6 +1,7 @@ #include #include #include +#include typedef CGAL::Combinatorial_map<3> CMap_3; typedef CMap_3::Dart_handle Dart_handle; @@ -13,19 +14,19 @@ int main() Dart_handle dh1 = cm.make_combinatorial_hexahedron(); // Add two edges along two opposite facets. - CGAL_assertion( cm.is_insertable_cell_1_in_cell_2 - (cm.beta(dh1,1),cm.beta(dh1,0)) ); + assert( cm.is_insertable_cell_1_in_cell_2 + (cm.beta(dh1,1),cm.beta(dh1,0)) ); cm.insert_cell_1_in_cell_2(cm.beta(dh1,1), cm.beta(dh1,0)); - CGAL_assertion( cm.is_valid() ); + assert( cm.is_valid() ); Dart_handle dh2=cm.beta(dh1,2,1,1,2); - CGAL_assertion( cm.is_insertable_cell_1_in_cell_2 - (dh2,cm.beta(dh2,1,1)) ); + assert( cm.is_insertable_cell_1_in_cell_2 + (dh2,cm.beta(dh2,1,1)) ); cm.insert_cell_1_in_cell_2(dh2, cm.beta(dh2,1,1)); - CGAL_assertion( cm.is_valid() ); + assert( cm.is_valid() ); // Insert a facet along these two new edges plus two initial edges // of the hexahedron. @@ -35,28 +36,28 @@ int main() path.push_back(cm.beta(dh2,0)); path.push_back(cm.beta(dh2,2,1)); - CGAL_assertion( (cm.is_insertable_cell_2_in_cell_3 + assert( (cm.is_insertable_cell_2_in_cell_3 (path.begin(),path.end())) ); Dart_handle dh3=cm.insert_cell_2_in_cell_3(path.begin(),path.end()); - CGAL_assertion( cm.is_valid() ); + assert( cm.is_valid() ); // Display the combinatorial map characteristics. cm.display_characteristics(std::cout) << ", valid=" << cm.is_valid() << std::endl; // We use the removal operations to get back to the initial hexahedron. - CGAL_assertion( (cm.is_removable<2>(dh3)) ); + assert( (cm.is_removable<2>(dh3)) ); cm.remove_cell<2>(dh3); - CGAL_assertion( cm.is_valid() ); + assert( cm.is_valid() ); - CGAL_assertion( (cm.is_removable<1>(cm.beta(dh1,1))) ); + assert( (cm.is_removable<1>(cm.beta(dh1,1))) ); cm.remove_cell<1>(cm.beta(dh1,1)); - CGAL_assertion( cm.is_valid() ); + assert( cm.is_valid() ); - CGAL_assertion( (cm.is_removable<1>(cm.beta(dh2,0))) ); + assert( (cm.is_removable<1>(cm.beta(dh2,0))) ); cm.remove_cell<1>(cm.beta(dh2,0)); - CGAL_assertion( cm.is_valid() ); + assert( cm.is_valid() ); // Display the combinatorial map characteristics. cm.display_characteristics(std::cout) << ", valid=" @@ -64,4 +65,3 @@ int main() return EXIT_SUCCESS; } - diff --git a/Combinatorial_map/include/CGAL/Cell_attribute.h b/Combinatorial_map/include/CGAL/Cell_attribute.h index 4409b2ebfe3..40ae79e7d89 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute.h @@ -14,6 +14,7 @@ #include #include +#include namespace CGAL { @@ -88,8 +89,7 @@ namespace CGAL { { m_id=id; } protected: - /// id of the cell - std::size_t m_id; + std::size_t m_id; ///< id of the cell }; /// If the tag WithId is false, we do not add id to cells. diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map.h b/Combinatorial_map/include/CGAL/Combinatorial_map.h index 32ea6e66ad5..9ebfee9a8cb 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map.h @@ -13,6 +13,7 @@ #define CGAL_COMBINATORIAL_MAP_H 1 #include +#include #include @@ -27,12 +28,7 @@ #include #include #include - -#if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) -#include -#else #include -#endif #include #include @@ -42,8 +38,9 @@ #include #include #include +#include +#include #include -#include #include #include @@ -184,11 +181,6 @@ namespace CGAL { */ Combinatorial_map_base() { -#if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) - CGAL_static_assertion_msg(Dart::dimension==dimension, - "Dimension of dart different from dimension of map"); -#endif - CGAL_static_assertion_msg(Helper::nb_attribs<=dimension+1, "Too many attributes in the tuple Attributes_enabled"); this->init_storage(); @@ -230,36 +222,39 @@ namespace CGAL { typename Converters, typename DartInfoConverter, typename PointConverter> void generic_copy(CMap2& amap, - boost::unordered_map* origin_to_copy, - boost::unordered_map* copy_to_origin, + std::unordered_map* origin_to_copy, + std::unordered_map* copy_to_origin, const Converters& converters, const DartInfoConverter& dartinfoconverter, const PointConverter& pointconverter, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { - this->clear(); - - /*this->mnb_used_marks = amap.mnb_used_marks; - this->mmask_marks = amap.mmask_marks; - this->automatic_attributes_management = - amap.automatic_attributes_management; - - for (size_type i = 0; i < NB_MARKS; ++i) + if(copy_marks) { - this->mfree_marks_stack[i] = amap.mfree_marks_stack[i]; - this->mused_marks_stack[i] = amap.mused_marks_stack[i]; - this->mindex_marks[i] = amap.mindex_marks[i]; - this->mnb_marked_darts[i] = amap.mnb_marked_darts[i]; - this->mnb_times_reserved_marks[i] = amap.mnb_times_reserved_marks[i]; + // Reserve all marks of amap not yet reserved + for (size_type i=0; icopies). // (here we cannot use CGAL::Unique_hash_map because it does not provide // iterators... - boost::unordered_map local_dartmap; + std::unordered_map local_dartmap; if (origin_to_copy==NULL) // Use local_dartmap if user does not provides its own unordered_map { origin_to_copy=&local_dartmap; } @@ -270,11 +265,21 @@ namespace CGAL { if (copy_perforated_darts || !amap.is_perforated(it)) { new_dart=mdarts.emplace(); - init_dart(new_dart); // , amap.get_marks(it)); + init_dart(new_dart); if (mark_perforated!=INVALID_MARK && amap.is_perforated(it)) { mark(new_dart, mark_perforated); } + if(copy_marks) + { + // Copy marks of amap + for(size_type i=0; i::iterator + typename std::unordered_map::iterator dartmap_iter, dartmap_iter_end=origin_to_copy->end(); for (dartmap_iter=origin_to_copy->begin(); dartmap_iter!=dartmap_iter_end; ++dartmap_iter) @@ -315,27 +320,28 @@ namespace CGAL { converters, pointconverter); } - CGAL_assertion (is_valid()); + CGAL_expensive_assertion(is_valid()); } // (1a) copy(amap, converters, dartinfoconverter, pointconverter) template void copy(CMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy, - boost::unordered_map + std::unordered_map * copy_to_origin, const Converters& converters, const DartInfoConverter& dartinfoconverter, const PointConverter& pointconverter, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { generic_copy (amap, origin_to_copy, copy_to_origin, - converters, dartinfoconverter, pointconverter, + converters, dartinfoconverter, pointconverter, copy_marks, copy_perforated_darts, mark_perforated); } @@ -343,127 +349,138 @@ namespace CGAL { template void copy_from_const(const CMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy, - boost::unordered_map + std::unordered_map * copy_to_origin, const Converters& converters, const DartInfoConverter& dartinfoconverter, const PointConverter& pointconverter, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { generic_copy (const_cast(amap), origin_to_copy, copy_to_origin, - converters, dartinfoconverter, pointconverter, + converters, dartinfoconverter, pointconverter, copy_marks, copy_perforated_darts, mark_perforated); } // (2a) copy(amap, converters, dartinfoconverter) template void copy(CMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy, - boost::unordered_map + std::unordered_map * copy_to_origin, const Converters& converters, const DartInfoConverter& dartinfoconverter, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { Default_converter_cmap_0attributes_with_point pointconverter; copy(amap, origin_to_copy, copy_to_origin, - converters, dartinfoconverter, pointconverter, + converters, dartinfoconverter, pointconverter, copy_marks, copy_perforated_darts, mark_perforated); } // (2b) copy_from_const(const amap, converters, dartinfoconverter) template void copy_from_const(const CMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy, - boost::unordered_map + std::unordered_map * copy_to_origin, const Converters& converters, const DartInfoConverter& dartinfoconverter, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { Default_converter_cmap_0attributes_with_point pointconverter; copy_from_const(amap, origin_to_copy, copy_to_origin, - converters, dartinfoconverter, pointconverter, + converters, dartinfoconverter, pointconverter, copy_marks, copy_perforated_darts, mark_perforated); } // (3a) copy(amap, converters) template void copy(CMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy, - boost::unordered_map + std::unordered_map * copy_to_origin, const Converters& converters, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { Default_converter_dart_info dartinfoconverter; copy(amap, origin_to_copy, copy_to_origin, converters, dartinfoconverter, - copy_perforated_darts, mark_perforated); + copy_marks, copy_perforated_darts, mark_perforated); } // (3b) copy_from_const(const amap, converters) template void copy_from_const(const CMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy, - boost::unordered_map + std::unordered_map * copy_to_origin, const Converters& converters, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { Default_converter_dart_info dartinfoconverter; copy_from_const(amap, origin_to_copy, copy_to_origin, converters, dartinfoconverter, - copy_perforated_darts, mark_perforated); + copy_marks, copy_perforated_darts, mark_perforated); } // (4a) copy(amap) template void copy(CMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy=nullptr, - boost::unordered_map + std::unordered_map * copy_to_origin=nullptr, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { std::tuple<> converters; - copy(amap, origin_to_copy, copy_to_origin, converters, + copy(amap, origin_to_copy, copy_to_origin, converters, copy_marks, copy_perforated_darts, mark_perforated); } // (4b) copy_from_const(const amap) template void copy_from_const(const CMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy=nullptr, - boost::unordered_map + std::unordered_map * copy_to_origin=nullptr, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { std::tuple<> converters; - copy_from_const(amap, origin_to_copy, copy_to_origin, converters, + copy_from_const(amap, origin_to_copy, copy_to_origin, converters, copy_marks, copy_perforated_darts, mark_perforated); } // Copy constructor from a map having exactly the same type. - Combinatorial_map_base (const Self & amap): Combinatorial_map_base() + Combinatorial_map_base(const Self & amap): Combinatorial_map_base() { copy_from_const(amap); } + // Move constructor + Combinatorial_map_base(Self && amap): Combinatorial_map_base() + { this->swap(amap); } + // "Copy constructor" from a map having different type. template @@ -554,10 +571,10 @@ namespace CGAL { /** Import the given hds which should be a model of an halfedge graph. */ template void import_from_halfedge_graph(const HEG& heg, - boost::unordered_map + std::unordered_map ::halfedge_descriptor, Dart_handle>* origin_to_copy=NULL, - boost::unordered_map + std::unordered_map ::halfedge_descriptor>* copy_to_origin=NULL, @@ -567,7 +584,7 @@ namespace CGAL { // Create an mapping between darts of the two maps (originals->copies). // (here we cannot use CGAL::Unique_hash_map because it does not provide // iterators... - boost::unordered_map + std::unordered_map ::halfedge_descriptor, Dart_handle> local_dartmap; if (origin_to_copy==NULL) // Used local_dartmap if user does not provides its own unordered_map @@ -590,7 +607,7 @@ namespace CGAL { } } - typename boost::unordered_map + typename std::unordered_map ::halfedge_descriptor, Dart_handle>::iterator dartmap_iter, dartmap_iter_end=origin_to_copy->end(); for (dartmap_iter=origin_to_copy->begin(); dartmap_iter!=dartmap_iter_end; @@ -610,7 +627,7 @@ namespace CGAL { } } - CGAL_assertion (is_valid()); + CGAL_expensive_assertion(is_valid()); } /** Clear the combinatorial map. Remove all darts and all attributes. @@ -2626,7 +2643,7 @@ namespace CGAL { if ( marks[acells[i]]==INVALID_MARK ) { marks[acells[i]] = get_new_mark(); - assert(is_whole_map_unmarked(marks[acells[i]])); + CGAL_assertion(is_whole_map_unmarked(marks[acells[i]])); } } @@ -3423,8 +3440,6 @@ namespace CGAL { } } - // CGAL_postcondition(amap2.is_valid()); - if ( res==amap.null_handle ) res = amap.darts().begin(); return res; } @@ -3457,10 +3472,6 @@ namespace CGAL { bool testAttributes=true, bool testPoint=true) const { -#if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) - CGAL_USE(testDartInfo); -#endif - typedef Combinatorial_map_base Map2; bool match = true; @@ -3509,11 +3520,9 @@ namespace CGAL { map2.mark(other, m2); // We first test info of darts -#if !defined(CGAL_CMAP_DART_DEPRECATED) || defined(CGAL_NO_DEPRECATED_CODE) if (match && testDartInfo) match=internal::Test_is_same_dart_info_functor:: run(*this, map2, current, other); -#endif // We need to test in both direction because // Foreach_enabled_attributes only test non void attributes @@ -3635,9 +3644,9 @@ namespace CGAL { } } - assert(is_whole_map_unmarked(m1)); - assert(is_whole_map_unmarked(markpush)); - assert(map2.is_whole_map_unmarked(m2)); + CGAL_postcondition(is_whole_map_unmarked(m1)); + CGAL_postcondition(is_whole_map_unmarked(markpush)); + CGAL_postcondition(map2.is_whole_map_unmarked(m2)); free_mark(m1); free_mark(markpush); map2.free_mark(m2); @@ -4659,7 +4668,7 @@ namespace CGAL { } // Make copies of the new facet for dimension >=4 - assert(!is_free(first, 2)); + CGAL_assertion(!is_free(first, 2)); for ( unsigned int dim=4; dim<=dimension; ++dim ) { if ( !is_free(beta(first, 2), dim) ) @@ -4683,7 +4692,7 @@ namespace CGAL { basic_link_beta_for_involution<2>(beta(it, 3, 2, dim), dd); } - assert(!is_free(it, 2)); + CGAL_assertion(!is_free(it, 2)); this->template basic_link_beta_for_involution<2>(beta(it, 2, dim), d); if ( prec!=null_handle ) @@ -4789,6 +4798,9 @@ namespace CGAL { Combinatorial_map(const Self & amap) : Base(amap) {} + Combinatorial_map(Self && amap) : Base(amap) + {} + template Combinatorial_map(const Combinatorial_map_base& diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_constructors.h b/Combinatorial_map/include/CGAL/Combinatorial_map_constructors.h deleted file mode 100644 index fa1e011dc5b..00000000000 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_constructors.h +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (c) 2010-2011 CNRS and LIRIS' Establishments (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) : Guillaume Damiand -// -#ifndef CGAL_COMBINATORIAL_MAP_CONSTRUCTORS_H -#define CGAL_COMBINATORIAL_MAP_CONSTRUCTORS_H 1 - -#include - -#ifndef CGAL_NO_DEPRECATED_CODE - -namespace CGAL { - - /** @file Combinatorial_map_constructors.h - * Basic creation operations for a combinatorial map. - * Create edge, triangle, quadrilateral, tetrahedron, hexahedron. - */ - - /** Create an edge. - * @param amap the used combinatorial map. - * @return a dart of the new edge. - */ - template < class Map > - CGAL_DEPRECATED typename Map::Dart_handle make_edge(Map& amap) - { return amap.make_edge(); } - - /** Create a combinatorial polygon of length alg - * (a cycle of alg darts beta1 links together). - * @param amap the used combinatorial map. - * @return a new dart. - */ - template < class Map > - CGAL_DEPRECATED typename Map::Dart_handle make_combinatorial_polygon(Map& amap, - unsigned int alg) - { return amap.make_combinatorial_polygon(alg); } - - /** Test if a face is a combinatorial polygon of length alg - * (a cycle of alg darts beta1 links together). - * @param amap the used combinatorial map. - * @param adart an intial dart - * @return true iff the face containing adart is a polygon of length alg. - */ - template < class Map > - CGAL_DEPRECATED bool is_face_combinatorial_polygon(const Map& amap, - typename Map::Dart_const_handle adart, - unsigned int alg) - { return amap.is_face_combinatorial_polygon(adart, alg); } - - /** Create a combinatorial tetrahedron from 4 triangles. - * @param amap the used combinatorial map. - * @param d1 a dart onto a first triangle. - * @param d2 a dart onto a second triangle. - * @param d3 a dart onto a third triangle. - * @param d4 a dart onto a fourth triangle. - * @return a new dart. - */ - template < class Map > - CGAL_DEPRECATED typename Map::Dart_handle - make_combinatorial_tetrahedron(Map& amap, - typename Map::Dart_handle d1, - typename Map::Dart_handle d2, - typename Map::Dart_handle d3, - typename Map::Dart_handle d4) - { return amap.make_combinatorial_tetrahedron(d1, d2, d3, d4); } - - /** Test if a volume is a combinatorial tetrahedron. - * @param amap the used combinatorial map. - * @param adart an intial dart - * @return true iff the volume containing adart is a combinatorial tetrahedron. - */ - template < class Map > - CGAL_DEPRECATED bool is_volume_combinatorial_tetrahedron(const Map& amap, - typename Map::Dart_const_handle d1) - { return amap.is_volume_combinatorial_tetrahedron(d1); } - - /** Create a new combinatorial tetrahedron. - * @param amap the used combinatorial map. - * @return a new dart. - */ - template < class Map > - CGAL_DEPRECATED typename Map::Dart_handle make_combinatorial_tetrahedron(Map& amap) - { return amap.make_combinatorial_tetrahedron(); } - - /** Create a combinatorial hexahedron from 6 quadrilaterals. - * @param amap the used combinatorial map. - * @param d1 a dart onto a first quadrilateral. - * @param d2 a dart onto a second quadrilateral. - * @param d3 a dart onto a third quadrilateral. - * @param d4 a dart onto a fourth quadrilateral. - * @param d5 a dart onto a fifth quadrilateral. - * @param d6 a dart onto a sixth quadrilateral. - * @return a dart of the new cuboidal_cell. - */ - template < class Map > - CGAL_DEPRECATED typename Map::Dart_handle - make_combinatorial_hexahedron(Map& amap, - typename Map::Dart_handle d1, - typename Map::Dart_handle d2, - typename Map::Dart_handle d3, - typename Map::Dart_handle d4, - typename Map::Dart_handle d5, - typename Map::Dart_handle d6) - { return amap.make_combinatorial_hexahedron(d1, d2, d3, d4, d5, d6); } - - /** Test if a volume is a combinatorial hexahedron. - * @param amap the used combinatorial map. - * @param adart an intial dart - * @return true iff the volume containing adart is a combinatorial hexahedron. - */ - template < class Map > - CGAL_DEPRECATED bool is_volume_combinatorial_hexahedron(const Map& amap, - typename Map::Dart_const_handle d1) - { return amap.is_volume_combinatorial_hexahedron(d1); } - - /** Create a new combinatorial hexahedron. - * @param amap the used combinatorial map. - * @return a new dart. - */ - template < class Map > - CGAL_DEPRECATED typename Map::Dart_handle make_combinatorial_hexahedron(Map& amap) - { return amap.make_combinatorial_hexahedron(); } - -} // namespace CGAL - -#endif // CGAL_NO_DEPRECATED_CODE - -#endif // CGAL_COMBINATORIAL_MAP_CONSTRUCTORS_H // -// EOF // diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_functors.h b/Combinatorial_map/include/CGAL/Combinatorial_map_functors.h index 6e7989cf743..a1c5cf06196 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_functors.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_functors.h @@ -92,7 +92,7 @@ struct Test_is_valid_attribute_functor size_type mark=amap.get_new_mark(); bool res = true; CGAL::internal::Test_is_valid_attribute_functor:: - run(amap, adart, mark, &res); + template run(amap, adart, mark, &res); amap.negate_mark(mark); if ( !amap.is_whole_map_marked(mark) ) diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h b/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h index 39c54355f58..8a1805d2fa4 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h @@ -17,32 +17,19 @@ namespace CGAL { -#if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) -template -struct Combinatorial_map_min_items; -#else struct Generic_map_min_items; -#endif template class Combinatorial_map_storage_1; template < unsigned int d_, class Refs_, -#if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) - class Items_=Combinatorial_map_min_items, -#else class Items_=Generic_map_min_items, -#endif class Alloc_=CGAL_ALLOCATOR(int), class Storage_= Combinatorial_map_storage_1 > class Combinatorial_map_base; template < unsigned int d_, -#if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) - class Items_=Combinatorial_map_min_items, -#else class Items_=Generic_map_min_items, -#endif class Alloc_=CGAL_ALLOCATOR(int), class Storage_= Combinatorial_map_storage_1 > class Combinatorial_map; diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h b/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h deleted file mode 100644 index fa2bee50c3e..00000000000 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (c) 2010-2011 CNRS and LIRIS' Establishments (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) : Guillaume Damiand -// -#ifndef CGAL_COMBINATORIAL_MAP_INSERTIONS_H -#define CGAL_COMBINATORIAL_MAP_INSERTIONS_H - -#include - -namespace CGAL -{ -/** @file Combinatorial_map_insertions.h - * Insertion operations on combinatorial map. - */ - -#ifndef CGAL_NO_DEPRECATED_CODE - -/** Insert a vertex in a given edge. - * @param amap the used combinatorial map. - * @param adart a dart of the edge (!=nullptr && !=null_dart_handle). - * @param update_attributes a boolean to update the enabled attributes - * (deprecated, now we use are_attributes_automatically_managed()) - * @return a dart of the new vertex. - */ -template -CGAL_DEPRECATED typename CMap::Dart_handle -insert_cell_0_in_cell_1( CMap& amap, typename CMap::Dart_handle adart, - typename CMap::template - Attribute_handle<0>::type ah=CMap::null_handle, - bool update_attributes=true ) -{ - return amap.insert_cell_0_in_cell_1(adart, ah, update_attributes); -} - -/** Insert a vertex in the given 2-cell which is split in triangles, - * once for each inital edge of the facet. - * @param amap the used combinatorial map. - * @param adart a dart of the facet to triangulate. - * @param update_attributes a boolean to update the enabled attributes - * (deprecated, now we use are_attributes_automatically_managed()) - * @return A dart incident to the new vertex. - */ -template < class CMap > -CGAL_DEPRECATED typename CMap::Dart_handle -insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart, - typename CMap::template - Attribute_handle<0>::type ah=CMap::null_handle, - bool update_attributes=true ) -{ - return amap.insert_cell_0_in_cell_2(adart, ah, update_attributes); -} -/** Insert a dangling edge in a 2-cell between given by a dart. - * @param amap the used combinatorial map. - * @param adart1 a first dart of the facet (!=nullptr && !=null_dart_handle). - * @param update_attributes a boolean to update the enabled attributes - * (deprecated, now we use are_attributes_automatically_managed()) - * @return a dart of the new edge, not incident to the vertex of adart1. - */ -template -CGAL_DEPRECATED typename CMap::Dart_handle -insert_dangling_cell_1_in_cell_2( CMap& amap, - typename CMap::Dart_handle adart1, - typename CMap::template - Attribute_handle<0>::type ah=CMap::null_handle, - bool update_attributes=true ) -{ - return amap.insert_dangling_cell_1_in_cell_2(adart1, - ah, update_attributes); -} - -/** Test if an edge can be inserted onto a 2-cell between two given darts. - * @param amap the used combinatorial map. - * @param adart1 a first dart. - * @param adart2 a second dart. - * @return true iff an edge can be inserted between adart1 and adart2. - */ -template < class CMap > -CGAL_DEPRECATED bool is_insertable_cell_1_in_cell_2 -(const CMap& amap, typename CMap::Dart_const_handle adart1, - typename CMap::Dart_const_handle adart2) -{ - return amap.is_insertable_cell_1_in_cell_2(adart1, adart2); -} - -/** Insert an edge in a 2-cell between two given darts. - * @param amap the used combinatorial map. - * @param adart1 a first dart of the facet (!=nullptr && !=null_dart_handle). - * @param adart2 a second dart of the facet. If nullptr insert a dangling edge. - * @param update_attributes a boolean to update the enabled attributes - * (deprecated, now we use are_attributes_automatically_managed()) - * @return a dart of the new edge, and not incident to the - * same vertex than adart1. - */ -template -CGAL_DEPRECATED typename CMap::Dart_handle -insert_cell_1_in_cell_2(CMap& amap, - typename CMap::Dart_handle adart1, - typename CMap::Dart_handle adart2, - bool update_attributes=true) -{ - return amap.insert_cell_1_in_cell_2(adart1, adart2, - update_attributes); -} - -/** Test if a 2-cell can be inserted onto a given 3-cell along - * a path of edges. - * @param amap the used combinatorial map. - * @param afirst iterator on the beginning of the path. - * @param alast iterator on the end of the path. - * @return true iff a 2-cell can be inserted along the path. - */ -template -CGAL_DEPRECATED bool is_insertable_cell_2_in_cell_3 -(const CMap& amap, InputIterator afirst, InputIterator alast) -{ - return amap.is_insertable_cell_2_in_cell_3(afirst, alast); -} - -/** Insert a 2-cell in a given 3-cell along a path of darts. - * @param amap the used combinatorial map. - * @param afirst iterator on the beginning of the path. - * @param alast iterator on the end of the path. - * @param update_attributes a boolean to update the enabled attributes - * (deprecated, now we use are_attributes_automatically_managed()) - * @return a dart of the new 2-cell. - */ -template -CGAL_DEPRECATED typename CMap::Dart_handle -insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast, - bool update_attributes=true) -{ - return amap.insert_cell_2_in_cell_3(afirst, alast, update_attributes); -} - -#endif // CGAL_NO_DEPRECATED_CODE - -} // namespace CGAL - -#endif // CGAL_COMBINATORIAL_MAP_INSERTIONS_H diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_min_items.h b/Combinatorial_map/include/CGAL/Combinatorial_map_min_items.h deleted file mode 100644 index 756dd994003..00000000000 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_min_items.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2010-2011 CNRS and LIRIS' Establishments (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) : Guillaume Damiand -// -#ifndef CGAL_COMBINATORIAL_MAP_MIN_ITEMS_H -#define CGAL_COMBINATORIAL_MAP_MIN_ITEMS_H 1 - -#if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) -#include -#include - -namespace CGAL { - - /** @file Combinatorial_map_min_items.h - * Definition of min item class for dD combinatorial map. - */ - - /** Minimal items for dD combinatorial map. - * Combinatorial_map_min_items defines what is the minimal item - * class for a d-map It provides definitions for darts without attribute. - */ - template - struct CGAL_DEPRECATED Combinatorial_map_min_items - { - /// Dart_wrapper defines the type of darts used, and enabled attributes. - template < class Refs > - struct Dart_wrapper - { - typedef CGAL::Dart< d, Refs > Dart; - typedef std::tuple<> Attributes; - }; - }; - -} // namespace CGAL - -#endif // defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) - -#endif // CGAL_COMBINATORIAL_MAP_MIN_ITEMS_H // -// EOF // diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h index eeaa637b8a2..04f40e8d958 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h @@ -62,18 +62,6 @@ namespace CGAL static bool run(const CMap&, typename CMap::Dart_const_handle) { return true; } }; - /** Test if an i-cell can be removed. - * An i-cell can be removed if i==CMap::dimension or i==CMap::dimension-1, - * or if there are at most two (i+1)-cell incident to it. - * @param adart a dart of the i-cell. - * @return true iff the i-cell can be removed. - */ -#ifndef CGAL_NO_DEPRECATED_CODE - template < class CMap, unsigned int i > - CGAL_DEPRECATED bool is_removable(const CMap& amap, - typename CMap::Dart_const_handle adart) - { return CGAL::Is_removable_functor::run(amap,adart); } -#endif // CGAL_NO_DEPRECATED_CODE /** Remove an i-cell, 0 - CGAL_DEPRECATED size_t remove_cell(CMap& amap, typename CMap::Dart_handle adart, - bool update_attributes = true) - { - return CGAL::Remove_cell_functor:: - run(amap,adart,update_attributes); - } -#endif // CGAL_NO_DEPRECATED_CODE - /** Test if an i-cell can be contracted. * An i-cell can be contracted if i==1 * or if there are at most two (i-1)-cell incident to it. @@ -508,17 +480,6 @@ namespace CGAL static bool run(const CMap&, typename CMap::Dart_const_handle) { return true; } }; - /** Test if an i-cell can be contracted. - * An i-cell can be contracted if i==1 - * or if there are at most two (i-1)-cell incident to it. - * @param adart a dart of the i-cell. - * @return true iff the i-cell can be contracted. - */ -#ifndef CGAL_NO_DEPRECATED_CODE - template < class CMap, unsigned int i > - CGAL_DEPRECATED bool is_contractible(const CMap& amap, typename CMap::Dart_const_handle adart) - { return CGAL::Is_contractible_functor::run(amap,adart); } -#endif // CGAL_NO_DEPRECATED_CODE /** Contract an i-cell, 1 - CGAL_DEPRECATED size_t contract_cell(CMap& amap, typename CMap::Dart_handle adart, - bool update_attributes) - { return CGAL::Contract_cell_functor::run(amap,adart, update_attributes); } -#endif // CGAL_NO_DEPRECATED_CODE - } // namespace CGAL #endif // CGAL_COMBINATORIAL_MAP_OPERATIONS_H // diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_save_load.h b/Combinatorial_map/include/CGAL/Combinatorial_map_save_load.h index ddf1da00724..d5847071994 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_save_load.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_save_load.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -161,15 +161,9 @@ namespace CGAL { struct My_functor_cmap_save_one_attrib { static void run(CMap& amap, boost::property_tree::ptree& ptree, - std::map& myDarts) + std::unordered_map& myDarts) { - // to check all i-cells of the map - typename CMap::template Attribute_range::type::const_iterator - it_attrib, itend_attrib; - it_attrib=amap.template attributes().begin(); - itend_attrib=amap.template attributes().end(); - // add dimension & type boost::property_tree::ptree& ndim = ptree.add("dimension", ""); ndim.put(".index", i); @@ -177,16 +171,20 @@ namespace CGAL { ndim.add("type_point", typeid(typename CMap::Point).name()); // for every attribute of the dimension - for (; it_attrib!=itend_attrib; ++it_attrib) + for (auto it=amap.template one_dart_per_cell().begin(), + itend=amap.template one_dart_per_cell().end(); it!=itend; ++it) { - // make composant, dart and property node - boost::property_tree::ptree & nattr = ndim.add("a", ""); - /* boost::property_tree::ptree & ndarts = */ - nattr.add("d", myDarts[it_attrib->dart()]); + if (amap.template attribute(it)!=nullptr) + { + // make composant, dart and property node + boost::property_tree::ptree & nattr = ndim.add("a", ""); + /* boost::property_tree::ptree & ndarts = */ + nattr.add("d", myDarts[it]); - // update property node to add a value node (from basic or custom type - write_cmap_attribute_node(nattr, it_attrib->info()); - write_cmap_attribute_node(nattr, it_attrib->point()); + // update property node to add a value node (from basic or custom type + write_cmap_attribute_node(nattr, amap.template info(it)); + write_cmap_attribute_node(nattr, amap.point(it)); + } } } }; @@ -196,15 +194,9 @@ namespace CGAL { struct My_functor_cmap_save_one_attrib { static void run(CMap& amap, boost::property_tree::ptree& ptree, - std::map& myDarts) + std::unordered_map& myDarts) { - // to check all i-cells of the map - typename CMap::template Attribute_range::type::const_iterator - it_attrib, itend_attrib; - it_attrib=amap.template attributes().begin(); - itend_attrib=amap.template attributes().end(); - // add dimension & type boost::property_tree::ptree& ndim = ptree.add("dimension", ""); ndim.put(".index", i); @@ -212,15 +204,19 @@ namespace CGAL { ndim.add("type_point", typeid(typename CMap::Point).name()); // for every attribute of the dimension - for (; it_attrib!=itend_attrib; ++it_attrib) + for (auto it=amap.template one_dart_per_cell().begin(), + itend=amap.template one_dart_per_cell().end(); it!=itend; ++it) { - // make composant, dart and property node - boost::property_tree::ptree & nattr = ndim.add("a", ""); - /* boost::property_tree::ptree & ndarts = */ - nattr.add("d", myDarts[it_attrib->dart()]); + if (amap.template attribute(it)!=nullptr) + { + // make composant, dart and property node + boost::property_tree::ptree & nattr = ndim.add("a", ""); + /* boost::property_tree::ptree & ndarts = */ + nattr.add("d", myDarts[it]); - // update property node to add a value node (from basic or custom type - write_cmap_attribute_node(nattr, it_attrib->point()); + // update property node to add a value node (from basic or custom type + write_cmap_attribute_node(nattr, amap.point(it)); + } } } }; @@ -230,15 +226,9 @@ namespace CGAL { struct My_functor_cmap_save_one_attrib { static void run(CMap& amap, boost::property_tree::ptree& ptree, - std::map& myDarts) + std::unordered_map& myDarts) { - // to check all i-cells of the map - typename CMap::template Attribute_range::type::const_iterator - it_attrib, itend_attrib; - it_attrib=amap.template attributes().begin(); - itend_attrib=amap.template attributes().end(); - // add dimension & type boost::property_tree::ptree& ndim = ptree.add("dimension", ""); ndim.put(".index", i); @@ -247,15 +237,19 @@ namespace CGAL { ndim.add("type_point", "void"); // for every attribute of the dimension - for (; it_attrib!=itend_attrib; ++it_attrib) + for (auto it=amap.template one_dart_per_cell().begin(), + itend=amap.template one_dart_per_cell().end(); it!=itend; ++it) { - // make composant, dart and property node - boost::property_tree::ptree & nattr = ndim.add("a", ""); - /* boost::property_tree::ptree & ndarts = */ - nattr.add("d", myDarts[it_attrib->dart()]); + if (amap.template attribute(it)!=nullptr) + { + // make composant, dart and property node + boost::property_tree::ptree & nattr = ndim.add("a", ""); + /* boost::property_tree::ptree & ndarts = */ + nattr.add("d", myDarts[it]); - // update property node to add a value node (from basic or custom type - write_cmap_attribute_node(nattr, it_attrib->info()); + // update property node to add a value node (from basic or custom type + write_cmap_attribute_node(nattr, amap.template info(it)); + } } } }; @@ -265,15 +259,9 @@ namespace CGAL { struct My_functor_cmap_save_one_attrib { static void run(CMap& amap, boost::property_tree::ptree& ptree, - std::map& myDarts) + std::unordered_map& myDarts) { - // to check all i-cells of the map - typename CMap::template Attribute_range::type::const_iterator - it_attrib, itend_attrib; - it_attrib=amap.template attributes().begin(); - itend_attrib=amap.template attributes().end(); - // add dimension & type boost::property_tree::ptree& ndim = ptree.add("dimension", ""); ndim.put(".index", i); @@ -281,12 +269,16 @@ namespace CGAL { ndim.add("type_point", "void"); // for every attribute of the dimension - for (; it_attrib!=itend_attrib; ++it_attrib) + for (auto it=amap.template one_dart_per_cell().begin(), + itend=amap.template one_dart_per_cell().end(); it!=itend; ++it) { - // make composant, dart and property node - boost::property_tree::ptree & nattr = ndim.add("a", ""); - /* boost::property_tree::ptree & ndarts = */ - nattr.add("d", myDarts[it_attrib->dart()]); + if (amap.template attribute(it)!=nullptr) + { + // make composant, dart and property node + boost::property_tree::ptree & nattr = ndim.add("a", ""); + /* boost::property_tree::ptree & ndarts = */ + nattr.add("d", myDarts[it]); + } } } }; @@ -296,8 +288,8 @@ namespace CGAL { { template static void run(CMap& amap, boost::property_tree::ptree& ptree, - std::map& myDarts) + std::unordered_map& myDarts) { My_functor_cmap_save_one_attrib::run(amap, ptree, myDarts); } @@ -305,12 +297,12 @@ namespace CGAL { template < class CMap > boost::property_tree::ptree cmap_save_darts - (CMap& amap, std::map& myDarts) + (CMap& amap, std::unordered_map& myDarts) { CGAL_assertion( myDarts.empty() ); - // First we numbered each dart by using the std::map. + // First we numbered each dart by using the unordered_map. typename CMap::Dart_range::const_iterator it(amap.darts().begin()); for(typename CMap::size_type num=1; num<=amap.number_of_darts(); ++num, ++it) @@ -349,8 +341,8 @@ namespace CGAL { template < class CMap > boost::property_tree::ptree cmap_save_attributes - (const CMap& amap, std::map& myDarts) + (const CMap& amap, std::unordered_map& myDarts) { using boost::property_tree::ptree; ptree pt; @@ -383,7 +375,7 @@ namespace CGAL { f(tree); // map dart => number - std::map myDarts; + std::unordered_map myDarts; // Save darts ptree pt_darts=cmap_save_darts(amap, myDarts); diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h b/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h index 949eb1ebc36..7474a9ef649 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h @@ -49,15 +49,11 @@ namespace CGAL { typedef typename Items_::template Dart_wrapper Dart_wrapper; -#if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) - typedef typename Dart_wrapper::Dart Dart; -#else typedef typename internal::template Get_dart_info::type Dart_info; typedef typename internal::template Get_darts_with_id::type Darts_with_id; typedef CGAL::Dart Dart; -#endif typedef std::allocator_traits Allocator_traits; typedef typename Allocator_traits::template rebind_alloc Dart_allocator; @@ -304,13 +300,11 @@ namespace CGAL { ah->set_dart(adart); } -#if !defined(CGAL_CMAP_DART_DEPRECATED) || defined(CGAL_NO_DEPRECATED_CODE) // Get the information associated with a given dart Dart_info& info(Dart_handle adart) { return adart->info(); } const Dart_info& info(Dart_const_handle adart) const { return adart->info(); } -#endif // Get the info of the given attribute template diff --git a/Combinatorial_map/include/CGAL/Dart.h b/Combinatorial_map/include/CGAL/Dart.h index fa4375ed202..60f5ccbc9bc 100644 --- a/Combinatorial_map/include/CGAL/Dart.h +++ b/Combinatorial_map/include/CGAL/Dart.h @@ -200,109 +200,6 @@ namespace CGAL { typename Helper::Attribute_handles mattribute_handles; }; -#if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) - -#define CGAL_BETAINV(i) (i>1?i:(i==1?0:1)) - - /** Definition of nD dart for combinatorial map. Add functions beta and attributes which - * are now deprecated. - */ - template - struct CGAL_DEPRECATED Dart : public Dart_without_info - { - template - friend class Combinatorial_map_storage_1; - - template - friend class CMap_linear_cell_complex_storage_1; - - template - friend class Compact_container; - - template - friend class Concurrent_compact_container; - - typedef Dart_without_info Base; - - using Base::dimension; - using Base::mf; - using Base::mattribute_handles; - - typedef typename Base::Dart_handle Dart_handle; - typedef typename Base::Dart_const_handle Dart_const_handle; - typedef typename Base::Helper Helper; - - /// Typedef for attributes - template - struct Attribute_handle: public Refs::template Attribute_handle - {}; - template - struct Attribute_const_handle: - public Refs::template Attribute_const_handle - {}; - - public: - /** Return the beta of this dart for a given dimension. - * @param i the dimension. - * @return beta(\em i). - */ - template - Dart_handle beta() - { - CGAL_assertion(i <= dimension); - return mf[i]; - } - Dart_handle beta(unsigned int i) - { - CGAL_assertion(i <= dimension); - return mf[i]; - } - template - Dart_const_handle beta() const - { - CGAL_assertion(i <= dimension); - return mf[i]; - } - Dart_const_handle beta(unsigned int i) const - { - CGAL_assertion(i <= dimension); - return mf[i]; - } - - /** Return the beta inverse of this dart for a given dimension. - * @param i the dimension. - * @return beta^{-1}(\em i). - */ - template - Dart_handle beta_inv() - { return beta(); } - Dart_handle beta_inv(unsigned int i) - { return beta(CGAL_BETAINV(i)); } - template - Dart_const_handle beta_inv() const - { return beta(); } - Dart_const_handle beta_inv(unsigned int i) const - { return beta(CGAL_BETAINV(i)); } - - /// @return a handle on the i-attribute - template - typename Attribute_handle::type attribute() - { - CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, - "attribute called but i-attributes are disabled."); - return std::get::value> - (mattribute_handles); - } - template - typename Attribute_const_handle::type attribute() const - { - CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, - "attribute called but i-attributes are disabled."); - return std::get::value> - (mattribute_handles); - } - }; -#else // CGAL_CMAP_DART_DEPRECATED // Dart definition with an info; // (there is a specialization below when Info_==void) template -#include #include "Combinatorial_map_test_iterators.h" #include diff --git a/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_3_test.h b/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_3_test.h index 68727f70d66..a7d8549bc06 100644 --- a/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_3_test.h +++ b/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_3_test.h @@ -12,8 +12,6 @@ #ifndef CGAL_COMBINATORIAL_MAP_3_TEST #define CGAL_COMBINATORIAL_MAP_3_TEST 1 -#include -#include #include "Combinatorial_map_test_iterators.h" #include diff --git a/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_copy_test.cpp b/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_copy_test.cpp index eb054e1114f..083e322054b 100644 --- a/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_copy_test.cpp +++ b/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_copy_test.cpp @@ -12,6 +12,7 @@ #include #include #include +#include using namespace std; @@ -291,7 +292,7 @@ void create2Dmap(Map& map) CreateAttributes::run(map); CreateAttributes::run(map); CreateAttributes::run(map); - CGAL_assertion ( map.is_valid() ); + assert( map.is_valid() ); } template void create3Dmap(Map& map) @@ -342,7 +343,7 @@ void create4Dmap(Map& map) CreateAttributes::run(map); CreateAttributes::run(map); CreateAttributes::run(map); - CGAL_assertion ( map.is_valid() ); + assert( map.is_valid() ); } bool testCopy() diff --git a/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_deprecated_test.cpp b/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_deprecated_test.cpp deleted file mode 100644 index 376243aafe4..00000000000 --- a/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_deprecated_test.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include - -#include - -#define CGAL_CMAP_DART_DEPRECATED 1 - -#include -#include -#include -#include -#include - -struct My_items -{ - /// Dart_wrapper defines the type of darts used, and enabled attributes. - template < class Refs > - struct Dart_wrapper - { - typedef CGAL::Dart< 3, Refs > Dart; - typedef std::tuple<> Attributes; - }; -}; - -typedef CGAL::Combinatorial_map<3, My_items> CMap; - -bool test() -{ - CMap map; - for ( int i=0; i<15; ++i ) - { - CGAL::make_edge(map); - CGAL::make_combinatorial_polygon(map, 6); - CGAL::make_combinatorial_tetrahedron(map); - CGAL::make_combinatorial_hexahedron(map); - } - - for ( int i=0; i<20; ++i ) - { - CMap::Dart_handle d1=map.darts().begin(); - while ( !map.is_free<3>(d1) ) ++d1; - CMap::Dart_handle d2=map.darts().begin(); - while ( !map.is_sewable<3>(d1, d2) ) ++d2; - map.sew<3>(d1,d2); - - if (CGAL::is_face_combinatorial_polygon(map, d1, 6)) - {} - if (CGAL::is_volume_combinatorial_hexahedron(map, d1)) - {} - if (CGAL::is_volume_combinatorial_tetrahedron(map, d1)) - {} - - if (CGAL::is_removable(map, d1)) - CGAL::remove_cell(map, d1); - else if (CGAL::is_contractible(map, d1)) - CGAL::contract_cell(map, d1, true); - - CMap::Dart_handle d3=CGAL::insert_cell_0_in_cell_1(map, d2); - CGAL::insert_cell_0_in_cell_2(map, d2); - - CGAL::insert_dangling_cell_1_in_cell_2(map, d2); - - if (CGAL::is_insertable_cell_1_in_cell_2(map, d2, d3)) - CGAL::insert_cell_1_in_cell_2(map, d2, d3); - - std::vector adarts; - adarts.push_back(d2); - adarts.push_back(d3); - adarts.push_back(map.beta<1>(d3)); - - if (CGAL::is_insertable_cell_2_in_cell_3(map, adarts.begin(), adarts.end())) - CGAL::insert_cell_2_in_cell_3(map, adarts.begin(), adarts.end()); - } - - return true; -} - -int main() -{ - std::cout<<"Combinatorial map deprecated test (v1)."< +template void convex_hull_3(const VertexListGraph& g, PolygonMesh& pm, - const NamedParameters& np); + const NamedParameters& np = parameters::default_values()); /*! \ingroup PkgConvexHull3Functions @@ -97,6 +97,39 @@ void convex_hull_3(InputIterator first, InputIterator last, Object& ch_object, const Traits& ch_traits = Default_traits); +/*! +\ingroup PkgConvexHull3Functions + +\brief computes the convex hull of the set of points in the range +[`first`, `last`). The result, which may be a point, a segment, +a triangle, or a triangle mesh, is stored as an indexed triangle soup +in a vector of points and a vector of index triples. + + +\tparam InputIterator must be an input iterator with a value type equivalent to `Traits::Point_3`. +\tparam PointRange a model of the concept `RandomAccessContainer` whose value type is the point type. +\tparam PolygonRange a model of the concepts `RandomAccessContainer` and `BackInsertionSequence` + whose `value_type` is itself a model of the concepts `RandomAccessContainer` + and `BackInsertionSequence` whose `value_type` is an unsigned integer type + convertible to `std::size_t` +\tparam Traits must be model of the concept `ConvexHullTraits_3`. + For the purposes of checking the postcondition that the convex hull + is valid, `Traits` must also be a model of the concept + `IsStronglyConvexTraits_3`. + +If the kernel `R` of the points determined by the value type of `InputIterator` +is a kernel with exact predicates but inexact constructions +(in practice we check `R::Has_filtered_predicates_tag` is `Tag_true` and `R::FT` is a floating point type), +then the default traits class of `convex_hull_3()` is `Convex_hull_traits_3`, and `R` otherwise. + + +*/ + + template +void convex_hull_3(InputIterator first, InputIterator last, + PointRange& vertices, + PolygonRange& faces, + const Traits& ch_traits = Default_traits); /*! \ingroup PkgConvexHull3Functions diff --git a/Convex_hull_3/doc/Convex_hull_3/examples.txt b/Convex_hull_3/doc/Convex_hull_3/examples.txt index b0c65d480a4..ed7a9043151 100644 --- a/Convex_hull_3/doc/Convex_hull_3/examples.txt +++ b/Convex_hull_3/doc/Convex_hull_3/examples.txt @@ -7,4 +7,5 @@ \example Convex_hull_3/quickhull_any_dim_3.cpp \example Convex_hull_3/extreme_points_3_sm.cpp \example Convex_hull_3/extreme_indices_3.cpp +\example Convex_hull_3/quickhull_indexed_triangle_set_3.cpp */ diff --git a/Convex_hull_3/examples/Convex_hull_3/CMakeLists.txt b/Convex_hull_3/examples/Convex_hull_3/CMakeLists.txt index 437b548268d..40050953f9d 100644 --- a/Convex_hull_3/examples/Convex_hull_3/CMakeLists.txt +++ b/Convex_hull_3/examples/Convex_hull_3/CMakeLists.txt @@ -34,6 +34,8 @@ endif() # Creating entries for all C++ files with "main" routine # ########################################################## +create_single_source_cgal_program("quickhull_indexed_triangle_set_3.cpp") + create_single_source_cgal_program("dynamic_hull_3.cpp") create_single_source_cgal_program("dynamic_hull_LCC_3.cpp") diff --git a/Convex_hull_3/examples/Convex_hull_3/quickhull_indexed_triangle_set_3.cpp b/Convex_hull_3/examples/Convex_hull_3/quickhull_indexed_triangle_set_3.cpp new file mode 100644 index 00000000000..256e9009a88 --- /dev/null +++ b/Convex_hull_3/examples/Convex_hull_3/quickhull_indexed_triangle_set_3.cpp @@ -0,0 +1,32 @@ +#include +#include + +#include +#include +#include + + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef K::Point_3 Point_3; + + +int main(int argc, char* argv[]) +{ + std::ifstream in( (argc>1)? argv[1] : "data/cube.xyz"); + std::vector points; + + std::vector vertices; + std::vector > faces; + + Point_3 p; + while(in >> p){ + points.push_back(p); + } + + + CGAL::convex_hull_3(points.begin(), points.end(), vertices, faces); + + std::cout << vertices.size() << " " << faces.size() << std::endl; + + return 0; +} diff --git a/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h b/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h index aed894dae89..2edd7244422 100644 --- a/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h +++ b/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include @@ -72,7 +72,7 @@ namespace CGAL Plane_3 > > result_inter; - boost::unordered_map primal_vertices; + std::unordered_map primal_vertices; size_t n = 0; // First, computing the primal vertices diff --git a/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_with_constructions_3.h b/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_with_constructions_3.h index be791a8e0bc..31dcb337b98 100644 --- a/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_with_constructions_3.h +++ b/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_with_constructions_3.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include @@ -51,7 +51,7 @@ namespace CGAL typename boost::property_map::type vpm_dual = get(CGAL::vertex_point, dual); // compute coordinates of extreme vertices in the dual polyhedron // from primal faces - boost::unordered_map extreme_points; + std::unordered_map extreme_points; for(face_descriptor fd : faces( primal)){ halfedge_descriptor h = halfedge(fd,primal); diff --git a/Convex_hull_3/include/CGAL/Convex_hull_3/internal/Indexed_triangle_set.h b/Convex_hull_3/include/CGAL/Convex_hull_3/internal/Indexed_triangle_set.h new file mode 100644 index 00000000000..524f45e6a65 --- /dev/null +++ b/Convex_hull_3/include/CGAL/Convex_hull_3/internal/Indexed_triangle_set.h @@ -0,0 +1,149 @@ +// Copyright (c) 2021 GeometryFactory Sarl +// 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) : Andreas Fabri + +#ifndef CGAL_INDEXED_TRIANGLE_SET_H +#define CGAL_INDEXED_TRIANGLE_SET_H + +#include +#include +#include + +#include +#include +#include +#include + +namespace CGAL { +namespace Convex_hull_3 { +namespace internal { + +template +struct Indexed_triangle_set +{ + V& vertices; + F& faces; + + typedef typename std::iterator_traits::value_type Index_triple; + typedef typename std::iterator_traits::value_type Index; + + Indexed_triangle_set(V& vertices, + F& faces) + : vertices(vertices), faces(faces) + {} +}; + +template +void add_isolated_points(const P& point, Indexed_triangle_set& its) +{ + its.vertices.push_back(point); +} + + +template +void copy_ch2_to_face_graph(const std::list

& CH_2, + Indexed_triangle_set& its) +{ + its.vertices.reserve(CH_2.size()); + CGAL::internal::resize(its.faces, CH_2.size()-2); + for(const P& p : CH_2){ + its.vertices.push_back(p); + } + + typedef typename Indexed_triangle_set::Index Index; + + for(std::size_t i = 1; i < CH_2.size()-1; ++i){ + CGAL::internal::resize(its.faces[i-1], 3); + its.faces[i-1][0] = static_cast(i); + its.faces[i-1][1] = static_cast(i + 1); + its.faces[i-1][2] = static_cast(i + 2); + } + +} + +} // namespace internal +} // namespace Convex_hull_3 + +template +void copy_face_graph(const TDS& tds, Convex_hull_3::internal::Indexed_triangle_set& its) +{ + typedef typename TDS::Vertex_iterator Vertex_iterator; + typedef typename TDS::Face_iterator Face_iterator; + CGAL::internal::resize(its.vertices, tds.number_of_vertices()); + CGAL::internal::resize(its.faces, tds.number_of_faces()); + typename Convex_hull_3::internal::Indexed_triangle_set::Index i = 0; + for(Vertex_iterator vit = tds.vertices_begin(); vit != tds.vertices_end(); ++vit){ + its.vertices[i] = vit->point(); + vit->info() = i++; + } + + i = 0; + for (Face_iterator fit = tds.faces_begin(); fit != tds.faces_end(); ++fit) { + CGAL::internal::resize(its.faces[i], 3); + its.faces[i][0] = fit->vertex(0)->info(); + its.faces[i][1] = fit->vertex(1)->info(); + its.faces[i][2] = fit->vertex(2)->info(); + ++i; + } +} + + +template +void clear(Convex_hull_3::internal::Indexed_triangle_set& its) +{ + CGAL::internal::resize(its.vertices, 0); + CGAL::internal::resize(its.faces, 0); +} + + +template +void make_tetrahedron(const P& p0, const P&p1, const P& p2, const P& p3, + Convex_hull_3::internal::Indexed_triangle_set& its) +{ CGAL::internal::resize(its.vertices, 4); + CGAL::internal::resize(its.faces, 4); + + its.vertices[0] = p0; + its.vertices[1] = p1; + its.vertices[2] = p2; + its.vertices[3] = p3; + for(std::size_t i = 0; i < 4; ++i){ + CGAL::internal::resize(its.faces[i], 3); + } + its.faces[0][0] = 0; + its.faces[0][1] = 1; + its.faces[0][2] = 2; + its.faces[1][0] = 1; + its.faces[1][1] = 0; + its.faces[1][2] = 3; + its.faces[2][0] = 3; + its.faces[2][1] = 0; + its.faces[2][2] = 2; + its.faces[3][0] = 2; + its.faces[3][1] = 1; + its.faces[3][2] = 3; +} + +} // namespace CGAL + +namespace boost { + +// this partial specialization is needed so that the general overload +// for make_tetrahedron can be eliminated as halfedge_descriptor is +// used in the returned type +template + struct graph_traits> +{ + typedef void* halfedge_descriptor; +}; + +} // namespace boost + +#endif // CGAL_INDEXED_TRIANGLE_SET_H diff --git a/Convex_hull_3/include/CGAL/Convex_hull_face_base_2.h b/Convex_hull_3/include/CGAL/Convex_hull_face_base_2.h index f44372153cd..7899a0da840 100644 --- a/Convex_hull_3/include/CGAL/Convex_hull_face_base_2.h +++ b/Convex_hull_3/include/CGAL/Convex_hull_face_base_2.h @@ -17,49 +17,53 @@ #include +#include #include -#include namespace CGAL { -template < typename Info_, typename GT, - typename Fb = Triangulation_face_base_2 > +template < typename GT, + typename Fb = Triangulation_ds_face_base_2< > > class Convex_hull_face_base_2 : public Fb { - Info_ _info; + int _info = 0; + public: typedef typename Fb::Vertex_handle Vertex_handle; typedef typename Fb::Face_handle Face_handle; - typedef Info_ Info; typename std::list::iterator it; std::list points; + template < typename TDS2 > struct Rebind_TDS { typedef typename Fb::template Rebind_TDS::Other Fb2; - typedef Convex_hull_face_base_2 Other; + typedef Convex_hull_face_base_2 Other; }; Convex_hull_face_base_2() : Fb(), _info(0) {} Convex_hull_face_base_2(Vertex_handle v0, - Vertex_handle v1, - Vertex_handle v2) + Vertex_handle v1, + Vertex_handle v2) : Fb(v0, v1, v2), _info(0) {} Convex_hull_face_base_2(Vertex_handle v0, - Vertex_handle v1, - Vertex_handle v2, - Face_handle n0, - Face_handle n1, - Face_handle n2 ) + Vertex_handle v1, + Vertex_handle v2, + Face_handle n0, + Face_handle n1, + Face_handle n2 ) : Fb(v0, v1, v2, n0, n1, n2), _info(0) {} - const Info& info() const { return _info; } - Info& info() { return _info; } + const int& info() const { return _info; } + int& info() { return _info; } + + static int ccw(int i) {return Triangulation_cw_ccw_2::ccw(i);} + static int cw(int i) {return Triangulation_cw_ccw_2::cw(i);} }; } //namespace CGAL diff --git a/Convex_hull_3/include/CGAL/Convex_hull_traits_3.h b/Convex_hull_3/include/CGAL/Convex_hull_traits_3.h index 5746d8293d3..4cf555e37b3 100644 --- a/Convex_hull_3/include/CGAL/Convex_hull_traits_3.h +++ b/Convex_hull_3/include/CGAL/Convex_hull_traits_3.h @@ -15,18 +15,16 @@ #include - #include -#include #include #include #include -#include #include #include #include namespace CGAL { + template < class R_ > class Point_triple { diff --git a/Convex_hull_3/include/CGAL/Convex_hull_vertex_base_2.h b/Convex_hull_3/include/CGAL/Convex_hull_vertex_base_2.h new file mode 100644 index 00000000000..2ec965bb809 --- /dev/null +++ b/Convex_hull_3/include/CGAL/Convex_hull_vertex_base_2.h @@ -0,0 +1,85 @@ +// Copyright (c) 2011 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) : Mael Rouxel-Labbé + +// vertex of a triangulation of any dimension <= 3 + +#ifndef CGAL_CONVEX_HULL_VERTEX_BASE_2_H +#define CGAL_CONVEX_HULL_VERTEX_BASE_2_H + +#include + +#include + +#include + +namespace CGAL { + +template < typename GT, + typename Vb = Triangulation_ds_vertex_base_2< > > +class Convex_hull_vertex_base_2 + : public Vb +{ +public: + typedef typename GT::Point_2 Point; + + typedef typename Vb::Face_handle Face_handle; + typedef typename Vb::Vertex_handle Vertex_handle; + +private: + int _info = 0; + Point _p; + +public: + template < typename TDS2 > + struct Rebind_TDS + { + typedef typename Vb::template Rebind_TDS::Other Vb2; + typedef Convex_hull_vertex_base_2 Other; + }; + + Convex_hull_vertex_base_2() + : Vb() {} + + Convex_hull_vertex_base_2(const Point& p) + : Vb(), _p(p) {} + + Convex_hull_vertex_base_2(const Point& p, Face_handle f) + : Vb(f), _p(p) {} + + Convex_hull_vertex_base_2(Face_handle f) + : Vb(f) {} + + void set_point(const Point& p) { _p = p; } + const Point& point() const { return _p; } + Point& point() { return _p; } + + const int& info() const { return _info; } + int& info() { return _info; } +}; + +template +std::istream& +operator>>(std::istream &is, Convex_hull_vertex_base_2& v) +{ + return is >> static_cast(v) >> v.point(); +} + +template +std::ostream& +operator<<(std::ostream &os, const Convex_hull_vertex_base_2& v) +{ + return os << static_cast(v) << v.point(); +} + +} //namespace CGAL + +#endif // CGAL_CONVEX_HULL_VERTEX_BASE_2_H diff --git a/Convex_hull_3/include/CGAL/convex_hull_3.h b/Convex_hull_3/include/CGAL/convex_hull_3.h index 20b12772563..14ce7ff15c8 100644 --- a/Convex_hull_3/include/CGAL/convex_hull_3.h +++ b/Convex_hull_3/include/CGAL/convex_hull_3.h @@ -17,24 +17,23 @@ #include -#include - -#include #include #include +#include +#include +#include +#include #include #include #include -#include -#include #include -#include #include #include +#include #include #include -#include +#include #include #include #include @@ -704,7 +703,6 @@ ch_quickhull_3_scan(TDS_2& tds, } Vertex_handle vh = tds.star_hole(edges.begin(), edges.end(), visible_set.begin(), visible_set.end()); vh->point() = farthest_pt; - vh->info() = 0; // now partition the set of outside set points among the new facets. @@ -772,15 +770,15 @@ ch_quickhull_face_graph(std::list& points, const Traits& traits) { typedef typename Traits::Point_3 Point_3; - typedef typename Traits::Plane_3 Plane_3; - typedef typename std::list::iterator P3_iterator; + typedef typename Traits::Plane_3 Plane_3; + typedef typename std::list::iterator P3_iterator; typedef Triangulation_data_structure_2< - Triangulation_vertex_base_with_info_2 >, - Convex_hull_face_base_2 > Tds; + Convex_hull_vertex_base_2 >, + Convex_hull_face_base_2 > Tds; - typedef typename Tds::Vertex_handle Vertex_handle; - typedef typename Tds::Face_handle Face_handle; + typedef typename Tds::Vertex_handle Vertex_handle; + typedef typename Tds::Face_handle Face_handle; // found three points that are not collinear, so construct the plane defined // by these points and then find a point that has maximum distance from this @@ -823,7 +821,6 @@ ch_quickhull_face_graph(std::list& points, Vertex_handle v2 = tds.create_vertex(); v2->set_point(*point3_it); Vertex_handle v3 = tds.create_vertex(); v3->set_point(*max_it); - v0->info() = v1->info() = v2->info() = v3->info() = 0; Face_handle f0 = tds.create_face(v0,v1,v2); Face_handle f1 = tds.create_face(v3,v1,v0); Face_handle f2 = tds.create_face(v3,v2,v1); @@ -1062,10 +1059,10 @@ void convex_hull_3(InputIterator first, InputIterator beyond, convex_hull_3(first, beyond, polyhedron, Traits()); } -template +template void convex_hull_3(const VertexListGraph& g, PolygonMesh& pm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using CGAL::parameters::choose_parameter; using CGAL::parameters::get_parameter; @@ -1080,13 +1077,38 @@ void convex_hull_3(const VertexListGraph& g, boost::make_transform_iterator(vertices(g).end(), v2p), pm); } -template -void convex_hull_3(const VertexListGraph& g, - PolygonMesh& pm) + + +template +void convex_hull_3(InputIterator first, InputIterator beyond, + PointRange& vertices, + TriangleRange& faces, + typename std::enable_if::value>::type* = 0, + typename std::enable_if::value>::type* = 0, + typename std::enable_if::value>::type* = 0) { - convex_hull_3(g,pm,CGAL::parameters::all_default()); + typedef typename std::iterator_traits::value_type Point_3; + typedef typename Kernel_traits::type Traits; + + Convex_hull_3::internal::Indexed_triangle_set its(vertices,faces); + convex_hull_3(first, beyond, its, Traits()); } + +template +void convex_hull_3(InputIterator first, InputIterator beyond, + PointRange& vertices, + TriangleRange& faces, + const Traits& traits, + typename std::enable_if::value>::type* = 0, + typename std::enable_if::value>::type* = 0, + typename std::enable_if::value>::type* = 0) +{ + Convex_hull_3::internal::Indexed_triangle_set its(vertices,faces); + convex_hull_3(first, beyond, its, traits); +} + + template OutputIterator extreme_points_3(const InputRange& range, @@ -1111,6 +1133,4 @@ extreme_points_3(const InputRange& range, OutputIterator out) } // namespace CGAL -#include - #endif // CGAL_CONVEX_HULL_3_H diff --git a/Convex_hull_3/package_info/Convex_hull_3/dependencies b/Convex_hull_3/package_info/Convex_hull_3/dependencies index ecc6d422e1b..406722ba9af 100644 --- a/Convex_hull_3/package_info/Convex_hull_3/dependencies +++ b/Convex_hull_3/package_info/Convex_hull_3/dependencies @@ -24,5 +24,4 @@ Random_numbers STL_Extension Stream_support TDS_2 -Triangulation_2 Triangulation_3 diff --git a/Convex_hull_3/test/Convex_hull_3/ch3_4points.cpp b/Convex_hull_3/test/Convex_hull_3/ch3_4points.cpp index 87714c6d437..ec2cf5ccebe 100644 --- a/Convex_hull_3/test/Convex_hull_3/ch3_4points.cpp +++ b/Convex_hull_3/test/Convex_hull_3/ch3_4points.cpp @@ -2,6 +2,7 @@ #include #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef K::Point_3 Point_3; @@ -12,9 +13,9 @@ int main() Point_3 points[] = { Point_3(1.0, 0.0, 0.0), Point_3(0.0, 1.0, 0.0), Point_3(0.0, 0.0, 1.0), Point_3(0.0, 0.0, 0.0) }; Gm_polyhedron P1; CGAL::convex_hull_3(points, &points[4], P1); - CGAL_assertion( CGAL::Polygon_mesh_processing::is_outward_oriented(P1) ); + assert( CGAL::Polygon_mesh_processing::is_outward_oriented(P1) ); Point_3 points_bis[] = { Point_3(0.0, 1.0, 0.0), Point_3(1.0, 0.0, 0.0), Point_3(0.0, 0.0, 1.0), Point_3(0.0, 0.0, 0.0) }; CGAL::convex_hull_3(points_bis, &points_bis[4], P1); - CGAL_assertion( CGAL::Polygon_mesh_processing::is_outward_oriented(P1) ); + assert( CGAL::Polygon_mesh_processing::is_outward_oriented(P1) ); } diff --git a/Convex_hull_3/test/Convex_hull_3/quickhull_degenerate_test_3.cpp b/Convex_hull_3/test/Convex_hull_3/quickhull_degenerate_test_3.cpp index c006f0586e5..ead5fa229d9 100644 --- a/Convex_hull_3/test/Convex_hull_3/quickhull_degenerate_test_3.cpp +++ b/Convex_hull_3/test/Convex_hull_3/quickhull_degenerate_test_3.cpp @@ -122,7 +122,8 @@ void test_coplanar_arbitrary() CGAL::convex_hull_3(points.begin(), points.end(), ch_object, Traits()); Polyhedron_3 P; Segment_3 seg; - assert( CGAL::assign(P, ch_object) || CGAL::assign(seg, ch_object)); + Triangle_3 tri; + assert( CGAL::assign(P, ch_object) || CGAL::assign(seg, ch_object) || CGAL::assign(tri, ch_object) ); } void test_collinear() @@ -152,9 +153,6 @@ void test_collinear() } -#include - - int main() { std::vector points; diff --git a/Convex_hull_3/test/Convex_hull_3/test_ch_3_ambiguity.cpp b/Convex_hull_3/test/Convex_hull_3/test_ch_3_ambiguity.cpp index 6bce70428e1..87588329136 100644 --- a/Convex_hull_3/test/Convex_hull_3/test_ch_3_ambiguity.cpp +++ b/Convex_hull_3/test/Convex_hull_3/test_ch_3_ambiguity.cpp @@ -23,7 +23,7 @@ int main(int argc, char* argv[]) Surface_mesh chull; // compute convex hull - auto np = CGAL::parameters::all_default(); + auto np = CGAL::parameters::default_values(); CGAL::convex_hull_3(poly, chull, np); std::cout << "The convex hull contains " << chull.number_of_vertices() << " vertices" << std::endl; return 0; diff --git a/Convex_hull_3/test/Convex_hull_3/test_quickhull_indexed_triangle_set_3.cpp b/Convex_hull_3/test/Convex_hull_3/test_quickhull_indexed_triangle_set_3.cpp new file mode 100644 index 00000000000..5d0e19a42a9 --- /dev/null +++ b/Convex_hull_3/test/Convex_hull_3/test_quickhull_indexed_triangle_set_3.cpp @@ -0,0 +1,77 @@ +#include +#include + +#include +#include +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef K::Point_3 Point_3; + + +template +void test() +{ + Vertices vertices; + Faces faces; + + std::vector points; + Point_3 p0(0,0,0), p1(0,0,1), p2(0,1,0), p3(1,0,0), p4(0.1, 0.1, 0.1); + + points.push_back(p0); + CGAL::convex_hull_3(points.begin(), points.end(), vertices, faces); + assert(vertices.size() == 1); + assert(faces.empty()); + assert(vertices[0] == p0); + + + points.push_back(p1); + CGAL::convex_hull_3(points.begin(), points.end(), vertices, faces); + assert(vertices.size() == 2); + assert(faces.empty()); + std::sort(vertices.begin(), vertices.end()); + assert( (vertices[0] == p0) && (vertices[1] == p1)); + + + points.push_back(p2); + CGAL::convex_hull_3(points.begin(), points.end(), vertices, faces); + assert(vertices.size() == 3); + assert(faces.size() == 1); + std::sort(vertices.begin(), vertices.end()); + assert( (vertices[0] == p0) && (vertices[1] == p1) && (vertices[2] == p2) ); + + points.push_back(p3); + CGAL::convex_hull_3(points.begin(), points.end(), vertices, faces); + assert(vertices.size() == 4); + assert(faces.size() == 4); + std::sort(vertices.begin(), vertices.end()); + assert( (vertices[0] == p0) && (vertices[1] == p1) && (vertices[2] == p2) && (vertices[3] == p3) ); + + + points.push_back(p4); + CGAL::convex_hull_3(points.begin(), points.end(), vertices, faces); + assert(vertices.size() == 4); + assert(faces.size() == 4); + std::sort(vertices.begin(), vertices.end()); + assert( (vertices[0] == p0) && (vertices[1] == p1) && (vertices[2] == p2) && (vertices[3] == p3) ); +} + + +int main() +{ + { + typedef std::vector Vertices; + typedef std::vector > Faces; + test(); + } + + { + typedef std::vector Vertices; + typedef std::deque > Faces; + test(); + } + + + return 0; +} diff --git a/Data/data/meshes/beam.off b/Data/data/meshes/beam.off new file mode 100644 index 00000000000..8d0908dc812 --- /dev/null +++ b/Data/data/meshes/beam.off @@ -0,0 +1,16 @@ +OFF +8 6 0 +2.7 2.7 2.3 +2.7 2.3 2.3 +2.3 2.7 2.3 +2.3 2.3 2.3 +2.7 2.7 -1.3 +2.7 2.3 -1.3 +2.3 2.7 -1.3 +2.3 2.3 -1.3 +4 0 1 3 2 +4 5 4 6 7 +4 0 2 6 4 +4 3 1 5 7 +4 0 4 5 1 +4 6 2 3 7 diff --git a/Distance_3/include/CGAL/Distance_3/Point_3_Triangle_3.h b/Distance_3/include/CGAL/Distance_3/Point_3_Triangle_3.h index a6f2e7c8e94..8b58e9a81a6 100644 --- a/Distance_3/include/CGAL/Distance_3/Point_3_Triangle_3.h +++ b/Distance_3/include/CGAL/Distance_3/Point_3_Triangle_3.h @@ -93,30 +93,75 @@ squared_distance_to_triangle_RT(const typename K::Point_3& pt, return; } - const bool b01 = on_left_of_triangle_edge(pt, normal, t0, t1, k); - if(!b01) + if(!on_left_of_triangle_edge(pt, normal, t0, t1, k)) { - squared_distance_RT(pt, segment(t0, t1), num, den, k); - return; - } + if(!on_left_of_triangle_edge(pt, normal, t1, t2, k)) + { + // can't be to the right of all three segments + squared_distance_RT(pt, segment(t0, t1), num, den, k); - const bool b12 = on_left_of_triangle_edge(pt, normal, t1, t2, k); - if(!b12) + typename K::RT num2, den2; + squared_distance_RT(pt, segment(t1, t2), num2, den2, k); + if(compare_quotients(num2,den2, num,den) == SMALLER) + { + num = num2; + den = den2; + } + } + else // on_left_of_triangle_edge(pt, normal, t1, t2, k) + { + if(!on_left_of_triangle_edge(pt, normal, t2, t0, k)) + { + squared_distance_RT(pt, segment(t0, t1), num, den, k); + + typename K::RT num2, den2; + squared_distance_RT(pt, segment(t2, t0), num2, den2, k); + if(compare_quotients(num2,den2, num,den) == SMALLER) + { + num = num2; + den = den2; + } + } + else // on_left_of_triangle_edge(pt, normal, t2, t0, k) + { + return squared_distance_RT(pt, segment(t0, t1), num, den, k); + } + } + } + else // on_left_of_triangle_edge(pt, normal, t0, t1, k) { - squared_distance_RT(pt, segment(t1, t2), num, den, k); - return; - } + if(!on_left_of_triangle_edge(pt, normal, t1, t2, k)) + { + if(!on_left_of_triangle_edge(pt, normal, t2, t0, k)) + { + squared_distance_RT(pt, segment(t1, t2), num, den, k); - const bool b20 = on_left_of_triangle_edge(pt, normal, t2, t0, k); - if(!b20) - { - squared_distance_RT(pt, segment(t2, t0), num, den, k); - return; + typename K::RT num2, den2; + squared_distance_RT(pt, segment(t2, t0), num2, den2, k); + if(compare_quotients(num2,den2, num,den) == SMALLER) + { + num = num2; + den = den2; + } + } + else // on_left_of_triangle_edge(pt, normal, t2, t0, k) + { + return squared_distance_RT(pt, segment(t1, t2), num, den, k); + } + } + else // on_left_of_triangle_edge(pt, normal, t1, t2, k) + { + if(!on_left_of_triangle_edge(pt, normal, t2, t0, k)) + { + return squared_distance_RT(pt, segment(t2, t0), num, den, k); + } + else // on_left_of_triangle_edge(pt, normal, t2, t0, k) + { + inside = true; + return squared_distance_to_plane_RT(normal, vector(t0, pt), num, den, k); + } + } } - - // The projection of pt is inside the triangle - inside = true; - squared_distance_to_plane_RT(normal, vector(t0, pt), num, den, k); } template @@ -174,21 +219,51 @@ squared_distance_to_triangle(const typename K::Point_3& pt, return (std::min)((std::min)(d1, d2), d3); } - const bool b01 = on_left_of_triangle_edge(pt, normal, t0, t1, k); - if(!b01) - return sq_dist(pt, segment(t0, t1)); - - const bool b12 = on_left_of_triangle_edge(pt, normal, t1, t2, k); - if(!b12) - return sq_dist(pt, segment(t1, t2)); - - const bool b20 = on_left_of_triangle_edge(pt, normal, t2, t0, k); - if(!b20) - return sq_dist(pt, segment(t2, t0)); - - // The projection of pt is inside the triangle - inside = true; - return squared_distance_to_plane(normal, vector(t0, pt), k); + if(!on_left_of_triangle_edge(pt, normal, t0, t1, k)) + { + if(!on_left_of_triangle_edge(pt, normal, t1, t2, k)) + { + // can't be to the right of all three segments + return (std::min)(sq_dist(pt, segment(t0, t1)), sq_dist(pt, segment(t1, t2))); + } + else // on_left_of_triangle_edge(pt, normal, t1, t2, k) + { + if(!on_left_of_triangle_edge(pt, normal, t2, t0, k)) + { + return (std::min)(sq_dist(pt, segment(t0, t1)), sq_dist(pt, segment(t2, t0))); + } + else // on_left_of_triangle_edge(pt, normal, t2, t0, k) + { + return sq_dist(pt, segment(t0, t1)); + } + } + } + else // on_left_of_triangle_edge(pt, normal, t0, t1, k) + { + if(!on_left_of_triangle_edge(pt, normal, t1, t2, k)) + { + if(!on_left_of_triangle_edge(pt, normal, t2, t0, k)) + { + return (std::min)(sq_dist(pt, segment(t1, t2)), sq_dist(pt, segment(t2, t0))); + } + else // on_left_of_triangle_edge(pt, normal, t2, t0, k) + { + return sq_dist(pt, segment(t1, t2)); + } + } + else // on_left_of_triangle_edge(pt, normal, t1, t2, k) + { + if(!on_left_of_triangle_edge(pt, normal, t2, t0, k)) + { + return sq_dist(pt, segment(t2, t0)); + } + else // on_left_of_triangle_edge(pt, normal, t2, t0, k) + { + inside = true; + return squared_distance_to_plane(normal, vector(t0, pt), k); + } + } + } } template diff --git a/Distance_3/test/Distance_3/test_distance_3.cpp b/Distance_3/test/Distance_3/test_distance_3.cpp index 29f66c839e1..ab67ad18d79 100644 --- a/Distance_3/test/Distance_3/test_distance_3.cpp +++ b/Distance_3/test/Distance_3/test_distance_3.cpp @@ -86,7 +86,7 @@ private: P random_point() const { - return P(r.get_double(m, M), r.get_double(m, M), r.get_double(m, M)); + return P(FT(r.get_double(m, M)), FT(r.get_double(m, M)), FT(r.get_double(m, M))); } Pl pl(int a, int b, int c, int d) @@ -208,6 +208,36 @@ private: check_squared_distance (p(1, 1, 1), t, 1); check_squared_distance (p(1, 0, 1), t, 1); check_squared_distance (p(0, 0, 1), t, 1); + + // Degenerate + check_squared_distance (p(1, 2, 3), T(p(4,3,2), p(4,3,2), p(4,3,2)), squared_distance(p(1, 2, 3), p(4,3,2))); + check_squared_distance (p(1, 2, 3), T(p(4,3,2), p(10,12,3), p(4,3,2)), squared_distance(p(1, 2, 3), p(4,3,2))); + check_squared_distance (p(0, 0, 0), T(p(4,3,2), p(4,-3,-2), p(4,3,2)), squared_distance(p(0, 0, 0), p(4,0,0))); + + // On the triangle + check_squared_distance (p(7, 1, -5), T(p(2,9,8), p(-4,-3,-5), p(7, 1, -5)), 0); // vertex + check_squared_distance (p(7, 1, -5), T(p(14,2,-10), p(-7,-1,5), p(8, 3, -1)), 0); // edge + check_squared_distance (p(1, 4, -3), T(p(0,-8,-3), p(-5,14,-3), p(10, 1, -3)), 0); // face + + // General + check_squared_distance (p(-15, 1, 0), T(p(-10, 1, 0), p(0,0,0), p(10,0,0)), 25); + check_squared_distance (p(-5, 0, 0), T(p(-10, 1, 0), p(0,0,0), p(10,0,0)), squared_distance(p(-5, 0, 0), S(p(-10, 1, 0), p(0,0,0)))); + check_squared_distance (p(0, -3, 0), T(p(-10, 1, 0), p(0,0,0), p(10,0,0)), 9); + check_squared_distance (p(3, -3, 0), T(p(-10, 1, 0), p(0,0,0), p(10,0,0)), squared_distance(p(3, -3, 0), S(p(0,0,0), p(10,0,0)))); + check_squared_distance (p(16, 1, 1), T(p(-10, 1, 0), p(0,0,0), p(10,0,0)), 38); + check_squared_distance (p(5, 5, 2), T(p(-10, 1, 0), p(0,0,0), p(10,0,0)), squared_distance(p(5, 5, 2), S(p(10,0,0), p(-10,1,0)))); + + for(int i=0; iDo not call global functions unqualified, that is, always specify explicitly the namespace where the function is defined. -

  • Do not give private types or typedefs a name likely to be used as - a public interface by an other class, e.g. prefer `Point_3_` - to `Point_3` (in general, add an underscore as suffix). The reason for this convention is that - SFINAE - does not extend to access control before C++11 (meaning that the existence of a - private type can break overloading for other classes). \section seccode_format Code format diff --git a/Documentation/doc/Documentation/Usage.txt b/Documentation/doc/Documentation/Usage.txt index c1d78002332..8537ba3548e 100644 --- a/Documentation/doc/Documentation/Usage.txt +++ b/Documentation/doc/Documentation/Usage.txt @@ -85,7 +85,7 @@ contains the following subdirectories: | :------------------------- | :----------| | `auxiliary` (Windows only) | precompiled \gmp and \mpfr for Windows | | `cmake/modules` | modules for finding and using libraries | -| `demo` | demo programs (most of them need \qt, geomview or other third-party products) | +| `demo` | demo programs (most of them need \qt, or other third-party products) | | `doc_html` | documentation (HTML) | | `examples` | example programs | | `include` | header files | diff --git a/Documentation/doc/Documentation/main.txt b/Documentation/doc/Documentation/main.txt index 4a295decbd4..085a2ad83b6 100644 --- a/Documentation/doc/Documentation/main.txt +++ b/Documentation/doc/Documentation/main.txt @@ -21,7 +21,7 @@ objects and predicates are regrouped in \ref PartKernels "CGAL Kernels". Finally, the \ref PartSupportLibrary "Support Library" offers geometric object generators and spatial sorting functions, as well as a matrix search framework and a solver for linear and quadratic programs. It further offers interfaces -to third party software such as the GUI libraries Qt, Geomview, and +to third party software such as the GUI libraries Qt, and the Boost Graph Library. The complete list of packages is available on the page \ref packages. diff --git a/Documentation/doc/Documentation/packages.txt b/Documentation/doc/Documentation/packages.txt index eaefdfcf0f6..3509bc41d00 100644 --- a/Documentation/doc/Documentation/packages.txt +++ b/Documentation/doc/Documentation/packages.txt @@ -163,7 +163,6 @@ \cgalPackageSection{PartVisualization,Visualization} -\package_listing{Geomview} \package_listing{GraphicsView} \package_listing{CGAL_ipelets} diff --git a/Documentation/doc/resources/1.8.13/BaseDoxyfile.in b/Documentation/doc/resources/1.8.13/BaseDoxyfile.in index 402a6913e1a..03b6c67ef41 100644 --- a/Documentation/doc/resources/1.8.13/BaseDoxyfile.in +++ b/Documentation/doc/resources/1.8.13/BaseDoxyfile.in @@ -2132,7 +2132,7 @@ ENABLE_PREPROCESSING = YES # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then # the macro expansion is limited to the macros specified with the PREDEFINED and @@ -2140,7 +2140,7 @@ MACRO_EXPANSION = NO # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = YES # If the SEARCH_INCLUDES tag is set to YES, the include files in the # INCLUDE_PATH will be searched if a #include is found. @@ -2172,7 +2172,14 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = DOXYGEN_RUNNING +PREDEFINED = DOXYGEN_RUNNING \ + "CGAL_NP_TEMPLATE_PARAMETERS=NamedParameters = CGAL::parameters::Default_named_parameters" \ + "CGAL_NP_CLASS=NamedParameters" \ + "CGAL_NP_TEMPLATE_PARAMETERS_1=NamedParameters1 = CGAL::parameters::Default_named_parameter" \ + "CGAL_NP_CLASS_1=NamedParameters1" \ + "CGAL_NP_TEMPLATE_PARAMETERS_2=NamedParameters2 = CGAL::parameters::Default_named_parameter" \ + "CGAL_NP_CLASS_2=NamedParameters2" \ + CGAL_DEPRECATED # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/Documentation/doc/resources/1.8.13/menu_version.js b/Documentation/doc/resources/1.8.13/menu_version.js index 48563b0a283..e8a424f40cd 100644 --- a/Documentation/doc/resources/1.8.13/menu_version.js +++ b/Documentation/doc/resources/1.8.13/menu_version.js @@ -6,8 +6,8 @@ var current_version_local = 'master' var all_versions = [ 'master', - '5.4-beta1', 'latest', + '5.4', '5.3.1', '5.2.4', '5.1.5', diff --git a/Documentation/doc/resources/1.8.14/BaseDoxyfile.in b/Documentation/doc/resources/1.8.14/BaseDoxyfile.in index 835b61dfd54..491ceed309c 100644 --- a/Documentation/doc/resources/1.8.14/BaseDoxyfile.in +++ b/Documentation/doc/resources/1.8.14/BaseDoxyfile.in @@ -2120,7 +2120,7 @@ ENABLE_PREPROCESSING = YES # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then # the macro expansion is limited to the macros specified with the PREDEFINED and @@ -2128,7 +2128,7 @@ MACRO_EXPANSION = NO # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = YES # If the SEARCH_INCLUDES tag is set to YES, the include files in the # INCLUDE_PATH will be searched if a #include is found. @@ -2160,7 +2160,14 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = DOXYGEN_RUNNING +PREDEFINED = DOXYGEN_RUNNING \ + "CGAL_NP_TEMPLATE_PARAMETERS=NamedParameters = CGAL::parameters::Default_named_parameters" \ + "CGAL_NP_CLASS=NamedParameters" \ + "CGAL_NP_TEMPLATE_PARAMETERS_1=NamedParameters1 = CGAL::parameters::Default_named_parameter" \ + "CGAL_NP_CLASS_1=NamedParameters1" \ + "CGAL_NP_TEMPLATE_PARAMETERS_2=NamedParameters2 = CGAL::parameters::Default_named_parameter" \ + "CGAL_NP_CLASS_2=NamedParameters2" \ + CGAL_DEPRECATED # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/Documentation/doc/resources/1.8.14/menu_version.js b/Documentation/doc/resources/1.8.14/menu_version.js index 48563b0a283..e8a424f40cd 100644 --- a/Documentation/doc/resources/1.8.14/menu_version.js +++ b/Documentation/doc/resources/1.8.14/menu_version.js @@ -6,8 +6,8 @@ var current_version_local = 'master' var all_versions = [ 'master', - '5.4-beta1', 'latest', + '5.4', '5.3.1', '5.2.4', '5.1.5', diff --git a/Documentation/doc/resources/1.8.20/BaseDoxyfile.in b/Documentation/doc/resources/1.8.20/BaseDoxyfile.in index a3d3d6c67c1..38d6df6f400 100644 --- a/Documentation/doc/resources/1.8.20/BaseDoxyfile.in +++ b/Documentation/doc/resources/1.8.20/BaseDoxyfile.in @@ -2203,7 +2203,7 @@ ENABLE_PREPROCESSING = YES # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then # the macro expansion is limited to the macros specified with the PREDEFINED and @@ -2211,7 +2211,7 @@ MACRO_EXPANSION = NO # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = YES # If the SEARCH_INCLUDES tag is set to YES, the include files in the # INCLUDE_PATH will be searched if a #include is found. @@ -2243,7 +2243,14 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = DOXYGEN_RUNNING +PREDEFINED = DOXYGEN_RUNNING \ + "CGAL_NP_TEMPLATE_PARAMETERS=NamedParameters = CGAL::parameters::Default_named_parameters" \ + "CGAL_NP_CLASS=NamedParameters" \ + "CGAL_NP_TEMPLATE_PARAMETERS_1=NamedParameters1 = CGAL::parameters::Default_named_parameter" \ + "CGAL_NP_CLASS_1=NamedParameters1" \ + "CGAL_NP_TEMPLATE_PARAMETERS_2=NamedParameters2 = CGAL::parameters::Default_named_parameter" \ + "CGAL_NP_CLASS_2=NamedParameters2" \ + CGAL_DEPRECATED # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/Documentation/doc/resources/1.8.20/menu_version.js b/Documentation/doc/resources/1.8.20/menu_version.js index 48563b0a283..e8a424f40cd 100644 --- a/Documentation/doc/resources/1.8.20/menu_version.js +++ b/Documentation/doc/resources/1.8.20/menu_version.js @@ -6,8 +6,8 @@ var current_version_local = 'master' var all_versions = [ 'master', - '5.4-beta1', 'latest', + '5.4', '5.3.1', '5.2.4', '5.1.5', diff --git a/Documentation/doc/resources/1.8.4/BaseDoxyfile.in b/Documentation/doc/resources/1.8.4/BaseDoxyfile.in index 0b6dd035849..9b33b9e51a1 100644 --- a/Documentation/doc/resources/1.8.4/BaseDoxyfile.in +++ b/Documentation/doc/resources/1.8.4/BaseDoxyfile.in @@ -1726,13 +1726,13 @@ ENABLE_PREPROCESSING = YES # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = YES # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # pointed to by INCLUDE_PATH will be searched when a #include is found. @@ -1760,7 +1760,14 @@ INCLUDE_FILE_PATTERNS = # undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = DOXYGEN_RUNNING +PREDEFINED = DOXYGEN_RUNNING \ + "CGAL_NP_TEMPLATE_PARAMETERS=NamedParameters = CGAL::parameters::Default_named_parameters" \ + "CGAL_NP_CLASS=NamedParameters" \ + "CGAL_NP_TEMPLATE_PARAMETERS_1=NamedParameters1 = CGAL::parameters::Default_named_parameter" \ + "CGAL_NP_CLASS_1=NamedParameters1" \ + "CGAL_NP_TEMPLATE_PARAMETERS_2=NamedParameters2 = CGAL::parameters::Default_named_parameter" \ + "CGAL_NP_CLASS_2=NamedParameters2" \ + CGAL_DEPRECATED # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. diff --git a/Documentation/doc/resources/1.8.4/menu_version.js b/Documentation/doc/resources/1.8.4/menu_version.js index 48563b0a283..e8a424f40cd 100644 --- a/Documentation/doc/resources/1.8.4/menu_version.js +++ b/Documentation/doc/resources/1.8.4/menu_version.js @@ -6,8 +6,8 @@ var current_version_local = 'master' var all_versions = [ 'master', - '5.4-beta1', 'latest', + '5.4', '5.3.1', '5.2.4', '5.1.5', diff --git a/Documentation/doc/resources/1.9.3/BaseDoxyfile.in b/Documentation/doc/resources/1.9.3/BaseDoxyfile.in index 960e9dafb10..a12bfce4648 100644 --- a/Documentation/doc/resources/1.9.3/BaseDoxyfile.in +++ b/Documentation/doc/resources/1.9.3/BaseDoxyfile.in @@ -1,4 +1,4 @@ -# Doxyfile 1.8.20 +# Doxyfile 1.9.3 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -2203,7 +2203,7 @@ ENABLE_PREPROCESSING = YES # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then # the macro expansion is limited to the macros specified with the PREDEFINED and @@ -2211,7 +2211,7 @@ MACRO_EXPANSION = NO # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = YES # If the SEARCH_INCLUDES tag is set to YES, the include files in the # INCLUDE_PATH will be searched if a #include is found. @@ -2243,7 +2243,15 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = DOXYGEN_RUNNING +PREDEFINED = DOXYGEN_RUNNING \ + "CGAL_NP_TEMPLATE_PARAMETERS=NamedParameters = CGAL::parameters::Default_named_parameters" \ + "CGAL_NP_CLASS=NamedParameters" \ + "CGAL_NP_TEMPLATE_PARAMETERS_1=NamedParameters1 = CGAL::parameters::Default_named_parameter" \ + "CGAL_NP_CLASS_1=NamedParameters1" \ + "CGAL_NP_TEMPLATE_PARAMETERS_2=NamedParameters2 = CGAL::parameters::Default_named_parameter" \ + "CGAL_NP_CLASS_2=NamedParameters2" \ + CGAL_DEPRECATED + # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/Documentation/doc/resources/1.9.3/menu_version.js b/Documentation/doc/resources/1.9.3/menu_version.js index 45f224cf7d1..e8a424f40cd 100644 --- a/Documentation/doc/resources/1.9.3/menu_version.js +++ b/Documentation/doc/resources/1.9.3/menu_version.js @@ -3,12 +3,13 @@ var url_re = /(cgal\.geometryfactory\.com\/CGAL\/doc\/|doc\.cgal\.org\/)(master|latest|(\d\.\d+|\d\.\d+\.\d+)(-beta\d)?)\//; var url_local = /.*\/doc_output\//; - var current_version_local = '5.3-beta1' + var current_version_local = 'master' var all_versions = [ 'master', - '5.3', 'latest', - '5.2.3', + '5.4', + '5.3.1', + '5.2.4', '5.1.5', '5.0.4', '4.14.3', diff --git a/Envelope_2/examples/Envelope_2/envelope_circles.cpp b/Envelope_2/examples/Envelope_2/envelope_circles.cpp index daae2157203..94da9077706 100644 --- a/Envelope_2/examples/Envelope_2/envelope_circles.cpp +++ b/Envelope_2/examples/Envelope_2/envelope_circles.cpp @@ -8,6 +8,7 @@ #include #include #include +#include typedef CGAL::Exact_rational Number_type; typedef CGAL::Cartesian Kernel; @@ -42,7 +43,7 @@ void print_diagram (const Diagram_1& diag) e = v->right(); } - CGAL_assertion (e->is_empty()); + assert(e->is_empty()); std::cout << "Edge: [empty]" << std::endl; return; diff --git a/Envelope_2/examples/Envelope_2/envelope_segments.cpp b/Envelope_2/examples/Envelope_2/envelope_segments.cpp index 751d4feb501..e3cd1d9fa99 100644 --- a/Envelope_2/examples/Envelope_2/envelope_segments.cpp +++ b/Envelope_2/examples/Envelope_2/envelope_segments.cpp @@ -10,6 +10,7 @@ #include #include +#include typedef CGAL::Exact_rational Number_type; typedef CGAL::Cartesian Kernel; @@ -74,7 +75,7 @@ int main () e = v->right(); } - CGAL_assertion (e->is_empty()); + assert(e->is_empty()); std::cout << "Edge: [empty]" << std::endl; return (0); diff --git a/Generalized_map/examples/Generalized_map/gmap_3_marks.cpp b/Generalized_map/examples/Generalized_map/gmap_3_marks.cpp index a0d3acb288d..e87b9413fbd 100644 --- a/Generalized_map/examples/Generalized_map/gmap_3_marks.cpp +++ b/Generalized_map/examples/Generalized_map/gmap_3_marks.cpp @@ -1,6 +1,7 @@ #include #include #include +#include typedef CGAL::Generalized_map<3> GMap_3; typedef GMap_3::Dart_handle Dart_handle; @@ -26,9 +27,9 @@ int main() Dart_handle dh1 = gm.make_combinatorial_tetrahedron(); Dart_handle dh2 = gm.make_combinatorial_tetrahedron(); - CGAL_assertion( gm.is_valid() ); - CGAL_assertion( gm.is_volume_combinatorial_tetrahedron(dh1) ); - CGAL_assertion( gm.is_volume_combinatorial_tetrahedron(dh2) ); + assert( gm.is_valid() ); + assert( gm.is_volume_combinatorial_tetrahedron(dh1) ); + assert( gm.is_volume_combinatorial_tetrahedron(dh2) ); // 3) 3-sew them. gm.sew<3>(dh1, dh2); @@ -59,4 +60,3 @@ int main() return EXIT_SUCCESS; } - diff --git a/Generalized_map/examples/Generalized_map/gmap_3_operations.cpp b/Generalized_map/examples/Generalized_map/gmap_3_operations.cpp index 9c3050d6dbd..7b99b1838f2 100644 --- a/Generalized_map/examples/Generalized_map/gmap_3_operations.cpp +++ b/Generalized_map/examples/Generalized_map/gmap_3_operations.cpp @@ -1,6 +1,7 @@ #include #include #include +#include typedef CGAL::Generalized_map<3> GMap_3; typedef GMap_3::Dart_handle Dart_handle; @@ -14,11 +15,11 @@ int main() // Add two edges along two opposite facets. gm.insert_cell_1_in_cell_2(d1,gm.alpha<0,1,0>(d1)); - CGAL_assertion( gm.is_valid() ); + assert( gm.is_valid() ); Dart_handle d2=gm.alpha<2,1,0,1,2>(d1); gm.insert_cell_1_in_cell_2(d2,gm.alpha<0,1,0>(d2)); - CGAL_assertion( gm.is_valid() ); + assert( gm.is_valid() ); // Insert a facet along these two new edges plus two initial edges // of the hexahedron. @@ -29,7 +30,7 @@ int main() path.push_back(gm.alpha<2,1>(d2)); Dart_handle d3=gm.insert_cell_2_in_cell_3(path.begin(),path.end()); - CGAL_assertion( gm.is_valid() ); + assert( gm.is_valid() ); // Display the generalized map characteristics. gm.display_characteristics(std::cout) << ", valid=" << @@ -37,14 +38,14 @@ int main() // We use the removal operations to get back to the initial hexahedron. gm.remove_cell<2>(d3); - CGAL_assertion( gm.is_valid() ); + assert( gm.is_valid() ); gm.remove_cell<1>(gm.alpha<1>(d1)); - CGAL_assertion( gm.is_valid() ); + assert( gm.is_valid() ); gm.remove_cell<1>(gm.alpha<1>(d2)); - CGAL_assertion( gm.is_valid() ); - CGAL_assertion( gm.is_volume_combinatorial_hexahedron(d1) ); + assert( gm.is_valid() ); + assert( gm.is_volume_combinatorial_hexahedron(d1) ); // Display the generalized map characteristics. gm.display_characteristics(std::cout) << ", valid=" @@ -52,4 +53,3 @@ int main() return EXIT_SUCCESS; } - diff --git a/Generalized_map/examples/Generalized_map/gmap_4_simple_example.cpp b/Generalized_map/examples/Generalized_map/gmap_4_simple_example.cpp index e447da890e0..0f31affd7e0 100644 --- a/Generalized_map/examples/Generalized_map/gmap_4_simple_example.cpp +++ b/Generalized_map/examples/Generalized_map/gmap_4_simple_example.cpp @@ -1,6 +1,7 @@ #include #include #include +#include typedef CGAL::Generalized_map<4> GMap_4; typedef GMap_4::Dart_handle Dart_handle; @@ -11,7 +12,7 @@ int main() Dart_handle d1 = gm.make_combinatorial_tetrahedron(); Dart_handle d2 = gm.make_combinatorial_tetrahedron(); - CGAL_assertion(gm.is_valid()); + assert(gm.is_valid()); gm.sew<4>(d1,d2); diff --git a/Generalized_map/include/CGAL/Generalized_map.h b/Generalized_map/include/CGAL/Generalized_map.h index ad8de549631..f8cef4ff7fa 100644 --- a/Generalized_map/include/CGAL/Generalized_map.h +++ b/Generalized_map/include/CGAL/Generalized_map.h @@ -12,6 +12,8 @@ #ifndef CGAL_GENERALIZED_MAP_H #define CGAL_GENERALIZED_MAP_H 1 +#include + #include #include #include @@ -32,10 +34,12 @@ #include #include #include +#include #include -#include #include +#include + #if defined( __INTEL_COMPILER ) // Workarounf for warning in function basic_link_beta_0 #pragma warning disable 1017 @@ -88,7 +92,6 @@ namespace CGAL { typedef Storage Base; typedef Generalized_map_base Self; typedef Refs_ Refs; - typedef typename Base::Dart Dart; typedef typename Base::Dart_handle Dart_handle; typedef typename Base::Dart_const_handle Dart_const_handle; @@ -177,7 +180,7 @@ namespace CGAL { CGAL_assertion(number_of_darts()==0); } - /** Copy the given generalized map into *this. + /** Copy the given generalized map 'amap' into *this. * Note that both GMap can have different dimensions and/or non void attributes. * Here GMap2 is necessarily non const; while Dart_handle_2 can be a const or non const handle. * This is the "generic" method, called by the different variants below. @@ -196,34 +199,39 @@ namespace CGAL { typename Converters, typename DartInfoConverter, typename PointConverter> void generic_copy(GMap2& amap, - boost::unordered_map* origin_to_copy, - boost::unordered_map* copy_to_origin, + std::unordered_map* origin_to_copy, + std::unordered_map* copy_to_origin, const Converters& converters, const DartInfoConverter& dartinfoconverter, const PointConverter& pointconverter, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { - this->clear(); - - /*this->mnb_used_marks = amap.mnb_used_marks; - this->mmask_marks = amap.mmask_marks; - this->automatic_attributes_management = - amap.automatic_attributes_management; - + if(copy_marks) + { + // Reserve all marks of amap not yet reserved for (size_type i = 0; i < NB_MARKS; ++i) { - this->mfree_marks_stack[i] = amap.mfree_marks_stack[i]; - this->mused_marks_stack[i] = amap.mused_marks_stack[i]; - this->mindex_marks[i] = amap.mindex_marks[i]; - this->mnb_marked_darts[i] = amap.mnb_marked_darts[i]; - this->mnb_times_reserved_marks[i] = amap.mnb_times_reserved_marks[i]; - } */ + if(!is_reserved(i) && amap.is_reserved(i)) + { + CGAL_assertion(mnb_used_markscopies). // (here we cannot use CGAL::Unique_hash_map because it does not provide // iterators... - boost::unordered_map local_dartmap; + std::unordered_map local_dartmap; if (origin_to_copy==NULL) // Use local_dartmap if user does not provides its own unordered_map { origin_to_copy=&local_dartmap; } @@ -234,11 +242,21 @@ namespace CGAL { if (copy_perforated_darts || !amap.is_perforated(it)) { new_dart=mdarts.emplace(); - init_dart(new_dart); //, amap.get_marks(it)); + init_dart(new_dart); if (mark_perforated!=INVALID_MARK && amap.is_perforated(it)) { mark(new_dart, mark_perforated); } + if(copy_marks) + { + // Copy marks of amap + for(size_type i=0; i::iterator + typename std::unordered_map::iterator dartmap_iter, dartmap_iter_end=origin_to_copy->end(); for (dartmap_iter=origin_to_copy->begin(); dartmap_iter!=dartmap_iter_end; ++dartmap_iter) @@ -279,27 +297,28 @@ namespace CGAL { converters, pointconverter); } - CGAL_assertion(is_valid()); + CGAL_expensive_assertion(is_valid()); } // (1a) copy(amap, converters, dartinfoconverter, pointconverter) template void copy(GMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy, - boost::unordered_map + std::unordered_map * copy_to_origin, const Converters& converters, const DartInfoConverter& dartinfoconverter, const PointConverter& pointconverter, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { generic_copy (amap, origin_to_copy, copy_to_origin, - converters, dartinfoconverter, pointconverter, + converters, dartinfoconverter, pointconverter, copy_marks, copy_perforated_darts, mark_perforated); } @@ -307,120 +326,127 @@ namespace CGAL { template void copy_from_const(const GMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy, - boost::unordered_map + std::unordered_map * copy_to_origin, const Converters& converters, const DartInfoConverter& dartinfoconverter, const PointConverter& pointconverter, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { generic_copy (const_cast(amap), origin_to_copy, copy_to_origin, - converters, dartinfoconverter, pointconverter, + converters, dartinfoconverter, pointconverter, copy_marks, copy_perforated_darts, mark_perforated); } // (2a) copy(amap, converters, dartinfoconverter) template void copy(GMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy, - boost::unordered_map + std::unordered_map * copy_to_origin, const Converters& converters, const DartInfoConverter& dartinfoconverter, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { Default_converter_cmap_0attributes_with_point pointconverter; copy(amap, origin_to_copy, copy_to_origin, converters, - dartinfoconverter, pointconverter, + dartinfoconverter, pointconverter, copy_marks, copy_perforated_darts, mark_perforated); } // (2b) copy_from_const(const amap, converters, dartinfoconverter) template void copy_from_const(const GMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy, - boost::unordered_map + std::unordered_map * copy_to_origin, const Converters& converters, const DartInfoConverter& dartinfoconverter, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { Default_converter_cmap_0attributes_with_point pointconverter; copy_from_const(amap, origin_to_copy, copy_to_origin, converters, - dartinfoconverter, pointconverter, + dartinfoconverter, pointconverter, copy_marks, copy_perforated_darts, mark_perforated); } // (3a) copy(amap, converters) template void copy(GMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy, - boost::unordered_map + std::unordered_map * copy_to_origin, const Converters& converters, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { Default_converter_dart_info dartinfoconverter; copy(amap, origin_to_copy, copy_to_origin, converters, dartinfoconverter, - copy_perforated_darts, mark_perforated); + copy_marks, copy_perforated_darts, mark_perforated); } // (3b) copy_from_const(const amap, converters) template void copy_from_const(const GMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy, - boost::unordered_map + std::unordered_map * copy_to_origin, const Converters& converters, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { Default_converter_dart_info dartinfoconverter; copy_from_const(amap, origin_to_copy, copy_to_origin, converters, dartinfoconverter, - copy_perforated_darts, mark_perforated); + copy_marks, copy_perforated_darts, mark_perforated); } // (4a) copy(amap) template void copy(GMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy=nullptr, - boost::unordered_map + std::unordered_map * copy_to_origin=nullptr, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { std::tuple<> converters; - copy(amap, origin_to_copy, copy_to_origin, converters, + copy(amap, origin_to_copy, copy_to_origin, converters, copy_marks, copy_perforated_darts, mark_perforated); } // (4b) copy_from_const(const amap) template void copy_from_const(const GMap2& amap, - boost::unordered_map + std::unordered_map * origin_to_copy=nullptr, - boost::unordered_map + std::unordered_map * copy_to_origin=nullptr, + bool copy_marks=true, bool copy_perforated_darts=false, size_type mark_perforated=INVALID_MARK) { std::tuple<> converters; - copy_from_const(amap, origin_to_copy, copy_to_origin, converters, + copy_from_const(amap, origin_to_copy, copy_to_origin, converters, copy_marks, copy_perforated_darts, mark_perforated); } @@ -428,6 +454,10 @@ namespace CGAL { Generalized_map_base(const Self & amap) : Generalized_map_base() { copy_from_const(amap); } + // Move constructor + Generalized_map_base(Self && amap): Generalized_map_base() + { this->swap(amap); } + // "Copy constructor" from a map having different type. template @@ -755,14 +785,14 @@ namespace CGAL { void set_next(Dart_handle dh1, Dart_handle dh2) { - assert(!this->template is_free<0>(dh1)); + CGAL_assertion(!this->template is_free<0>(dh1)); this->template link_alpha<1>(this->template alpha<0>(dh1), dh2); } template void set_opposite(Dart_handle dh1, Dart_handle dh2) { - assert(!this->template is_free<0>(dh1)); - assert(!this->template is_free<0>(dh2)); + CGAL_assertion(!this->template is_free<0>(dh1)); + CGAL_assertion(!this->template is_free<0>(dh2)); this->template link_alpha(this->template alpha<0>(dh1), dh2); this->template link_alpha(dh1, this->template alpha<0>(dh2)); } @@ -780,7 +810,7 @@ namespace CGAL { size_type number_of_halfedges() const { - assert(is_without_boundary(0)); + CGAL_assertion(is_without_boundary(0)); return number_of_darts()/2; } @@ -1752,7 +1782,7 @@ namespace CGAL { if ( marks[acells[i]]==INVALID_MARK ) { marks[acells[i]] = get_new_mark(); - assert(is_whole_map_unmarked(marks[acells[i]])); + CGAL_assertion(is_whole_map_unmarked(marks[acells[i]])); } } @@ -2426,8 +2456,6 @@ namespace CGAL { } } - // CGAL_postcondition(amap2.is_valid()); - if ( res==amap.null_handle ) res = amap.darts().begin(); return res; } @@ -2632,9 +2660,9 @@ namespace CGAL { } } - assert(is_whole_map_unmarked(m1)); - assert(is_whole_map_unmarked(markpush)); - assert(map2.is_whole_map_unmarked(m2)); + CGAL_postcondition(is_whole_map_unmarked(m1)); + CGAL_postcondition(is_whole_map_unmarked(markpush)); + CGAL_postcondition(map2.is_whole_map_unmarked(m2)); free_mark(m1); free_mark(markpush); map2.free_mark(m2); @@ -2771,11 +2799,11 @@ namespace CGAL { if (aorientationmark==INVALID_MARK) { - assert(is_whole_map_marked(orientationmark)); + CGAL_assertion(is_whole_map_marked(orientationmark)); free_mark(orientationmark); } - assert(is_whole_map_marked(ccmark)); + CGAL_assertion(is_whole_map_marked(ccmark)); free_mark(ccmark); } @@ -2817,11 +2845,11 @@ namespace CGAL { if (aorientationmark==INVALID_MARK) { - assert(is_whole_map_unmarked(orientationmark)); + CGAL_assertion(is_whole_map_unmarked(orientationmark)); free_mark(orientationmark); } - assert(is_whole_map_unmarked(ccmark)); + CGAL_postcondition(is_whole_map_unmarked(ccmark)); free_mark(ccmark); return orientable; @@ -3854,6 +3882,9 @@ namespace CGAL { Generalized_map(const Self & amap) : Base(amap) {} + Generalized_map(Self && amap) : Base(amap) + {} + template Generalized_map(const Generalized_map_base& amap) : diff --git a/Generalized_map/include/CGAL/Generalized_map_save_load.h b/Generalized_map/include/CGAL/Generalized_map_save_load.h index 1b727e84493..bd9b2480756 100644 --- a/Generalized_map/include/CGAL/Generalized_map_save_load.h +++ b/Generalized_map/include/CGAL/Generalized_map_save_load.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include @@ -70,12 +70,12 @@ namespace CGAL { template < class GMap > boost::property_tree::ptree gmap_save_darts (const GMap& amap, - std::map& myDarts) { CGAL_assertion( myDarts.empty() ); - // First we numbered each dart by using the std::map. + // First we numbered each dart by using the unordered_map. typename GMap::Dart_range::const_iterator it(amap.darts().begin()); for(typename GMap::size_type num=1; num<=amap.number_of_darts(); ++num, ++it) @@ -119,7 +119,7 @@ namespace CGAL { ptree tree; // map dart => number - std::map myDarts; + std::unordered_map myDarts; // Save darts ptree pt_darts=gmap_save_darts(amap, myDarts); diff --git a/Generator/examples/Generator/random_segments2.cpp b/Generator/examples/Generator/random_segments2.cpp index d13c64c333b..f8c4fa99f62 100644 --- a/Generator/examples/Generator/random_segments2.cpp +++ b/Generator/examples/Generator/random_segments2.cpp @@ -8,6 +8,7 @@ #include #include #include +#include using namespace CGAL; @@ -41,16 +42,16 @@ int main() { Count_iterator t2_end( t2, 50); std::copy( t2_begin, t2_end, std::back_inserter(segs)); - CGAL_assertion( segs.size() == 100); + assert( segs.size() == 100); for ( Vector::iterator i = segs.begin(); i != segs.end(); i++){ - CGAL_assertion( i->source().x() <= 250); - CGAL_assertion( i->source().x() >= -250); - CGAL_assertion( i->source().y() <= 250); - CGAL_assertion( i->source().y() >= -250); - CGAL_assertion( i->target().x() <= 250); - CGAL_assertion( i->target().x() >= -250); - CGAL_assertion( i->target().y() <= 250); - CGAL_assertion( i->target().y() >= -250); + assert( i->source().x() <= 250); + assert( i->source().x() >= -250); + assert( i->source().y() <= 250); + assert( i->source().y() >= -250); + assert( i->target().x() <= 250); + assert( i->target().x() >= -250); + assert( i->target().y() <= 250); + assert( i->target().y() >= -250); } return 0; } diff --git a/Geomview/TODO b/Geomview/TODO deleted file mode 100644 index 6b19b556a92..00000000000 --- a/Geomview/TODO +++ /dev/null @@ -1,61 +0,0 @@ -- recuperer le dernier objet insere dans geomview -- pouvoir detruire des objets -- avoir une option pour que les segments soient des petits cylindres, - pour qu'on puisse enfin faire des demos 3D... -- INPUT BUG : not really fixed : if it takes long to run geomview (eg the - first time you run the program), then the bug is still there. - Try to fix it properly with select(). - It's still probably a bug in Geomview. -- The remote geomview (with rsh) facility probably doesn't work. - But is it useful ? -- Missing operators (for 2d and 3d Voronoi diagrams) : - - Ray_[23], Line_[23] : an easy one is already there, but to do it - perfectly, we should draw the segment resulting from the intersection of - the object with the BBox. - - Circle_2 -- Discretisation for Sphere and Circle should be configurable for the stream. -- Is there a way to see edges like cylinders somewhat (possibly generate them - ourselves), so that we know which one is in front of which other one ? -- For T3D : I want to be able to tell Geomview or the CGAL program to stop - displaying a tetrahedron that I select, so that I can see the inside. - Maybe it's not really worth it, finally. See the real needs first. -- I also want to display only the convex hull of a T3D. -- See how we can use this as a debugger : ask Frederic details on his stuff. - The fact we're multiprocess probably means we'll even have less problems - than multi-threads... -- Should wired_flag be checked for Triangle_[23] and other kernel stuff ? - -Color: ------- -- Color is not passed correctly to triangulations, and probably other kernel - objects. That must be checked, along with transparency. -- See how we can mix the Color output with the raw mode. - Currently it's not clear to me. - Check how to do transparency with Geomview ? - (passing the one from CGAL::IO::Color) - -Demo : ------- -- Add demo files for polyhedrons ? - -Doc: ---- -- Monique's comment : -> > Also note that terrains are supported directly. -> -> Je comprends mal cette remarque: -> Soit c'est trop court et il faut expliquer que tout ca c'est template et que -> la sortie en tient compte et que donc ca marche bien, et pas que pour les -> terrains, les terrains ne sont qu'un exemple (important il est vrai, mais -> bon) de ce qu'on peut faire comme Triangulation_2 un peu speciale, quand il -> y aura des triangulations de surfaces ca marchera pareil. -> Soit c'est trop long, si tout ca est bien evident autant ne pas le dire. -> qu'en penses-tu ? - -Medite bien, tu me raconteras. - -Ce qu'il faudrait dire qq part c'est que ces sorties en marcheront que si -l'utilisateur a defini des sorties geomview pour les points, les segments, -les triangles et le tetraedres qu'il fournit dans la Traits. -C'est peut-etre dans la doc de Triangulation_2,3 qu'il faut l'ecrire ? -pourquoi ne pas l'ecrire aussi dans la doc geomview ? diff --git a/Geomview/demo/Geomview/CMakeLists.txt b/Geomview/demo/Geomview/CMakeLists.txt deleted file mode 100644 index 5384209c55e..00000000000 --- a/Geomview/demo/Geomview/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# Created by the script cgal_create_cmake_script -# This is the CMake script for compiling a CGAL application. - -cmake_minimum_required(VERSION 3.1...3.20) -project(Geomview_Demo) - -if(NOT POLICY CMP0070 AND POLICY CMP0053) - # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. - cmake_policy(SET CMP0053 OLD) -endif() - -set_property(DIRECTORY PROPERTY CGAL_NO_TESTING TRUE) - -find_package(CGAL REQUIRED) - -create_single_source_cgal_program("input.cpp") -create_single_source_cgal_program("kernel.cpp") -create_single_source_cgal_program("gv_terrain.cpp") diff --git a/Geomview/demo/Geomview/README b/Geomview/demo/Geomview/README deleted file mode 100644 index 6e538a75351..00000000000 --- a/Geomview/demo/Geomview/README +++ /dev/null @@ -1,9 +0,0 @@ -This directory contains demo programs for the interface of CGAL with the -Geomview 3D viewer. - -- kernel is a program that shows the output of kernel objects. -- input is a program demonstrating how you can enter a point in Geomview and - pass it to the CGAL program. -- gv_terrain is a program that show successively the same set of points in a 2D - Delaunay triangulation (projected), 3D Delaunay, and terrain. Alternatively - in wired or plain mode. diff --git a/Geomview/demo/Geomview/data/points3 b/Geomview/demo/Geomview/data/points3 deleted file mode 100644 index 67bdf9a9dab..00000000000 --- a/Geomview/demo/Geomview/data/points3 +++ /dev/null @@ -1,100 +0,0 @@ -50 50 100 -100 50 100 -150 50 110 -200 50 120 -261 50 130 -300 50 150 -341 50 140 -400 50 130 -450 50 120 -500 50 110 -50 100 100 -100 100 100 -155 100 100 -200 100 120 -250 100 140 -320 100 150 -350 101 170 -400 100 150 -420 104 120 -500 100 100 -50 150 100 -100 150 100 -150 150 100 -230 150 150 -250 150 140 -300 150 120 -350 150 130 -400 150 100 -450 150 110 -500 150 100 -50 200 100 -100 200 100 -150 200 120 -230 200 150 -250 200 140 -320 204 120 -350 200 120 -400 200 150 -450 200 120 -500 200 100 -50 250 100 -100 250 100 -154 250 120 -220 255 140 -270 250 160 -306 250 200 -330 250 150 -350 258 140 -450 250 120 -500 250 100 -50 300 100 -100 300 100 -150 300 100 -230 300 120 -250 300 160 -320 300 180 -370 300 140 -400 300 120 -450 300 100 -500 300 100 -70 350 100 -100 350 100 -150 350 110 -210 350 120 -260 350 140 -300 350 150 -350 350 150 -400 350 140 -450 350 100 -500 350 100 -50 400 100 -100 400 100 -150 400 110 -200 400 100 -250 400 130 -300 400 150 -350 400 130 -400 400 110 -450 400 100 -500 400 100 -50 450 100 -100 450 100 -150 450 100 -200 450 100 -250 450 120 -300 450 120 -350 450 110 -400 450 100 -450 450 100 -500 450 100 -50 500 100 -100 500 100 -150 500 100 -200 500 100 -260 500 110 -300 500 100 -370 500 100 -400 500 100 -450 500 100 -500 500 100 diff --git a/Geomview/demo/Geomview/gv_terrain.cpp b/Geomview/demo/Geomview/gv_terrain.cpp deleted file mode 100644 index 7506d6fcc44..00000000000 --- a/Geomview/demo/Geomview/gv_terrain.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include - -#ifndef CGAL_USE_GEOMVIEW -int main() -{ - std::cout << "Geomview doesn't work on Windows, so..." << std::endl; - return 0; -} -#else - -#include -#include // for sleep() - -#include - -#include -#include - -#include -#include -#include - -#include - -typedef CGAL::Cartesian K; - -typedef K::Point_2 Point2; -typedef CGAL::Projection_traits_xy_3 Gt3; -typedef Gt3::Point Point3; - -typedef CGAL::Delaunay_triangulation_2 Delaunay; -typedef CGAL::Delaunay_triangulation_2 Terrain; - -typedef CGAL::Delaunay_triangulation_3 Delaunay3d; - -int main() -{ - CGAL::Geomview_stream gv(CGAL::Bbox_3(-100, -100, -100, 600, 600, 600)); - gv.set_line_width(4); - // gv.set_trace(true); - gv.set_bg_color(CGAL::IO::Color(0, 200, 200)); - // gv.clear(); - - Delaunay D; - Delaunay3d D3d; - Terrain T; - std::ifstream iFile("data/points3", std::ios::in); - Point3 p; - - while ( iFile >> p ) - { - D.insert( Point2(p.x(), p.y()) ); - D3d.insert( p ); - T.insert( p ); - } - - // use different colors, and put a few sleeps/clear. - - gv << CGAL::IO::blue(); - std::cout << "Drawing 2D Delaunay triangulation in wired mode.\n"; - gv.set_wired(true); - gv << D; - -#if 1 // It's too slow ! Needs to use OFF for that. - gv << CGAL::IO::red(); - std::cout << "Drawing its Voronoi diagram.\n"; - gv.set_wired(true); - D.draw_dual(gv); -#endif - - sleep(5); - gv.clear(); - - std::cout << "Drawing 2D Delaunay triangulation in non-wired mode.\n"; - gv.set_wired(false); - gv << D; - sleep(5); - gv.clear(); - - std::cout << "Drawing 3D Delaunay triangulation in wired mode.\n"; - gv.set_wired(true); - gv << D3d; - sleep(5); - gv.clear(); - std::cout << "Drawing 3D Delaunay triangulation in non-wired mode.\n"; - gv.set_wired(false); - gv << D3d; - sleep(5); - gv.clear(); - - std::cout << "Drawing Terrain in wired mode.\n"; - gv.set_wired(true); - gv << T; - sleep(5); - gv.clear(); - std::cout << "Drawing Terrain in non-wired mode.\n"; - gv.set_wired(false); - gv << T; - - std::cout << "Enter a key to finish" << std::endl; - char ch; - std::cin >> ch; - - return 0; -} -#endif diff --git a/Geomview/demo/Geomview/input.cpp b/Geomview/demo/Geomview/input.cpp deleted file mode 100644 index 3745ca79a90..00000000000 --- a/Geomview/demo/Geomview/input.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2000, 2001, 2004 -// Utrecht University (The Netherlands), -// ETH Zurich (Switzerland), -// INRIA Sophia-Antipolis (France), -// Max-Planck-Institute Saarbruecken (Germany), -// and Tel-Aviv University (Israel). 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) : Sylvain Pion - -// How to enter a point in Geomview. - -#include -#include - -#ifndef CGAL_USE_GEOMVIEW -int main() { - std::cout << "Geomview doesn't work on Windows, so..." << std::endl; - return 0; -} -#else - -#include - -typedef CGAL::Cartesian K; - -int main() -{ - CGAL::Geomview_stream gv(CGAL::Bbox_3(0, 0, 0, 350, 350, 350)); - - std::cout << "Please enter a point, by right-clicking on the pickplane" - << std::endl; - - K::Point_3 p; - gv >> p; - - std::cout << "Here are the coordinates of the selected point : " - << p << std::endl; - - return 0; -} -#endif diff --git a/Geomview/demo/Geomview/kernel.cpp b/Geomview/demo/Geomview/kernel.cpp deleted file mode 100644 index 3b623dd1e5b..00000000000 --- a/Geomview/demo/Geomview/kernel.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) 2000, 2001, 2004 -// Utrecht University (The Netherlands), -// ETH Zurich (Switzerland), -// INRIA Sophia-Antipolis (France), -// Max-Planck-Institute Saarbruecken (Germany), -// and Tel-Aviv University (Israel). 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) : Sylvain Pion - -// Demo program for Geomview_stream with kernel objects. - -#include -#include - -#ifndef CGAL_USE_GEOMVIEW -int main() { - std::cout << "Geomview doesn't work on Windows, so..." << std::endl; - return 0; -} -#else - -#include - -#include -#include - -typedef CGAL::Cartesian K; - -int main() -{ - CGAL::Geomview_stream gv(CGAL::Bbox_3(0, 0, 0, 350, 350, 350)); - - // gv.set_trace(true); - gv.clear(); // remove the pickplane. - - gv << K::Point_2 (200, 100); - gv << CGAL::IO::blue(); - gv << K::Point_3 (200, 100, 100); - gv << CGAL::red(); - gv << K::Segment_2 (K::Point_2(200, 100), - K::Point_2(300, 100)); - gv << CGAL::green(); - gv << K::Segment_3 (K::Point_3(200, 100, 100), - K::Point_3(300, 100, 200)); - gv << CGAL::deep_blue(); - gv << K::Sphere_3 (K::Point_3(100, 100, 100), 1000); - gv << CGAL::violet(); - gv << K::Triangle_2 (K::Point_2(200, 200), - K::Point_2(220, 220), - K::Point_2(180, 220)); - gv << CGAL::orange(); - gv << K::Triangle_3 (K::Point_3(200, 200, 50), - K::Point_3(220, 220, 80), - K::Point_3(180, 220, 100)); - gv << CGAL::purple(); - gv << K::Tetrahedron_3 (K::Point_3(100, 100, 180), - K::Point_3(120, 70, 220), - K::Point_3(100, 100, 220), - K::Point_3(120, 150, 250)); - gv << CGAL::Bbox_2(10, 10, 30, 30); - gv << CGAL::Bbox_3(10, 10, 10, 30, 30, 30); - - gv << CGAL::red(); - gv << K::Ray_2(K::Point_2(205,205), K::Point_2(500,500)); - gv << K::Ray_3(K::Point_3(250,250,250), K::Point_3(500,500,500)); - gv << K::Line_2(K::Point_2(195,195), K::Point_2(500,500)); - gv << K::Line_3(K::Point_3(150,150,150), K::Point_3(500,500,500)); - - gv.look_recenter(); - - std::cout << "Stopping in 1 minute" << std::endl; - sleep(60); - - return 0; -} -#endif diff --git a/Geomview/doc/Geomview/CGAL/IO/Geomview_stream.h b/Geomview/doc/Geomview/CGAL/IO/Geomview_stream.h deleted file mode 100644 index 27f91c6d009..00000000000 --- a/Geomview/doc/Geomview/CGAL/IO/Geomview_stream.h +++ /dev/null @@ -1,428 +0,0 @@ -namespace CGAL { - -/*! - \ingroup PkgGeomviewRef - - An object of the class `Geomview_stream` is a stream in which geometric - objects can be inserted and where geometric objects can be extracted - from. The constructor starts Geomview either on the local either on - a remote machine. - -\cgalHeading{Implementation} - - The constructor forks a process and establishes two pipes between the - processes. The forked process is then overlaid with Geomview. The - file descriptors `stdin` and `stdout` of Geomview are hooked - on the two pipes. - - All insert operators construct expressions in `gcl`, the Geomview - command language, which is a subset of \lisp. These expressions - are sent to Geomview via the pipe. The extract operators notify `interest` - for a certain kind of events. When such an event happens Geomview - sends a description of the event in `gcl` and the extract operator has - to parse this expression. - - In order to implement further insert and extract operators you should - take a look at the implementation and at the Geomview manual. - -*/ -class Geomview_stream { -public: - -/// \name Creation -/// @{ - /*! - Introduces a Geomview stream `gs` with a camera that sees the - bounding box. The command `geomview` must be in the user's `PATH`. - If `machine` and `login` are not `nullptr`, - Geomview is started on the remote machine using `rsh`. - */ - Geomview_stream(const Bbox_3 &bbox - = Bbox_3(0,0,0, 1,1,1), - const char *machine = nullptr, - const char *login = nullptr); -/// @} - - - /*! - [`begin`;`end`) is an iterator range with value type - `Triangle_3`. This method uses the OFF format to draw several triangles - at once, which is much faster than drawing them one by one. - */ - template < class InputIterator > - void draw_triangles(InputIterator begin, InputIterator end); - -/// \name Colors - /// Geomview distinguishes between edge and face colors. The edge color - /// is at the same time the color of vertices. - -/// @{ - /*! - Makes `c` the color of vertices, edges and faces in subsequent IO - operations. - */ - Geomview_stream& operator<<(const Color& c); - - /*! - Changes the background color. Returns the old value. - */ - Color set_bg_color(const Color& c); - - /*! - Changes the vertex color. Returns the old value. - */ - Color set_vertex_color(const Color& c); - - /*! - Changes the edge color. Returns the old value. - */ - Color set_edge_color(const Color& c); - /*! - Changes the face color. Returns the old value. - */ - Color set_face_color(const Color& c); -/// @} - -/// \name Miscellaneous -/// @{ - /*! - Deletes all objects. - */ - void clear(); - - /*! - Creates a pickplane (useful after a clear). - */ - void pickplane(); - /*! - Positions the camera in a way that all objects can be seen. - */ - void look_recenter(); - /*! - Returns the line width. - */ - int get_line_width() const; - /*! - Sets the line width to `w`. Returns the previous value. - */ - int set_line_width(int w); - /*! - Returns the radius of vertices. - */ - double get_vertex_radius() const; - /*! - Sets the radius of vertices to `d`. Returns the previous value. - */ - double set_vertex_radius(double r) const; - /*! - Used to obtain unique identifier names passed to Geomview. On successive - calls with the same `s` value, it will return a string which is `s` - appended with the numbers 0, then 1, then 2... Note that all counters are - reset when `clear`() is called. - */ - string get_new_id(string s); - /*! - Sets wired mode. In wired mode, some structures output only there edges, - not there surfaces. - Returns the previous value. By default, wired mode is off. - */ - bool set_wired(bool b); - /*! - Returns `true` iff wired mode is on. - */ - bool get_wired(); - -/// @} - -/// \name Advanced and Developers Features -/// The following functions are helpful if you develop your own insert -/// and extract functions. The following functions allow to pass a string -/// from Geomview and to read data sent back by Geomview. -/// @{ - /*! - Inserts string `s` into the stream. - */ - Geomview_stream& operator<<(string s); - - /*! - Extracts a string `s` from the stream. - \pre You have to allocate enough memory. - */ - Geomview_stream& operator>>(char* s); - - /*! - Inserts `i` into the stream. Puts whitespace around if the - stream is in \ascii mode. - */ - Geomview_stream& operator<<(int i); - - /*! - Inserts `i` into the stream. Puts whitespace around if the - stream is in \ascii mode. - */ - Geomview_stream& operator<<(unsigned int i); - - /*! - Inserts `i` into the stream. Puts whitespace around if the - stream is in \ascii mode. Currently implemented by converting to int, so it - can be truncated on 64 bit platforms. - */ - Geomview_stream& operator<<(long i); - - /*! - Inserts `i` into the stream. Puts whitespace around if the - stream is in \ascii mode. Currently implemented by converting to unsigned int, - so it can be truncated on 64 bit platforms. - */ - Geomview_stream& operator<<(unsigned long i); - - /*! - Inserts double `d` into the stream. Puts whitespace around if the - stream is in \ascii mode. - */ - Geomview_stream& operator<<(double d); - - /*! - Sets tracing on. The data that are sent to `Geomview` are also - sent to `cerr`. Returns the previous value. By default tracing is - off. - */ - bool set_trace(bool b); - - /*! - Returns `true` iff tracing is on. - */ - bool get_trace(); - - /*! - Sets raw mode. In raw mode, kernel points are output without headers and - footers, just the coordinates (in binary or \ascii mode). This allows the - implementation of the stream functions for other objects to re-use the - code for points internally, by temporary saving the raw mode to true, and - restoring it after. - Returns the previous value. By default, raw mode is off. - */ - bool set_raw(bool b); - - /*! - Returns `true` iff raw mode is on. - */ - bool get_raw(); - - /*! - Sets echo mode. In echo mode, when you select a point in Geomview, the point - is actually sent back to Geomview. - Returns the previous value. By default, echo mode is on. - */ - bool set_echo(bool b); - - /*! - Returns `true` iff echo mode is on. - */ - bool get_echo(); - - /*! - Sets whether we are in binary mode. - */ - bool set_binary_mode(bool b = true); - - /*! - Sets whether we are in \ascii mode. - */ - bool set_ascii_mode(bool b = true); - - /*! - Returns `true` iff `gs` is in binary mode. - */ - bool get_binary_mode(); - - /*! - Returns `true` iff `gs` is in \ascii mode. - */ - bool get_ascii_mode(); - -/// @} - -}; /* end Geomview_stream */ - -/*! - Inserts the point `p` into the stream `gs`. - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream& gs, const Point_2& p); - -/// \addtogroup GeomviewOutput Output Operators for CGAL Kernel Classes -/// \ingroup PkgGeomviewRef -/// The following classes of the \cgal kernel have output -/// operators. 2D objects are embedded in the `xy`-plane. -/// @{ - -/*! - Inserts the point `p` into the stream `gs`. - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream& gs, const Point_3& p); - -/*! - Inserts the segment `s` into the stream `gs`. - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream& gs, const Segment_2& s); - -/*! - Inserts the segment `s` into the stream `gs`. - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream& gs, const Segment_3& s); - -/*! - Inserts the ray `r` into the stream `gs`. - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream& gs, const Ray_2& r); - -/*! - Inserts the ray `r` into the stream `gs`. - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream& gs, const Ray_3& r); - -/*! - Inserts the line `l` into the stream `gs`. - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream& gs, const Line_2& l); - -/*! - Inserts the line `l` into the stream `gs`. - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream& gs, const Line_3& l); - -/*! - Inserts the triangle `t` into the stream `gs`. - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream& gs, const Triangle_2& t); - -/*! - Inserts the triangle `t` into the stream `gs`. - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream& gs, const Triangle_3& t); - -/*! - Inserts the tetrahedron `t` into the stream `gs`. - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream& gs, const Tetrahedron_3& t); - -/*! - Inserts the sphere `s` into the stream `gs`. - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream& gs, const Sphere_3& s); - -/*! - Inserts the bounding box `b` into the stream `gs`. - \relates Geomview_stream -*/ -Geomview_stream& -operator<<(Geomview_stream& gs, const Bbox_2& b); - -/*! - Inserts the bounding box `b` into the stream `gs`. - \relates Geomview_stream -*/ -Geomview_stream& -operator<<(Geomview_stream& gs, const Bbox_3& b); - - -/// @} - -/// \addtogroup GeomviewInput Input Operators for CGAL Kernel Classes -/// \ingroup PkgGeomviewRef -/// An input operator is provided for points. The user has to select -/// a point on the pick plane with the right mouse button. The pick plane -/// can be moved anywhere with the left mouse button, before a point is entered. -/// @{ - -/*! - Extracts the point `p` from the stream `gs`. The point is - echoed by default, and it depends on the stream echo mode status. - \relates Geomview_stream -*/ -template -Geomview_stream& -operator>>(Geomview_stream& gs, Point_3& p); - -/// @} - -/// \addtogroup GeomviewOutputClasses Output Operators for CGAL Basic Library Classes -/// \ingroup PkgGeomviewRef -/// Output operators are provided for polyhedral surfaces, as well as for 3D -/// and 2D triangulations. The latter allow to visualize terrrains if the -/// point type isa 3D point. -/// @{ - -/*! - Inserts the polyhedron `P` into the stream `gs`. - - Include: `CGAL/IO/Polyhedron_geomview_ostream.h` - - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream &G, const Polyhedron_3 &P); - -/*! - - Inserts the 2D triangulation `T` into the stream `gs`. - The actual output depends on whether the stream is in wired mode or not. - Also note that in the case of terrains (when `GT::Point_2` is - `Point_3`), then the 3D terrain is displayed. - - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream &G, const Triangulation_2 &T); - -/*! - Inserts the 3D triangulation `T` into the stream `gs`. - The actual output depends on whether the stream is in wired mode or not. - - \relates Geomview_stream -*/ -template -Geomview_stream& -operator<<(Geomview_stream &G, const Triangulation_3 &T); - -/// @} - -} /* end namespace CGAL */ diff --git a/Geomview/doc/Geomview/Doxyfile.in b/Geomview/doc/Geomview/Doxyfile.in deleted file mode 100644 index 9182bdceb1f..00000000000 --- a/Geomview/doc/Geomview/Doxyfile.in +++ /dev/null @@ -1,5 +0,0 @@ -@INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS} - -PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - Geomview" -EXAMPLE_PATH = ${CGAL_PACKAGE_DIR}/demo - diff --git a/Geomview/doc/Geomview/Geomview.txt b/Geomview/doc/Geomview/Geomview.txt deleted file mode 100644 index bc5c19d97f5..00000000000 --- a/Geomview/doc/Geomview/Geomview.txt +++ /dev/null @@ -1,56 +0,0 @@ - -namespace CGAL { -/*! - -\mainpage User Manual -\anchor Chapter_Geomview -\cgalAutoToc -\authors Andreas Fabri and Sylvain Pion - -\section GeomviewDefinition Definition - -This chapter presents the \cgal interface to Geomview \cgalFootnote{http://www.geomview.org/}, which is a -viewer for three-dimensional objects, originally developed at the Geometry -Center in Minneapolis \cgalFootnote{http://www.geom.uiuc.edu/}. - -Note: The functionality described in this chapter is not available on Windows. - -An object of the class `Geomview_stream` is a stream in which geometric -objects can be inserted and where geometric objects can be extracted -from. The constructor starts Geomview either on the local either on -a remote machine. - -Not all but most classes of the \cgal kernel have output -operators for the `Geomview_stream`. -2D objects are embedded in the `xy`-plane. -Input is only provided for points. -Polyhedron and 2D and 3D triangulations have output -operators for the `Geomview_stream`. - -\section GeomviewImplementation Implementation - -The constructor forks a process and establishes two pipes between the -processes. The forked process is then overlaid with Geomview. The -file descriptors `stdin` and `stdout` of Geomview are hooked -on the two pipes. - -All insert operators construct expressions in `gcl`, the Geomview -command language, which is a subset of \lisp. These expressions -are sent to Geomview via the pipe. The extract operators notify `interest` -for a certain kind of events. When such an event happens Geomview -sends a description of the event in `gcl` and the extract operator has -to parse this expression. - -In order to implement further insert and extract operators you should -take a look at the implementation and at the Geomview manual. - -\section GeomviewExample Example - -The following program ouputs successively a 2D -Delaunay triangulation (projected), a 3D Delaunay, and a terrain -from the set of points. -\cgalExample{Geomview/gv_terrain.cpp} - -*/ -} /* namespace CGAL */ - diff --git a/Geomview/doc/Geomview/PackageDescription.txt b/Geomview/doc/Geomview/PackageDescription.txt deleted file mode 100644 index 0f1d8fbd8de..00000000000 --- a/Geomview/doc/Geomview/PackageDescription.txt +++ /dev/null @@ -1,25 +0,0 @@ -/// \defgroup PkgGeomviewRef Geomview Reference -/*! -\addtogroup PkgGeomviewRef -\todo check generated documentation -\cgalPkgDescriptionBegin{Geomview,PkgGeomview} -\cgalPkgPicture{geomview.png} -\cgalPkgSummaryBegin -\cgalPkgAuthors{Andreas Fabri and Sylvain Pion} -\cgalPkgDesc{This package implements an interface to Geomview, an interactive 3D viewing program, originally developed at the Geometry Center in Minneapolis.} -\cgalPkgManuals{Chapter_Geomview,PkgGeomviewRef} -\cgalPkgSummaryEnd -\cgalPkgShortInfoBegin -\cgalPkgSince{2.0} -\cgalPkgBib{cgal:fp-gv} -\cgalPkgLicense{\ref licensesLGPL "LGPL"} -\cgalPkgShortInfoEnd -\cgalPkgDescriptionEnd - -\cgalClassifedRefPages - -\cgalCRPSection{Classes} -- `CGAL::Geomview_stream` - -*/ - diff --git a/Geomview/doc/Geomview/dependencies b/Geomview/doc/Geomview/dependencies deleted file mode 100644 index c0330a78330..00000000000 --- a/Geomview/doc/Geomview/dependencies +++ /dev/null @@ -1,9 +0,0 @@ -Manual -Kernel_23 -STL_Extension -Algebraic_foundations -Circulator -Stream_support -Triangulation_2 -Triangulation_3 -Polyhedron diff --git a/Geomview/doc/Geomview/examples.txt b/Geomview/doc/Geomview/examples.txt deleted file mode 100644 index 197a8ea5055..00000000000 --- a/Geomview/doc/Geomview/examples.txt +++ /dev/null @@ -1,3 +0,0 @@ -/*! -\example Geomview/gv_terrain.cpp -*/ diff --git a/Geomview/doc/Geomview/fig/geomview.png b/Geomview/doc/Geomview/fig/geomview.png deleted file mode 100644 index b5d98cd4ba2..00000000000 Binary files a/Geomview/doc/Geomview/fig/geomview.png and /dev/null differ diff --git a/Geomview/include/CGAL/IO/Geomview_stream.h b/Geomview/include/CGAL/IO/Geomview_stream.h deleted file mode 100644 index ff7be329017..00000000000 --- a/Geomview/include/CGAL/IO/Geomview_stream.h +++ /dev/null @@ -1,605 +0,0 @@ -// Copyright (c) 1997,1998,1999,2000,2001 -// Utrecht University (The Netherlands), -// ETH Zurich (Switzerland), -// INRIA Sophia-Antipolis (France), -// Max-Planck-Institute Saarbruecken (Germany), -// and Tel-Aviv University (Israel). 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, Sylvain Pion - -#ifndef CGAL_GEOMVIEW_STREAM_H -#define CGAL_GEOMVIEW_STREAM_H - -#include - -#ifdef CGAL_USE_GEOMVIEW - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -namespace CGAL { - -class CGAL_EXPORT Geomview_stream { -public: - Geomview_stream(const Bbox_3 &bbox = Bbox_3(0,0,0, 1,1,1), - const char *machine = nullptr, - const char *login = nullptr); - - bool fail() const { return false; } - bool good() const { return true; } - explicit operator bool() { return true; } - - ~Geomview_stream(); - - void precision(const int p) { prec = p; } - int precision() const { return prec; } - - Geomview_stream &operator<<(const Color &c); - Geomview_stream &operator<<(const std::string & s); - Geomview_stream &operator<<(int i); - Geomview_stream &operator<<(unsigned int i); - Geomview_stream &operator<<(long i); - Geomview_stream &operator<<(unsigned long i); - Geomview_stream &operator<<(double d); - - template < class InputIterator > - void - draw_triangles(InputIterator begin, InputIterator end); - - Geomview_stream &operator>>(char *expr); - - void clear(); - void look_recenter(); - - void set_bg_color(const Color &c); - - Color get_vertex_color() const; - Color get_edge_color() const; - Color get_face_color() const; - - Color set_vertex_color(const Color&); - Color set_edge_color(const Color&); - Color set_face_color(const Color&); - - double vcr() const; - double vcg() const; - double vcb() const; - - double ecr() const; - double ecg() const; - double ecb() const; - - double fcr() const; - double fcg() const; - double fcb() const; - - double get_vertex_radius() const - { - return radius; - } - double set_vertex_radius(double r) - { - std::swap(r, radius); - return r; - } - - int get_line_width() const - { - return line_width; - } - int set_line_width(int w) - { - std::swap(w, line_width); - return w; - } - - bool set_wired(bool b) - { - std::swap(b, wired_flag); - return b; - } - bool get_wired() const - { - return wired_flag; - } - - bool set_echo(bool b) - { - std::swap(b, echo_flag); - return b; - } - bool get_echo() const - { - return echo_flag; - } - - bool set_raw(bool b) - { - std::swap(b, raw_flag); - return b; - } - bool get_raw() const - { - return raw_flag; - } - - bool set_trace(bool b) - { - std::swap(b, trace_flag); - return b; - } - bool get_trace() const - { - return trace_flag; - } - - void trace(const std::string s) const - { - if (get_trace()) - std::cerr << s; - } - void trace(double d) const - { - if (get_trace()) - std::cerr << d << ' '; - } - void trace(int i) const - { - if (get_trace()) - std::cerr << i << ' '; - } - void trace(unsigned int i) const - { - if (get_trace()) - std::cerr << i << ' '; - } - - bool set_binary_mode(bool b = true) - { - std::swap(b, binary_flag); - return b; - } - bool set_ascii_mode(bool b = true) - { - return !set_binary_mode(!b); - } - bool get_binary_mode() const - { - return binary_flag; - } - bool get_ascii_mode() const - { - return !binary_flag; - } - - std::string get_new_id(const std::string & s); - - const Bbox_3 & get_bbox() - { - return bb; - } - - void pickplane() - { - pickplane(get_bbox()); - } - - static char* nth(char* s, int count); - static void parse_point(const char* pickpoint, - double &x, double &y, double &z, double &w); -private: - void setup_geomview(const char *machine, const char *login); - void frame(const Bbox_3 &bbox); - void pickplane(const Bbox_3 &bbox); - - Bbox_3 bb; - Color vertex_color, edge_color, face_color; - bool wired_flag; // decides if we draw surfaces or edges. - bool echo_flag; // decides if we echo the point we get back to Geomview. - bool raw_flag; // decides if we output footers and headers. - bool trace_flag; // makes operator<<() write a trace on cerr. - bool binary_flag; // makes operator<<() write binary format - int line_width; // width of edges - double radius; // radius of vertices - int in, out; // file descriptors for input and output pipes - int pid; // the geomview process identification - int prec; // precision of the (ASCII) stream - std::map id; // used to get a unique ID per type. -}; - -// Factorize code for Point_2 and Point_3. -template < class FT > -void -output_point(Geomview_stream &gv, const FT &x, const FT &y, const FT &z) -{ - bool ascii_bak = true; // the initialization value shuts up the compiler. - if (!gv.get_raw()) { - ascii_bak = gv.set_ascii_mode(); - gv << "(geometry " << gv.get_new_id("P") - << " {appearance {linewidth 5 material {edgecolor " - << gv.vcr() << gv.vcg() << gv.vcb() << "}}{SKEL 1 1 "; - } - - gv << CGAL::to_double(x) << CGAL::to_double(y) << CGAL::to_double(z); - - if (!gv.get_raw()) { - gv << "1 0\n}})"; - gv.set_ascii_mode(ascii_bak); - } -} - -#if defined CGAL_POINT_2_H && \ - !defined CGAL_GV_OUT_POINT_2_H -#define CGAL_GV_OUT_POINT_2_H -template < class R > -Geomview_stream& -operator<<(Geomview_stream &gv, const Point_2 &p) -{ - typename R::FT zero(0); - output_point(gv, p.x(), p.y(), zero); - return gv; -} -#endif - -#if defined CGAL_POINT_3_H && \ - !defined CGAL_GV_OUT_POINT_3_H -#define CGAL_GV_OUT_POINT_3_H -template < class R > -Geomview_stream& -operator<<(Geomview_stream &gv, const Point_3 &p) -{ - output_point(gv, p.x(), p.y(), p.z()); - return gv; -} -#endif - -// The following code is the same for Segment_2 and Segment_3. -template < class Segment > -void -output_segment(Geomview_stream &gv, const Segment &segment) -{ - bool ascii_bak = gv.set_ascii_mode(); - gv << "(geometry " << gv.get_new_id("Seg") - << " {appearance {linewidth " - << gv.get_line_width() << "}{VECT " - << 1 << 2 << 1 // 1 polyline, two vertices, 1 color - << 2 // the first polyline contains 2 vertices - << 1; // and it has 1 color - - // here are start and end points - bool raw_bak = gv.set_raw(true); - gv << segment.source() << segment.target(); - gv.set_raw(raw_bak); - - // and the color of the segment and its opaqueness - gv << gv.ecr() << gv.ecg() << gv.ecb() << 1.0 << "}})"; - gv.set_ascii_mode(ascii_bak); -} - -#if defined CGAL_SEGMENT_2_H && \ - !defined CGAL_GV_OUT_SEGMENT_2_H -#define CGAL_GV_OUT_SEGMENT_2_H -template < class R > -Geomview_stream& -operator<<(Geomview_stream &gv, const Segment_2 &segment) -{ - output_segment(gv, segment); - return gv; -} -#endif - -#if defined CGAL_SEGMENT_3_H && \ - !defined CGAL_GV_OUT_SEGMENT_3_H -#define CGAL_GV_OUT_SEGMENT_3_H -template < class R > -Geomview_stream& -operator<<(Geomview_stream &gv, const Segment_3 &segment) -{ - output_segment(gv, segment); - return gv; -} -#endif - -// The following code is the same for Triangle_2 and Triangle_3. -template < class Triangle > -void -output_triangle(Geomview_stream &gv, const Triangle &triangle) -{ - bool ascii_bak = gv.set_ascii_mode(); - gv << "(geometry " << gv.get_new_id("Tr") - << " {appearance {+edge material {edgecolor " - << gv.ecr() << gv.ecg() << gv.ecb() << " } shading constant}{ "; - gv.set_binary_mode(); - // it's a planar polygon - gv << "OFF BINARY\n" - - // it has 3 vertices, 1 face and 3 edges - << 3 << 1 << 3; - - bool raw_bak = gv.set_raw(true); - for(int i=0; i<3; i++) - gv << triangle[i]; - gv.set_raw(raw_bak); - - // the face - gv << 3 << 0 << 1 << 2 << 4 << gv.fcr() << gv.fcg() << gv.fcb() << 1.0 - << "}})"; - gv.set_ascii_mode(ascii_bak); -} - -// Draws a set of triangles as OFF format (it's faster than one by one). -template < class InputIterator > -void -Geomview_stream::draw_triangles(InputIterator begin, InputIterator end) -{ - typedef typename std::iterator_traits::value_type Triangle; - typedef typename Kernel_traits::Kernel Kernel; - typedef typename Kernel::Point_3 Point; - typedef typename Kernel::Less_xyz_3 Comp; - - // We first copy everything in a vector to only require an InputIterator. - std::vector triangles(begin, end); - typedef typename std::vector::const_iterator Tit; - - // Put the points in a map and a vector. - // The index of a point in the vector is the value associated - // to it in the map. - typedef std::map Point_map; - Point_map point_map(Kernel().less_xyz_3_object()); - std::vector points; - for (Tit i = triangles.begin(); i != triangles.end(); ++i) - for (int j = 0; j < 3; ++j) - if (point_map.insert(typename Point_map::value_type(i->vertex(j), - points.size())).second) - points.push_back(i->vertex(j)); - - bool ascii_bak = get_ascii_mode(); - bool raw_bak = set_raw(true); - - // Header. - set_binary_mode(); - (*this) << "(geometry " << get_new_id("triangles") - << " {appearance {}{ OFF BINARY\n" - << points.size() << triangles.size() << 0; - - // Points coordinates. - std::copy(points.begin(), points.end(), - Ostream_iterator(*this)); - - // Triangles vertices indices. - for (Tit tit = triangles.begin(); tit != triangles.end(); ++tit) { - (*this) << 3; - for (int j = 0; j < 3; ++j) - (*this) << point_map[tit->vertex(j)]; - (*this) << 0; // without color. - } - // Footer. - (*this) << "}})"; - - set_raw(raw_bak); - set_ascii_mode(ascii_bak); -} - -#if defined CGAL_TRIANGLE_2_H && \ - !defined CGAL_GV_OUT_TRIANGLE_2_H -#define CGAL_GV_OUT_TRIANGLE_2_H -template < class R > -Geomview_stream& -operator<<(Geomview_stream &gv, const Triangle_2 &triangle) -{ - output_triangle(gv, triangle); - return gv; -} -#endif - -#if defined CGAL_TRIANGLE_3_H && \ - !defined CGAL_GV_OUT_TRIANGLE_3_H -#define CGAL_GV_OUT_TRIANGLE_3_H -template < class R > -Geomview_stream& -operator<<(Geomview_stream &gv, const Triangle_3 &triangle) -{ - output_triangle(gv, triangle); - return gv; -} -#endif - -#if defined CGAL_TETRAHEDRON_3_H && \ - !defined CGAL_GV_OUT_TETRAHEDRON_3_H -#define CGAL_GV_OUT_TETRAHEDRON_3_H -template < class R > -Geomview_stream& -operator<<(Geomview_stream &gv, const Tetrahedron_3 &t) -{ - bool ascii_bak = gv.set_ascii_mode(); - gv << "(geometry " << gv.get_new_id("Tetra") - << " {appearance {}{ "; - gv.set_binary_mode(); - gv << "OFF BINARY\n" - - // it has 4 vertices, 4 face and 6 edges - << 4 << 4 << 6 ; - - // the vertices - bool raw_bak = gv.set_raw(true); - for(int i=0; i<4; i++) - gv << t[i]; - gv.set_raw(raw_bak); - - // the faces - double r = gv.fcr(), - g = gv.fcg(), - b = gv.fcb(); - gv << 3 << 0 << 1 << 2 << 4 << r << g << b << 1.0 - << 3 << 3 << 0 << 1 << 4 << r << g << b << 1.0 - << 3 << 3 << 1 << 2 << 4 << r << g << b << 1.0 - << 3 << 3 << 0 << 2 << 4 << r << g << b << 1.0 - << "}})"; - gv.set_ascii_mode(ascii_bak); - return gv; -} -#endif - -#if defined CGAL_SPHERE_3_H && \ - !defined CGAL_GV_OUT_SPHERE_3_H -#define CGAL_GV_OUT_SPHERE_3_H -template < class R > -Geomview_stream& -operator<<(Geomview_stream &gv, const Sphere_3 &S) -{ - bool ascii_bak = gv.set_ascii_mode(); - gv << "(geometry " << gv.get_new_id("Sph") - << " {appearance {+edge material {edgecolor " - << gv.ecr() << gv.ecg() << gv.ecb() << "} shading constant}{ " - << "SPHERE\n" - << std::sqrt(CGAL::to_double(S.squared_radius())) << "\n"; - - bool raw_bak = gv.set_raw(true); - gv << Point_3(S.center()) << "}})"; - gv.set_raw(raw_bak); - gv.set_ascii_mode(ascii_bak); - - return gv; -} -#endif - -#if defined CGAL_RAY_2_H && \ - !defined CGAL_GV_OUT_RAY_2_H -#define CGAL_GV_OUT_RAY_2_H -template < class R > -Geomview_stream& -operator<<(Geomview_stream &gv, const Ray_2 &r) -{ - // Note: it won't work if double is not convertible to an RT... - const Bbox_3 & bb = gv.get_bbox(); - Object result = intersection(Iso_rectangle_2( - Point_2(bb.xmin(), bb.ymin()), - Point_2(bb.xmax(), bb.ymax())), r); - Point_2 ipoint; - Segment_2 iseg; - if (assign(ipoint, result)) - gv << ipoint; - else if (assign(iseg, result)) - gv << iseg; - return gv; -} -#endif - -#if defined CGAL_LINE_2_H && \ - !defined CGAL_GV_OUT_LINE_2_H -#define CGAL_GV_OUT_LINE_2_H -template < class R > -Geomview_stream& -operator<<(Geomview_stream &gv, const Line_2 &r) -{ - // Note: it won't work if double is not convertible to an RT... - const Bbox_3 & bb = gv.get_bbox(); - Object result = intersection(Iso_rectangle_2( - Point_2(bb.xmin(), bb.ymin()), - Point_2(bb.xmax(), bb.ymax())), r); - Point_2 ipoint; - Segment_2 iseg; - if (assign(ipoint, result)) - gv << ipoint; - else if (assign(iseg, result)) - gv << iseg; - return gv; -} -#endif - -// Ray and Line drawing should be done by intersecting them with the BBox -// of the Geomview_stream. But for now we take the easy approach. - -#if defined CGAL_RAY_3_H && \ - !defined CGAL_GV_OUT_RAY_3_H -#define CGAL_GV_OUT_RAY_3_H -template < class R > -Geomview_stream& -operator<<(Geomview_stream &gv, const Ray_3 &r) -{ - typename R::Segment_3 s(r.source(), r.point(1)); - gv << s; - return gv; -} -#endif - -#if defined CGAL_LINE_3_H && \ - !defined CGAL_GV_OUT_LINE_3_H -#define CGAL_GV_OUT_LINE_3_H -template < class R > -Geomview_stream& -operator<<(Geomview_stream &gv, const Line_3 &r) -{ - typename R::Segment_3 s(r.point(-1), r.point(1)); - gv << s; - return gv; -} -#endif - -CGAL_EXPORT Geomview_stream& -operator<<(Geomview_stream &gv, const Bbox_2 &bbox); - -CGAL_EXPORT Geomview_stream& -operator<<(Geomview_stream &gv, const Bbox_3 &bbox); - -#if defined CGAL_POINT_3_H && !defined CGAL_GV_IN_POINT_3_H -#define CGAL_GV_IN_POINT_3_H -template < class R > -Geomview_stream& -operator>>(Geomview_stream &gv, Point_3 &point) -{ - const char *gclpick = - "(pick world pickplane * nil nil nil nil nil nil nil)"; - - bool ascii_bak = gv.set_ascii_mode(); - gv << "(pickable pickplane yes) (ui-target pickplane yes)" - << "(interest " << gclpick << ")"; - - char sexpr[1024]; - gv >> sexpr; // this reads a gcl expression - - const char* pickpoint = Geomview_stream::nth(sexpr, 3); - // this gives something as: (0.0607123 0.0607125 4.76837e-07 0.529628) - double x, y, z, w; - Geomview_stream::parse_point(pickpoint, x, y, z, w); - point = Point_3(x, y, z, w); - - // we echo the input - if (gv.get_echo()) - gv << point; - - // we are done and tell geomview to stop sending pick events - gv << "(uninterest " << gclpick << ") (pickable pickplane no)"; - gv.set_ascii_mode(ascii_bak); - - return gv; -} -#endif - -} //namespace CGAL - -#ifdef CGAL_HEADER_ONLY -#include -#endif // CGAL_HEADER_ONLY - -#endif // CGAL_USE_GEOMVIEW - -#endif // CGAL_GEOMVIEW_STREAM_H diff --git a/Geomview/include/CGAL/IO/Geomview_stream_impl.h b/Geomview/include/CGAL/IO/Geomview_stream_impl.h deleted file mode 100644 index 216371cd715..00000000000 --- a/Geomview/include/CGAL/IO/Geomview_stream_impl.h +++ /dev/null @@ -1,607 +0,0 @@ -// Copyright (c) 1999-2004 -// Utrecht University (The Netherlands), -// ETH Zurich (Switzerland), -// INRIA Sophia-Antipolis (France), -// Max-Planck-Institute Saarbruecken (Germany), -// and Tel-Aviv University (Israel). 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, Herve Bronnimann, Sylvain Pion - -#ifdef CGAL_USE_GEOMVIEW - -#ifdef CGAL_HEADER_ONLY -#define CGAL_INLINE_FUNCTION inline -#else -#define CGAL_INLINE_FUNCTION -#endif - -#include -#include -#include -#include -#include -#include - -#include // kill() on SunPro requires these 2 #includes. -#include - -#include - -namespace CGAL { - -CGAL_INLINE_FUNCTION -Geomview_stream::Geomview_stream(const Bbox_3 &bbox, - const char *machine, - const char *login) - : bb(bbox), vertex_color(black()), edge_color(black()), face_color(black()), - wired_flag(false), echo_flag(true), raw_flag(false), - trace_flag(false), binary_flag(false), - line_width(1),prec(6) -{ - setup_geomview(machine, login); - frame(bbox); - pickplane(bbox); - set_vertex_radius((bbox.xmax() - bbox.xmin())/100.0); -} - -CGAL_INLINE_FUNCTION -Geomview_stream::~Geomview_stream() -{ - kill(pid, SIGKILL); // kills geomview -} - -CGAL_INLINE_FUNCTION -void Geomview_stream::setup_geomview(const char *machine, const char *login) -{ - int pipe_out[2], pipe_in[2]; - - // Communication between CGAL and geomview should be possible - // in two directions. To achieve this we open two pipes - - std::cout << "Starting Geomview..." << std::flush; - if (pipe(pipe_out) < 0) { - CGAL_error_msg( "out pipe failed" ); - } - - if (pipe(pipe_in) < 0) { - CGAL_error_msg( "in pipe failed" ); - } - - switch (pid = fork()){ - case -1: - CGAL_error_msg( "fork failed" ); - case 0: // The child process - close(pipe_out[1]); // does not write to the out pipe, - close(pipe_in[0]); // does not read from the in pipe. - - if (dup2(pipe_out[0], 0) != 0) - std::cerr << "Connect pipe to stdin failed." << std::endl; - if (dup2(pipe_in[1], 1) != 1) - std::cerr << "Connect pipe to stdout failed." << std::endl; - - if (machine && (std::strlen(machine)>0)) { - std::string s (" rgeomview "); - s += machine; - s += ":0.0"; - execlp("rsh", "rsh", machine, "-l", login, s.data(), - static_cast(nullptr)); // cast to stop gcc warning - } else { - execlp("geomview", "geomview", "-c", "-", - static_cast(nullptr)); // cast to stop gcc warning - } - - // if we get to this point something went wrong. - std::cerr << "execl geomview failed" << std::endl; - switch(errno) { - case EACCES: - std::cerr << "please check your environment variable PATH" - << std::endl; - std::cerr << "make sure the file `geomview' is contained in it" - << std::endl; - std::cerr << "and is executable" << std::endl; - break; - case ELOOP: - std::cerr << "too many links for filename `geomview'" << std::endl; - break; - default: - std::cerr << "error number " << errno << " (check `man execlp')" - << std::endl; - }; - CGAL_error(); - default: // The parent process - close(pipe_out[0]); // does not read from the out pipe, - close(pipe_in[1]); // does not write to the in pipe. - - in = pipe_in[0]; - out = pipe_out[1]; - - // Necessary to wait a little bit for Geomview, - // otherwise you won't be able to ask for points... - sleep(1); - -#if 1 - // We want to get rid of the requirement in the CGAL doc about - // (echo "started"). But we want to be backward compatible, that is, - // people who have this echo in their .geomview must still have CGAL - // working, at least for a few public releases. - // So the plan is to send, from CGAL, the command : (echo "CGAL-3D") - // It's the same length as "started", 7. - // Then we read 7 chars from Geomview, and test which string it is. - // If it's "CGAL-3D", then fine, the user doesn't have .geomview with - // the back-compatible echo command. - // In the very long run, we'll be able to get rid of all this code as - // well. - // Maybe we should simply read the pipe, till we find "CGAL-3D" ? - - *this << "(echo \"CGAL-3D\")"; - - char inbuf[10]; - std::size_t retread=::read(in, inbuf, 7); - (void)retread; - - if (std::strncmp(inbuf, "started", 7) == 0) - { - // std::cerr << "You still have a .geomview file with the\n" - // << "(echo \"started\") command. Note that this is not\n" - // << "compulsory anymore, since CGAL 2.3" << std::endl; - - // Then the next one is supposed to be CGAL-3D. - retread=::read(in, inbuf, 7); - (void)retread; - if (std::strncmp(inbuf, "CGAL-3D", 7) != 0) - std::cerr << "Unexpected string from Geomview !" << std::endl; - } - else if (std::strncmp(inbuf, "CGAL-3D", 7) == 0) - { - // std::cerr << "Good, you don't have a .geomview file with the\n" - // << "(echo \"started\") command" << std::endl; - } - else - { - std::cerr << "Unexcepted string from Geomview at initialization!\n" - << "Going on nevertheless !" << std::endl; - } -#else - // Old original version - char inbuf[10]; - // Waits for "started" from the .geomview file. - retread=::read(in, inbuf, 7); - (void)retread; -#endif - - std::cout << "done." << std::endl; - - (*this) << "(normalization g* none)(bbox-draw g* no)"; - } -} - -CGAL_INLINE_FUNCTION -void -Geomview_stream::pickplane(const Bbox_3 &bbox) -{ - bool bin_bak = set_binary_mode(); - (*this) << "(geometry pickplane {QUAD BINARY\n" - << 1 - // here are the four corners - << bbox.xmin() << bbox.ymin() << bbox.zmin() - << bbox.xmin() << bbox.ymax() << bbox.zmin() - << bbox.xmax() << bbox.ymax() << bbox.zmin() - << bbox.xmax() << bbox.ymin() << bbox.zmin() - - // close the text bracket - << "}) (pickable pickplane no)"; - IO::set_ascii_mode(bin_bak); -} - -CGAL_INLINE_FUNCTION -void -Geomview_stream::clear() -{ - (*this) << "(delete World)"; - id.clear(); -} - -CGAL_INLINE_FUNCTION -void -Geomview_stream::look_recenter() -{ - (*this) << "(look-recenter World)"; -} - -CGAL_INLINE_FUNCTION -Geomview_stream& -Geomview_stream::operator<<(const std::string & s) -{ - if ((int)s.length() != ::write(out, s.data(), s.length())) { - CGAL_error_msg( "write problem in the pipe while sending data to geomview" ); - } - trace(s); - - return *this; -} - -CGAL_INLINE_FUNCTION -Geomview_stream& -Geomview_stream::operator<<(int i) -{ - // Depending on the mode chosen - if (get_binary_mode()) { - // we write raw binary data to the stream. - int num = i; - I_swap_to_big_endian(num); - std::size_t retwrite=::write(out, (char*)&num, sizeof(num)); - (void)retwrite; - trace(i); - } else { - // transform the int in a character sequence and put whitespace around - std::ostringstream str; - str.precision(prec); - str << i << ' ' << std::ends; - *this << str.str().c_str(); - } - - return *this; -} - -CGAL_INLINE_FUNCTION -Geomview_stream& -Geomview_stream::operator<<(unsigned int i) -{ - // Depending on the mode chosen - if (get_binary_mode()) { - // we write raw binary data to the stream. - unsigned int num = i; - I_swap_to_big_endian(num); - std::size_t retwrite=::write(out, (char*)&num, sizeof(num)); - (void)retwrite; - trace(i); - } else { - // transform the int in a character sequence and put whitespace around - std::ostringstream str; - str.precision(prec); - str << i << ' ' << std::ends; - *this << str.str().c_str(); - } - - return *this; -} - -CGAL_INLINE_FUNCTION -Geomview_stream& -Geomview_stream::operator<<(long i) -{ - return operator<<((int) i); -} - -CGAL_INLINE_FUNCTION -Geomview_stream& -Geomview_stream::operator<<(unsigned long i) -{ - return operator<<((unsigned int) i); -} - -CGAL_INLINE_FUNCTION -Geomview_stream& -Geomview_stream::operator<<(double d) -{ - float f = float(d); - if (get_binary_mode()) { - float num = float(d); - I_swap_to_big_endian(num); - std::size_t retwrite= ::write(out, (char*)&num, sizeof(num)); - (void)retwrite; - trace(f); - } else { - // 'copy' the float in a string and append a blank - std::ostringstream str; - str.precision(prec); - str << f << ' ' << std::ends; - *this << str.str().c_str(); - } - return *this; -} - -CGAL_INLINE_FUNCTION -Geomview_stream& -operator<<(Geomview_stream &gv, const Bbox_2 &bbox) -{ - bool ascii_bak = gv.set_ascii_mode(); - gv << "(geometry " << gv.get_new_id("Bbox") - << " {VECT 1 5 0 5 0 "; - // here are the four corners - - gv << bbox.xmin() << bbox.ymin() << 0.0 - << bbox.xmin() << bbox.ymax() << 0.0 - << bbox.xmax() << bbox.ymax() << 0.0 - << bbox.xmax() << bbox.ymin() << 0.0 - << bbox.xmin() << bbox.ymin() << 0.0; - - // close the text bracket - gv << "})"; - gv.set_ascii_mode(ascii_bak); - - return gv; -} - -CGAL_INLINE_FUNCTION -Geomview_stream& -operator<<(Geomview_stream &gv, const Bbox_3 &bbox) -{ - bool ascii_bak = gv.set_ascii_mode(); - gv << "(geometry " << gv.get_new_id("Bbox") - << " {appearance {material {edgecolor " - << gv.ecr() << gv.ecg() << gv.ecb() << "}}{SKEL 8 4 " - // here are the corners - << bbox.xmin() << bbox.ymin() << bbox.zmin() - << bbox.xmin() << bbox.ymax() << bbox.zmin() - << bbox.xmax() << bbox.ymax() << bbox.zmin() - << bbox.xmax() << bbox.ymin() << bbox.zmin() - << bbox.xmax() << bbox.ymin() << bbox.zmax() - << bbox.xmax() << bbox.ymax() << bbox.zmax() - << bbox.xmin() << bbox.ymax() << bbox.zmax() - << bbox.xmin() << bbox.ymin() << bbox.zmax() - - << "10 0 1 2 3 4 5 6 7 0 3\n" - << "2 1 6\n" - << "2 2 5\n" - << "2 4 7\n" - - // close the text bracket - << "}})"; - gv.set_ascii_mode(ascii_bak); - - return gv; -} - -CGAL_INLINE_FUNCTION -void -Geomview_stream::set_bg_color(const Color &c) -{ - bool ascii_bak = set_ascii_mode(); - *this << "(backcolor \"Camera\" " - << double(c.r())/255.0 - << double(c.g())/255.0 - << double(c.b())/255.0 - << ")"; - set_ascii_mode(ascii_bak); -} - -CGAL_INLINE_FUNCTION -Geomview_stream& -Geomview_stream::operator<<(const Color &c) -{ - vertex_color = edge_color = face_color = c; - return (*this); -} - -CGAL_INLINE_FUNCTION -Color -Geomview_stream::get_vertex_color() const -{ - return vertex_color; -} - -CGAL_INLINE_FUNCTION -Color -Geomview_stream::get_edge_color() const -{ - return edge_color; -} - -CGAL_INLINE_FUNCTION -Color -Geomview_stream::get_face_color() const -{ - return face_color; -} - -CGAL_INLINE_FUNCTION -Color -Geomview_stream::set_vertex_color(const Color &c) -{ - Color old = vertex_color; - vertex_color = c; - return old; -} - -CGAL_INLINE_FUNCTION -Color -Geomview_stream::set_edge_color(const Color &c) -{ - Color old = edge_color; - edge_color = c; - return old; -} - -CGAL_INLINE_FUNCTION -Color -Geomview_stream::set_face_color(const Color &c) -{ - Color old = face_color; - face_color = c; - return old; -} - -CGAL_INLINE_FUNCTION -double -Geomview_stream::vcr() const -{ - return double(vertex_color.r())/255.0; -} - -CGAL_INLINE_FUNCTION -double -Geomview_stream::vcg() const -{ - return double(vertex_color.g())/255.0; -} - -CGAL_INLINE_FUNCTION -double -Geomview_stream::vcb() const -{ - return double(vertex_color.b())/255.0; -} - -CGAL_INLINE_FUNCTION -double -Geomview_stream::ecr() const -{ - return double(edge_color.r())/255.0; -} - -CGAL_INLINE_FUNCTION -double -Geomview_stream::ecg() const -{ - return double(edge_color.g())/255.0; -} - -CGAL_INLINE_FUNCTION -double -Geomview_stream::ecb() const -{ - return double(edge_color.b())/255.0; -} - -CGAL_INLINE_FUNCTION -double -Geomview_stream::fcr() const -{ - return double(face_color.r())/255.0; -} - -CGAL_INLINE_FUNCTION -double -Geomview_stream::fcg() const -{ - return double(face_color.g())/255.0; -} - -CGAL_INLINE_FUNCTION -double -Geomview_stream::fcb() const -{ - return double(face_color.b())/255.0; -} - -CGAL_INLINE_FUNCTION -void -Geomview_stream::frame(const Bbox_3 &bbox) -{ - (*this) << bbox << "(look-recenter g0 c0)"; -} - -CGAL_INLINE_FUNCTION -Geomview_stream& -Geomview_stream::operator>>(char *expr) -{ - // Skip whitespaces - do { - std::size_t retread=::read(in, expr, 1); - (void)retread; - } while (expr[0] != '('); - - int pcount = 1; - int i = 1; - while (1) { - std::size_t retread=::read(in, &expr[i], 1); - (void)retread; - if (expr[i] == ')'){ - pcount--; - } else if (expr[i] == '('){ - pcount++; - } - if (pcount == 0){ - expr[i+1]='\0'; - break; // we encountered a balanced number of parantheses - } - i++; - } - return *this; -} - -// Parse a Lisp expression, return a pointer to the beginning of the -// nth subexpression, and terminate it by '\0'. -// It's either a word terminated by ' ' or ')', or a well parenthesed -// expression, or a quoted "string". -CGAL_INLINE_FUNCTION -char* -Geomview_stream::nth(char* s, int count) -{ - s++; // skip first character (always a parenthesis) - - // Skip "count" words. - for(; count != 0; count--) { - while (*s == ' ') // skip whitespaces - s++; - s++; - while (*s != ' ') // skip a word - s++; - } - while (*s == ' ') // skip whitespaces - s++; - - // Now we have the beginning of the searched sub-expression. - int j = 1; - if (*s == '(') // Case of a well-parenthesed expression. - for (int pcount = 1; pcount != 0;) { - if (s[j] == ')') pcount--; - if (s[j] == '(') pcount++; - j++; - } - else if (*s == '"') { // Case of a quoted "string". - while (s[j] != '"') - j++; - j++; - } - else // Case of a word terminated by ' ' or ')'. - while (s[j] != ' ' && s[j] != ')') - j++; - - s[j] = '\0'; - return s; -} - -CGAL_INLINE_FUNCTION -void -Geomview_stream::parse_point(const char* pickpoint, - double &x, double &y, double &z, double &w) -{ - std::stringstream ss; - ss << pickpoint << std::ends; - - char parenthesis; - ss >> parenthesis >> x >> y >> z >> w; -} - -CGAL_INLINE_FUNCTION -std::string -Geomview_stream::get_new_id(const std::string & s) -{ - std::ostringstream str; - str << s << id[s]++ << std::ends; - return str.str(); -} - -} //namespace CGAL - -#else - -#ifndef CGAL_HEADER_ONLY -// Add a dummy symbol to prevent warnings of empty translation unit. -namespace CGAL { -namespace { -int dummy; -} -} //namespace CGAL -#endif - -#endif // CGAL_USE_GEOMVIEW diff --git a/Geomview/package_info/Geomview/copyright b/Geomview/package_info/Geomview/copyright deleted file mode 100644 index a35c66ade4c..00000000000 --- a/Geomview/package_info/Geomview/copyright +++ /dev/null @@ -1,5 +0,0 @@ -Utrecht University (The Netherlands), -ETH Zurich (Switzerland), -INRIA Sophia-Antipolis (France), -Max-Planck-Institute Saarbruecken (Germany), -Tel-Aviv University (Israel). diff --git a/Geomview/package_info/Geomview/dependencies b/Geomview/package_info/Geomview/dependencies deleted file mode 100644 index 1598b3438f7..00000000000 --- a/Geomview/package_info/Geomview/dependencies +++ /dev/null @@ -1,9 +0,0 @@ -Algebraic_foundations -Installation -Interval_support -Kernel_23 -Modular_arithmetic -Number_types -Profiling_tools -STL_Extension -Stream_support diff --git a/Geomview/package_info/Geomview/description.txt b/Geomview/package_info/Geomview/description.txt deleted file mode 100644 index 96427114051..00000000000 --- a/Geomview/package_info/Geomview/description.txt +++ /dev/null @@ -1 +0,0 @@ -Geomview package: an interface to the Geometry Center's popular 3D viewer diff --git a/Geomview/package_info/Geomview/license.txt b/Geomview/package_info/Geomview/license.txt deleted file mode 100644 index 5c1c5d8436f..00000000000 --- a/Geomview/package_info/Geomview/license.txt +++ /dev/null @@ -1 +0,0 @@ -LGPL (v3 or later) diff --git a/Geomview/package_info/Geomview/maintainer b/Geomview/package_info/Geomview/maintainer deleted file mode 100644 index 7e028c78627..00000000000 --- a/Geomview/package_info/Geomview/maintainer +++ /dev/null @@ -1 +0,0 @@ -cgal-develop diff --git a/Geomview/test/Geomview/CMakeLists.txt b/Geomview/test/Geomview/CMakeLists.txt deleted file mode 100644 index 4f055c0c866..00000000000 --- a/Geomview/test/Geomview/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Created by the script cgal_create_cmake_script -# This is the CMake script for compiling a CGAL application. - -cmake_minimum_required(VERSION 3.1...3.22) -project(Geomview_Tests) - -find_package(CGAL REQUIRED) - -# create a target per cppfile -file( - GLOB cppfiles - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) -foreach(cppfile ${cppfiles}) - create_single_source_cgal_program("${cppfile}") -endforeach() diff --git a/Geomview/test/Geomview/kernel_objects.cpp b/Geomview/test/Geomview/kernel_objects.cpp deleted file mode 100644 index 13adb554f65..00000000000 --- a/Geomview/test/Geomview/kernel_objects.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// Simple test program for Geomview_stream. -// See the demo directory for more extensive use. -// -// Sylvain Pion, 2000. - -#include - -#ifndef CGAL_USE_GEOMVIEW -#include -int main() -{ - std::cout << "Geomview untested on Windows." << std::endl; - return 0; -} -#else - -#include - -#include - -#include - -typedef CGAL::Cartesian K; - -void test_parse_point() -{ - const char *test_point="( 123 456 789 1 )"; - double x, y, z, w; - CGAL::Geomview_stream::parse_point(test_point, x, y, z, w); - K::Point_3 p(x, y, z, w); - assert(p == K::Point_3(123, 456, 789)); -} - -int main() -{ - test_parse_point(); - return 0; -} -#endif diff --git a/GraphicsView/demo/Segment_Delaunay_graph_2/include/CGAL/Constraints_loader.h b/GraphicsView/demo/Segment_Delaunay_graph_2/include/CGAL/Constraints_loader.h index 66899ca4237..2e2968b9679 100644 --- a/GraphicsView/demo/Segment_Delaunay_graph_2/include/CGAL/Constraints_loader.h +++ b/GraphicsView/demo/Segment_Delaunay_graph_2/include/CGAL/Constraints_loader.h @@ -9,7 +9,14 @@ #include #include +#include +#if BOOST_VERSION < 107200 #include +using boost::progress_display; +#else +#include +using boost::timer::progress_display; +#endif namespace CGAL { @@ -118,9 +125,9 @@ class Constraints_loader { std::cerr << " done (" << timer.time() << "s)\n"; std::cerr << "Inserting constraints...\n"; - boost::progress_display show_progress(constraints.size(), - std::cerr, - ""); + progress_display show_progress(constraints.size(), + std::cerr, + ""); timer.reset(); timer.start(); for(typename Constraints_container::const_iterator diff --git a/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/include/CGAL/Constraints_loader.h b/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/include/CGAL/Constraints_loader.h index 66899ca4237..2e2968b9679 100644 --- a/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/include/CGAL/Constraints_loader.h +++ b/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/include/CGAL/Constraints_loader.h @@ -9,7 +9,14 @@ #include #include +#include +#if BOOST_VERSION < 107200 #include +using boost::progress_display; +#else +#include +using boost::timer::progress_display; +#endif namespace CGAL { @@ -118,9 +125,9 @@ class Constraints_loader { std::cerr << " done (" << timer.time() << "s)\n"; std::cerr << "Inserting constraints...\n"; - boost::progress_display show_progress(constraints.size(), - std::cerr, - ""); + progress_display show_progress(constraints.size(), + std::cerr, + ""); timer.reset(); timer.start(); for(typename Constraints_container::const_iterator diff --git a/GraphicsView/include/CGAL/Buffer_for_vao.h b/GraphicsView/include/CGAL/Buffer_for_vao.h index 57c91cb7701..882bf7c98d7 100644 --- a/GraphicsView/include/CGAL/Buffer_for_vao.h +++ b/GraphicsView/include/CGAL/Buffer_for_vao.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -58,7 +59,7 @@ namespace internal ++nb; } - assert(nb>0); + CGAL_assertion(nb>0); return (typename Kernel_traits::Kernel::Construct_scaled_vector_3() (normal, 1.0/nb)); } diff --git a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h index 3bf83132a3a..111b70f0fd3 100644 --- a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h +++ b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h @@ -52,6 +52,7 @@ #include #include #include +#include namespace CGAL { @@ -612,7 +613,7 @@ protected: vao[VAO_MONO_POINTS].bind(); unsigned int bufn = 0; - assert(bufn(arrays[POS_MONO_POINTS].size()*sizeof(float))); @@ -629,7 +630,7 @@ protected: vao[VAO_COLORED_POINTS].bind(); ++bufn; - assert(bufn(arrays[POS_COLORED_POINTS].size()*sizeof(float))); @@ -638,7 +639,7 @@ protected: buffers[bufn].release(); ++bufn; - assert(bufn(arrays[COLOR_POINTS].size()*sizeof(float))); @@ -654,7 +655,7 @@ protected: vao[VAO_MONO_SEGMENTS].bind(); ++bufn; - assert(bufn(arrays[POS_MONO_SEGMENTS].size()*sizeof(float))); @@ -671,7 +672,7 @@ protected: vao[VAO_COLORED_SEGMENTS].bind(); ++bufn; - assert(bufn(arrays[POS_COLORED_SEGMENTS].size()*sizeof(float))); @@ -681,7 +682,7 @@ protected: buffers[bufn].release(); ++bufn; - assert(bufn(arrays[COLOR_SEGMENTS].size()*sizeof(float))); @@ -699,7 +700,7 @@ protected: vao[VAO_MONO_RAYS].bind(); ++bufn; - assert(bufn(arrays[POS_MONO_RAYS].size()*sizeof(float))); @@ -717,7 +718,7 @@ protected: vao[VAO_COLORED_RAYS].bind(); ++bufn; - assert(bufn(arrays[POS_COLORED_RAYS].size()*sizeof(float))); @@ -727,7 +728,7 @@ protected: buffers[bufn].release(); ++bufn; - assert(bufn(arrays[COLOR_RAYS].size()*sizeof(float))); @@ -744,7 +745,7 @@ protected: vao[VAO_MONO_LINES].bind(); ++bufn; - assert(bufn(arrays[POS_MONO_LINES].size()*sizeof(float))); @@ -762,7 +763,7 @@ protected: vao[VAO_COLORED_LINES].bind(); ++bufn; - assert(bufn(arrays[POS_COLORED_LINES].size()*sizeof(float))); @@ -772,7 +773,7 @@ protected: buffers[bufn].release(); ++bufn; - assert(bufn(arrays[COLOR_LINES].size()*sizeof(float))); @@ -792,7 +793,7 @@ protected: // 5.1.1) points of the mono faces ++bufn; - assert(bufn(arrays[POS_MONO_FACES].size()*sizeof(float))); @@ -803,7 +804,7 @@ protected: // 5.1.2) normals of the mono faces ++bufn; - assert(bufn(arrays[POS_COLORED_FACES].size()*sizeof(float))); @@ -842,7 +843,7 @@ protected: // 5.2.2) normals of the color faces ++bufn; - assert(bufn(arrays[COLOR_FACES].size()*sizeof(float))); @@ -886,7 +887,7 @@ protected: vao[VAO_CLIPPING_PLANE].bind(); ++bufn; - assert(bufn < NB_VBO_BUFFERS); + CGAL_assertion(bufn < NB_VBO_BUFFERS); buffers[bufn].bind(); buffers[bufn].allocate(arrays[POS_CLIPPING_PLANE].data(), static_cast(arrays[POS_CLIPPING_PLANE].size() * sizeof(float))); diff --git a/HalfedgeDS/examples/HalfedgeDS/hds_prog_color.cpp b/HalfedgeDS/examples/HalfedgeDS/hds_prog_color.cpp index adcfdc0c5fe..ce64abdac99 100644 --- a/HalfedgeDS/examples/HalfedgeDS/hds_prog_color.cpp +++ b/HalfedgeDS/examples/HalfedgeDS/hds_prog_color.cpp @@ -1,6 +1,7 @@ #include #include #include +#include // A face type with a color member variable. template @@ -30,6 +31,6 @@ int main() { HDS hds; Face_handle f = hds.faces_push_back( Face( CGAL::IO::red())); f->color = CGAL::IO::blue(); - CGAL_assertion( f->color == CGAL::IO::blue()); + assert( f->color == CGAL::IO::blue()); return 0; } diff --git a/HalfedgeDS/examples/HalfedgeDS/hds_prog_compact.cpp b/HalfedgeDS/examples/HalfedgeDS/hds_prog_compact.cpp index 2c6844a496b..dd1f3d6c432 100644 --- a/HalfedgeDS/examples/HalfedgeDS/hds_prog_compact.cpp +++ b/HalfedgeDS/examples/HalfedgeDS/hds_prog_compact.cpp @@ -2,6 +2,7 @@ #include #include #include +#include // Define a new halfedge class. We assume that the Halfedge_handle can // be created from a pointer (e.g. the HalfedgeDS is based here on the @@ -55,15 +56,15 @@ public: (nxt & (~ std::ptrdiff_t(1)))); } void set_opposite( Halfedge_handle h) { - CGAL_precondition(( &* h - 1 == &* HDS::halfedge_handle(this)) || - ( &* h + 1 == &* HDS::halfedge_handle(this))); + assert(( &* h - 1 == &* HDS::halfedge_handle(this)) || + ( &* h + 1 == &* HDS::halfedge_handle(this))); if ( &* h - 1 == &* HDS::halfedge_handle(this)) nxt |= 1; else nxt &= (~ std::ptrdiff_t(1)); } void set_next( Halfedge_handle h) { - CGAL_precondition( ((std::ptrdiff_t)(&*h) & 1) == 0); + assert( ((std::ptrdiff_t)(&*h) & 1) == 0); nxt = ((std::ptrdiff_t)(&*h)) | (nxt & 1); } private: // Support for the Vertex_handle. @@ -99,6 +100,6 @@ int main() { HDS hds(1,2,2); Decorator decorator(hds); decorator.create_loop(); - CGAL_assertion( decorator.is_valid()); + assert( decorator.is_valid()); return 0; } diff --git a/HalfedgeDS/examples/HalfedgeDS/hds_prog_compact2.cpp b/HalfedgeDS/examples/HalfedgeDS/hds_prog_compact2.cpp index ff101610451..1c7e49e928e 100644 --- a/HalfedgeDS/examples/HalfedgeDS/hds_prog_compact2.cpp +++ b/HalfedgeDS/examples/HalfedgeDS/hds_prog_compact2.cpp @@ -2,6 +2,7 @@ #include #include #include +#include // Define a new halfedge class. We assume that the Halfedge_handle can // be created from a pointer (e.g. the HalfedgeDS is based here on the @@ -37,14 +38,14 @@ public: // pointer arithmetic, then convert pointer back to handle again. Halfedge_handle h = HDS::halfedge_handle(this); // proper handle if ( nxt & 1) - return HDS::halfedge_handle( &* h + 1); - return HDS::halfedge_handle( &* h - 1); + return HDS::halfedge_handle( std::next(&*h) ); + return HDS::halfedge_handle( std::prev(&*h)); } Halfedge_const_handle opposite() const { // same as above Halfedge_const_handle h = HDS::halfedge_handle(this); // proper handle if ( nxt & 1) - return HDS::halfedge_handle( &* h + 1); - return HDS::halfedge_handle( &* h - 1); + return HDS::halfedge_handle( std::next(&*h)); + return HDS::halfedge_handle( std::prev(&*h)); } Halfedge_handle next() { return HDS::halfedge_handle((Halfedge*)(nxt & (~ std::ptrdiff_t(1)))); @@ -54,15 +55,15 @@ public: (~ std::ptrdiff_t(1)))); } void set_opposite( Halfedge_handle h) { - CGAL_precondition(( &* h - 1 == &* HDS::halfedge_handle(this)) || - ( &* h + 1 == &* HDS::halfedge_handle(this))); - if ( &* h - 1 == &* HDS::halfedge_handle(this)) + assert(( std::prev(&*h) == &* HDS::halfedge_handle(this)) || + ( std::next(&*h)== &* HDS::halfedge_handle(this))); + if ( std::prev(&*h) == &* HDS::halfedge_handle(this)) nxt |= 1; else nxt &= (~ std::ptrdiff_t(1)); } void set_next( Halfedge_handle h) { - CGAL_precondition( ((std::ptrdiff_t)(&*h) & 1) == 0); + assert( ((std::ptrdiff_t)(&*h) & 1) == 0); nxt = ((std::ptrdiff_t)(&*h)) | (nxt & 1); } private: // Support for the Vertex_handle. @@ -98,6 +99,6 @@ int main() { HDS hds; Decorator decorator(hds); decorator.create_loop(); - CGAL_assertion( decorator.is_valid()); + assert( decorator.is_valid()); return 0; } diff --git a/HalfedgeDS/examples/HalfedgeDS/hds_prog_default.cpp b/HalfedgeDS/examples/HalfedgeDS/hds_prog_default.cpp index 766d8d287ce..3f570bfa960 100644 --- a/HalfedgeDS/examples/HalfedgeDS/hds_prog_default.cpp +++ b/HalfedgeDS/examples/HalfedgeDS/hds_prog_default.cpp @@ -1,5 +1,6 @@ #include #include +#include struct Traits { typedef int Point_2; }; typedef CGAL::HalfedgeDS_default HDS; @@ -9,6 +10,6 @@ int main() { HDS hds; Decorator decorator(hds); decorator.create_loop(); - CGAL_assertion( decorator.is_valid()); + assert( decorator.is_valid()); return 0; } diff --git a/HalfedgeDS/examples/HalfedgeDS/hds_prog_edge_iterator.cpp b/HalfedgeDS/examples/HalfedgeDS/hds_prog_edge_iterator.cpp index 494552136f6..4e0d8fb6a42 100644 --- a/HalfedgeDS/examples/HalfedgeDS/hds_prog_edge_iterator.cpp +++ b/HalfedgeDS/examples/HalfedgeDS/hds_prog_edge_iterator.cpp @@ -1,6 +1,7 @@ #include #include #include +#include struct Traits { typedef int Point_2; }; typedef CGAL::HalfedgeDS_default HDS; @@ -13,10 +14,10 @@ int main() { Decorator decorator(hds); decorator.create_loop(); decorator.create_segment(); - CGAL_assertion( decorator.is_valid()); + assert( decorator.is_valid()); int n = 0; for ( Iterator e = hds.halfedges_begin(); e != hds.halfedges_end(); ++e) ++n; - CGAL_assertion( n == 2); // == 2 edges + assert( n == 2); // == 2 edges return 0; } diff --git a/HalfedgeDS/examples/HalfedgeDS/hds_prog_graph.cpp b/HalfedgeDS/examples/HalfedgeDS/hds_prog_graph.cpp index 32c087268ea..f5e7a26a443 100644 --- a/HalfedgeDS/examples/HalfedgeDS/hds_prog_graph.cpp +++ b/HalfedgeDS/examples/HalfedgeDS/hds_prog_graph.cpp @@ -1,6 +1,7 @@ #include #include #include +#include // no traits needed, argument can be arbitrary dummy. typedef CGAL::HalfedgeDS_default HDS; @@ -10,6 +11,6 @@ int main() { HDS hds; Decorator decorator(hds); decorator.create_loop(); - CGAL_assertion( decorator.is_valid()); + assert( decorator.is_valid()); return 0; } diff --git a/HalfedgeDS/examples/HalfedgeDS/hds_prog_graph2.cpp b/HalfedgeDS/examples/HalfedgeDS/hds_prog_graph2.cpp index e33ec754b24..e042370de9a 100644 --- a/HalfedgeDS/examples/HalfedgeDS/hds_prog_graph2.cpp +++ b/HalfedgeDS/examples/HalfedgeDS/hds_prog_graph2.cpp @@ -1,6 +1,7 @@ #include #include #include +#include // An items type using a halfedge with previous-pointer. struct My_items : public CGAL::HalfedgeDS_min_items { @@ -22,6 +23,6 @@ int main() { HDS hds; Decorator decorator(hds); decorator.create_loop(); - CGAL_assertion( decorator.is_valid()); + assert( decorator.is_valid()); return 0; } diff --git a/HalfedgeDS/examples/HalfedgeDS/hds_prog_halfedge_iterator.cpp b/HalfedgeDS/examples/HalfedgeDS/hds_prog_halfedge_iterator.cpp index f1aea66723c..f81b87be6ee 100644 --- a/HalfedgeDS/examples/HalfedgeDS/hds_prog_halfedge_iterator.cpp +++ b/HalfedgeDS/examples/HalfedgeDS/hds_prog_halfedge_iterator.cpp @@ -1,5 +1,6 @@ #include #include +#include struct Traits { typedef int Point_2; }; typedef CGAL::HalfedgeDS_default HDS; @@ -11,10 +12,10 @@ int main() { Decorator decorator(hds); decorator.create_loop(); decorator.create_segment(); - CGAL_assertion( decorator.is_valid()); + assert( decorator.is_valid()); int n = 0; for ( Iterator i = hds.halfedges_begin(); i != hds.halfedges_end(); ++i ) ++n; - CGAL_assertion( n == 4); // == 2 edges + assert( n == 4); // == 2 edges return 0; } diff --git a/HalfedgeDS/examples/HalfedgeDS/hds_prog_vector.cpp b/HalfedgeDS/examples/HalfedgeDS/hds_prog_vector.cpp index 6e7fab933bb..9843c8199cc 100644 --- a/HalfedgeDS/examples/HalfedgeDS/hds_prog_vector.cpp +++ b/HalfedgeDS/examples/HalfedgeDS/hds_prog_vector.cpp @@ -1,6 +1,7 @@ #include #include #include +#include struct Traits { typedef int Point_2; }; typedef CGAL::HalfedgeDS_vector< Traits, CGAL::HalfedgeDS_items_2> HDS; @@ -10,6 +11,6 @@ int main() { HDS hds(1,2,2); Decorator decorator(hds); decorator.create_loop(); - CGAL_assertion( decorator.is_valid()); + assert( decorator.is_valid()); return 0; } diff --git a/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h b/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h index 9e23682febd..2bb8c41276b 100644 --- a/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h +++ b/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h @@ -15,7 +15,7 @@ #include // include this to avoid a VC15 warning -#include +#include #include #include diff --git a/Hash_map/test/Hash_map/Hash.cpp b/Hash_map/test/Hash_map/Hash.cpp index 11c54cfcb0a..fc12a7571fb 100644 --- a/Hash_map/test/Hash_map/Hash.cpp +++ b/Hash_map/test/Hash_map/Hash.cpp @@ -129,7 +129,7 @@ int main() fct::vertex_descriptor>(A); fct::edge_descriptor>(A); - Kernel::Point_3 p3; + Kernel::Point_3 p3(CGAL::ORIGIN); Polyhedron P; CGAL::make_triangle(p3,p3,p3,P); fct4(P); @@ -155,5 +155,3 @@ int main() return 0; } - - diff --git a/Heat_method_3/examples/Heat_method_3/heat_method_polyhedron.cpp b/Heat_method_3/examples/Heat_method_3/heat_method_polyhedron.cpp index 57888ef1daf..6f9757efbe8 100644 --- a/Heat_method_3/examples/Heat_method_3/heat_method_polyhedron.cpp +++ b/Heat_method_3/examples/Heat_method_3/heat_method_polyhedron.cpp @@ -2,8 +2,7 @@ #include #include -#include - +#include #include #include @@ -23,7 +22,7 @@ int main(int argc, char* argv[]) return 1; } // map for the distance values to the source set - boost::unordered_map vertex_distance; + std::unordered_map vertex_distance; vertex_descriptor source = *(vertices(tm).first); diff --git a/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h b/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h index 5713d0cad39..fd38855d2d5 100644 --- a/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h +++ b/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h @@ -51,12 +51,6 @@ struct Direct struct Intrinsic_Delaunay {}; -namespace internal { - - template - bool has_degenerate_faces(const TriangleMesh& tm, const Traits& traits); -} - namespace internal { template -bool has_degenerate_faces(const TriangleMesh& tm, const Traits& traits) -{ - typedef typename Traits::Point_3 Point; - typedef typename Traits::Vector_3 Vector_3; - typename Traits::Construct_vector_3 - construct_vector = traits.construct_vector_3_object(); - typename Traits::Compute_scalar_product_3 - scalar_product = traits.compute_scalar_product_3_object(); - typename Traits::Construct_cross_product_vector_3 - cross_product = traits.construct_cross_product_vector_3_object(); - - typename boost::property_map< TriangleMesh, boost::vertex_point_t>::const_type - vpm = get(boost::vertex_point, tm); - for (typename boost::graph_traits::face_descriptor f : faces(tm)) - { - const Point p1 = get(vpm, target(halfedge(f, tm), tm)); - const Point p2 = get(vpm, target(next(halfedge(f, tm), tm), tm)); - const Point p3 = get(vpm, target(next(next(halfedge(f, tm), tm), tm), tm)); - Vector_3 v = cross_product(construct_vector(p1, p2), construct_vector(p1, p3)); - if(scalar_product(v, v) == 0.) - return true; - } - return false; -} - template -#include +#include #include #include #include +#include #ifndef DOXYGEN_RUNNING @@ -53,8 +54,31 @@ struct IDT_vertex_distance_property_map; // forward declaration namespace internal { - template - bool has_degenerate_faces(const TriangleMesh& tm, const Traits& traits); +template +bool has_degenerate_faces(const TriangleMesh& tm, const Traits& traits) +{ + typedef typename Traits::Point_3 Point; + typedef typename Traits::Vector_3 Vector_3; + typename Traits::Construct_vector_3 + construct_vector = traits.construct_vector_3_object(); + typename Traits::Compute_scalar_product_3 + scalar_product = traits.compute_scalar_product_3_object(); + typename Traits::Construct_cross_product_vector_3 + cross_product = traits.construct_cross_product_vector_3_object(); + + typename boost::property_map< TriangleMesh, boost::vertex_point_t>::const_type + vpm = get(boost::vertex_point, tm); + for (typename boost::graph_traits::face_descriptor f : faces(tm)) + { + const Point p1 = get(vpm, target(halfedge(f, tm), tm)); + const Point p2 = get(vpm, target(next(halfedge(f, tm), tm), tm)); + const Point p3 = get(vpm, target(next(next(halfedge(f, tm), tm), tm), tm)); + Vector_3 v = cross_product(construct_vector(p1, p2), construct_vector(p1, p3)); + if(scalar_product(v, v) == 0.) + return true; + } + return false; +} } template @@ -462,7 +486,7 @@ private: std::vector mark_edges; public: - boost::unordered_map v2v, vtov; + std::unordered_map v2v, vtov; }; } // namespace Heat_method_3 @@ -612,6 +636,15 @@ vertex(typename boost::graph_traits >:: } +template +typename boost::graph_traits >::halfedge_descriptor +halfedge(typename boost::graph_traits >::vertex_descriptor vd, + const Intrinsic_Delaunay_triangulation_3& /* idt */) +{ + return vd.hd; +} + template typename boost::graph_traits >::halfedge_descriptor diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous_converter.h b/Homogeneous_kernel/include/CGAL/Homogeneous_converter.h index 601d9ac504f..22edf4e3e18 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous_converter.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous_converter.h @@ -28,6 +28,9 @@ #include #include #include +#include + +#include namespace CGAL { @@ -47,13 +50,25 @@ public: using Base::operator(); - Bbox_2 + Origin + operator()(Origin o) const + { + return o; + } + + Null_vector + operator()(Null_vector n) const + { + return n; + } + + const Bbox_2& operator()(const Bbox_2& b) { return b; } - Bbox_3 + const Bbox_3& operator()(const Bbox_3& b) { return b; @@ -62,13 +77,21 @@ public: typename K2::RT operator()(const typename K1::RT &a) const { - return c(a); + return rc(a); } typename K2::FT operator()(const typename K1::FT &a) const { - return c(a); + return fc(a); + } + + template + T + operator()(const T t, + typename std::enable_if::value>::type* = nullptr) const + { + return t; } typename K2::Point_2 diff --git a/Hyperbolic_triangulation_2/include/CGAL/Hyperbolic_triangulation_2/internal/Hyperbolic_Delaunay_triangulation_traits_2_functions.h b/Hyperbolic_triangulation_2/include/CGAL/Hyperbolic_triangulation_2/internal/Hyperbolic_Delaunay_triangulation_traits_2_functions.h index 04e247e7ddb..a0d7e74a3ab 100644 --- a/Hyperbolic_triangulation_2/include/CGAL/Hyperbolic_triangulation_2/internal/Hyperbolic_Delaunay_triangulation_traits_2_functions.h +++ b/Hyperbolic_triangulation_2/include/CGAL/Hyperbolic_triangulation_2/internal/Hyperbolic_Delaunay_triangulation_traits_2_functions.h @@ -17,6 +17,7 @@ #include #include +#include namespace CGAL { @@ -123,7 +124,7 @@ public: Circle_2 circle = _gt.construct_circle_2_object()(center, sq_radius); // uncomment!!! - //assert(circle.has_on_boundary(p) && circle.has_on_boundary(q)); + // CGAL_assertion(circle.has_on_boundary(p) && circle.has_on_boundary(q)); if(_gt.orientation_2_object()(p, q, center) == LEFT_TURN) return Circular_arc_2(circle, p, q); diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 80e19d3e22d..ec7f26d5aeb 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -1,6 +1,38 @@ Release History =============== + +[Release 5.5](https://github.com/CGAL/cgal/releases/tag/v5.5) +----------- + +Release date: June 2022 + +### [dD Spatial Searching](https://doc.cgal.org/5.5/Manual/packages.html#PkgSpatialSearchingD) + +- Added the member function `write_graphviz()` to the class The Kd_tree` that writes the tree in a stream in the [Graphviz](https://graphviz.org/) format. + +### [3D Convex Hulls](https://doc.cgal.org/5.5/Manual/packages.html#PkgConvexHull3) + +- Added an overload of the function `CGAL::convex_hull_3()`, which writes the result in an indexed triangle set. + +### [CGAL and the Boost Graph Library (BGL)](https://doc.cgal.org/5.5/Manual/packages.html#PkgBGL) + +- Added the function [`invert_selection()`](https://doc.cgal.org/5.5/BGL/structCGAL_1_1Face__filtered__graph.html#aa428541ebbdd35f9a6e9a3ffd60178df) in the class [`Face_filtered_graph`](https://doc.cgal.org/5.5/BGL/structCGAL_1_1Face__filtered__graph.html), which toggles the selected status of a graph: selected faces are deselected, and unselected faces are selected. + +### Combinatorial Maps + +- Removed old code deprecated in CGAL 4.9 and 4.10 (global fonctions, and information associated with darts). + +### [Tetrahedral Mesh Generation](https://doc.cgal.org/5.5/Manual/packages.html#PkgMesh3) + +- Added the function + [`remove_isolated_vertices()`](https://doc.cgal.org/5.5/Mesh_3/classCGAL_1_1Mesh__complex__3__in__triangulation__3.html#ace57c4e777da457c6e33b4f6e89949ce) + as a post-processing step for the tetrahedral mesh generation. + +### [2D Polygons](https://doc.cgal.org/5.5/Manual/packages.html#PkgPolygon2) + +- Add vertex, edge, and hole ranges. + [Release 5.4](https://github.com/CGAL/cgal/releases/tag/v5.4) ----------- @@ -17,6 +49,10 @@ Release date: January 2022 is now thread-safe. See changes in `2D and 3D Linear Geometry Kernel` for more details. +- The class `Geomview_stream` and all the dependent features have + been removed from CGAL. Those features were actually no longer + supported since CGAL-5.3 but it was not properly announced. + ### [Shape Regularization](https://doc.cgal.org/5.4/Manual/packages.html#PkgShapeRegularization) (new package) - This package enables to regularize a set of segments and open or closed contours in 2D diff --git a/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h b/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h index 1e4f7bb3ca0..2df627952a3 100644 --- a/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h +++ b/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h @@ -25,13 +25,13 @@ # undef CGAL_USE_GMP #endif -#if defined(__has_include) +#if defined(__has_include) && ( ! defined _MSC_VER || _MSC_VER > 1900) # if CGAL_USE_GMP && ! __has_include() -# pragma CGAL_WARNING( cannot be found. Less efficient number types will be used instead. Define CGAL_NO_GMP=1 if that is on purpose.) +# pragma CGAL_WARNING(" cannot be found. Less efficient number types will be used instead. Define CGAL_NO_GMP=1 if that is on purpose.") # undef CGAL_USE_GMP # undef CGAL_USE_MPFR # elif CGAL_USE_MPFR && ! __has_include() -# pragma CGAL_WARNING( cannot be found and the GMP support in CGAL requires it. Less efficient number types will be used instead. Define CGAL_NO_GMP=1 if that is on purpose.) +# pragma CGAL_WARNING(" cannot be found and the GMP support in CGAL requires it. Less efficient number types will be used instead. Define CGAL_NO_GMP=1 if that is on purpose.") # undef CGAL_USE_GMP # undef CGAL_USE_MPFR # endif // CGAL_USE_MPFR and no diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 2b392b6d8ca..a6348c7d617 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -285,12 +285,6 @@ using std::min; using std::max; #endif -//-------------------------------------------------------------------// -// Is Geomview usable ? -//#if !defined(_MSC_VER) && !defined(__MINGW32__) -//# define CGAL_USE_GEOMVIEW -//#endif - //-------------------------------------------------------------------// // Compilers provide different macros to access the current function name @@ -529,7 +523,7 @@ namespace cpp11{ /// Macro `CGAL_WARNING`. /// Must be used with `#pragma`, this way: /// -/// #pragma CGAL_WARNING(This line should trigger a warning) +/// #pragma CGAL_WARNING("This line should trigger a warning") /// /// @{ #ifdef BOOST_MSVC diff --git a/Installation/include/CGAL/version.h b/Installation/include/CGAL/version.h index fa9576b1852..5283590d252 100644 --- a/Installation/include/CGAL/version.h +++ b/Installation/include/CGAL/version.h @@ -17,12 +17,12 @@ #define CGAL_VERSION_H #ifndef SWIG -#define CGAL_VERSION 5.4-beta2 +#define CGAL_VERSION 5.5-dev #define CGAL_GIT_HASH abcdef #endif -#define CGAL_VERSION_NR 1050400920 +#define CGAL_VERSION_NR 1050500900 #define CGAL_SVN_REVISION 99999 -#define CGAL_RELEASE_DATE 20211215 +#define CGAL_RELEASE_DATE 20220531 #include diff --git a/Installation/lib/cmake/CGAL/CGALConfig.cmake b/Installation/lib/cmake/CGAL/CGALConfig.cmake index 160e3363489..4f3a16b5026 100644 --- a/Installation/lib/cmake/CGAL/CGALConfig.cmake +++ b/Installation/lib/cmake/CGAL/CGALConfig.cmake @@ -83,8 +83,15 @@ if (NOT CGAL_DATA_DIR) if (EXISTS "${CGAL_ROOT}/data") set(CGAL_DATA_DIR "${CGAL_ROOT}/data") else() - message("CGAL_ROOT = ${CGAL_ROOT}") - message(WARNING "CGAL_DATA_DIR cannot be deduced, set the variable CGAL_DATA_DIR to set the default value of CGAL::data_file_path()") + if (EXISTS "${CMAKE_SOURCE_DIR}/../data") + set(CGAL_DATA_DIR "${CMAKE_SOURCE_DIR}/../data") + else() + if (EXISTS "${CMAKE_SOURCE_DIR}/../../data") + set(CGAL_DATA_DIR "${CMAKE_SOURCE_DIR}/../../data") + else() + message(WARNING "CGAL_DATA_DIR cannot be deduced, set the variable CGAL_DATA_DIR to set the default value of CGAL::data_file_path()") + endif() + endif() endif() endif() endif() diff --git a/Installation/lib/cmake/CGAL/CGALConfigVersion.cmake b/Installation/lib/cmake/CGAL/CGALConfigVersion.cmake index c9c4c5f3c11..315ff61ca1a 100644 --- a/Installation/lib/cmake/CGAL/CGALConfigVersion.cmake +++ b/Installation/lib/cmake/CGAL/CGALConfigVersion.cmake @@ -1,8 +1,8 @@ set(CGAL_MAJOR_VERSION 5) -set(CGAL_MINOR_VERSION 4) +set(CGAL_MINOR_VERSION 5) set(CGAL_BUGFIX_VERSION 0) include(${CMAKE_CURRENT_LIST_DIR}/CGALConfigBuildVersion.cmake) -set(CGAL_VERSION_PUBLIC_RELEASE_VERSION "5.4-beta2") +set(CGAL_VERSION_PUBLIC_RELEASE_VERSION "5.5-dev") set(CGAL_VERSION_PUBLIC_RELEASE_NAME "CGAL-${CGAL_VERSION_PUBLIC_RELEASE_VERSION}") if (CGAL_BUGFIX_VERSION AND CGAL_BUGFIX_VERSION GREATER 0) diff --git a/Interpolation/demo/Interpolation/CMakeLists.txt b/Interpolation/demo/Interpolation/CMakeLists.txt deleted file mode 100644 index 296400a3198..00000000000 --- a/Interpolation/demo/Interpolation/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Created by the script cgal_create_cmake_script -# This is the CMake script for compiling a CGAL application. - -cmake_minimum_required(VERSION 3.1...3.20) -project(Interpolation_Demo) - -if(NOT POLICY CMP0070 AND POLICY CMP0053) - # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. - cmake_policy(SET CMP0053 OLD) -endif() - -set_property(DIRECTORY PROPERTY CGAL_NO_TESTING TRUE) - -find_package(CGAL REQUIRED) - -create_single_source_cgal_program("interpolation_2_demo.cpp") -create_single_source_cgal_program("surface_voronoi.cpp") diff --git a/Interpolation/demo/Interpolation/README b/Interpolation/demo/Interpolation/README deleted file mode 100644 index f7cd4e0125f..00000000000 --- a/Interpolation/demo/Interpolation/README +++ /dev/null @@ -1,27 +0,0 @@ -These demos use Geomview -[see the chapter Geomview in the cgal manual - support library: -Geomview 1.8.1 is required. The geomview command must be in the user's $PATH, -otherwise the program will not be able to execute.] - -------- gv_interpolation_2 ------------------------------------------------- -using Geomview - -This demo program dumps the plot of the different interpolation functions -using a very simple data set -shows: the differentiability (or not) at the data points - the closeness to the gradient at the data points - -1) Construction of a Delaunay triangulation of the data points. - -2) Interpolation on a grid using a user chosen interpolation function. - -3) Dumps the plot of the interpolation functions (.off file) - -4) Displays the data points in geomview. --------------------------------------------------------------- - -------- surface_voronoi ----------------------------------------------- -This demo program displays the intersection between the three dimensional -Voronoi diagram of a point cloud issued from a surface (sphere,cylinder -or cube) and the tangent plane of another surface point. --------------------------------------------------------------- diff --git a/Interpolation/demo/Interpolation/interpolation_2_demo.cpp b/Interpolation/demo/Interpolation/interpolation_2_demo.cpp deleted file mode 100644 index 9fd09814a58..00000000000 --- a/Interpolation/demo/Interpolation/interpolation_2_demo.cpp +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright (c) 2003 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) : Julia Floetotto - - -// Geomview doesn't work on M$ at the moment, so we don't compile this -// file. -//********************** -//demo 2D Interpolation over the plane - using 2D natural neighbors -//********************** - -#include - -#ifndef CGAL_USE_GEOMVIEW -#include -int main() -{ - std::cerr << "Geomview doesn't work on this platform" << std::endl; - return 0; -} -#else - -#include -#include -#include -#include -#include - - -#include -#include -#include -#include -#include - -#include -#include - -#include - - -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; - -typedef CGAL::Delaunay_triangulation_2 Dt; -typedef CGAL::Interpolation_traits_2 ITraits; - -typedef K::FT Coord_type; -typedef K::Point_2 Point_2; -typedef K::Vector_2 Vector_2; - -typedef K::Point_3 Point_3; -typedef K::Vector_3 Vector_3; -typedef K::Segment_3 Segment_3; -typedef K::Triangle_3 Triangle_3; - -typedef std::map Point_value_map ; -typedef std::map Point_vector_map; - -typedef std::vector Point_vector_3; -typedef std::vector Point_vector_2; - -typedef std::vector< std::pair< K::Point_2, K::FT > > - Point_coordinate_vector; - - -////////////////////// -// VISU GEOMVIEW -////////////////////// - -template -void visu_points(CGAL::Geomview_stream & gv, const Point_vector & points) -{ - int n = points.size(); - for(int i=0; i -void -visu_graph(CGAL::Geomview_stream & gv, const Point_vector& points, int m) -{ - - //generate list of triangles: - std::vector< Triangle_3 > tr; - tr.reserve(2*(m-1)*(m-1)); - - //indices - for(int i=0; i< m-1;i++) - for(int j=0; j< m-1; j++){ - tr.push_back(Triangle_3(points[i*m + j], - points[j+1 + i*m], - points[(j+1) + (i+1)*m])); - tr.push_back(Triangle_3(points[i*m + j],points[(j+1) + (i+1)*m], - points[j + (i+1)*m])); - } - gv.draw_triangles(tr.begin(), tr.end()); -} - -////////////////////////////////////////////////////////////////////////// -////POINT GENERATION: -void generate_grid_points(Point_vector_2& points, int m, float h) -{ - - //int n = (m+1)*(m+1); - int n = m*m; - points.clear(); - points.reserve(n); - - std::cout <<" generate " <()); - -} - -////////////////////// - -int main(int , char** ) -{ - - //parameters: - int m = 78; - double h = 10; - double g = 2; - Coord_type w(4); - Point_vector_2 sample; - //3D function graph: 2D points + function value in z-direction: - Point_vector_3 sample_3; - - Dt T; - Point_value_map values; - Point_vector_map gradients; - - sample.push_back( Point_2(h,h)); - sample.push_back( Point_2( -h,h)); - sample.push_back( Point_2( h,-h )); - sample.push_back( Point_2( -h,-h)); - sample.push_back( Point_2( 0.0, h/2)); - sample.push_back( Point_2( 0.0,-h/2)); - sample.push_back( Point_2( h/2, 0.0 )); - sample.push_back( Point_2( -h/2, 0.0)); - sample.push_back( Point_2(0.0,0.0)); - - int s = sample.size(); - for(int j=0; j> method; - - - //INTERPOLATION: - Point_coordinate_vector coords; - std::pair interpolation_result; - Coord_type value = 0; // initialization to remove compiler warning - int n = points.size(); - ITraits traits; - - std::cout << "Interpolation at "<, - K::FT, bool> coordinate_result = - CGAL::natural_neighbor_coordinates_2(T, points[i], - std::back_inserter(coords)); - K::FT norm = coordinate_result.second; - //test if the computation was successful - assert(coordinate_result.third && norm>0); - - switch(method){ - case 0: - value = CGAL::linear_interpolation(coords.begin(),coords.end(),norm, - CGAL::Data_access(values)); - break; - case 1: - interpolation_result = CGAL::quadratic_interpolation(coords.begin(),coords.end(), - norm, points[i], - CGAL::Data_access< Point_value_map> - (values), - CGAL::Data_access< Point_vector_map> - (gradients),traits); break; - case 2: - interpolation_result = CGAL::sibson_c1_interpolation(coords.begin(),coords.end(), - norm, points[i], - CGAL::Data_access - (values), - CGAL::Data_access - (gradients), traits); break; - case 3: - interpolation_result = CGAL::sibson_c1_interpolation_square(coords.begin(),coords.end(), - norm, points[i], - CGAL::Data_access - (values), - CGAL::Data_access - (gradients), traits); break; - case 4: - interpolation_result = CGAL::farin_c1_interpolation(coords.begin(),coords.end(), - norm, points[i], - CGAL::Data_access - (values), - CGAL::Data_access - (gradients), traits); break; - - default: std::cout <<"No valid choice of interpolant." << - std::endl; break; - } - if(method==0) - points_3.push_back(Point_3(points[i].x(), points[i].y(),value)); - else if(interpolation_result.second) - points_3.push_back(Point_3(points[i].x(), points[i].y(), - interpolation_result.first)); - else std::cout <<"Interpolation failed"<0){ - std::cout << "The function gradients are displayed by red lines " - <<" in the geomview application." << std::endl; - gv <> ch; - - return 0; -} - -#endif // CGAL_USE_GEOMVIEW diff --git a/Interpolation/demo/Interpolation/surface_voronoi.cpp b/Interpolation/demo/Interpolation/surface_voronoi.cpp deleted file mode 100644 index fbb4dd28581..00000000000 --- a/Interpolation/demo/Interpolation/surface_voronoi.cpp +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright (c) 2003 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) : Julia Floetotto - -#include - -#ifndef CGAL_USE_GEOMVIEW -#include -int main() -{ - std::cerr << "Geomview doesn't work on this platform" << std::endl; - return 0; -} -#else - -#ifdef CGAL_STL_SGI_CC -#define STL_HASH_TABLES -#endif - -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - - -#include -#include - -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; - -typedef CGAL::Voronoi_intersection_2_traits_3 Gt; -typedef CGAL::Regular_triangulation_2 Regular_triangulation; - -typedef Regular_triangulation::Face_iterator Face_iterator; - -typedef K::FT Coord_type; -typedef K::Point_3 Point; -typedef K::Vector_3 Vector; -typedef K::Segment_3 Segment; -typedef K::Point_2 Point_2; -//others -typedef std::vector Point_vector; -typedef std::vector Point_2_vector; - -typedef CGAL::Aff_transformation_3 Transformation; - - -////////////////////// -// VISU GEOMVIEW -////////////////////// -template -void visu_points(CGAL::Geomview_stream & os, const Point_vector & points) -{ - int n = points.size(); - for(int i=0; i g(r); - std::copy_n( g, n, std::back_inserter(points)); - p = Point(0,0, r); - normal = Vector(p - CGAL::ORIGIN); -} - -// on a cylinder -void generate_cylinder_points(const int& n, - const double& r, - const double& height, - Point_vector& points, - //the test point + normal - Point &p, Vector &normal){ - - Point_2_vector points_2; - points_2.reserve(n); - CGAL::Random_points_on_circle_2 g(r); - std::copy_n( g, n , std::back_inserter(points_2)); - CGAL::Random random; - - double h; - for(int i=0; i< n; i++){ - h = random.get_double(0.0,height); - points.push_back(Point(points_2[i].x(),points_2[i].y(),h)); - random.get_double(0.0,height); - } - p = Point(r,0,0.5*height); - normal = Vector(p.x(), p.y(),0); -} - -// on a cube -void generate_cube_points(const int& n, - const double& r, - Point_vector& points, - //the test point + normal - Point &p, Vector &normal){ - - Point_2_vector points_2; - int m=n/6; - points_2.reserve(m); - CGAL::points_on_square_grid_2(r,m,std::back_inserter(points_2), - CGAL::Creator_uniform_2()); - //take the tangent plane to the sphere: - for(int i=0; i < m; i++){ - points.push_back(Point(points_2[i].x(), points_2[i].y(), -r)); - points.push_back(Point(points_2[i].x(), points_2[i].y(), r)); - points.push_back(Point(-r, points_2[i].x(), points_2[i].y())); - points.push_back(Point(r, points_2[i].x(), points_2[i].y())); - points.push_back(Point(points_2[i].x(), -r, points_2[i].y())); - points.push_back(Point(points_2[i].x(), r, points_2[i].y())); - } - p = Point(0,0,r); - normal = Vector(0,0,1); -} - - - -////////////////////// - -int main() -{ - CGAL::Geomview_stream gv(CGAL::Bbox_3(0,0,0, 2, 2, 2)); - gv.set_bg_color(CGAL::IO::Color(0, 200, 200)); - gv.clear(); - - int n=150; - double r = 5.0; - - // Create test point set. Prepare a vector for 100 points. - int d; - std::cout<<"Choose type of surface: 0 -- sphere, 1 -- cylinder," - << "2 -- cube "<< std::endl; - std::cin>> d; - Point_vector points; - points.reserve(n); - //create points - Point p; Vector normal; - switch(d){ - case 0: generate_sphere_points(n,r,points, p, normal); break; - case 1: generate_cylinder_points(n,r, 4*r, points, p, normal); break; - case 2: generate_cube_points(n,r,points, p, normal); break; - } - - - Transformation transform; - std::cout <<"Choose type of affine transformation: 0 -- identity,"<< - " 1 -- rotation, 2 -- translation " << std::endl; - std::cin >> d; - switch(d){ - case 0: transform = Transformation(CGAL::IDENTITY); - break; - case 1: - transform = Transformation(Coord_type(1),Coord_type(0),Coord_type(0), - Coord_type(0), - Coord_type(0),Coord_type(0.9063), - Coord_type(-0.42261826),Coord_type(0), - Coord_type(0),Coord_type(0.42261826), - Coord_type(0.9063),Coord_type(0)); - break; - case 2: - transform = Transformation(CGAL::TRANSLATION, Vector(2,3,-1)); - break; - } - //apply affine transformation to points - Point_vector pts; - std::transform( points.begin(),points.end(), std::back_inserter(pts), - transform); - points=pts; - p= transform(p); - normal =transform(normal); - - //define the triangulation: - Gt traits = Gt(p,normal); - Regular_triangulation T(traits); - - //insert the points: - Gt::Construct_weighted_point_2 p2wp = traits.construct_weighted_point_2_object(); - - Point_vector::const_iterator pvit = points.begin(), pvend = points.end(); - for(; pvit!=pvend; ++pvit){ - T.insert(p2wp(*pvit++)); - } - - char ch; - gv << CGAL::violet(); - visu_points(gv,points); - - gv << CGAL::IO::red() << Segment(p, p+ 0.3*normal); - gv << CGAL::IO::orange() <> ch; - - return 1; -} - -#endif // CGAL_USE_GEOMVIEW diff --git a/Intersections_2/include/CGAL/Intersections_2/Segment_2_Segment_2.h b/Intersections_2/include/CGAL/Intersections_2/Segment_2_Segment_2.h index d912b2faf30..19d1b300232 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Segment_2_Segment_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Segment_2_Segment_2.h @@ -34,6 +34,22 @@ namespace Intersections { namespace internal { +// indices of lexicographically smallest endpoints +// depending on config parameter of S2S2_inter_info. +// {s1_id0,s1_id1,s2_id0,s2_id1} +constexpr int s2s2_id[8][4] = +{ +// seg1 seg2 + { 0,1, 0,1 }, + { 0,1, 1,0 }, + { 1,0, 0,1 }, + { 1,0, 1,0 }, + { 0,1, 0,1 }, + { 1,0, 0,1 }, + { 0,1, 1,0 }, + { 1,0, 1,0 } +}; + // struct used to report the combinaric of the intersection // of 2 2D segments. // More information could be gathered if exposed in do_intersect. @@ -43,9 +59,20 @@ struct S2S2_inter_info bool inter = false; bool dim = 0; std::array pt_ids = {-1,-1}; + // integer in [0,7] indicating segment endpoint ordering for determinism + // 0: p0 < p1 - p2 < p3 - p0 < p2 + // 1: p0 < p1 - p3 < p2 - p0 < p3 + // 2: p1 < p0 - p2 < p3 - p1 < p2 + // 3: p1 < p0 - p3 < p2 - p1 < p3 + // 4: p2 < p3 - p0 < p1 - p2 < p0 + // 5: p2 < p3 - p1 < p0 - p2 < p1 + // 6: p3 < p2 - p0 < p1 - p3 < p0 + // 7: p3 < p2 - p1 < p0 - p3 < p1 + int config; - S2S2_inter_info(bool inter) + S2S2_inter_info(bool inter, int c=-1) : inter(inter) + , config(c) {} // intersection is an input endpoint @@ -77,7 +104,7 @@ seg_seg_do_intersect_crossing( const typename K::Point_2& p1, const typename K::Point_2& p2, const typename K::Point_2& p3, const typename K::Point_2& p4, int /* i1 */, int i2, int i3, int /* i4 */, - const K& k, bool extra_test) + const K& k, bool extra_test, int config) { switch (make_certain(k.orientation_2_object()(p1,p2,p3))) { case LEFT_TURN: @@ -89,7 +116,7 @@ seg_seg_do_intersect_crossing( case RIGHT_TURN: return S2S2_inter_info(false); case LEFT_TURN: - return S2S2_inter_info(true); + return S2S2_inter_info(true, config); default: CGAL_unreachable(); } @@ -101,7 +128,7 @@ seg_seg_do_intersect_crossing( case COLLINEAR: return S2S2_inter_info(i2); case RIGHT_TURN: - return S2S2_inter_info(true); + return S2S2_inter_info(true, config); case LEFT_TURN: return S2S2_inter_info(false); default: @@ -127,7 +154,7 @@ seg_seg_do_intersect_crossing( const typename K::Point_2& p3, const typename K::Point_2& p4, const K& k) { - return seg_seg_do_intersect_crossing(p1,p2,p3,p4,0,0,0,0,k,false).inter; + return seg_seg_do_intersect_crossing(p1,p2,p3,p4,0,0,0,0,k,false,-1).inter; } @@ -138,7 +165,7 @@ seg_seg_do_intersect_contained( const typename K::Point_2& p1, const typename K::Point_2& p2, const typename K::Point_2& p3, const typename K::Point_2& p4, int /* i1 */, int /* i2 */, int i3, int i4, - const K& k, bool extra_test) + const K& k, bool extra_test, int config) { switch (make_certain(k.orientation_2_object()(p1,p2,p3))) { case LEFT_TURN: @@ -148,7 +175,7 @@ seg_seg_do_intersect_contained( case COLLINEAR: return S2S2_inter_info(i4); case RIGHT_TURN: - return S2S2_inter_info(true); + return S2S2_inter_info(true, config); case LEFT_TURN: return S2S2_inter_info(false); default: @@ -164,7 +191,7 @@ seg_seg_do_intersect_contained( case RIGHT_TURN: return S2S2_inter_info(false); case LEFT_TURN: - return S2S2_inter_info(true); + return S2S2_inter_info(true, config); default: CGAL_unreachable(); } @@ -188,7 +215,7 @@ seg_seg_do_intersect_contained( const typename K::Point_2& p3, const typename K::Point_2& p4, const K& k) { - return seg_seg_do_intersect_contained(p1,p2,p3,p4,0,0,0,0,k,false).inter; + return seg_seg_do_intersect_contained(p1,p2,p3,p4,0,0,0,0,k,false,-1).inter; } template @@ -229,14 +256,14 @@ do_intersect_with_info(const typename K::Segment_2 &seg1, case LARGER: switch(make_certain(compare_xy(A2,B2))) { case SMALLER: - return seg_seg_do_intersect_crossing(A1,A2,B1,B2, A1_id,A2_id,B1_id+2,B2_id+2, k, extra_test); + return seg_seg_do_intersect_crossing(A1,A2,B1,B2, A1_id,A2_id,B1_id+2,B2_id+2, k, extra_test, (seg1_is_left_to_right ? 0:2) + (seg2_is_left_to_right ? 0:1) ); case EQUAL: // A1 < B1 < B2 = A1 if (extra_test && k.collinear_2_object()(A1, A2, B1)) return S2S2_inter_info(B1_id+2, B2_id+2); // DI_MORE_INFO_TAG: A2==B2 but only B2 is reported return S2S2_inter_info(A2_id); // DI_MORE_INFO_TAG: A2==B2 but only A2 is reported case LARGER: - return seg_seg_do_intersect_contained(A1,A2,B1,B2, A1_id,A2_id,B1_id+2,B2_id+2, k, extra_test); + return seg_seg_do_intersect_contained(A1,A2,B1,B2, A1_id,A2_id,B1_id+2,B2_id+2, k, extra_test, (seg1_is_left_to_right ? 0:2) + (seg2_is_left_to_right ? 0:1)); default: CGAL_unreachable(); } @@ -275,14 +302,14 @@ do_intersect_with_info(const typename K::Segment_2 &seg1, case LARGER: switch(make_certain(compare_xy(B2,A2))) { case SMALLER: - return seg_seg_do_intersect_crossing(B1,B2,A1,A2, B1_id+2,B2_id+2,A1_id,A2_id, k, extra_test); + return seg_seg_do_intersect_crossing(B1,B2,A1,A2, B1_id+2,B2_id+2,A1_id,A2_id, k, extra_test, 4 + (seg1_is_left_to_right ? 0:1) + (seg2_is_left_to_right ? 0:2)); case EQUAL: // B1 < A1 < A2 = B2 if (extra_test && k.collinear_2_object()(B1, A1, B2)) return S2S2_inter_info(A1_id, A2_id); // DI_MORE_INFO_TAG: A2==B2 but only A2 is reported return S2S2_inter_info(A2_id); // DI_MORE_INFO_TAG: A2==B2 but only A2 is reported case LARGER: - return seg_seg_do_intersect_contained(B1,B2,A1,A2, B1_id+2,B2_id+2,A1_id,A2_id, k, extra_test); + return seg_seg_do_intersect_contained(B1,B2,A1,A2, B1_id+2,B2_id+2,A1_id,A2_id, k, extra_test, 4 + (seg1_is_left_to_right ? 0:1) + (seg2_is_left_to_right ? 0:2)); default: CGAL_unreachable(); } @@ -366,15 +393,22 @@ Segment_2_Segment_2_pair::intersection_type() const } // segments intersect in their interiors - typename K::FT s1_dx = _seg1->point(0).x() - _seg1->point(1).x(), - s1_dy = _seg1->point(0).y() - _seg1->point(1).y(), - s2_dx = _seg2->point(1).x() - _seg2->point(0).x(), - s2_dy = _seg2->point(1).y() - _seg2->point(0).y(), - lx = _seg2->point(1).x() - _seg1->point(1).x(), - ly = _seg2->point(1).y() - _seg1->point(1).y(); + int c = inter_info.config; + std::array pts = c < 4 + ? CGAL::make_array( _seg1->point(s2s2_id[c][0]), _seg1->point(s2s2_id[c][1]), + _seg2->point(s2s2_id[c][2]), _seg2->point(s2s2_id[c][3]) ) + : CGAL::make_array( _seg2->point(s2s2_id[c][2]), _seg2->point(s2s2_id[c][3]), + _seg1->point(s2s2_id[c][0]), _seg1->point(s2s2_id[c][1]) ); + + typename K::FT s1_dx = pts[0].x() - pts[1].x(), + s1_dy = pts[0].y() - pts[1].y(), + s2_dx = pts[3].x() - pts[2].x(), + s2_dy = pts[3].y() - pts[2].y(), + lx = pts[3].x() - pts[1].x(), + ly = pts[3].y() - pts[1].y(); typename K::FT alpha = (lx*s2_dy-ly*s2_dx)/(s1_dx*s2_dy-s1_dy*s2_dx); - _intersection_point = K().construct_barycenter_2_object()(_seg1->point(0), alpha, _seg1->point(1)); + _intersection_point = K().construct_barycenter_2_object()(pts[0], alpha, pts[1]); return _result; } diff --git a/Intersections_2/test/Intersections_2/test_intersections_2.cpp b/Intersections_2/test/Intersections_2/test_intersections_2.cpp index 40c55d26c66..434123fcdd2 100644 --- a/Intersections_2/test/Intersections_2/test_intersections_2.cpp +++ b/Intersections_2/test/Intersections_2/test_intersections_2.cpp @@ -481,6 +481,27 @@ struct Test check_intersection (S(p( -1,-1), p( -2,-2)), S(p(-2,-2), p(-1,-1)), S(p(-2,-2),p(-1,-1))); check_intersection (S(p( -2,-2), p( -1,-1)), S(p(-1,-1), p(-2,-2)), S(p(-2,-2),p(-1,-1))); check_intersection (S(p( -2,-2), p( -1,-1)), S(p(-2,-2), p(-1,-1)), S(p(-2,-2),p(-1,-1))); + + //check determinism of crossing point + P p1a(-122.37323046264295, 37.7435274415764); + P p1b(-122.3711959178425, 37.74348027376899); + P p2a(-122.37130249711004, 37.74203327688176); + P p2b(-122.3722247426892, 37.74401427059434); + std::set ds; + auto test = [&ds](S s1, S s2) + { + P i = boost::get

    (*CGAL::intersection(s1,s2)); + ds.insert(CGAL::to_double(i.x())); ds.insert(CGAL::to_double(i.y())); + assert(ds.size()==2); + }; + test(S(p1a,p1b), S(p2a,p2b)); + test(S(p1a,p1b), S(p2b,p2a)); + test(S(p1b,p1a), S(p2b,p2a)); + test(S(p1b,p1a), S(p2a,p2b)); + test(S(p2a,p2b), S(p1a,p1b)); + test(S(p2b,p2a), S(p1a,p1b)); + test(S(p2b,p2a), S(p1b,p1a)); + test(S(p2a,p2b), S(p1b,p1a)); } void R_R() diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Line_3_do_intersect.h b/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Line_3_do_intersect.h index 1caea8e0919..6062ba6085a 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Line_3_do_intersect.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Line_3_do_intersect.h @@ -63,7 +63,7 @@ bbox_line_do_intersect_aux(const LFT px, const LFT py, const LFT pz, } //if px is not in the x-slab - if(dmin == FT(0) && (tmin > FT(0) || tmax < FT(0))) + if(is_zero(dmin) && (is_positive(tmin) || is_negative(tmax))) return false; FT dmax = dmin; diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Segment_3_do_intersect.h b/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Segment_3_do_intersect.h index 1c27d3c530b..8819bdaa651 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Segment_3_do_intersect.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Segment_3_do_intersect.h @@ -157,13 +157,14 @@ do_intersect_bbox_segment_aux(const FT& px, const FT& py, const FT& pz, // ----------------------------------- // treat x coord // ----------------------------------- - typedef typename Coercion_traits::Type CFT; + typedef typename Coercion_traits::Type CFT; + typename Coercion_traits::Cast to_CFT; CFT dmin, tmin, tmax, dmax; if(qx >= px) { - if(bounded_0 && px > bxmax) + if(bounded_0 && compare(px, bxmax) == LARGER) return false; // segment on the right of bbox - if(bounded_1 && qx < bxmin) + if(bounded_1 && compare(qx, bxmin) == SMALLER) return false; // segment on the left of bbox if(bounded_1 && bxmax > qx) @@ -173,32 +174,32 @@ do_intersect_bbox_segment_aux(const FT& px, const FT& py, const FT& pz, } else { - tmax = bxmax - px; + tmax = to_CFT(bxmax) - px; dmax = qx - px; } - tmin = bxmin - px; + tmin = CFT(bxmin) - px; dmin = qx - px; } else { - if(bounded_1 && qx > bxmax) + if(bounded_1 && compare(qx, bxmax) == LARGER) return false; // segment on the right of bbox - if(bounded_0 && px < bxmin) + if(bounded_0 && compare(px, bxmin) == SMALLER) return false; // segment on the left of bbox - if(bounded_1 && bxmin < qx) + if(bounded_1 && compare(bxmin, qx) == SMALLER) { tmax = 1; dmax = 1; } else { - tmax = px - bxmin; + tmax = px - to_CFT(bxmin); dmax = px - qx; } - tmin = px - bxmax; + tmin = px - to_CFT(bxmax); dmin = px - qx; } @@ -210,7 +211,7 @@ do_intersect_bbox_segment_aux(const FT& px, const FT& py, const FT& pz, if((px == qx) && // <=> (dmin == 0) (!(bounded_0 && bounded_1))) // do not check for a segment { - if(px > bxmax || px < bxmin) + if(compare(px, bxmax) == LARGER || compare(px, bxmin) == SMALLER) return false; // Note: for a segment the condition has already been tested by the two @@ -221,11 +222,11 @@ do_intersect_bbox_segment_aux(const FT& px, const FT& py, const FT& pz, // is a NaN. But the case with NaNs is treated as if the interval // [t1, t2] was ]-inf, +inf[. - CGAL_assertion(dmin >= 0); - CGAL_assertion(dmax >= 0); + CGAL_assertion(! is_negative(dmin)); + CGAL_assertion(! is_negative(dmax)); if(bounded_0) { - CGAL_assertion(tmin >= 0); - CGAL_assertion(tmax >= 0); + CGAL_assertion(! is_negative(tmin)); + CGAL_assertion(! is_negative(tmax)); } // ----------------------------------- @@ -234,44 +235,44 @@ do_intersect_bbox_segment_aux(const FT& px, const FT& py, const FT& pz, CFT dymin, tymin, tymax, dymax; if(qy >= py) { - if(bounded_0 && py > bymax) + if(bounded_0 && compare(py, bymax) == LARGER) return false; // segment on the right of bbox - if(bounded_1 && qy < bymin) + if(bounded_1 && compare(qy, bymin) == SMALLER) return false; // segment on the left of bbox - if(bounded_1 && bymax > qy) + if(bounded_1 && compare(bymax, qy) == LARGER) { tymax = 1; dymax = 1; } else { - tymax = bymax - py; + tymax = to_CFT(bymax) - py; dymax = qy - py; } - tymin = bymin - py; + tymin = to_CFT(bymin) - py; dymin = qy - py; } else { - if(bounded_1 && qy > bymax) + if(bounded_1 && compare(qy, bymax) == LARGER) return false; // segment on the right of bbox - if(bounded_0 && py < bymin) + if(bounded_0 && compare(py, bymin) == SMALLER) return false; // segment on the left of bbox - if(bounded_1 && bymin < qy) + if(bounded_1 && compare(bymin, qy) == SMALLER) { tymax = 1; dymax = 1; } else { - tymax = py - bymin; + tymax = py - to_CFT(bymin); dymax = py - qy; } - tymin = py - bymax; + tymin = py - CFT(bymax); dymin = py - qy; } @@ -283,7 +284,7 @@ do_intersect_bbox_segment_aux(const FT& px, const FT& py, const FT& pz, if((py == qy) && // <=> (dmin == 0) (! (bounded_0 && bounded_1))) // do not check for a segment { - if(py > bymax || py < bymin) + if(py > to_CFT(bymax) || compare(py, bymin) == SMALLER) return false; } @@ -291,12 +292,12 @@ do_intersect_bbox_segment_aux(const FT& px, const FT& py, const FT& pz, // is a NaN. But the case with NaNs is treated as if the interval // [t1, t2] was ]-inf, +inf[. - CGAL_assertion(dymin >= 0); - CGAL_assertion(dymax >= 0); + CGAL_assertion(! is_negative(dymin)); + CGAL_assertion(! is_negative(dymax)); if(bounded_0) { - CGAL_assertion(tymin >= 0); - CGAL_assertion(tymax >= 0); + CGAL_assertion(! is_negative(tymin)); + CGAL_assertion(! is_negative(tymax)); } // ----------------------------------- @@ -305,44 +306,44 @@ do_intersect_bbox_segment_aux(const FT& px, const FT& py, const FT& pz, CFT dzmin, tzmin, tzmax, dzmax; if(qz >= pz) { - if(bounded_0 && pz > bzmax) + if(bounded_0 && compare(pz, bzmax)== LARGER) return false; // segment on the right of bbox - if(bounded_1 && qz < bzmin) + if(bounded_1 && compare(qz, bzmin) == SMALLER) return false; // segment on the left of bbox - if(bounded_1 && bzmax > qz) + if(bounded_1 && compare(bzmax, qz) == LARGER) { tzmax = 1; dzmax = 1; } else { - tzmax = bzmax - pz; + tzmax = to_CFT(bzmax) - pz; dzmax = qz - pz; } - tzmin = bzmin - pz; + tzmin = to_CFT(bzmin) - pz; dzmin = qz - pz; } else { - if(bounded_1 && qz > bzmax) + if(bounded_1 && compare(qz, bzmax) == LARGER) return false; // segment on the right of bbox - if(bounded_0 && pz < bzmin) - return false; // segment on the left of bbox + if(bounded_0 && compare(pz, bzmin) == SMALLER) + return false; // segment on the left of bbox - if(bounded_1 && bzmin < qz) + if(bounded_1 && compare(bzmin, qz) == SMALLER) { tzmax = 1; dzmax = 1; } else { - tzmax = pz - bzmin; + tzmax = pz - to_CFT(bzmin); dzmax = pz - qz; } - tzmin = pz - bzmax; + tzmin = pz - to_CFT(bzmax); dzmin = pz - qz; } @@ -354,7 +355,7 @@ do_intersect_bbox_segment_aux(const FT& px, const FT& py, const FT& pz, if((pz == qz) && // <=> (dmin == 0) (! (bounded_0 && bounded_1))) // do not check for a segment { - if(pz > bzmax || pz < bzmin) + if(compare(pz, bzmax) == LARGER || compare(pz, bzmin) == SMALLER) return false; } @@ -362,12 +363,12 @@ do_intersect_bbox_segment_aux(const FT& px, const FT& py, const FT& pz, // is a NaN. But the case with NaNs is treated as if the interval // [t1, t2] was ]-inf, +inf[. - CGAL_assertion(dzmin >= 0); - CGAL_assertion(dzmax >= 0); + CGAL_assertion(! is_negative(dzmin)); + CGAL_assertion(! is_negative(dzmax)); if(bounded_0) { - CGAL_assertion(tzmin >= 0); - CGAL_assertion(tzmax >= 0); + CGAL_assertion(! is_negative(tzmin)); + CGAL_assertion(! is_negative(tzmax)); } typedef Do_intersect_bbox_segment_aux_is_greater Is_greater; @@ -421,8 +422,8 @@ do_intersect_bbox_segment_aux(const FT& px, const FT& py, const FT& pz, if(is_indeterminate(b)) return b; - CGAL_assertion(dmin >= 0); - CGAL_assertion(dmax >= 0); + CGAL_assertion(! is_negative(dmin)); + CGAL_assertion(! is_negative(dmax)); // If t1 > tzmax || tzmin > t2, return false. if((px != qx || py != qy) && diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Plane_3_intersection.h b/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Plane_3_intersection.h index 1f544221ad7..b052243ff0c 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Plane_3_intersection.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Plane_3_intersection.h @@ -62,7 +62,7 @@ intersection(const typename K::Iso_cuboid_3& cub, } }; // description of faces of the bbox - constexpr std::array face_indices + static constexpr std::array face_indices { { 0, 1, 2, 3, 2, 1, 5, 6, 3, 2, 6, 7, @@ -70,7 +70,7 @@ intersection(const typename K::Iso_cuboid_3& cub, 4, 0, 3, 7, 6, 5, 4, 7 } }; - constexpr std::array edge_indices + static constexpr std::array edge_indices { { 0, 1, 2, 3, 1, 4, 5, 6, 2, 6, 7, 8, diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Sphere_3_do_intersect.h b/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Sphere_3_do_intersect.h index dbf67d10b8c..f6090ba7cbf 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Sphere_3_do_intersect.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Sphere_3_do_intersect.h @@ -28,7 +28,7 @@ bool do_intersect_sphere_box_3(const typename K::Sphere_3& sphere, const K&) { typedef typename K::FT SFT; - typedef typename Coercion_traits::Type FT; + typedef typename Coercion_traits::Type FT; typedef typename K::Point_3 Point; typename Coercion_traits::Cast to_FT; diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/Plane_3_Tetrahedron_3_intersection.h b/Intersections_3/include/CGAL/Intersections_3/internal/Plane_3_Tetrahedron_3_intersection.h index bd7b49193f3..37e092956d7 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/Plane_3_Tetrahedron_3_intersection.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/Plane_3_Tetrahedron_3_intersection.h @@ -52,13 +52,13 @@ intersection(const typename K::Tetrahedron_3& tet, } }; // description of faces of the bbox - constexpr std::array face_indices + static constexpr std::array face_indices { { 0, 1, 2, 0, 1, 3, 1, 2, 3, 2, 0, 3 } }; - constexpr std::array edge_indices + static constexpr std::array edge_indices { { 0, 1, 2, 0, 3, 5, 1, 4, 3, diff --git a/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h b/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h index 8c365a8b257..3e4bba13a43 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h @@ -1800,7 +1800,7 @@ const CGAL::Vector_3& w); // This is there to keep the global functions in alphabetical order // instead of processing order. -/// \defgroup do_intersect_grp CGAL::do_intersect() +/// \defgroup do_intersect_grp Intersection Testing Functions - CGAL::do_intersect() /// \ingroup kernel_global_function /// \defgroup do_intersect_linear_grp CGAL::do_intersect() (2D/3D Linear Kernel) /// \ingroup do_intersect_grp @@ -2056,7 +2056,7 @@ const CGAL::Point_3& t); // Same reason as in defgroup do_intersect. -/// \defgroup intersection_grp CGAL::intersection() +/// \defgroup intersection_grp Intersection Computation Functions - CGAL::intersection() /// \ingroup kernel_global_function /// \defgroup intersection_linear_grp CGAL::intersection() (2D/3D Linear Kernel) /// \ingroup intersection_grp diff --git a/Kernel_23/doc/Kernel_23/CGAL/Projection_traits_3.h b/Kernel_23/doc/Kernel_23/CGAL/Projection_traits_3.h index 13b700b97fb..9c468b37b22 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Projection_traits_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Projection_traits_3.h @@ -20,6 +20,7 @@ provides exact predicates. \cgalModels `ConstrainedTriangulationTraits_2` \cgalModels `PolygonTraits_2` \cgalModels `ConformingDelaunayTriangulationTraits_2` +\cgalModels `Barycentric_coordinates::BarycentricTraits_2` \sa `CGAL::Projection_traits_xy_3` \sa `CGAL::Projection_traits_xz_3` diff --git a/Kernel_23/doc/Kernel_23/CGAL/Projection_traits_xy_3.h b/Kernel_23/doc/Kernel_23/CGAL/Projection_traits_xy_3.h index bdda2985723..ab57d5cfb67 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Projection_traits_xy_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Projection_traits_xy_3.h @@ -32,7 +32,7 @@ provides exact predicates. \cgalModels `ConvexHullTraits_2` \cgalModels `DelaunayMeshTraits_2` \cgalModels `AnalyticWeightTraits_2` -\cgalModels `BarycentricTraits_2` +\cgalModels `Barycentric_coordinates::BarycentricTraits_2` \sa `CGAL::Projection_traits_3` */ diff --git a/Kernel_23/doc/Kernel_23/Kernel_23.txt b/Kernel_23/doc/Kernel_23/Kernel_23.txt index c9c4509580e..3680f47268d 100644 --- a/Kernel_23/doc/Kernel_23/Kernel_23.txt +++ b/Kernel_23/doc/Kernel_23/Kernel_23.txt @@ -290,7 +290,7 @@ crash or compute incorrect results due to accumulated rounding errors. \subsubsection Kernel_23PredefinedKernels Predefined Kernels -For the user's convenience, \cgal provides 3 typedefs to generally useful +For the user's convenience, \cgal provides 5 typedefs to generally useful kernels.

      diff --git a/Kernel_23/doc/Kernel_23/dependencies b/Kernel_23/doc/Kernel_23/dependencies index 91e24d123e9..d42e28aec70 100644 --- a/Kernel_23/doc/Kernel_23/dependencies +++ b/Kernel_23/doc/Kernel_23/dependencies @@ -5,6 +5,7 @@ Convex_hull_2 Triangulation_2 Mesh_2 Number_types +Barycentric_coordinates_2 Algebraic_foundations Circular_kernel_2 Circular_kernel_3 diff --git a/Kernel_23/test/Kernel_23/test_Has_conversion.cpp b/Kernel_23/test/Kernel_23/test_Has_conversion.cpp index ff50c047bf3..c6f393a502d 100644 --- a/Kernel_23/test/Kernel_23/test_Has_conversion.cpp +++ b/Kernel_23/test/Kernel_23/test_Has_conversion.cpp @@ -10,6 +10,8 @@ // // Author(s) : Mael Rouxel-Labbé +#include + #include #include #include @@ -42,26 +44,26 @@ int main() CGAL_USE_TYPE(FSH); CGAL_USE_TYPE(EPECK); - CGAL_assertion((CGAL::Has_conversion::value)); - CGAL_assertion((CGAL::Has_conversion::value)); + assert((CGAL::Has_conversion::value)); + assert((CGAL::Has_conversion::value)); - CGAL_assertion(!(CGAL::Has_conversion::value)); - CGAL_assertion(!(CGAL::Has_conversion::value)); + assert(!(CGAL::Has_conversion::value)); + assert(!(CGAL::Has_conversion::value)); - CGAL_assertion((CGAL::Has_conversion::value)); - CGAL_assertion((CGAL::Has_conversion::value)); - CGAL_assertion((CGAL::Has_conversion::value)); + assert((CGAL::Has_conversion::value)); + assert((CGAL::Has_conversion::value)); + assert((CGAL::Has_conversion::value)); - CGAL_assertion((CGAL::Has_conversion::value)); - CGAL_assertion((CGAL::Has_conversion::value)); - CGAL_assertion((CGAL::Has_conversion::value)); + assert((CGAL::Has_conversion::value)); + assert((CGAL::Has_conversion::value)); + assert((CGAL::Has_conversion::value)); - CGAL_assertion(!(CGAL::Has_conversion::value)); - CGAL_assertion(!(CGAL::Has_conversion::value)); + assert(!(CGAL::Has_conversion::value)); + assert(!(CGAL::Has_conversion::value)); // below will produce static assert failures -// CGAL_assertion((CGAL::Has_conversion::value)); -// CGAL_assertion((CGAL::Has_conversion::value)); +// assert((CGAL::Has_conversion::value)); +// assert((CGAL::Has_conversion::value)); } diff --git a/Kernel_23/test/Kernel_23/test_converter.cpp b/Kernel_23/test/Kernel_23/test_converter.cpp new file mode 100644 index 00000000000..8a94f9845cf --- /dev/null +++ b/Kernel_23/test/Kernel_23/test_converter.cpp @@ -0,0 +1,76 @@ +#include +#include +#include +#include +#include + +#include +#include + +#ifdef CGAL_USE_CORE +#include +#endif + +#include + +int main() +{ + using EPICK = CGAL::Exact_predicates_inexact_constructions_kernel; + using EPECK = CGAL::Exact_predicates_exact_constructions_kernel; + using SCLD = CGAL::Simple_cartesian; + using SCI = CGAL::Simple_cartesian >; + using SHI = CGAL::Simple_homogeneous >; + using NT_exact = CGAL::internal::Exact_field_selector::Type; + using SHD = CGAL::Simple_homogeneous; + using SHE = CGAL::Simple_homogeneous; + + CGAL::Cartesian_converter sci_to_epick; + CGAL::Cartesian_converter scld_to_epick; + CGAL::Cartesian_converter sci_to_epeck; + CGAL::Cartesian_converter epeck_to_epick; + CGAL::Homogeneous_converter shi_to_shd; + CGAL::Homogeneous_converter she_to_shd; + CGAL::Homogeneous_converter she_to_she; + + assert(sci_to_epick(SCI::FT(2)) == EPICK::FT(2)); + assert(scld_to_epick((long double)(2.)) /*long double is FT*/ == EPICK::FT(2)); + + // fundamental types != FT + assert(sci_to_epick((long int)(2)) == (long int)(2)); + assert(sci_to_epick(2.) == 2.); + assert(sci_to_epick(bool(true)) == true); + assert(sci_to_epick(true) == true); + assert(sci_to_epick(false) == false); + assert(sci_to_epick(CGAL::ON_POSITIVE_SIDE) == CGAL::ON_POSITIVE_SIDE); + +#ifdef CGAL_USE_CORE + using SSCE = CGAL::Simple_cartesian; + CGAL::Cartesian_converter scce_to_epick; + + assert(scce_to_epick(2.) == 2.); + assert(scce_to_epick((signed long long int)(1)) == 1); + scce_to_epick(CORE::Expr(2.) == EPICK::FT(2)); +#endif + + assert(sci_to_epeck((signed char)('a')) == (signed char)('a')); + + assert(epeck_to_epick(EPECK::FT(2)) == EPICK::FT(2)); + assert(epeck_to_epick(2.) == 2.); + + // Homogeneous + assert(shi_to_shd(2.) == 2.); + assert(shi_to_shd(SHI::RT(2.)) == SHD::RT(2.)); + + assert(she_to_shd(SHE::RT(2)) == SHD::RT(2)); + assert(she_to_shd(SHE::FT(2.)) == SHD::FT(2.)); + assert(she_to_shd(2.) == 2.); + assert(she_to_she(SHE::RT(2)) == SHE::RT(2)); + + std::cout << "NT_exact is " << typeid(NT_exact).name() << std::endl; + CGAL::NT_converter, CGAL::Quotient > qnte_to_qnte; + assert(qnte_to_qnte(2.) == CGAL::Quotient(2.)); + + std::cout << "Done" << std::endl; + + return EXIT_SUCCESS; +} diff --git a/Kernel_d/include/CGAL/Kernel_d/Cartesian_converter_d.h b/Kernel_d/include/CGAL/Kernel_d/Cartesian_converter_d.h index a136b3da81d..e38fea77163 100644 --- a/Kernel_d/include/CGAL/Kernel_d/Cartesian_converter_d.h +++ b/Kernel_d/include/CGAL/Kernel_d/Cartesian_converter_d.h @@ -82,13 +82,13 @@ public: : c(), k(), result_point_(20) {} Origin - operator()(const Origin& o) const + operator()(Origin o) const { return o; } Null_vector - operator()(const Null_vector& n) const + operator()(Null_vector n) const { return n; } @@ -99,6 +99,14 @@ public: return c(a); } + template + T + operator()(const T t, + typename std::enable_if::value>::type* = nullptr) const + { + return t; + } + std::vector operator()(const std::vector& v) const { @@ -110,11 +118,6 @@ public: return res; } - int operator()(const int &a) - { - return a; - } - typename K2::Point_d operator()(const typename K1::Point_d &a) const { diff --git a/Linear_cell_complex/benchmark/Linear_cell_complex_2/surface_mesh/IO_off.cpp b/Linear_cell_complex/benchmark/Linear_cell_complex_2/surface_mesh/IO_off.cpp index 9c7615c7d33..d1be42f9fe4 100644 --- a/Linear_cell_complex/benchmark/Linear_cell_complex_2/surface_mesh/IO_off.cpp +++ b/Linear_cell_complex/benchmark/Linear_cell_complex_2/surface_mesh/IO_off.cpp @@ -11,7 +11,7 @@ #include "IO.h" #include -#include +#include #include //== IMPLEMENTATION =========================================================== diff --git a/Linear_cell_complex/demo/Linear_cell_complex/typedefs.h b/Linear_cell_complex/demo/Linear_cell_complex/typedefs.h index d3d334865de..787b5a48aac 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/typedefs.h +++ b/Linear_cell_complex/demo/Linear_cell_complex/typedefs.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/Linear_cell_complex/doc/Linear_cell_complex/CGAL/Linear_cell_complex.h b/Linear_cell_complex/doc/Linear_cell_complex/CGAL/Linear_cell_complex.h deleted file mode 100644 index d9b8a3d47c4..00000000000 --- a/Linear_cell_complex/doc/Linear_cell_complex/CGAL/Linear_cell_complex.h +++ /dev/null @@ -1,17 +0,0 @@ - -namespace CGAL { - -/*! -\ingroup PkgLinearCellComplexClasses - -The class `Linear_cell_complex` represents a linear cell complex in dimension `d`, in an ambient space of dimension `d2`, using a combinatorial map as underlying combinatorial data-structure. - -\deprecated This class is deprecated since CGAL 4.9 and has been renamed to `Linear_cell_complex_for_combinatorial_map`. - -*/ - -template< typename d, typename d2, typename LCCTraits, typename Items, typename Alloc > -class Linear_cell_complex { -}; /* end Linear_cell_complex */ - -} /* end namespace CGAL */ diff --git a/Linear_cell_complex/doc/Linear_cell_complex/CGAL/Linear_cell_complex_for_combinatorial_map.h b/Linear_cell_complex/doc/Linear_cell_complex/CGAL/Linear_cell_complex_for_combinatorial_map.h index c3de00eda78..7b59ef6b01c 100644 --- a/Linear_cell_complex/doc/Linear_cell_complex/CGAL/Linear_cell_complex_for_combinatorial_map.h +++ b/Linear_cell_complex/doc/Linear_cell_complex/CGAL/Linear_cell_complex_for_combinatorial_map.h @@ -22,10 +22,6 @@ Note that there is an additional, and undocumented, template parameter `CMap` fo \sa `CGAL::Linear_cell_complex_traits` \sa `CGAL::Linear_cell_complex_min_items` -\deprecated Before CGAL 4.9, this class was named `%Linear_cell_complex`. This old name still exist for backward compatibility. - -\deprecated Before CGAL 4.9, `Items` had to define the type of dart used. This is now deprecated, the `Dart` type is no more defined in the item class, but replaced by the `Dart_info` type. See deprecated note in the `Linear_cell_complex_min_items` class. `CGAL_CMAP_DART_DEPRECATED` can be defined to keep the old behavior. - */ template< typename d, typename d2, typename LCCTraits, typename Items, typename Alloc > diff --git a/Linear_cell_complex/doc/Linear_cell_complex/CGAL/Linear_cell_complex_min_items.h b/Linear_cell_complex/doc/Linear_cell_complex/CGAL/Linear_cell_complex_min_items.h index 16123f214f4..a9b3bc0ade4 100644 --- a/Linear_cell_complex/doc/Linear_cell_complex/CGAL/Linear_cell_complex_min_items.h +++ b/Linear_cell_complex/doc/Linear_cell_complex/CGAL/Linear_cell_complex_min_items.h @@ -8,8 +8,6 @@ The class `Linear_cell_complex_min_items` defines `void` as the information asso \cgalModels `LinearCellComplexItems` -\deprecated Before CGAL 4.9, this class was templated by the dimension of the darts, and users must define the type of darts used (see also deprecated class `Combinatorial_map_min_items`). `CGAL_CMAP_DART_DEPRECATED` can be defined to keep the old behavior (only possible with `Combinatorial_map` and not for `Generalized_map`). - \cgalHeading{Example} The following example shows one implementation of the `Linear_cell_complex_min_items` class. diff --git a/Linear_cell_complex/examples/Linear_cell_complex/linear_cell_complex_4.cpp b/Linear_cell_complex/examples/Linear_cell_complex/linear_cell_complex_4.cpp index c912b78abb2..e83e81fb878 100644 --- a/Linear_cell_complex/examples/Linear_cell_complex/linear_cell_complex_4.cpp +++ b/Linear_cell_complex/examples/Linear_cell_complex/linear_cell_complex_4.cpp @@ -1,6 +1,7 @@ #include #include #include +#include typedef CGAL::Linear_cell_complex_for_generalized_map<4,5> LCC_4; typedef LCC_4::Dart_handle Dart_handle; @@ -42,24 +43,24 @@ int main() // Add one vertex on the middle of the edge containing dart d1. Dart_handle d3 = lcc.insert_barycenter_in_cell<1>(d1); - CGAL_assertion( lcc.is_valid() ); + assert( lcc.is_valid() ); lcc.display_characteristics(std::cout); std::cout<<", valid="<is_whole_map_marked(mymark) ); this->free_mark(mymark); return res; diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h index 9ec501d454b..494b5e68fa0 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -204,9 +205,7 @@ namespace CGAL { m_file_header = scanner; // Remember file header after return. Linear_cell_complex_incremental_builder_3 B(alcc); - B.begin_surface(scanner.size_of_vertices(), - scanner.size_of_facets(), - scanner.size_of_halfedges()); + B.begin_surface(); typedef typename LCC::Point Point; @@ -247,7 +246,7 @@ namespace CGAL { } */ for (std::size_t j=0; j #include #include +#include namespace CGAL { @@ -96,6 +97,9 @@ namespace CGAL { Linear_cell_complex_for_combinatorial_map(const Self& alcc) : Base(alcc) {} + Linear_cell_complex_for_combinatorial_map(Self&& alcc) : Base(alcc) + {} + template class CMap2, @@ -146,20 +150,32 @@ namespace CGAL { return *this; } + friend std::ostream& operator<< (std::ostream& os, const Self& amap) + { + save_combinatorial_map(amap, os); + return os; + } + + friend std::ifstream& operator>> (std::ifstream& is, Self& amap) + { + load_combinatorial_map(is, amap); + return is; + } + /** Import the given hds which should be a model of an halfedge graph. */ template void import_from_halfedge_graph(const HEG& heg , const PointConverter& pointconverter, - boost::unordered_map + std::unordered_map ::halfedge_descriptor, Dart_handle>* origin_to_copy=NULL, - boost::unordered_map + std::unordered_map ::halfedge_descriptor>* copy_to_origin=NULL) { - boost::unordered_map + std::unordered_map ::halfedge_descriptor, Dart_handle> local_dartmap; if (origin_to_copy==NULL) // Used local_dartmap if user does not provides its own unordered_map @@ -171,7 +187,7 @@ namespace CGAL { Point_property_map; Point_property_map ppmap = get(CGAL::vertex_point, heg); - typename boost::unordered_map + typename std::unordered_map ::halfedge_descriptor, Dart_handle>::iterator dartmap_iter, dartmap_iter_end=origin_to_copy->end(); for (dartmap_iter=origin_to_copy->begin(); dartmap_iter!=dartmap_iter_end; @@ -190,10 +206,10 @@ namespace CGAL { /** Import the given hds which should be a model of an halfedge graph. */ template void import_from_halfedge_graph(const HEG& heg, - boost::unordered_map + std::unordered_map ::halfedge_descriptor, Dart_handle>* origin_to_copy=NULL, - boost::unordered_map + std::unordered_map ::halfedge_descriptor>* copy_to_origin=NULL) diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_for_generalized_map.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_for_generalized_map.h index de9900a1c8d..b432adb2965 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_for_generalized_map.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_for_generalized_map.h @@ -95,6 +95,9 @@ namespace CGAL { Linear_cell_complex_for_generalized_map(const Self & alcc) : Base(alcc) {} + Linear_cell_complex_for_generalized_map(Self && alcc) : Base(alcc) + {} + template class CMap2, @@ -145,6 +148,18 @@ namespace CGAL { Base::operator=(alcc); return *this; } + + friend std::ostream& operator<< (std::ostream& os, const Self& amap) + { + save_generalized_map(amap, os); + return os; + } + + friend std::ifstream& operator>> (std::ifstream& is, Self& amap) + { + load_generalized_map(is, amap); + return is; + } }; } // namespace CGAL diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_fwd.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_fwd.h index d7a05e197b1..9ee33103833 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_fwd.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_fwd.h @@ -33,12 +33,7 @@ template ::type > struct Linear_cell_complex_traits; -#if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) - template - struct CGAL_DEPRECATED Linear_cell_complex_min_items; -#else - struct Linear_cell_complex_min_items; -#endif +struct Linear_cell_complex_min_items; template < unsigned int d_, unsigned int ambient_dim, class Traits_, @@ -52,46 +47,25 @@ class Linear_cell_complex_base; template < unsigned int d_, unsigned int ambient_dim = d_, class Traits_ = Linear_cell_complex_traits, -#if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) - class Items_ = Linear_cell_complex_min_items, -#else class Items_ = Linear_cell_complex_min_items, -#endif class Alloc_ = CGAL_ALLOCATOR(int), template class CMap = Combinatorial_map_base, class Storage_ = CMap_linear_cell_complex_storage_1 > - class Linear_cell_complex_for_combinatorial_map; +class Linear_cell_complex_for_combinatorial_map; - template < unsigned int d_, unsigned int ambient_dim = d_, - class Traits_ = Linear_cell_complex_traits, - class Items_ = Linear_cell_complex_min_items, - class Alloc_ = CGAL_ALLOCATOR(int), - template - class CMap = Generalized_map_base, - class Storage_ = GMap_linear_cell_complex_storage_1 > - class Linear_cell_complex_for_generalized_map; - -#if !defined(CGAL_NO_DEPRECATED_CODE) - template < unsigned int d_, unsigned int ambient_dim = d_, - class Traits_ = Linear_cell_complex_traits, -#if defined(CGAL_CMAP_DART_DEPRECATED) - class Items_ = Linear_cell_complex_min_items, -#else - class Items_ = Linear_cell_complex_min_items, -#endif - class Alloc_ = CGAL_ALLOCATOR(int), - template - class CMap = Combinatorial_map_base, - class Storage_ = CMap_linear_cell_complex_storage_1 > - class Linear_cell_complex; -#endif +template < unsigned int d_, unsigned int ambient_dim = d_, + class Traits_ = Linear_cell_complex_traits, + class Items_ = Linear_cell_complex_min_items, + class Alloc_ = CGAL_ALLOCATOR(int), + template + class CMap = Generalized_map_base, + class Storage_ = GMap_linear_cell_complex_storage_1 > +class Linear_cell_complex_for_generalized_map; } // CGAL diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h index 8f4ed8b1846..1aaac16e103 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h @@ -14,9 +14,13 @@ #include #include +#include +#include #include +#include namespace CGAL { +/////////////////////////////////////////////////////////////////////////////// template struct Add_vertex_to_face @@ -67,143 +71,336 @@ namespace CGAL { typename LCC::Dart_handle prev_dart) { // here we need to create a last dart and 0-link it - assert(prev_dart!=lcc.null_handle); + CGAL_assertion(prev_dart!=lcc.null_handle); lcc.template link_alpha<0>(prev_dart, lcc.create_dart(vh)); } }; - - // Incremental builder - template < class LCC_ > - class Linear_cell_complex_incremental_builder_3 +/////////////////////////////////////////////////////////////////////////////// +template +struct Find_opposite_2_no_control // No difference for CMap and GMap +{ + typedef typename LCC::Dart_handle DH; + typedef typename LCC::Vertex_attribute_handle VAH; + static DH run(LCC&, + std::unordered_map>& + vertex_to_dart_map_in_surface, + VAH vah1, VAH vah2) { - public: - typedef LCC_ LCC; - typedef typename LCC::Dart_handle Dart_handle; - typedef typename LCC::Vertex_attribute_handle Vertex_attribute_handle; - typedef typename LCC::Point Point_3; - typedef typename LCC::size_type size_type; - - Linear_cell_complex_incremental_builder_3(LCC & alcc) : - lcc(alcc) - {} - - Vertex_attribute_handle add_vertex(const Point_3& p) + // We are searching edge vah2->vah1 (the opposite of edge vah1->vah2) + auto it2=vertex_to_dart_map_in_surface.find(vah2); + if (it2!=vertex_to_dart_map_in_surface.end()) { - Vertex_attribute_handle res = lcc.create_vertex_attribute(p); - vertex_map.push_back(res); - vertex_to_dart_map.push_back(std::vector()); - ++new_vertices; - return res; + auto it1=it2->second.find(vah1); + if (it1!=it2->second.end()) + { return it1->second; } + } + return nullptr; + } +}; +/////////////////////////////////////////////////////////////////////////////// +template +struct Find_opposite_2_with_control +{ + typedef typename LCC::Dart_handle DH; + typedef typename LCC::Vertex_attribute_handle VAH; + static DH run(LCC&, + std::unordered_map>&, + VAH, VAH) + { return nullptr; } +}; +template +struct Find_opposite_2_with_control +{ + typedef typename LCC::Dart_handle DH; + typedef typename LCC::Vertex_attribute_handle VAH; + static DH run(LCC& lcc, + std::unordered_map>& + vertex_to_dart_map_in_surface, + VAH vah1, VAH vah2) + { + DH res=Find_opposite_2_no_control::run(lcc, + vertex_to_dart_map_in_surface, + vah1, vah2); + if (res!=nullptr) + { + if (!lcc.template is_free<2>(res)) + { // Here a dart vah1->vah2 already exists, and it was already 2-sewn. + std::cerr<<"ERROR in My_linear_cell_complex_incremental_builder_3: try to use a same oriented edge twice."<::run(lcc, + vertex_to_dart_map_in_surface, + vah2, vah1)!=nullptr) + { // Here a dart vah1->vah2 already exists (but it was not already 2-sewn). + std::cerr<<"ERROR in My_linear_cell_complex_incremental_builder_3: try to use a same oriented edge twice."< +struct Find_opposite_2_with_control +{ + typedef typename LCC::Dart_handle DH; + typedef typename LCC::Vertex_attribute_handle VAH; + static DH run(LCC& lcc, + std::unordered_map>& + vertex_to_dart_map_in_surface, + VAH vah1, VAH vah2) + { + DH res=Find_opposite_2_no_control::run(lcc, + vertex_to_dart_map_in_surface, + vah1, vah2); + if (res!=nullptr) { - first_dart = lcc.null_handle; - prev_dart = lcc.null_handle; - // std::cout<<"Begin facet: "<(res)) + { // Here a dart vah1->vah2 already exists, and it was already 2-sewn. + std::cerr<<"ERROR in My_linear_cell_complex_incremental_builder_3: try to use a same oriented edge twice."< +struct Add_edge_in_associative_array +{ + typedef typename LCC::Dart_handle DH; + typedef typename LCC::Vertex_attribute_handle VAH; + static void run(LCC&, DH, + std::unordered_map>&) + {} +}; +template +struct Add_edge_in_associative_array +{ + typedef typename LCC::Dart_handle DH; + typedef typename LCC::Vertex_attribute_handle VAH; + static void run(LCC& lcc, DH dh, + std::unordered_map>& + vertex_to_dart_map_in_surface) + { + vertex_to_dart_map_in_surface[lcc.vertex_attribute(dh)].insert + (std::make_pair(lcc.vertex_attribute(lcc.next(dh)), dh)); + } +}; +template +struct Add_edge_in_associative_array +{ + typedef typename LCC::Dart_handle DH; + typedef typename LCC::Vertex_attribute_handle VAH; + static void run(LCC& lcc, DH dh, + std::unordered_map>& + vertex_to_dart_map_in_surface) + { + vertex_to_dart_map_in_surface[lcc.vertex_attribute(dh)].insert + (std::make_pair(lcc.vertex_attribute(lcc.template alpha<0>(dh)), dh)); - void add_vertex_to_facet(size_type i) + vertex_to_dart_map_in_surface + [lcc.vertex_attribute(lcc.template alpha<0>(dh))].insert + (std::make_pair(lcc.vertex_attribute(dh), lcc.template alpha<0>(dh))); + } +}; +/////////////////////////////////////////////////////////////////////////////// +template +struct Sew3_for_LCC_incremental_builder +{ + static void run(LCC_& lcc, + typename LCC_::Dart_handle dh1, typename LCC_::Dart_handle dh2) + { + if(dh1!=nullptr) { - CGAL_assertion( i:: - run(lcc, vertex_map[i], prev_dart); - - if ( prev_dart!=lcc.null_handle ) + if(!lcc.template is_free<3>(dh1)) { - Dart_handle opposite= - find_dart_between(i,lcc.vertex_attribute(prev_dart)); - if ( opposite!=lcc.null_handle ) - { - CGAL_assertion( lcc.template is_free<2>(opposite) ); - lcc.template set_opposite<2>(prev_dart, opposite); - } - - add_dart_in_vertex_to_dart_map(prev_dart, prev_vertex); + std::cerr<<"ERROR in My_linear_cell_complex_incremental_builder_3: " + <<"it exists more than 2 faces with same indices."<(lcc.other_orientation(dh1), dh2); } } + } +}; +template +struct Sew3_for_LCC_incremental_builder +{ + static void run(LCC_&, typename LCC_::Dart_handle, typename LCC_::Dart_handle) + {} +}; +/////////////////////////////////////////////////////////////////////////////// +// Incremental builder +template < class LCC_ > +class Linear_cell_complex_incremental_builder_3 +{ +public: + typedef LCC_ LCC; + typedef typename LCC::Dart_handle DH; + typedef typename LCC::Vertex_attribute_handle VAH; + typedef typename LCC::Point Point_3; + typedef typename LCC::size_type size_type; - // End of the facet. Return the first dart of this facet. - Dart_handle end_facet() + Linear_cell_complex_incremental_builder_3(LCC & alcc) : + lcc(alcc) + {} + + VAH add_vertex(const Point_3& p) + { + VAH res=lcc.create_vertex_attribute(p); + vertex_map.push_back(res); + return res; + } + + void begin_facet() + { // std::cout<<"Begin facet: "<::run(lcc, vertex_map[i], prev_dart); + if ( prev_dart!=lcc.null_handle ) { - CGAL_assertion( first_dart!=lcc.null_handle && prev_dart!=lcc.null_handle ); - - Add_vertex_to_face::run_for_last(lcc, vertex_map[first_vertex], - prev_dart); - - lcc.set_next(prev_dart, first_dart); - - Dart_handle opposite = - find_dart_between(first_vertex,lcc.vertex_attribute(prev_dart)); + DH opposite=Find_opposite_2_with_control:: + run(lcc, + vertex_to_dart_map_in_surface, + lcc.vertex_attribute(prev_dart), + lcc.vertex_attribute(cur_dart)); if ( opposite!=lcc.null_handle ) { CGAL_assertion( lcc.template is_free<2>(opposite) ); lcc.template set_opposite<2>(prev_dart, opposite); } - add_dart_in_vertex_to_dart_map(prev_dart, prev_vertex); + Add_edge_in_associative_array::run(lcc, prev_dart, + vertex_to_dart_map_in_surface); - return first_dart; + if (imax_vertex) { max_vertex=i; } } + else + { first_dart=cur_dart; min_vertex=max_vertex=i; min_dart=cur_dart; } - void begin_surface( std::size_t v, std::size_t /*f*/, std::size_t /*h*/) + prev_dart=cur_dart; + } + + // End of the facet. Return the first dart of this facet. + DH end_facet() + { + CGAL_assertion( first_dart!=lcc.null_handle && prev_dart!=lcc.null_handle ); + + Add_vertex_to_face::run_for_last(lcc, + lcc.vertex_attribute(first_dart), + prev_dart); + + lcc.set_next(prev_dart, first_dart); + + DH opposite=Find_opposite_2_with_control:: + run(lcc, + vertex_to_dart_map_in_surface, + lcc.vertex_attribute(prev_dart), + lcc.vertex_attribute(first_dart)); + if ( opposite!=lcc.null_handle ) { - new_vertices = 0; - first_dart = lcc.null_handle; - prev_dart = lcc.null_handle; - vertex_map.clear(); - vertex_to_dart_map.clear(); - vertex_map.reserve(v); - vertex_to_dart_map.reserve(v); - // lcc.reserve(v,h); + CGAL_assertion( lcc.template is_free<2>(opposite) ); + lcc.template set_opposite<2>(prev_dart, opposite); } + Add_edge_in_associative_array::run(lcc, prev_dart, + vertex_to_dart_map_in_surface); + + if(LCC::dimension>2) + { + opposite=opposite_face(); + Sew3_for_LCC_incremental_builder::run(lcc, opposite, min_dart); + add_face_in_array(); + } + return first_dart; + } + + DH add_facet(std::initializer_list l) + { + begin_facet(); + for (std::size_t i:l) + { add_vertex_to_facet(i); } + return end_facet(); + } + + void begin_surface() + { + vertex_to_dart_map_in_surface.clear(); + } + // End of the surface. Return one dart of the created surface. - Dart_handle end_surface() + DH end_surface() { return first_dart; } protected: - - Dart_handle find_dart_between(size_type i, Vertex_attribute_handle vh) + /** test if the two given facets have the same vertex handle but with + * opposite orientations. For closed facets. + * @return true iff the two facets have the same vertex handle with opposite + * orientation. + */ + bool are_facets_opposite_and_same_vertex_handles(DH d1, DH d2) const + { + DH s1=d1; + DH s2=d2; + do { - typename std::vector::reverse_iterator - it(vertex_to_dart_map[i].rbegin()); - typename std::vector::reverse_iterator - itend(vertex_to_dart_map[i].rend()); + CGAL_assertion(lcc.is_next_exist(d1) && lcc.is_previous_exist(d2)); + CGAL_assertion(lcc.other_extremity(d2)!=lcc.null_handle); - for ( ; it!=itend; ++it ) - { - if ( lcc.vertex_attribute(lcc.next(*it))==vh ) return (*it); - } - return lcc.null_handle; + if (lcc.vertex_attribute(d1)!=lcc.vertex_attribute(d2)) + { return false; } + d1=lcc.next(d1); + d2=lcc.previous(d2); } + while(d1!=s1); - void add_dart_in_vertex_to_dart_map( Dart_handle adart, size_type i ) + if (d2!=s2) { return false; } + return true; + } + + DH opposite_face() + { + auto it1=faces.find(min_vertex); + if(it1==faces.end()) { return nullptr; } + auto it2=it1->second.find(max_vertex); + if(it2==it1->second.end()) { return nullptr; } + for(auto it3=it2->second.begin(), it3end=it2->second.end(); it3!=it3end; ++it3) { - CGAL_assertion( adart!=lcc.null_handle ); - vertex_to_dart_map[i].push_back(adart); + if (are_facets_opposite_and_same_vertex_handles(*it3, min_dart)) + { return lcc.previous(*it3); } } + return nullptr; + } - private: - std::vector vertex_map; - std::vector > vertex_to_dart_map; + void add_face_in_array() + { + faces[min_vertex][max_vertex].push_back(min_dart); + } - LCC& lcc; - Dart_handle first_dart; - Dart_handle prev_dart; - size_type first_vertex; - size_type prev_vertex; - size_type new_vertices; - }; +private: + LCC& lcc; + std::vector vertex_map; // Map each index to the corresponding vertex handle + + // A map to associate to each edge of a surface its dart. The edge is given + // by its two vertex handles (source-target). + std::unordered_map> vertex_to_dart_map_in_surface; + std::unordered_map>> faces; + + DH first_dart; /// First dart of the current face + DH prev_dart; /// Prev dart of the current face + DH min_dart; /// dart with the min vertex of the current facet. + std::size_t min_vertex, max_vertex; /// min and max indices of vertices of the current face +}; } //namespace CGAL diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_min_items.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_min_items.h index c5276efd6c4..0862fa3f040 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_min_items.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_min_items.h @@ -12,10 +12,6 @@ #ifndef CGAL_LINEAR_CELL_COMPLEX_MIN_ITEMS_H #define CGAL_LINEAR_CELL_COMPLEX_MIN_ITEMS_H 1 -#if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) -#include -#endif - #include #include #include @@ -31,21 +27,6 @@ namespace CGAL { * for a linear cell complex. It provides definitions for attributes * associated to vertices (containing points), and information associated with darts. */ -#if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) - template - struct CGAL_DEPRECATED Linear_cell_complex_min_items - { - /// Dart_wrapper defines the type of darts used. - template - struct Dart_wrapper - { - typedef CGAL::Dart Dart; - - typedef CGAL::Cell_attribute_with_point Vertex_attrib; - typedef std::tuple Attributes; - }; - }; -#else struct Linear_cell_complex_min_items { /// Dart_wrapper defines the type of darts used. @@ -56,7 +37,6 @@ namespace CGAL { typedef std::tuple Attributes; }; }; -#endif } // namespace CGAL diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_operations.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_operations.h index 496a4c58fd8..025ed1d5f60 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_operations.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_operations.h @@ -15,6 +15,7 @@ #include #include #include +#include namespace CGAL { @@ -82,7 +83,7 @@ namespace CGAL { } while(adart!=start); - assert(nb>0); + CGAL_assertion(nb>0); return (typename LCC::Traits::Construct_scaled_vector()(normal, 1.0/nb)); // return normal / std::sqrt(normal * normal); } @@ -201,7 +202,7 @@ namespace CGAL { } while(adart!=start); - assert(nb>1); + CGAL_assertion(nb>1); return typename LCC::Traits::Construct_translated_point() (CGAL::ORIGIN, typename LCC::Traits::Construct_scaled_vector() (vec, 1.0/nb)); diff --git a/Linear_cell_complex/include/CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h b/Linear_cell_complex/include/CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h index 3354388be33..c8e62374b8c 100644 --- a/Linear_cell_complex/include/CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h +++ b/Linear_cell_complex/include/CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h @@ -29,6 +29,7 @@ #include #include +#include #define CGAL_LCC_TEMPLATE_ARGS templateget_f(2); } @@ -605,6 +606,31 @@ void set_halfedge(typename boost::graph_traits::face_descriptor f } // namespace CGAL +namespace std { + +#if defined(BOOST_MSVC) +# pragma warning(push) +# pragma warning(disable:4099) // For VC10 it is class hash +#endif + +#ifndef CGAL_CFG_NO_STD_HASH + +template +struct hash> +{ + std::size_t operator()(const CGAL::internal::EdgeHandle& edge) const + { + return hash_value(edge); + } +}; +#endif // CGAL_CFG_NO_STD_HASH + +#if defined(BOOST_MSVC) +# pragma warning(pop) +#endif + +} // std namespace + #undef CGAL_LCC_TEMPLATE_ARGS #undef CGAL_LCC_TYPE diff --git a/Linear_cell_complex/test/Linear_cell_complex/LCC_3_incremental_builder_test.cpp b/Linear_cell_complex/test/Linear_cell_complex/LCC_3_incremental_builder_test.cpp new file mode 100644 index 00000000000..2569b0f929b --- /dev/null +++ b/Linear_cell_complex/test/Linear_cell_complex/LCC_3_incremental_builder_test.cpp @@ -0,0 +1,179 @@ +#include +#include +#include +#include + +#include "Linear_cell_complex_3_test.h" + +/////////////////////////////////////////////////////////////////////////////// +/* 3 + * /|\ + * 0-|-2 + * \|/ + * 1 + */ +template +void make_tetrahedron_with_builder(IncrementalBuilder& ib, + std::size_t i0, + std::size_t i1, + std::size_t i2, + std::size_t i3) +{ + ib.begin_surface(); + ib.add_facet({i0,i1,i2}); + ib.add_facet({i1,i0,i3}); + ib.add_facet({i2,i1,i3}); + ib.add_facet({i0,i2,i3}); + ib.end_surface(); +} +/////////////////////////////////////////////////////////////////////////////// +/* 4 + * /|\ + * 0-|-3 + * | | | + * 1---2 + */ +template +void make_pyramid_with_builder(IncrementalBuilder& ib, + std::size_t i0, + std::size_t i1, + std::size_t i2, + std::size_t i3, + std::size_t i4) +{ + ib.begin_surface(); + ib.add_facet({i0,i1,i2,i3}); + ib.add_facet({i1,i0,i4}); + ib.add_facet({i2,i1,i4}); + ib.add_facet({i3,i2,i4}); + ib.add_facet({i0,i3,i4}); + ib.end_surface(); +} +/////////////////////////////////////////////////////////////////////////////// +/* 3 + * /|\ + * 4---5 + * | | | + * | 0 | + * |/ \| + * 1---2 + */ +template +void make_prism_with_builder(IncrementalBuilder& ib, + std::size_t i0, + std::size_t i1, + std::size_t i2, + std::size_t i3, + std::size_t i4, + std::size_t i5) +{ + ib.begin_surface(); + ib.add_facet({i0,i1,i2}); + ib.add_facet({i1,i0,i3,i4}); + ib.add_facet({i2,i1,i4,i5}); + ib.add_facet({i0,i2,i5,i3}); + ib.add_facet({i5,i4,i3}); + ib.end_surface(); +} +/////////////////////////////////////////////////////////////////////////////// +/* 7----6 + * /| /| + * 4----5 | + * | 3--|-2 + * |/ |/ + * 0----1 + */ +template +void make_hexahedron_with_builder(IncrementalBuilder& ib, + std::size_t i0, + std::size_t i1, + std::size_t i2, + std::size_t i3, + std::size_t i4, + std::size_t i5, + std::size_t i6, + std::size_t i7) +{ + ib.begin_surface(); + ib.add_facet({i0,i1,i2,i3}); + ib.add_facet({i1,i0,i4,i5}); + ib.add_facet({i2,i1,i5,i6}); + ib.add_facet({i3,i2,i6,i7}); + ib.add_facet({i0,i3,i7,i4}); + ib.add_facet({i7,i6,i5,i4}); + ib.end_surface(); +} +/////////////////////////////////////////////////////////////////////////////// +template +bool test_ib(const char* filename) +{ + typedef typename LCC::Point Point; + LCC lcc; + CGAL::Linear_cell_complex_incremental_builder_3 ib(lcc); + + ib.add_vertex(Point(0,0,0)); // 0 + ib.add_vertex(Point(1,0,0)); // 1 + ib.add_vertex(Point(1,2,0)); // 2 + ib.add_vertex(Point(0,2,0)); // 3 + + ib.add_vertex(Point(0,0,1.5)); // 4 + ib.add_vertex(Point(1,0,1.5)); // 5 + ib.add_vertex(Point(1,2,1.5)); // 6 + ib.add_vertex(Point(0,2,1.5)); // 7 + + ib.add_vertex(Point(0.5,1,2.5)); // 8 + + ib.add_vertex(Point(2,0,0)); // 9 + ib.add_vertex(Point(2,0,1)); // 10 + + trace_test_begin(); + make_hexahedron_with_builder(ib, 0,1,2,3,4,5,6,7); + make_pyramid_with_builder(ib, 4,5,6,7,8); + make_prism_with_builder(ib, 2,1,9,6,5,10); + make_tetrahedron_with_builder(ib, 6,5,10,8); + + if ( !check_number_of_cells_3(lcc, 11, 22, 16, 4, 1) ) + { return false; } + + LCC lcc2; + std::ifstream input(std::string("data/")+filename); + if (!input) + { + std::cout<<"Problem to load LCC data/"<>lcc2; + input.close(); + + if (!lcc.is_isomorphic_to(lcc2)) + { return false; } + trace_test_end(); + + return true; +} + +int main() +{ + std::cout<<"LCC_3_incremental_builder_test (v1)."<"); + typedef CGAL::Linear_cell_complex_for_combinatorial_map<3> LCC3; + if ( !test_ib("lcc3_ib_test.cmap") ) + { + std::cout<<" Error during Test_LCC_3."<"); + typedef CGAL::Linear_cell_complex_for_generalized_map<3> GLCC3; + if ( !test_ib("lcc3_ib_test.gmap") ) + { + std::cout<<" Error during Test_LCC_3."< #include +#include using namespace std; @@ -188,7 +189,7 @@ struct Converter_map9_points_into_map5_points (const CMap9& map1, CMap5& map2, CMap9::Dart_const_handle dh1, CMap5::Dart_handle dh2) const { - CGAL_assertion( map1.attribute<0>(dh1)!=map1.null_handle ); + assert( map1.attribute<0>(dh1)!=map1.null_handle ); CMap5::Attribute_handle<0>::type res = map2.attribute<0>(dh2); if ( res==map2.null_handle ) @@ -245,7 +246,7 @@ struct Converter_gmap9_points_into_gmap5_points (const GMap9& map1, GMap5& map2, GMap9::Dart_const_handle dh1, GMap5::Dart_handle dh2) const { - CGAL_assertion( map1.attribute<0>(dh1)!=map1.null_handle ); + assert( map1.attribute<0>(dh1)!=map1.null_handle ); GMap5::Attribute_handle<0>::type res = map2.attribute<0>(dh2); if ( res==map2.null_handle ) @@ -502,7 +503,7 @@ void create2Dmap(Map& map) CreateAttributes::run(map); CreateAttributes::run(map); CreateAttributes::run(map); - CGAL_assertion ( map.is_valid() ); + assert( map.is_valid() ); } template void create3Dmap(Map& map) @@ -526,7 +527,7 @@ void create3Dmap(Map& map) CreateAttributes::run(map); CreateAttributes::run(map); CreateAttributes::run(map); - CGAL_assertion ( map.is_valid() ); + assert( map.is_valid() ); } template @@ -572,7 +573,7 @@ void create4Dmap(Map& map) CreateAttributes::run(map); CreateAttributes::run(map); CreateAttributes::run(map); - CGAL_assertion ( map.is_valid() ); + assert( map.is_valid() ); } template +25394131176172082351010244118471222469144514315121621131818419162024176221527231126247252119282629232732222835212538243025314029333326623431643236633627373435393928403738304244434841524541946551247571144491049425047515648535343545155585245575060584659565461606257616556596858635932647034626633666067646569696170676863voidN4CGAL7Point_3INS_5EpickEEE17

      000

      49

      100

      52

      120

      18

      020

      38

      001.5

      66

      101.5

      68

      121.5

      39

      021.5

      70

      0.512.5

      53

      200

      69

      201

      \ No newline at end of file diff --git a/Linear_cell_complex/test/Linear_cell_complex/data/lcc3_ib_test.gmap b/Linear_cell_complex/test/Linear_cell_complex/data/lcc3_ib_test.gmap new file mode 100644 index 00000000000..6eca4776f71 --- /dev/null +++ b/Linear_cell_complex/test/Linear_cell_complex/data/lcc3_ib_test.gmap @@ -0,0 +1,2 @@ + +2810139421835176426572586347133101629111121040111339141246131545161420159191824488171938720181694192115932220449221234391242228902317278926326252752826242729233028422931413230363125353440833357363432353731383648373947403812393311424830544143295344422252434521514644145045471349484638564741375550565846495157455250644451536343545270425355694156547648554975475862505759496058805961796260666157656468521246365511236664621286567611276866721266763711257074546971537270687173677472787369777680567577557876747779738078607975598286888183878482968385958684104858110388948218878981179088110248991109239290114229193113219492982093879719961028495978398969497999310098112991011111021001061019510510411086103105851061041021051071011081061161071091151101089010910389112116100120111113991191141129211811311591117116114108122115111107121118122124114117119123113120118130112119121129111122120136116121117135115124128118641231251176312612414068125127139671281261326612712313165130134120129131119132130128131133127134132138133129137136140122135137121138136134137139133140138126139135125voidN4CGAL7Point_3INS_5EpickEEE40

      000

      97

      100

      110

      120

      35

      020

      80

      001.5

      131

      101.5

      140

      121.5

      77

      021.5

      139

      0.512.5

      105

      200

      137

      201

      \ No newline at end of file diff --git a/Maintenance/infrastructure/cgal.geometryfactory.com/crontab b/Maintenance/infrastructure/cgal.geometryfactory.com/crontab index 36586b1f87c..27a916856a1 100644 --- a/Maintenance/infrastructure/cgal.geometryfactory.com/crontab +++ b/Maintenance/infrastructure/cgal.geometryfactory.com/crontab @@ -19,16 +19,18 @@ LC_CTYPE=en_US.UTF-8 # The script also updates the manual tools. # "master" alone -0 21 * * Sun,Tue cd $HOME/CGAL/create_internal_release && /usr/bin/time scl enable rh-git29 -- $HOME/bin/create_release $HOME/CGAL/branches/master.git --do-it --public --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,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 || 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 || echo ERROR +# from branch 5.4 +0 21 * * Fri cd $HOME/CGAL/create_internal_release-5.4-branch && /usr/bin/time scl enable rh-git29 -- $HOME/bin/create_release $HOME/CGAL/branches/CGAL-5.4-branch.git --public --do-it || echo ERROR # from branch 5.3 0 21 * * Sat cd $HOME/CGAL/create_internal_release-5.3-branch && /usr/bin/time scl enable rh-git29 -- $HOME/bin/create_release $HOME/CGAL/branches/CGAL-5.3-branch.git --public --do-it || echo ERROR -# from branch 5.2 -0 21 * * Fri cd $HOME/CGAL/create_internal_release-5.2-branch && /usr/bin/time scl enable rh-git29 -- $HOME/bin/create_release $HOME/CGAL/branches/CGAL-5.2-branch.git --public --do-it || echo ERROR ## Older stuff +# from branch 5.2 +#0 21 * * Fri cd $HOME/CGAL/create_internal_release-5.2-branch && /usr/bin/time scl enable rh-git29 -- $HOME/bin/create_release $HOME/CGAL/branches/CGAL-5.2-branch.git --public --do-it || echo ERROR # from branch 5.1 #0 21 * * Fri cd $HOME/CGAL/create_internal_release-5.1-branch && /usr/bin/time scl enable rh-git29 -- $HOME/bin/create_release $HOME/CGAL/branches/CGAL-5.1-branch.git --public --do-it || echo ERROR # from branch 5.0 diff --git a/Maintenance/public_release/announcement/announcement.md b/Maintenance/public_release/announcement/announcement.md index 4a5f32cada2..e98ad1e27ae 100644 --- a/Maintenance/public_release/announcement/announcement.md +++ b/Maintenance/public_release/announcement/announcement.md @@ -1,93 +1,88 @@ -%The CGAL Open Source Project is pleased to announce the release 5.3 of CGAL, the Computational Geometry Algorithms Library. +The CGAL Open Source Project is pleased to announce the release 5.4 of CGAL, the Computational Geometry Algorithms Library. -Besides fixes and general enhancement to existing packages, the following has changed since CGAL 5.2: +Besides fixes and general enhancement to existing packages, the following has changed since CGAL 5.3: -### [General changes](https://doc.cgal.org/5.3/Manual/general_intro.html) +### [General changes](https://doc.cgal.org/5.4/Manual/general_intro.html) -- The support for the compiled version of CGAL is dropped. Only the header-only version is supported. +- Added the cmake target `CGAL::CGAL_Basic_viewer` to ease the compilation of programs using the basic viewer-based function `CGAL::draw()`. This target will define the macro and link with `CGAL_Qt5` target when linked with it. -- On Windows, the type used for `Exact_rational`, in `Epick` and indirectly (through `Lazy_exact_nt`) - `Epeck` may now be `boost::multiprecision::mpq_rational`, as has been the case on other platforms - for several releases. This depends on various options and is added to a list that includes - `mpq_class`, `CGAL::Gmpq`, `leda_rational` and `CGAL::Quotient`. +- The kernel providing exact constructions and exact predicates ([`CGAL::Exact_predicates_exact_constructions_kernel`](https://doc.cgal.org/5.4/Kernel_23/classCGAL_1_1Exact__predicates__exact__constructions__kernel.html)) is now thread-safe. See changes in `2D and 3D Linear Geometry Kernel` for more details. -### [Quadtrees, Octrees, and Orthtrees](https://doc.cgal.org/5.3/Manual/packages.html#PkgOrthtree) (new package) +- The class `Geomview_stream` and all the dependent features have been removed from CGAL. Those features were actually no longer supported since CGAL-5.3 but it was not properly announced. -- This package implements a tree data structure in which each node encloses a hypercubic section - of space and each non-leave node has hypercubic children whose edge lengths are half its edge length. - Such a data structure is known as a quadtree in 2D, an octree in 3D, and is generalized - as an "orthtree" in higher dimensions. +### [Shape Regularization](https://doc.cgal.org/5.4/Manual/packages.html#PkgShapeRegularization) (new package) -### [Triangulations on the Sphere](https://doc.cgal.org/5.3/Manual/packages.html#PkgTriangulationOnSphere2) (new package) +- This package enables to regularize a set of segments and open or closed contours in 2D and a set of planes in 3D such that all input objects are rotated and aligned with respect to the user-specified conditions. In addition, it provides a global regularization framework that can be adjusted for the user needs and any type of geometric objects. -- This package enables the construction and manipulation of Delaunay triangulations on the 2-sphere. - Triangulations are built incrementally and can be modified by insertion or removal of vertices. - Point location querying and primitives to build the dual Voronoi diagram are provided. +### [Weights](https://doc.cgal.org/5.4/Manual/packages.html#PkgWeights) (new package) -### File Input / Output +- This package provides a simple and unified interface to different types of weights. In particular, it groups all weights into three category: analytic weights including all basic weights which can be computed analytically for a query point with respect to its local neighbors in 2D and 3D; barycentric weights, including all weights which can be computed for a query point with respect to the vertices of a planar polygon; and weighting regions, including all weights which are used to balance other weights. -- Point set, polygon soup, and polygon mesh file I/O functions have been harmonized and documented: - - Point set I/O functions can be found in the packages [Point_set_processing_3](https://doc.cgal.org/5.3/Manual/packages.html#PkgPolygonMeshProcessing), and [Point_set_3](https://doc.cgal.org/5.3/Manual/packages.html#PkgPointSet3). - - Polygon mesh I/O functions can be found in the package [BGL](https://doc.cgal.org/5.3/Manual/packages.html#PkgBGL). - - Polygon soup I/O can be found in the package [Stream_support](https://doc.cgal.org/5.3/Manual/packages.html#PkgStreamSupport). +### [2D Generalized Barycentric Coordinates](https://doc.cgal.org/5.4/Manual/packages.html#PkgBarycentricCoordinates2) (major changes) -A comprehensive list of the supported file formats is available in the Stream_support package -[here](https://doc.cgal.org/5.3/Stream_support/index.html#IOstreamSupportedFormats); -inversely, the following [page](https://doc.cgal.org/5.3/Stream_support/IOStreamSupportedFileFormats.html) -can be used to find out which CGAL data structures can be used given a specific file format. +- **Breaking change**: The headers `Segment_coordinates_2.h` and `Triangle_coordinates_2.h` are renamed to `segment_coordinates_2.h` and `triangle_coordinates_2.h`. +- The classes [`Segment_coordinates_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1Segment__coordinates__2.html) and [`Triangle_coordinates_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1Triangle__coordinates__2.html) are deprecated. The free functions [`compute_segment_coordinates_2()`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1Segment__coordinates__2.html#a134d363dccaeecb5621fa608fac76eaf) and [`compute_triangle_coordinates_2()`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1Triangle__coordinates__2.html#a958fee3ad9613d7bfa9d7a976aa3548f) are deprecated as well. Instead, the free functions [`segment_coordinates_2()`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/group__PkgBarycentricCoordinates2RefFunctions.html#gab856ca68d37f58e6cdf74c8aac6f4245) and [`triangle_coordinates_2()`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/group__PkgBarycentricCoordinates2RefFunctions.html#gaa378786f8996dbcefe7923ebb711e4dd) should be used. +- The enums [`Query_point_location`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/namespaceCGAL_1_1Barycentric__coordinates.html#aedeeb072a2024053a016afd15e591331) and [`Type_of_algorithm`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/namespaceCGAL_1_1Barycentric__coordinates.html#a5e5682512438422f23d6080edc49c05b) are deprecated. Instead, the enum [`Computation_policy_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/namespaceCGAL_1_1Barycentric__coordinates.html#a478bbcec416216b2274ee4b4e97b0e6c) should be used. +- The classes [`Wachspress_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1Wachspress__2.html), [`Discrete_harmonic_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1Discrete__harmonic__2.html), [`Mean_value_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1Mean__value__2.html), and [`Generalized_barycentric_coordinates_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1Generalized__barycentric__coordinates__2.html) are deprecated. As consequence, the concept [`BarycentricCoordinates_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1BarycentricCoordinates__2.html) is deprecated as well. Instead, the classes [`Wachspress_coordinates_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1Wachspress__coordinates__2.html), [`Discrete_harmonic_coordinates_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1Discrete__harmonic__coordinates__2.html), and [`Mean_value_coordinates_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1Mean__value__coordinates__2.html) should be used. +- Added the class [`Harmonic_coordinates_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1Harmonic__coordinates__2.html) to compute approximate harmonic coordinates in 2D. These coordinates satisfy all properties of barycentric coordinates inside any simple polygon. +- Added a new concept [`DiscretizedDomain_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1DiscretizedDomain__2.html) and a model of this concept called [`Delaunay_domain_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1Delaunay__domain__2.html), which is based on the [Mesh 2](https://doc.cgal.org/5.4/Manual/packages.html#PkgMesh2) package. A model of this concept is required to use [`Harmonic_coordinates_2`](https://doc.cgal.org/5.4/Barycentric_coordinates_2/classCGAL_1_1Barycentric__coordinates_1_1Harmonic__coordinates__2.html). +- Added free functions to compute Wachspress, discrete harmonic, and mean value coordinates. +- All free functions and classes are now using ranges and property maps. -### [Requirements](https://doc.cgal.org/5.3/Manual/thirdparty.html) +### [2D and 3D Linear Geometry Kernel](https://doc.cgal.org/5.4/Manual/packages.html#PkgKernel23) -- The CMake minimal version is now `3.14`. -- The GNU compiler g++ versions 6 and 7 are no longer tested. Only version 8.3 or later are supported +- Most operations on [`CGAL::Exact_predicates_exact_constructions_kernel`](https://doc.cgal.org/5.4/Kernel_23/classCGAL_1_1Exact__predicates__exact__constructions__kernel.html) objects are now thread-safe if [`CGAL::Exact_rational`](https://doc.cgal.org/5.4/Number_types/group__nt__cgal.html#ga0849ff44771b19582218ebdfa5614f64) is [`mpq_class`](https://doc.cgal.org/5.3/Number_types/classmpq__class.html) (from `GMPXX`), `boost::multiprecision::mpq_rational` or [`CGAL::Quotient`](https://doc.cgal.org/5.3/Number_types/classCGAL_1_1MP__Float.html). The objects are not atomic though, so the usual restrictions on avoiding race conditions apply. For users who do not use threads, this can be disabled with `CGAL_HAS_NO_THREADS`. -### [2D and 3D Linear Geometry Kernel](https://doc.cgal.org/5.3/Manual/packages.html#PkgKernel23) +- Added documentation for the class [`Projection_traits_3`](https://doc.cgal.org/5.4/Kernel_23/classCGAL_1_1Projection__traits__3.html), which enables the use of 2D algorithms on the projections of 3D data onto an arbitrary plane. -- Added `is_translation()`, `is_scaling()`, `is_reflection()`, and `is_rotation()` to the classes - [`Aff_transformation_2`](https://doc.cgal.org/5.3/Kernel_23/classCGAL_1_1Aff__transformation__2.html) - and [`Aff_transformation_3`](https://doc.cgal.org/5.3/Kernel_23/classCGAL_1_1Aff__transformation__3.html), - which enable determining if the transformations use a specialized representation internally. +- Added `construct_centroid_2_object()` and `compute_determinant_2_object()` in [`Projection_traits_xy_3`](https://doc.cgal.org/5.4/Kernel_23/classCGAL_1_1Projection__traits__xy__3.html), [`Projection_traits_xz_3`](https://doc.cgal.org/5.4/Kernel_23/classCGAL_1_1Projection__traits__xz__3.html), and [`Projection_traits_yz_3`](https://doc.cgal.org/5.4/Kernel_23/classCGAL_1_1Projection__traits__yz__3.html) classes. -### [2D Regularized Boolean Set-Operations](https://doc.cgal.org/5.3/Manual/packages.html#PkgBooleanSetOperations2) -- Added documentation for the free functions [`oriented_side(const Point_2& p, ....)`](https://doc.cgal.org/5.3/Boolean_set_operations_2/group__boolean__oriented__side.html) - that accept a point and a polygon. -- Documentation has been improved across the whole package. +- Added the functor [`NonZeroCoordinateIndex_3`](https://doc.cgal.org/5.4/Kernel_23/classKernel_1_1NonZeroCoordinateIndex__3.html) to the concept [`Kernel`](https://doc.cgal.org/5.4/Kernel_23/classKernel.html) with `int operator()(Vector_3)` which returns the index of any coordinate of the vector different from zero, or `-1`. -### [Polygon Mesh Processing](https://doc.cgal.org/5.3/Manual/packages.html#PkgPolygonMeshProcessing) +### [dD Kernel](https://doc.cgal.org/5.4/Manual/packages.html#PkgKernelD) -- Added the class [`CGAL::Polyhedral_envelope`](https://doc.cgal.org/5.3/Polygon_mesh_processing/structCGAL_1_1Polyhedral__envelope.html), - providing a way to quickly check if a primitive (point, segment, or triangle) - is within a polyhedral envelope around a set of triangles. It is based on the work of - Bolun Wang, Teseo Schneider, Yixin Hu, Marco Attene, and Daniele Panozzo. - "Exact and efficient polyhedral envelope containment check." (ACM Trans. Graph., 39-4, July 2020). -- Added more functions in the [visitor of the corefinement based methods](https://doc.cgal.org/5.3/Polygon_mesh_processing/classPMPCorefinementVisitor.html) - to track all edge creations. +- Most operations on [`Epeck_d`](https://doc.cgal.org/5.4/Kernel_d/structCGAL_1_1Epeck__d.html) objects are now thread-safe, see 2D and 3D Linear Geometry Kernel for details. -### [Surface Mesh Topology](https://doc.cgal.org/5.3/Manual/packages.html#PkgSurfaceMeshTopologySummary) -- Added the function [`CGAL::Surface_mesh_topology::Curves_on_surface_topology::is_homotopic_to_simple_cycle()`](https://doc.cgal.org/5.3/Surface_mesh_topology/classCGAL_1_1Surface__mesh__topology_1_1Curves__on__surface__topology.html#a8d7c4cba2cf2cff542f5cd93117233db), - which can be used to determine whehter a closed path on a surface mesh can be continously - transformed to a cycle without self intersection. +### [2D Arrangements](https://doc.cgal.org/5.4/Manual/packages.html#PkgArrangementOnSurface2) -### [Surface Mesh Simplification](https://doc.cgal.org/5.3/Manual/packages.html#PkgSurfaceMeshSimplification) -- Added a filtering mechanism so that costly tests get only applied to the next candidate for the edge collapse. -- Added the class [`Polyhedral_envelope_filter`](https://doc.cgal.org/5.3/Surface_mesh_simplification/classCGAL_1_1Surface__mesh__simplification_1_1Polyhedral__envelope__filter.html), - which enables to perform mesh simplification inside a polyhedral envelope of the input mesh. +- **Breaking Change:** The traits function objects `Compare_x_at_limit_2` and `Compare_x_near_limit_2` are renamed to `Compare_x_on_boundary_2` and `Compare_x_near_boundary_2`, respectively. -### [2D Polyline Simplification](https://doc.cgal.org/5.3/Manual/packages.html#PkgPolylineSimplification2) -- When polylines have common subsequences of vertices, these subsequences may now be simplifified simultaneously. +- A [new hierarchy of traits concepts](https://doc.cgal.org/5.4/Arrangement_on_surface_2/group__PkgArrangementOnSurface2Concepts.html) has been introduced. It captures all the valid combinations of boundary conditions for the 4 boundary sides of the parameter space. The 4 boundaries are Bottom, Top, Left, and Right. Each boundary side can be either contracted, identified, close, open, or oblivious. Not all possible combinations are valid. If one side is identified then the other must be as well. Two adjacent sides cannot be contracted. -### [dD Triangulations](https://doc.cgal.org/5.3/Manual/packages.html#PkgTriangulations) -- Added the function [`insert_if_in_star()`](https://doc.cgal.org/5.3/Triangulation/classCGAL_1_1Regular__triangulation.html#aa8df2d138f341939e834bcdd7cb6c71a) - to the class [`CGAL::Regular_triangulation`](https://doc.cgal.org/5.3/Triangulation/classCGAL_1_1Regular__triangulation.html), - which enables users to insert a point `p` in a regular triangulation on the condition that `p` - appears post-insertion in the star of a user-specified, existing vertex. +- A new geometric traits, [`Arr_geodesic_arc_on_sphere_traits_2`](https://doc.cgal.org/5.4/Arrangement_on_surface_2/classCGAL_1_1Arr__geodesic__arc__on__sphere__traits__2.html) has been introduced. It handles arcs of great circles embedded on the unit sphere. -### [2D and 3D Alpha Shapes](https://doc.cgal.org/5.3/Manual/packages.html#PkgAlphaShapes2) -- **Breaking change**: The following deprecated classes have been removed: `Alpha_shape_euclidean_traits_2`, - `Weighted_alpha_shape_euclidean_traits_2`, `Alpha_shape_euclidean_traits_3`, and - `Weighted_alpha_shape_euclidean_traits_3`. All CGAL kernel can be used directly as models - of the concepts of the 2D and 3D Alpha Shape packages. +### [2D Regularized Boolean Set-Operations](https://doc.cgal.org/5.4/Manual/packages.html#PkgBooleanSetOperations2) -### [Classification](https://doc.cgal.org/5.3/Manual/packages.html#PkgClassification) -- **Breaking change**: the support for TensorFlow has been dropped; the - classifier `CGAL::TensorFlow::Neural_network_classifier` has been removed. +- Added an extra parameter (`UsePolylines`) to all free functions ( [`complement()`](https://doc.cgal.org/5.4/Boolean_set_operations_2/group__boolean__complement.html), [`do_intersect()`](https://doc.cgal.org/5.4/Boolean_set_operations_2/group__boolean__do__intersect.html), [`intersection()`](https://doc.cgal.org/5.4/Boolean_set_operations_2/group__boolean__intersection.html), [`join()`](https://doc.cgal.org/5.4/Boolean_set_operations_2/group__boolean__join.html), [`difference()`](https://doc.cgal.org/5.4/Boolean_set_operations_2/group__boolean__difference.html), [`symmetric_difference()`](https://doc.cgal.org/5.4/Boolean_set_operations_2/group__boolean__symmetric__difference.html), and [`oriented_side`](https://doc.cgal.org/5.4/Boolean_set_operations_2/group__boolean__oriented__side.html)) to control whether to use `Arr_polyline_traits_2` as default traits. It is the new default as it provides better performances in general. + +### [3D Mesh Generation](https://doc.cgal.org/5.4/Manual/packages.html#PkgMesh3) + +- Added support of weighted images for an improved quality of meshes generated from labeled images, along with a function [`CGAL::Mesh_3::generate_label_weights()`](https://doc.cgal.org/5.4/Mesh_3/namespaceCGAL_1_1Mesh__3.html#ae5914bf77180ff8948c08046154ee727) to generate the weights. + +### [Polygon Mesh Processing](https://doc.cgal.org/5.4/Manual/packages.html#PkgPolygonMeshProcessing) + +- Added the function [`CGAL::Polygon_mesh_processing::match_faces()`](https://doc.cgal.org/5.4/Polygon_mesh_processing/group__measure__grp.html#ga10f7cd81645bafe936ac5eb4e58e67ef), which, given two polygon meshes, identifies their common faces as well as faces present in only either of them. + +- Added the functions: [`CGAL::Polygon_mesh_processing::bounded_error_Hausdorff_distance()`](https://doc.cgal.org/5.4/Polygon_mesh_processing/group__PMP__distance__grp.html#ga6d4ecea831c33ac10eec42b5021fc183) that computes an estimate of the one-sided Hausdorff distance between two triangle meshes which is bounded by a user-specified error bound; [`CGAL::Polygon_mesh_processing::bounded_error_symmetric_Hausdorff_distance()`](https://doc.cgal.org/5.4/Polygon_mesh_processing/group__PMP__distance__grp.html#ga9a7a682b5d9523135c8502e72117dffd) that computes an estimate of the symmetric Hausdorff distance bounded by a user-specified error bound; and [`CGAL::Polygon_mesh_processing::is_Hausdorff_distance_larger()`](https://doc.cgal.org/5.4/Polygon_mesh_processing/group__PMP__distance__grp.html#gab19e751107025a443e86baa9763aebf3) that returns `true` if the bounded-error Hausdorff distance between two meshes is larger than the user-specified max distance. + +- Added the functions [`CGAL::Polygon_mesh_processing::squared_edge_length()`](https://doc.cgal.org/5.4/Polygon_mesh_processing/group__measure__grp.html#ga30fa03722cd7aa599f6dcb115f54fec5) and [`CGAL::Polygon_mesh_processing::squared_face_area()`](https://doc.cgal.org/5.4/Polygon_mesh_processing/group__measure__grp.html#ga6eda3738815fd678df225f79ccfc3e03), which, compared to [`CGAL::Polygon_mesh_processing::edge_length()`](https://doc.cgal.org/5.4/Polygon_mesh_processing/group__measure__grp.html#gae1674775d9fecada7f25710f425cff3a) and [`CGAL::Polygon_mesh_processing::face_area()`](https://doc.cgal.org/5.4/Polygon_mesh_processing/group__measure__grp.html#ga6a1d7a825c09490b1e6613295343482b), enable avoiding square-root operations. + +- Added more functions in the [visitor of the corefinement based methods](https://doc.cgal.org/5.4/Polygon_mesh_processing/classPMPCorefinementVisitor.html) to track all vertex creations. + +- Added an option to [`CGAL::Polygon_mesh_processing::self_intersections()`](https://doc.cgal.org/5.4/Polygon_mesh_processing/group__PMP__intersection__grp.html#gaf19c80ec12cbff7ebe9e69453f1d40b8) to report only a limited number of intersections (`maximum_number()`). + +### [The Heat Method](https://doc.cgal.org/5.4/Manual/packages.html#PkgHeatMethod) + +- **Breaking change**: Added the functor `Compute_squared_length_3` providing `operator(const Vector_3& v)`, which computes the squared length of `v`, to the [`HeatMethodTraits_3`](https://doc.cgal.org/5.4/Heat_method_3/classHeatMethodTraits__3.html) concept. + +### [Point Set Processing](https://doc.cgal.org/5.4/Manual/packages.html#PkgPointSetProcessing3) + +- Added support for [`libpointmatcher::GenericDescriptorOutlierFilter`](https://github.com/ethz-asl/libpointmatcher) that enables providing a map from a point to a weight associated with this point. + +### [Shape Detection](https://doc.cgal.org/5.4/Manual/packages.html#PkgShapeDetection) + +- Added new shapes to the Region Growing algorithm on a point set: circles in 2D, spheres in 3D, and cylinders in 3D. + +### [CGAL and Solvers](https://doc.cgal.org/5.4/Manual/packages.html#PkgSolverInterface) + +- Added support for the [OSQP solver](https://osqp.org/). This solver enables to efficiently compute the convex Quadratic Programming (QP) problems arising in the context of several packages. diff --git a/Maintenance/public_release/announcement/mailing.eml b/Maintenance/public_release/announcement/mailing.eml index 3bb2342f034..e57ba451037 100644 --- a/Maintenance/public_release/announcement/mailing.eml +++ b/Maintenance/public_release/announcement/mailing.eml @@ -1,157 +1,93 @@ -Subject: CGAL 5.3 Released, Computational Geometry Algorithms Library +Subject: CGAL 5.4 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.3 +The CGAL Open Source Project is pleased to announce the release 5.4 of CGAL, the Computational Geometry Algorithms Library. Besides fixes and general enhancement to existing packages, the following -has changed since CGAL 5.2: +has changed since CGAL 5.3: + General changes -- The support for the compiled version of CGAL is dropped. Only the - header-only version is supported. +- Added the cmake target CGAL::CGAL_Basic_viewer to ease the + compilation of programs using the basic viewer-based function + CGAL::draw(). This target will define the macro and link with + CGAL_Qt5 target when linked with it. -- On Windows, the type used for Exact_rational, in Epick and - indirectly (through Lazy_exact_nt) Epeck may now be - boost::multiprecision::mpq_rational, as has been the case on other - platforms for several releases. This depends on various options and - is added to a list that includes mpq_class, CGAL::Gmpq, - leda_rational and CGAL::Quotient. +- The kernel providing exact constructions and exact predicates + (CGAL::Exact_predicates_exact_constructions_kernel) is now + thread-safe. + more details. + +- The class Geomview_stream and all the dependent features have + been removed from CGAL. Those features were actually no longer + supported since CGAL-5.3 but it was not properly announced. -Quadtrees, Octrees, and Orthtrees (new package) +Shape Regularization (new package) -- This package implements a tree data structure in which each node - encloses a hypercubic section of space and each non-leave node has - hypercubic children whose edge lengths are half its edge length. - Such a data structure is known as a quadtree in 2D, an octree in 3D, - and is generalized as an “orthtree” in higher dimensions. +- This package enables to regularize a set of segments and open or + closed contours in 2D and a set of planes in 3D such that all input + objects are rotated and aligned with respect to the user-specified + conditions. In addition, it provides a global regularization + framework that can be adjusted for the user needs and any type of + geometric objects. - https://www.cgal.org/2021/04/27/Orthtree/ + https://www.cgal.org/2021/11/16/shape-regularization/ - https://doc.cgal.org/5.3/Manual/packages.html#PkgOrthtree + https://doc.cgal.org/5.4/Manual/packages.html#PkgShapeRegularization -Triangulations on the Sphere (new package) +Weights (new package) -- This package enables the construction and manipulation of Delaunay - triangulations on the 2-sphere. Triangulations are built - incrementally and can be modified by insertion or removal of - vertices. Point location querying and primitives to build the dual - Voronoi diagram are provided. +- This package provides a simple and unified interface to different + types of weights. In particular, it groups all weights into three + category: analytic weights including all basic weights which can be + computed analytically for a query point with respect to its local + neighbors in 2D and 3D; barycentric weights, including all weights + which can be computed for a query point with respect to the vertices + of a planar polygon; and weighting regions, including all weights + which are used to balance other weights. - https://doc.cgal.org/5.3/Manual/packages.html#PkgTriangulationOnSphere2 + https://doc.cgal.org/5.4/Manual/packages.html#PkgWeights -File Input / Output +2D Generalized Barycentric Coordinates (major changes) -- Point set, polygon soup, and polygon mesh file I/O functions have - been harmonized and documented: - - Point set I/O functions can be found in the packages - Point_set_processing_3, and Point_set_3. - - Polygon mesh I/O functions can be found in the package BGL. - - Polygon soup I/O can be found in the package Stream_support. +- Breaking change: The headers Segment_coordinates_2.h and + Triangle_coordinates_2.h are renamed to segment_coordinates_2.h and + triangle_coordinates_2.h. +- The classes Segment_coordinates_2 and Triangle_coordinates_2 are + deprecated. The free functions compute_segment_coordinates_2() and + compute_triangle_coordinates_2() are deprecated as well. Instead, + the free functions segment_coordinates_2() and + triangle_coordinates_2() should be used. +- The enums Query_point_location and Type_of_algorithm are deprecated. + Instead, the enum Computation_policy_2 should be used. +- The classes Wachspress_2, Discrete_harmonic_2, Mean_value_2, and + Generalized_barycentric_coordinates_2 are deprecated. As + consequence, the concept BarycentricCoordinates_2 is deprecated as + well. Instead, the classes Wachspress_coordinates_2, + Discrete_harmonic_coordinates_2, and Mean_value_coordinates_2 should + be used. +- Added the class Harmonic_coordinates_2 to compute approximate + harmonic coordinates in 2D. These coordinates satisfy all properties + of barycentric coordinates inside any simple polygon. +- Added a new concept DiscretizedDomain_2 and a model of this concept + called Delaunay_domain_2, which is based on the Mesh 2 package. A + model of this concept is required to use Harmonic_coordinates_2. +- Added free functions to compute Wachspress, discrete harmonic, and + mean value coordinates. +- All free functions and classes are now using ranges and property + maps. -A comprehensive list of the supported file formats is available in the -Stream_support package: - - https://doc.cgal.org/5.3/Stream_support/index.html#IOstreamSupportedFormats - -Inversely, the following page can be used to find out which CGAL data -structures can be used given a specific file format. - - https://doc.cgal.org/5.3/Stream_support/IOStreamSupportedFileFormats.html + https://doc.cgal.org/5.4/Manual/packages.html#PkgBarycentricCoordinates2 -Requirements - -- The CMake minimal version is now 3.14. - -- The GNU compiler g++ versions 6 and 7 are no longer tested. Only - version 8.3 or later are supported - - -2D and 3D Linear Geometry Kernel - -- Added is_translation(), is_scaling(), is_reflection(), and - is_rotation() to the classes Aff_transformation_2 and - Aff_transformation_3, which enable determining if the - transformations use a specialized representation internally. - - -2D Regularized Boolean Set-Operations - -- Added documentation for the free functions - oriented_side(const Point_2& p, ....) that accept a point and a - polygon. -- Documentation has been improved across the whole package. - - -Polygon Mesh Processing - -- Added the class CGAL::Polyhedral_envelope, providing a way to - quickly check if a primitive (point, segment, or triangle) is within - a polyhedral envelope around a set of triangles. It is based on the - work of Bolun Wang, Teseo Schneider, Yixin Hu, Marco Attene, and - Daniele Panozzo. “Exact and efficient polyhedral envelope - containment check.” (ACM Trans. Graph., 39-4, July 2020). -- Added more functions in the visitor of the corefinement based - methods to track all edge creations. - - -Surface Mesh Topology - -- Added the function - CGAL::Surface_mesh_topology::Curves_on_surface_topology::is_homotopic_to_simple_cycle(), - which can be used to determine whehter a closed path on a surface - mesh can be continously transformed to a cycle without self - intersection. - - -Surface Mesh Simplification - -- Added a filtering mechanism so that costly tests get only applied to - the next candidate for the edge collapse. -- Added the class Polyhedral_envelope_filter, which enables to perform - mesh simplification inside a polyhedral envelope of the input mesh. - - -2D Polyline Simplification - -- When polylines have common subsequences of vertices, these - subsequences may now be simplifified simultaneously. - - -dD Triangulations - -- Added the function insert_if_in_star() to the class - CGAL::Regular_triangulation, which enables users to insert a point p - in a regular triangulation on the condition that p appears - post-insertion in the star of a user-specified, existing vertex. - - -2D and 3D Alpha Shapes - -- Breaking change: The following deprecated classes have been removed: - Alpha_shape_euclidean_traits_2, - Weighted_alpha_shape_euclidean_traits_2, - Alpha_shape_euclidean_traits_3, and - Weighted_alpha_shape_euclidean_traits_3. All CGAL kernel can be used - directly as models of the concepts of the 2D and 3D Alpha Shape - packages. - - -Classification - -- Breaking change: the support for TensorFlow has been dropped; the - classifier CGAL::TensorFlow::Neural_network_classifier has been - removed. - - -See https://www.cgal.org/2021/07/06/cgal53/ for a +See https://www.cgal.org/2022/01/31/cgal54/ for a complete list of changes. diff --git a/Mesh_2/test/Mesh_2/test_lipschitz.cpp b/Mesh_2/test/Mesh_2/test_lipschitz.cpp index c600a9868b9..9bd5894489a 100644 --- a/Mesh_2/test/Mesh_2/test_lipschitz.cpp +++ b/Mesh_2/test/Mesh_2/test_lipschitz.cpp @@ -1,3 +1,4 @@ +#include #include "test_dependencies.h" // and additionally @@ -28,6 +29,6 @@ int main() CGAL::Lipschitz_sizing_field_2 lip_size(cdt); lip_size.set_K(2.); - CGAL_assertion(lip_size.get_K() == 2.); + assert(lip_size.get_K() == 2.); } diff --git a/Mesh_2/test/Mesh_2/test_lloyd.cpp b/Mesh_2/test/Mesh_2/test_lloyd.cpp index a07c417cc06..005464fa2dd 100644 --- a/Mesh_2/test/Mesh_2/test_lloyd.cpp +++ b/Mesh_2/test/Mesh_2/test_lloyd.cpp @@ -40,7 +40,7 @@ struct Lloyd_tester std::cerr << "Reading fish-and-rectangle.poly..."; std::ifstream poly_file("fish-and-rectangle.poly"); CGAL::IO::read_triangle_poly_file(cdt, poly_file, std::back_inserter(seeds)); - CGAL_assertion( cdt.is_valid() ); + assert( cdt.is_valid() ); std::cerr << " done.\nNumber of vertices: " << cdt.number_of_vertices() << "\nNumber of seeds: " << seeds.size() << "\n\n"; @@ -50,14 +50,13 @@ struct Lloyd_tester seeds.begin(), seeds.end(), Criteria(0.125, 0.1)); std::cerr << " done.\nNumber of vertices: " << cdt.number_of_vertices() << "\n\n"; - CGAL_assertion( cdt.is_valid() ); - CGAL_assertion( 580 <= cdt.number_of_vertices() && + assert( cdt.is_valid() ); + assert( 580 <= cdt.number_of_vertices() && cdt.number_of_vertices() <= 640 ); - CGAL_assertion_code( - const size_type number_of_constraints = number_of_constrained_edges(cdt)); - CGAL_assertion_code( - const size_type number_of_vertices1 = cdt.number_of_vertices()); + + const size_type number_of_constraints = number_of_constrained_edges(cdt); + const size_type number_of_vertices1 = cdt.number_of_vertices(); CGAL::Mesh_optimization_return_code rc = CGAL::lloyd_optimize_mesh_2(cdt, @@ -70,9 +69,9 @@ struct Lloyd_tester std::cerr << " done (return code = "<< rc <<").\n"; std::cerr << "Number of vertices: " << number_of_vertices2 << "\n\n"; - CGAL_assertion( cdt.is_valid() ); - CGAL_assertion( number_of_vertices1 == number_of_vertices2 ); - CGAL_assertion( number_of_constraints == number_of_constrained_edges(cdt)); + assert( cdt.is_valid() ); + assert( number_of_vertices1 == number_of_vertices2 ); + assert( number_of_constraints == number_of_constrained_edges(cdt)); } }; diff --git a/Mesh_3/doc/Mesh_3/CGAL/Mesh_complex_3_in_triangulation_3.h b/Mesh_3/doc/Mesh_3/CGAL/Mesh_complex_3_in_triangulation_3.h index d46c9ea2b83..fad13d11a51 100644 --- a/Mesh_3/doc/Mesh_3/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/Mesh_3/doc/Mesh_3/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -74,6 +74,24 @@ typedef CurveIndex Curve_index; /// \name Operations /// @{ +/*! + The tetrahedral mesh generation algorithm implemented in `CGAL::make_mesh_3()` + and `CGAL::refine_mesh_3()` does not guarantee that all the points inserted + by the algorithm are actually present in the final mesh. + + In most cases, all points are used, but if the geometry of the object + has small features, compared to the size of the simplices (triangles and tetrahedra), + it might be that the Delaunay facets that are selected in the restricted Delaunay + triangulation miss some vertices of the triangulation. + The concurrent version of the tetrahedral mesh generation algorithm + also inserts a small set of auxiliary vertices that belong to the triangulation + but are isolated from the complex at the end of the meshing process. + + This function removes these so-called \em isolated vertices, that belong to the + triangulation but not to any cell of the `C3T3`, from the triangulation. +*/ +void remove_isolated_vertices(); + /*! Outputs the mesh to `os` in medit format. diff --git a/Mesh_3/doc/Mesh_3/Mesh_3.txt b/Mesh_3/doc/Mesh_3/Mesh_3.txt index 08e82efd875..d2776ca6730 100644 --- a/Mesh_3/doc/Mesh_3/Mesh_3.txt +++ b/Mesh_3/doc/Mesh_3/Mesh_3.txt @@ -282,6 +282,23 @@ optimization processes. Compared effect of a global optimizer and the perturber. The left part shows the distribution of dihedral angles of mesh cells, right after Delaunay refinement (top), after some ODT smoothing (middle) and after perturbation (bottom). The numbers under the histograms give the measure in degrees of the smallest and biggest dihedral angles in the mesh. \cgalFigureEnd +\subsection Mesh_3PostProcessing Post-processing + +The tetrahedral mesh generation algorithm by Delaunay refinement provided by this package +does not guarantee that all the vertices of the output mesh are actually present in the final mesh. + +In most cases, all points are used, but if the geometry of the object +has small features, compared to the size of the simplices (triangles and tetrahedra), +it might be that the Delaunay facets that are selected in the restricted Delaunay +triangulation miss some vertices of the triangulation. +The concurrent version of the tetrahedral mesh generation algorithm +also inserts a small set of auxiliary vertices that belong to the triangulation +but are isolated from the complex at the end of the meshing process. + +These so-called \em isolated vertices belong to the triangulation but not to any cell +of the `C3T3`. They can be removed using the function `remove_isolated_vertices()`. + + \section Mesh_3_section_interface Interface \subsection Mesh_3TheGlobalFunctions The Global Functions diff --git a/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex.cpp b/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex.cpp index d87fd6bd85c..134092b3fba 100644 --- a/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex.cpp @@ -8,6 +8,7 @@ #include #include +#include // Domain typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -54,8 +55,7 @@ const std::pair incident_subdomains[] = { int main() { const std::size_t nb_patches = sizeof(filenames) / sizeof(const char*); - CGAL_assertion(sizeof(incident_subdomains) == - nb_patches * sizeof(std::pair)); + assert(sizeof(incident_subdomains) == nb_patches * sizeof(std::pair)); std::vector patches(nb_patches); for(std::size_t i = 0; i < nb_patches; ++i) { std::ifstream input(CGAL::data_file_path(filenames[i])); diff --git a/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex_sm.cpp b/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex_sm.cpp index 025870f6cbc..789b5737892 100644 --- a/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex_sm.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex_sm.cpp @@ -9,6 +9,7 @@ #include #include #include +#include // Domain typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -63,8 +64,8 @@ int main() #endif const std::size_t nb_patches = sizeof(filenames) / sizeof(const char*); - CGAL_assertion(sizeof(incident_subdomains) == - nb_patches * sizeof(std::pair)); + assert(sizeof(incident_subdomains) == + nb_patches * sizeof(std::pair)); std::vector patches(nb_patches); for(std::size_t i = 0; i < nb_patches; ++i) { std::ifstream input(CGAL::data_file_path(filenames[i])); 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 8177abbade4..adf53d159c5 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h @@ -81,7 +81,7 @@ protected: typedef unsigned int Nb_frozen_points_type; Mesh_global_optimizer_base(const Bbox_3 &, int) - : big_moves_size_(0) {} + : nb_frozen_points_(0), big_moves_size_(0) {} void update_big_moves(const FT& new_sq_move) { @@ -106,7 +106,16 @@ protected: Lock_data_structure *get_lock_data_structure() { return 0; } void unlock_all_elements() {} + + // Workaround for problem with VC and /permissive + // See: https://gist.github.com/afabri/0416bebec1c32fb4efd6632446698972 + void increment_frozen_points() const + { + ++nb_frozen_points_; + } + protected: + mutable unsigned int nb_frozen_points_; std::size_t big_moves_size_; std::multiset big_moves_; }; @@ -116,6 +125,7 @@ protected: template class Mesh_global_optimizer_base { + protected: typedef typename Tr::Geom_traits Gt; typedef typename Gt::FT FT; @@ -126,7 +136,7 @@ protected: typedef std::atomic Nb_frozen_points_type ; Mesh_global_optimizer_base(const Bbox_3 &bbox, int num_grid_cells_per_axis) - : big_moves_size_(0) + : nb_frozen_points_(0), big_moves_size_(0) , m_lock_ds(bbox, num_grid_cells_per_axis) { big_moves_current_size_ = 0; @@ -183,9 +193,14 @@ protected: m_lock_ds.unlock_all_points_locked_by_this_thread(); } + void increment_frozen_points() const + { + ++nb_frozen_points_; + } public: protected: + mutable std::atomic nb_frozen_points_; std::atomic big_moves_current_size_; std::atomic big_moves_smallest_; std::size_t big_moves_size_; @@ -221,6 +236,8 @@ class Mesh_global_optimizer using Base::get_lock_data_structure; using Base::big_moves_; using Base::big_moves_size_; + using Base::nb_frozen_points_; + using Base::increment_frozen_points; typedef typename C3T3::Triangulation Tr; typedef typename Tr::Geom_traits Gt; @@ -240,7 +257,6 @@ class Mesh_global_optimizer typedef Hash_handles_with_or_without_timestamps Hash_fct; typedef typename boost::unordered_set Vertex_set; typedef typename Base::Moves_vector Moves_vector; - typedef typename Base::Nb_frozen_points_type Nb_frozen_points_type; #ifdef CGAL_INTRUSIVE_LIST typedef Intrusive_list Outdated_cell_set; @@ -566,7 +582,6 @@ private: CGAL::Real_timer running_time_; bool do_freeze_; - mutable Nb_frozen_points_type nb_frozen_points_; #ifdef CGAL_MESH_3_OPTIMIZER_VERBOSE mutable FT sum_moves_; @@ -602,8 +617,6 @@ Mesh_global_optimizer(C3T3& c3t3, , sum_moves_(0) #endif // CGAL_MESH_3_OPTIMIZER_VERBOSE { - nb_frozen_points_ = 0; // We put it here in case it's an "atomic" - // If we're multi-thread tr_.set_lock_data_structure(get_lock_data_structure()); @@ -906,7 +919,7 @@ compute_move(const Vertex_handle& v) // Move point only if the displacement is big enough w.r.t. the local size if ( local_move_sq_ratio < sq_freeze_ratio_ ) { - ++nb_frozen_points_; + increment_frozen_points(); return CGAL::NULL_VECTOR; } @@ -962,7 +975,7 @@ update_mesh(const Moves_vector& moves, FT size = std::get<2>(*it); #ifdef CGAL_MESH_3_OPTIMIZER_VERBOSE - std::cout << "Moving #" << it - moves.begin() + std::cerr << "Moving #" << it - moves.begin() << " addr: " << &*v << " pt: " << tr_.point(v) << " move: " << move << std::endl; diff --git a/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h b/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h index aaa82040a83..483c96be347 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h +++ b/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h @@ -57,14 +57,7 @@ #endif #include -#ifdef CGAL_MESH_3_USE_RELAXED_HEAP -# error This option CGAL_MESH_3_USE_RELAXED_HEAP is no longer supported -// The reason is that the Boost relaxed heap does not ensure a strict order -// of the priority queue. -#include -#else #include -#endif //CGAL_MESH_3_USE_RELAXED_HEAP #include #include @@ -507,11 +500,8 @@ private: }; typedef std::less less_PVertex; - #ifdef CGAL_MESH_3_USE_RELAXED_HEAP - typedef boost::relaxed_heap PQueue; - #else - typedef ::CGAL::internal::mutable_queue_with_remove, less_PVertex, PVertex_id> PQueue; - #endif //CGAL_MESH_3_USE_RELAXED_HEAP + typedef Modifiable_priority_queue PQueue; + public: /** @@ -942,10 +932,9 @@ perturb(const FT& sliver_bound, PQueue& pqueue, Visitor& visitor) const { this->create_task_group(); - while (pqueue.size() > 0) + while (!pqueue.empty()) { - PVertex pv = pqueue.top(); - pqueue.pop(); + PVertex pv = pqueue.top_and_pop(); enqueue_task(pv, sliver_bound, visitor, bad_vertices); } @@ -977,8 +966,7 @@ perturb(const FT& sliver_bound, PQueue& pqueue, Visitor& visitor) const while ( !is_time_limit_reached() && !pqueue.empty() ) { // Get pqueue head - PVertex pv = pqueue.top(); - pqueue.pop(); + PVertex pv = pqueue.top_and_pop(); --pqueue_size; CGAL_assertion(pv.is_perturbable()); @@ -1245,7 +1233,7 @@ update_priority_queue(const PVertex& pv, PQueue& pqueue) const } else { - pqueue.remove(pv); + pqueue.erase(pv); return -1; } } diff --git a/Mesh_3/include/CGAL/Mesh_3/experimental/Get_facet_patch_id.h b/Mesh_3/include/CGAL/Mesh_3/experimental/Get_facet_patch_id.h index 926cad5a1aa..a7acb042d45 100644 --- a/Mesh_3/include/CGAL/Mesh_3/experimental/Get_facet_patch_id.h +++ b/Mesh_3/include/CGAL/Mesh_3/experimental/Get_facet_patch_id.h @@ -22,7 +22,9 @@ namespace CGAL { namespace Mesh_3 { // backward compatibility with user code template -using Get_facet_patch_id_sm = Facet_patch_id_map; +using Get_facet_patch_id_sm + = Facet_patch_id_map; }} // end namespace CGAL::Mesh_3 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 a2553333dc1..0973865378f 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 @@ -104,7 +104,7 @@ private: #ifdef CGAL_MESH_3_EXPERIMENTAL_USE_PATCHES_IDS //help to accelerate aabb_tree queries in m_ptree - std::shared_ptr m_kd_tree; + mutable std::shared_ptr m_kd_tree; Facet_patch_id_map m_facet_patch_id_map; const Patches_ids_map& patches_ids_map; @@ -387,7 +387,7 @@ private: } #ifdef CGAL_MESH_3_EXPERIMENTAL_USE_PATCHES_IDS - void kd_tree() + void kd_tree() const { typedef typename MeshDomain::Polyhedron Polyhedron; if(m_kd_tree.get() == 0) { diff --git a/Mesh_3/include/CGAL/Mesh_3/parameters_defaults.h b/Mesh_3/include/CGAL/Mesh_3/parameters_defaults.h index 67b43f0d995..e9f06c9c590 100644 --- a/Mesh_3/include/CGAL/Mesh_3/parameters_defaults.h +++ b/Mesh_3/include/CGAL/Mesh_3/parameters_defaults.h @@ -24,7 +24,7 @@ #include namespace CGAL { -namespace parameters { namespace default_values { +namespace parameters { namespace default_values_for_mesh_3 { // exude_mesh_3 const double exude_sliver_bound = 0.; @@ -51,7 +51,7 @@ const double lloyd_convergence_ratio = 0.02; const double odt_freeze_ratio = 0.01; const double odt_convergence_ratio = 0.02; -} } // end namespace parameters::default_values +} } // end namespace parameters::default_values_for_mesh_3 } // end namespace CGAL #endif // CGAL_MESH_3_PARAMETERS_DEFAULTS_H 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 4ccf832bff7..b887a6b6223 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 @@ -229,49 +229,107 @@ public: far_vertices_.push_back(vh); } + void remove_isolated_vertex(Vertex_handle v) + { + Triangulation& tr = triangulation(); + + std::vector new_cells; + new_cells.reserve(32); + tr.remove_and_give_new_cells(v, std::back_inserter(new_cells)); + + typename std::vector::iterator nc_it = new_cells.begin(); + typename std::vector::iterator nc_it_end = new_cells.end(); + for (; nc_it != nc_it_end; ++nc_it) + { + Cell_handle c = *nc_it; + for (int i = 0; i < 4; ++i) + { + Facet mirror_facet = tr.mirror_facet(std::make_pair(c, i)); + if (is_in_complex(mirror_facet)) + { + set_surface_patch_index(c, i, + surface_patch_index(mirror_facet)); + c->set_facet_surface_center(i, + mirror_facet.first->get_facet_surface_center(mirror_facet.second)); + } + } + /*int i_inf; + if (c->has_vertex(tr.infinite_vertex(), i_inf)) + { + Facet mirror_facet = tr.mirror_facet(std::make_pair(c, i_inf)); + if (is_in_complex(mirror_facet)) + { + set_surface_patch_index(c, i_inf, + surface_patch_index(mirror_facet)); + } + }*/ + } + } + void remove_far_points() { - Triangulation &tr = triangulation(); //triangulation().remove(far_vertices_.begin(), far_vertices_.end()); typename Far_vertices_vec::const_iterator it = far_vertices_.begin(); typename Far_vertices_vec::const_iterator it_end = far_vertices_.end(); for ( ; it != it_end ; ++it) { - std::vector new_cells; - new_cells.reserve(32); - tr.remove_and_give_new_cells(*it, std::back_inserter(new_cells)); - - typename std::vector::iterator nc_it = new_cells.begin(); - typename std::vector::iterator nc_it_end = new_cells.end(); - for ( ; nc_it != nc_it_end ; ++nc_it) - { - Cell_handle c = *nc_it; - for (int i = 0 ; i < 4 ; ++i) - { - Facet mirror_facet = tr.mirror_facet(std::make_pair(c, i)); - if (is_in_complex(mirror_facet)) - { - set_surface_patch_index(c, i, - surface_patch_index(mirror_facet)); - c->set_facet_surface_center(i, - mirror_facet.first->get_facet_surface_center(mirror_facet.second)); - } - } - /*int i_inf; - if (c->has_vertex(tr.infinite_vertex(), i_inf)) - { - Facet mirror_facet = tr.mirror_facet(std::make_pair(c, i_inf)); - if (is_in_complex(mirror_facet)) - { - set_surface_patch_index(c, i_inf, - surface_patch_index(mirror_facet)); - } - }*/ - } + remove_isolated_vertex(*it); } far_vertices_.clear(); } + void remove_isolated_vertices() + { + Triangulation& tr = triangulation(); + for (Vertex_handle v : tr.finite_vertex_handles()) + v->set_meshing_info(0); + + for (typename Base::Cells_in_complex_iterator c = this->cells_in_complex_begin(); + c != this->cells_in_complex_end(); + ++c) + { + for (int i = 0; i < 4; ++i) + { + Vertex_handle vi = c->vertex(i); + vi->set_meshing_info(vi->meshing_info() + 1); + } + } + + for (typename Base::Facets_in_complex_iterator fit = this->facets_in_complex_begin(); + fit != this->facets_in_complex_end(); + ++fit) + { + Facet f = *fit; + for (int i = 1; i < 4; ++i) + { + Vertex_handle vi = f.first->vertex((f.second + i) % 4); + vi->set_meshing_info(vi->meshing_info() + 1); + } + } + + std::vector isolated; + for (Vertex_handle v : tr.finite_vertex_handles()) + { + if (v->meshing_info() == 0.) + isolated.push_back(v); + } + +#ifdef CGAL_MESH_3_VERBOSE + std::cout << "Remove " << isolated.size() << " isolated vertices..."; + std::cout.flush(); +#endif + + CGAL_assertion(far_vertices_.size() <= isolated.size()); + far_vertices_.clear(); + + for (Vertex_handle v : isolated) + remove_isolated_vertex(v); + +#ifdef CGAL_MESH_3_VERBOSE + std::cout << "\nRemove " << isolated.size() << " isolated vertices done." << std::endl; +#endif + } + /** * Returns the number of edges of c3t3 */ diff --git a/Mesh_3/include/CGAL/Mesh_triangulation_3.h b/Mesh_3/include/CGAL/Mesh_triangulation_3.h index 8d97e0696fe..68e168b6e00 100644 --- a/Mesh_3/include/CGAL/Mesh_triangulation_3.h +++ b/Mesh_3/include/CGAL/Mesh_triangulation_3.h @@ -154,7 +154,6 @@ private: Concurrency_tag> {}; using Triangulation = Mesh_3_regular_triangulation_3_wrapper; - ; public: using type = Triangulation; diff --git a/Mesh_3/include/CGAL/Polyhedral_complex_mesh_domain_3.h b/Mesh_3/include/CGAL/Polyhedral_complex_mesh_domain_3.h index e7f5d308f2f..17e69ff984c 100644 --- a/Mesh_3/include/CGAL/Polyhedral_complex_mesh_domain_3.h +++ b/Mesh_3/include/CGAL/Polyhedral_complex_mesh_domain_3.h @@ -100,12 +100,12 @@ with a model of the concept `IntersectionGeometricTraits_3`. \sa `CGAL::Mesh_polyhedron_3` */ template < class IGT_, - class Polyhedron = typename Mesh_polyhedron_3::type, + class Polyhedron_ = typename Mesh_polyhedron_3::type, class TriangleAccessor=CGAL::Default > class Polyhedral_complex_mesh_domain_3 : public Mesh_domain_with_polyline_features_3< - Polyhedral_mesh_domain_3< Polyhedron, + Polyhedral_mesh_domain_3< Polyhedron_, IGT_, CGAL::Default, int, //Use_patch_id_tag @@ -113,6 +113,7 @@ class Polyhedral_complex_mesh_domain_3 { public: /// The base class + typedef Polyhedron_ Polyhedron; typedef Mesh_domain_with_polyline_features_3< Polyhedral_mesh_domain_3< Polyhedron, IGT_, CGAL::Default, @@ -123,21 +124,6 @@ private: typedef Polyhedral_mesh_domain_3 BaseBase; typedef Polyhedral_complex_mesh_domain_3 Self; - -protected: - typedef typename Base::Surface_patch_index Patch_id; - typedef typename boost::property_map - >::type VIPMap; - typedef typename boost::property_traits::value_type Set_of_indices; - - typedef boost::adjacency_list< - boost::setS, // this avoids parallel edges - boost::vecS, - boost::undirectedS, - typename IGT::Point_3, - Set_of_indices> Featured_edges_copy_graph; - /// @endcond public: @@ -167,6 +153,7 @@ public: typedef typename Base::AABB_tree AABB_tree; typedef typename Base::AABB_primitive AABB_primitive; typedef typename Base::AABB_primitive_id AABB_primitive_id; + typedef typename Base::Surface_patch_index Patch_id; // Backward compatibility #ifndef CGAL_MESH_3_NO_DEPRECATED_SURFACE_INDEX typedef Surface_patch_index Surface_index; @@ -180,8 +167,23 @@ public: typedef std::vector Bare_polyline; typedef Mesh_3::Polyline_with_context Polyline_with_context; + +protected: + typedef typename boost::property_map + >::type VIPMap; + typedef typename boost::property_traits::value_type Set_of_indices; + + typedef boost::adjacency_list< + boost::setS, // this avoids parallel edges + boost::vecS, + boost::undirectedS, + typename IGT::Point_3, + Set_of_indices> Featured_edges_copy_graph; + /// @endcond +public: /// Constructor /*! Constructs a domain defined by a set of polyhedral surfaces, describing a polyhedral complex. @@ -766,10 +768,10 @@ detect_features(FT angle_in_degree, nb_of_patch_plus_one +=PMP::sharp_edges_segmentation(p, angle_in_degree , eif , pid_map - , PMP::parameters::first_index(nb_of_patch_plus_one) - .face_index_map(get_initialized_face_index_map(p)) - .vertex_incident_patches_map(vip_map) - .vertex_feature_degree_map(vertex_feature_degree_map)); + , CGAL::parameters::first_index(nb_of_patch_plus_one) + .face_index_map(get_initialized_face_index_map(p)) + .vertex_incident_patches_map(vip_map) + .vertex_feature_degree_map(vertex_feature_degree_map)); Mesh_3::internal::Is_featured_edge is_featured_edge(p); 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 92d85005330..e6d5622abd2 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 @@ -399,9 +399,9 @@ detect_features(FT angle_in_degree, std::vector& poly) nb_of_patch_plus_one += PMP::sharp_edges_segmentation(p, angle_in_degree , eif_map , pid_map - , PMP::parameters::first_index(nb_of_patch_plus_one) - .face_index_map(get_initialized_face_index_map(p)) - .vertex_incident_patches_map(vip_map)); + , CGAL::parameters::first_index(nb_of_patch_plus_one) + .face_index_map(get_initialized_face_index_map(p)) + .vertex_incident_patches_map(vip_map)); Mesh_3::internal::Is_featured_edge is_featured_edge(p); diff --git a/Mesh_3/include/CGAL/exude_mesh_3.h b/Mesh_3/include/CGAL/exude_mesh_3.h index 4d02d12e8de..3d9cb841b7c 100644 --- a/Mesh_3/include/CGAL/exude_mesh_3.h +++ b/Mesh_3/include/CGAL/exude_mesh_3.h @@ -48,7 +48,7 @@ BOOST_PARAMETER_FUNCTION( (required (in_out(c3t3),*) ) (optional (time_limit_, *, 0 ) - (sliver_bound_, *, parameters::default_values::exude_sliver_bound ) + (sliver_bound_, *, parameters::default_values_for_mesh_3::exude_sliver_bound ) ) ) { diff --git a/Mesh_3/include/CGAL/lloyd_optimize_mesh_3.h b/Mesh_3/include/CGAL/lloyd_optimize_mesh_3.h index c7918967974..8b3ec746e76 100644 --- a/Mesh_3/include/CGAL/lloyd_optimize_mesh_3.h +++ b/Mesh_3/include/CGAL/lloyd_optimize_mesh_3.h @@ -51,9 +51,9 @@ BOOST_PARAMETER_FUNCTION( (optional (time_limit_, *, 0 ) (max_iteration_number_, *, 0 ) - (convergence_, *, parameters::default_values::lloyd_convergence_ratio ) - (freeze_bound_, *, parameters::default_values::lloyd_freeze_ratio ) - (do_freeze_, *, parameters::default_values::do_freeze )) + (convergence_, *, parameters::default_values_for_mesh_3::lloyd_convergence_ratio ) + (freeze_bound_, *, parameters::default_values_for_mesh_3::lloyd_freeze_ratio ) + (do_freeze_, *, parameters::default_values_for_mesh_3::do_freeze )) ) { return lloyd_optimize_mesh_3_impl(c3t3, domain, diff --git a/Mesh_3/include/CGAL/odt_optimize_mesh_3.h b/Mesh_3/include/CGAL/odt_optimize_mesh_3.h index a195ee23d5d..a08d1154717 100644 --- a/Mesh_3/include/CGAL/odt_optimize_mesh_3.h +++ b/Mesh_3/include/CGAL/odt_optimize_mesh_3.h @@ -51,9 +51,9 @@ BOOST_PARAMETER_FUNCTION( (optional (time_limit_, *, 0 ) (max_iteration_number_, *, 0 ) - (convergence_, *, parameters::default_values::odt_convergence_ratio ) - (freeze_bound_, *, parameters::default_values::odt_freeze_ratio ) - (do_freeze_, *, parameters::default_values::do_freeze )) + (convergence_, *, parameters::default_values_for_mesh_3::odt_convergence_ratio ) + (freeze_bound_, *, parameters::default_values_for_mesh_3::odt_freeze_ratio ) + (do_freeze_, *, parameters::default_values_for_mesh_3::do_freeze )) ) { return odt_optimize_mesh_3_impl(c3t3, domain, diff --git a/Mesh_3/include/CGAL/perturb_mesh_3.h b/Mesh_3/include/CGAL/perturb_mesh_3.h index 0e4168aab30..669fad1dfb0 100644 --- a/Mesh_3/include/CGAL/perturb_mesh_3.h +++ b/Mesh_3/include/CGAL/perturb_mesh_3.h @@ -52,9 +52,9 @@ BOOST_PARAMETER_FUNCTION( (required (in_out(c3t3),*) (domain,*) ) (optional (time_limit_, *, 0 ) - (sliver_bound_, *, parameters::default_values::perturb_sliver_bound ) + (sliver_bound_, *, parameters::default_values_for_mesh_3::perturb_sliver_bound ) (sliver_criterion_, *, - parameters::default_values::default_sliver_criterion(c3t3,sliver_bound_)) + parameters::default_values_for_mesh_3::default_sliver_criterion(c3t3,sliver_bound_)) (perturbation_vector_, *, default_perturbation_vector(c3t3,domain,sliver_criterion_)) ) diff --git a/Mesh_3/include/CGAL/refine_mesh_3.h b/Mesh_3/include/CGAL/refine_mesh_3.h index acbf847b26b..0c1e550f41e 100644 --- a/Mesh_3/include/CGAL/refine_mesh_3.h +++ b/Mesh_3/include/CGAL/refine_mesh_3.h @@ -254,7 +254,7 @@ CGAL_IGNORE_BOOST_PARAMETER_NAME_WARNINGS // ----------------------------------- BOOST_PARAMETER_FUNCTION((internal::Perturb_options), perturb, tag, (optional (time_limit_, *, internal::undef_parameter ) - (sliver_bound_, *, default_values::perturb_sliver_bound ))) + (sliver_bound_, *, default_values_for_mesh_3::perturb_sliver_bound ))) { internal::Perturb_options options(true); @@ -273,7 +273,7 @@ inline internal::Perturb_options no_perturb() { return internal::Perturb_options // ----------------------------------- BOOST_PARAMETER_FUNCTION((internal::Exude_options), exude, tag, (optional (time_limit_, *, internal::undef_parameter ) - (sliver_bound_, *, default_values::exude_sliver_bound ))) + (sliver_bound_, *, default_values_for_mesh_3::exude_sliver_bound ))) { internal::Exude_options options(true); @@ -293,8 +293,8 @@ inline internal::Exude_options no_exude() { return internal::Exude_options(false BOOST_PARAMETER_FUNCTION((internal::Odt_options), odt, tag, (optional (time_limit_, *, 0 ) (max_iteration_number_, *, 0 ) - (convergence_, *, default_values::odt_convergence_ratio ) - (freeze_bound_, *, default_values::odt_freeze_ratio ))) + (convergence_, *, default_values_for_mesh_3::odt_convergence_ratio ) + (freeze_bound_, *, default_values_for_mesh_3::odt_freeze_ratio ))) { internal::Odt_options options(true); @@ -314,8 +314,8 @@ inline internal::Odt_options no_odt() { return internal::Odt_options(false); } BOOST_PARAMETER_FUNCTION((internal::Lloyd_options), lloyd, tag, (optional (time_limit_, *, 0 ) (max_iteration_number_, *, 0 ) - (convergence_, *, default_values::lloyd_convergence_ratio ) - (freeze_bound_, *, default_values::lloyd_freeze_ratio ))) + (convergence_, *, default_values_for_mesh_3::lloyd_convergence_ratio ) + (freeze_bound_, *, default_values_for_mesh_3::lloyd_freeze_ratio ))) { internal::Lloyd_options options(true); diff --git a/Mesh_3/include/CGAL/remove_far_points_in_mesh_3.h b/Mesh_3/include/CGAL/remove_far_points_in_mesh_3.h index 283111d9533..66c4121c1f0 100644 --- a/Mesh_3/include/CGAL/remove_far_points_in_mesh_3.h +++ b/Mesh_3/include/CGAL/remove_far_points_in_mesh_3.h @@ -71,6 +71,21 @@ private: } // namespace Mesh_3 +/*! +\ingroup PkgMesh3Functions + +The concurrent version of the tetrahedral mesh generation algorithm implemented in +`CGAL::make_mesh_3()` and `CGAL::refine_mesh_3()` inserts a small set of +auxiliary vertices that belong to the triangulation but are isolated from the complex +at the end of the meshing process. + +This function removes these so called "far points" from `c3t3.triangulation()`, +without modifying the mesh complex. + +\tparam C3T3 is required to be a model of the concept `MeshComplex_3InTriangulation_3`. +The argument `c3t3` is passed by +reference as its underlying triangulation is modified by the function. +*/ template void remove_far_points_in_mesh_3(C3T3& c3t3) diff --git a/Mesh_3/test/Mesh_3/test_c3t3_into_facegraph.cpp b/Mesh_3/test/Mesh_3/test_c3t3_into_facegraph.cpp index 9a953580e1b..05ea8149ca6 100644 --- a/Mesh_3/test/Mesh_3/test_c3t3_into_facegraph.cpp +++ b/Mesh_3/test/Mesh_3/test_c3t3_into_facegraph.cpp @@ -12,6 +12,7 @@ #include #include +#include int main (int argc, char** argv){ typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -49,7 +50,7 @@ int main (int argc, char** argv){ cit != c3t3.triangulation().finite_cells_end(); ++cit) { - CGAL_assertion(cit->subdomain_index() >= 0); + assert(cit->subdomain_index() >= 0); c3t3.add_to_complex(cit, cit->subdomain_index()); for(int i=0; i < 4; ++i) { @@ -89,6 +90,6 @@ int main (int argc, char** argv){ std::ofstream out("graph.off"); out << poly; - CGAL_assertion(is_valid(poly)); + assert(is_valid(poly)); return EXIT_SUCCESS; } diff --git a/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp b/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp index 2a4bc5a5748..d4b01ec740a 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp @@ -13,6 +13,7 @@ #include #include +#include int main (int argc, char** argv){ typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -55,7 +56,7 @@ int main (int argc, char** argv){ cit != c3t3.triangulation().finite_cells_end(); ++cit) { - CGAL_assertion(cit->subdomain_index() >= 0); + assert(cit->subdomain_index() >= 0); c3t3.add_to_complex(cit, cit->subdomain_index()); for(int i=0; i < 4; ++i) { @@ -95,6 +96,6 @@ int main (int argc, char** argv){ std::ofstream out("graph.off"); out << poly; - CGAL_assertion(is_valid(poly)); + assert(is_valid(poly)); return EXIT_SUCCESS; } diff --git a/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp b/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp index 62efe80cde0..0d151fc1b9b 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp @@ -61,6 +61,8 @@ public: CGAL::parameters::no_exude(), CGAL::parameters::no_perturb()); + c3t3.remove_isolated_vertices(); + // Verify this->verify_c3t3_volume(c3t3, 1772330*0.95, 1772330*1.05); this->verify(c3t3,domain,criteria, Bissection_tag()); diff --git a/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp b/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp index 045eefe6f70..d359509388f 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -137,12 +138,12 @@ void test() if(0 != output_c3t3[5*(i-1)+j].compare(output_c3t3[5*i+j])) { std::cerr << "Meshing operation " << j << " is not deterministic.\n"; - CGAL_assertion(false); + assert(false); } if (0 != output_surfaces[5 * (i - 1) + j].compare(output_surfaces[5 * i + j])) { std::cerr << "Output surface after operation " << j << " is not deterministic.\n"; - CGAL_assertion(false); + assert(false); } } } diff --git a/Mesh_3/test/Mesh_3/test_meshing_polyhedron_with_features.cpp b/Mesh_3/test/Mesh_3/test_meshing_polyhedron_with_features.cpp index 3805cf33825..9babdd1a160 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_polyhedron_with_features.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_polyhedron_with_features.cpp @@ -23,10 +23,56 @@ #include #include +#include + +static constexpr bool verbose = +#if CGAL_MESH_3_VERBOSE + true; +#else + false; +#endif + + +std::stringstream cerr_output; template struct Polyhedron_with_features_tester : public Tester { + std::streambuf* old_cerr_buf; + std::string tag_name; + + Polyhedron_with_features_tester(std::string tag_name) + : old_cerr_buf(std::cerr.rdbuf(verbose ? cerr_output.rdbuf() : std::cerr.rdbuf())) + , tag_name(tag_name) + { + } + ~Polyhedron_with_features_tester() + { + std::cerr.rdbuf(old_cerr_buf); + if(verbose) { + const auto output = cerr_output.str(); + const auto str_size= output.size(); + const auto str_begin = output.data(); + const auto str_end = str_begin + str_size; + constexpr auto nb = static_cast>(10000); + auto pos1 = str_begin + (std::min)(nb, str_size); + assert(pos1 <= str_end); + const auto pos2 = str_end - (std::min)(nb, str_size); + assert(pos2 >= str_begin); + if(pos2 <= pos1) { + pos1 = str_end; + } + std::cerr << "NOW THE FIRST AND LAST 10k CHARACTERS OF THE CERR OUTPUT:\n"; + std::cerr << "-----\n" << std::string(str_begin, pos1) << "\n-----\n"; + if(pos1 != str_end) { + std::cerr << "[...]\n-----\n" << std::string(pos2, str_end) << "\n-----\n"; + } + const auto file_name = std::string("test_meshing_verbose-") + tag_name + ".txt"; + std::ofstream file_output(file_name); + file_output << output; + std::cerr << "Full log is output to " << file_name << "\n"; + } + } void operator()() const { typedef CGAL::Mesh_3::Robust_intersection_traits_3 Gt; @@ -107,14 +153,17 @@ struct Polyhedron_with_features_tester : public Tester int main() { - Polyhedron_with_features_tester test_epic; - std::cerr << "Mesh generation from a polyhedron with edges:\n"; - test_epic(); - + { + std::cerr << "Mesh generation from a polyhedron with edges:\n"; + Polyhedron_with_features_tester test_epic("sequential"); + test_epic(); + } #ifdef CGAL_LINKED_WITH_TBB - Polyhedron_with_features_tester test_epic_p; - std::cerr << "Parallel mesh generation from a polyhedron with edges:\n"; - test_epic_p(); + { + std::cerr << "Parallel mesh generation from a polyhedron with edges:\n"; + Polyhedron_with_features_tester test_epic_p("parallel"); + test_epic_p(); + } #endif return EXIT_SUCCESS; diff --git a/Minkowski_sum_2/examples/Minkowski_sum_2/bops_linear.h b/Minkowski_sum_2/examples/Minkowski_sum_2/bops_linear.h index 65668686580..d6e57c0eef1 100644 --- a/Minkowski_sum_2/examples/Minkowski_sum_2/bops_linear.h +++ b/Minkowski_sum_2/examples/Minkowski_sum_2/bops_linear.h @@ -2,6 +2,7 @@ #define BOPS_LINEAR_H #include +#include #include #include diff --git a/Minkowski_sum_2/examples/Minkowski_sum_2/sum_triangle_square.cpp b/Minkowski_sum_2/examples/Minkowski_sum_2/sum_triangle_square.cpp index 5923d1e5fdf..de46f19e9e4 100644 --- a/Minkowski_sum_2/examples/Minkowski_sum_2/sum_triangle_square.cpp +++ b/Minkowski_sum_2/examples/Minkowski_sum_2/sum_triangle_square.cpp @@ -21,7 +21,7 @@ int main() // Compute the Minkowski sum. Polygon_with_holes_2 sum = CGAL::minkowski_sum_2(P, Q); - CGAL_assertion(sum.number_of_holes() == 0); + assert(sum.number_of_holes() == 0); std::cout << "P (+) Q = " << sum.outer_boundary() << std::endl; return 0; } diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Decomposition_strategy_adapter.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Decomposition_strategy_adapter.h index af25be58284..d1d828284b6 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Decomposition_strategy_adapter.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Decomposition_strategy_adapter.h @@ -51,12 +51,34 @@ protected: bool m_own_traits; // inidicates whether the kernel should be freed up. public: + // The pointer to the traits and the flag that indicate ownership should be + // replaced with a smart pointer. Meanwhile, the copy constructor and + // copy assignment prevent double delition. Notice that once a copy + // constructor (assignment) is present, the move constructor (assignment) + // is implicitly not generated anyway. + /*! Default constructor. */ Polygon_decomposition_strategy_adapter() : m_traits(nullptr), m_own_traits(false) { init(); } + /*! Copy constructor. */ + Polygon_decomposition_strategy_adapter + (const Polygon_decomposition_strategy_adapter& other) : + m_traits((other.m_own_traits) ? new Traits_2 : other.m_traits), + m_own_traits(other.m_own_traits) + { init(); } + + /*! Copy assignment. */ + Polygon_decomposition_strategy_adapter& + operator=(const Polygon_decomposition_strategy_adapter& other) { + m_traits = (other.m_own_traits) ? new Traits_2 : other.m_traits; + m_own_traits = other.m_own_traits; + init(); + return *this; + } + /*! Constructor. */ Polygon_decomposition_strategy_adapter(const Traits_2& traits) : m_traits(traits), diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_by_reduced_convolution_2.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_by_reduced_convolution_2.h index 01dd1009a39..07c56481531 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_by_reduced_convolution_2.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_by_reduced_convolution_2.h @@ -20,10 +20,10 @@ #include #include +#include #include -#include -#include +#include namespace CGAL { @@ -240,7 +240,7 @@ private: std::vector p2_dirs = directions_of_polygon(p2_vertices); // Contains states that were already visited - boost::unordered_set visited_states; + std::unordered_set> visited_states; // Init the queue with vertices from the first column std::queue state_queue; diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_conv_2.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_conv_2.h index d726319ee41..10ab7f494f9 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_conv_2.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_conv_2.h @@ -117,12 +117,34 @@ private: Ccw_in_between_2 f_ccw_in_between; public: + // The pointer to the kernel and the flag that indicate ownership should be + // replaced with a smart pointer. Meanwhile, the copy constructor and + // copy assignment prevent double delition. Notice that once a copy + // constructor (assignment) is present, the move constructor (assignment) + // is implicitly not generated anyway. + /*! Default constructor. */ Minkowski_sum_by_convolution_2() : m_kernel(new Kernel), m_own_kernel(true) { init(); } + /*! Copy constructor. */ + Minkowski_sum_by_convolution_2 + (const Minkowski_sum_by_convolution_2& other) : + m_kernel((other.m_own_kernel) ? new Kernel : other.m_kernel), + m_own_kernel(other.m_own_kernel) + { init(); } + + /*! Copy assignment. */ + Minkowski_sum_by_convolution_2& + operator=(const Minkowski_sum_by_convolution_2& other) { + m_kernel = (other.m_own_kernel) ? new Kernel : other.m_kernel; + m_own_kernel = other.m_own_kernel; + init(); + return *this; + } + /*! Constructor. */ Minkowski_sum_by_convolution_2(const Kernel& kernel) : m_kernel(&kernel), diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_decomp_2.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_decomp_2.h index c96600d025e..0b63f66612b 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_decomp_2.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_decomp_2.h @@ -90,6 +90,12 @@ private: Compare_xy_2 f_compare_xy; public: + // The pointers and the corresponding flags that indicate ownerships should + // be replaced with smart pointers. Meanwhile, the copy constructor and + // copy assignment prevent double delition. Notice that once a copy + // constructor (assignment) is present, the move constructor (assignment) + // is implicitly not generated anyway. + //! Default constructor. Minkowski_sum_by_decomposition_2() : m_decomposition_strategy1(nullptr), @@ -100,6 +106,36 @@ public: m_own_traits(false) { init(); } + //! Copy constructor. + Minkowski_sum_by_decomposition_2 + (const Minkowski_sum_by_decomposition_2& other) : + m_decomposition_strategy1((other.m_own_strategy1) ? + new Decomposition_strategy1 : + other.m_decomposition_strategy1), + m_decomposition_strategy2((other.m_own_strategy2) ? + new Decomposition_strategy2 : + other.m_decomposition_strategy2), + m_own_strategy1(other.m_own_strategy1), + m_own_strategy2(other.m_own_strategy2), + m_traits((other.m_own_traits) ? new Traits_2 : other.m_traits), + m_own_traits(other.m_own_traits) + { init(); } + + //! Copy assignment. + Minkowski_sum_by_decomposition_2& + operator=(const Minkowski_sum_by_decomposition_2& other) { + m_decomposition_strategy1 = (other.m_own_strategy1) ? + new Decomposition_strategy1 : other.m_decomposition_strategy1; + m_decomposition_strategy2 = (other.m_own_strategy2) ? + new Decomposition_strategy2 : other.m_decomposition_strategy2; + m_own_strategy1 = other.m_own_strategy1; + m_own_strategy2 = other.m_own_strategy2; + m_traits = (other.m_own_traits) ? new Traits_2 : other.m_traits; + m_own_traits = other.m_own_traits; + init(); + return *this; + } + //! Constructor. Minkowski_sum_by_decomposition_2(const Decomposition_strategy1& strategy1, const Decomposition_strategy2& strategy2, diff --git a/Minkowski_sum_2/include/CGAL/Polygon_vertical_decomposition_2.h b/Minkowski_sum_2/include/CGAL/Polygon_vertical_decomposition_2.h index 7c6d07ada92..15889b136d1 100644 --- a/Minkowski_sum_2/include/CGAL/Polygon_vertical_decomposition_2.h +++ b/Minkowski_sum_2/include/CGAL/Polygon_vertical_decomposition_2.h @@ -100,12 +100,34 @@ private: Equal_2 f_equal; public: + // The pointer to the traits and the flag that indicate ownership should be + // replaced with a smart pointer. Meanwhile, the copy constructor and + // copy assignment prevent double delition. Notice that once a copy + // constructor (assignment) is present, the move constructor (assignment) + // is implicitly not generated anyway. + /*! Default constructor. */ Polygon_vertical_decomposition_2() : m_traits(nullptr), m_own_traits(false) { init(); } + /*! Copy constructor. */ + Polygon_vertical_decomposition_2 + (const Polygon_vertical_decomposition_2& other) : + m_traits((other.m_own_traits) ? new Traits_2 : other.m_traits), + m_own_traits(other.m_own_traits) + { init(); } + + /*! Copy assignment. */ + Polygon_vertical_decomposition_2& + operator=(const Polygon_vertical_decomposition_2& other) { + m_traits = (other.m_own_traits) ? new Traits_2 : other.m_traits; + m_own_traits = other.m_own_traits; + init(); + return *this; + } + /*! Constructor */ Polygon_vertical_decomposition_2(const Traits_2& traits) : m_traits(&traits), diff --git a/Minkowski_sum_2/include/CGAL/Small_side_angle_bisector_decomposition_2.h b/Minkowski_sum_2/include/CGAL/Small_side_angle_bisector_decomposition_2.h index c0ff417cc65..d69531af6a3 100644 --- a/Minkowski_sum_2/include/CGAL/Small_side_angle_bisector_decomposition_2.h +++ b/Minkowski_sum_2/include/CGAL/Small_side_angle_bisector_decomposition_2.h @@ -106,12 +106,34 @@ private: Ccw_in_between_2 f_ccw_in_between; public: + // The pointer to the kernel and the flag that indicate ownership should be + // replaced with a smart pointer. Meanwhile, the copy constructor and + // copy assignment prevent double delition. Notice that once a copy + // constructor (assignment) is present, the move constructor (assignment) + // is implicitly not generated anyway. + /*! Default constructor. */ Small_side_angle_bisector_decomposition_2() : m_kernel(new Kernel), m_own_kernel(true) { init(); } + /*! Copy constructor. */ + Small_side_angle_bisector_decomposition_2 + (const Small_side_angle_bisector_decomposition_2& other) : + m_kernel((other.m_own_kernel) ? new Kernel : other.m_kernel), + m_own_kernel(other.m_own_kernel) + { init(); } + + /*! Copy assignment. */ + Small_side_angle_bisector_decomposition_2& + operator=(const Small_side_angle_bisector_decomposition_2& other) { + m_kernel = (other.m_own_kernel) ? new Kernel : other.m_kernel; + m_own_kernel = other.m_own_kernel; + init(); + return *this; + } + /*! Constructor. */ Small_side_angle_bisector_decomposition_2(const Kernel& kernel) : m_kernel(&kernel), diff --git a/Modifier/test/Modifier/test_modifier.cpp b/Modifier/test/Modifier/test_modifier.cpp index b247c524476..6c32ee3eeba 100644 --- a/Modifier/test/Modifier/test_modifier.cpp +++ b/Modifier/test/Modifier/test_modifier.cpp @@ -37,7 +37,7 @@ public: void delegate( Modifier_base& modifier) { modifier(i); // check validity - CGAL_postcondition( i > 0); + assert( i > 0); } int get_i() const { return i;} // read access }; diff --git a/Nef_2/examples/Nef_2/nef_2_construction.cpp b/Nef_2/examples/Nef_2/nef_2_construction.cpp index 903bee5bf28..cb434cf297f 100644 --- a/Nef_2/examples/Nef_2/nef_2_construction.cpp +++ b/Nef_2/examples/Nef_2/nef_2_construction.cpp @@ -1,6 +1,7 @@ #include #include #include +#include typedef CGAL::Exact_integer RT; typedef CGAL::Filtered_extended_homogeneous Extended_kernel; @@ -15,13 +16,13 @@ int main() { Line l(2,4,2); // l : 2x + 4y + 2 = 0 Nef_polyhedron N2(l,Nef_polyhedron::INCLUDED); Nef_polyhedron N3 = N2.complement(); - CGAL_assertion(N1 == N2.join(N3)); + assert(N1 == N2.join(N3)); Point p1(0,0), p2(10,10), p3(-20,15); Point triangle[3] = { p1, p2, p3 }; Nef_polyhedron N4(triangle, triangle+3); Nef_polyhedron N5 = N2.intersection(N4); - CGAL_assertion(N5 <= N2 && N5 <= N4); + assert(N5 <= N2 && N5 <= N4); return 0; } diff --git a/Nef_2/include/CGAL/Nef_2/Polynomial_impl.h b/Nef_2/include/CGAL/Nef_2/Polynomial_impl.h index 921f2e9ff9d..66417e9b99a 100644 --- a/Nef_2/include/CGAL/Nef_2/Polynomial_impl.h +++ b/Nef_2/include/CGAL/Nef_2/Polynomial_impl.h @@ -87,15 +87,23 @@ Polynomial Polynomial::gcd( int f1c = f1.content(), f2c = f2.content(); f1 /= f1c; f2 /= f2c; int F = CGAL::gcd(f1c,f2c); - Polynomial q,r; int M=1,D; + Polynomial q,r; + int D; +#ifdef CGAL_USE_TRACE + int M=1; bool first = true; +#endif while ( ! f2.is_zero() ) { Polynomial::pseudo_div(f1,f2,q,r,D); +#ifdef CGAL_USE_TRACE if (!first) M*=D; +#endif CGAL_NEF_TRACEV(f1);CGAL_NEF_TRACEV(f2);CGAL_NEF_TRACEV(q);CGAL_NEF_TRACEV(r);CGAL_NEF_TRACEV(M); r /= r.content(); f1=f2; f2=r; +#ifdef CGAL_USE_TRACE first=false; +#endif } CGAL_NEF_TRACEV(f1.content()); return Polynomial(F)*f1.abs(); @@ -172,15 +180,20 @@ Polynomial Polynomial::gcd( Polynomial f2 = p2.abs(); double f1c = f1.content(), f2c = f2.content(); f1 /= f1c; f2 /= f2c; - Polynomial q,r; double M=1,D; + Polynomial q,r; double D; +#ifdef CGAL_USE_TRACE + double M=1; bool first = true; +#endif while ( ! f2.is_zero() ) { Polynomial::pseudo_div(f1,f2,q,r,D); +#ifdef CGAL_USE_TRACE if (!first) M*=D; + first=false; +#endif CGAL_NEF_TRACEV(f1);CGAL_NEF_TRACEV(f2);CGAL_NEF_TRACEV(q);CGAL_NEF_TRACEV(r);CGAL_NEF_TRACEV(M); r /= r.content(); f1=f2; f2=r; - first=false; } CGAL_NEF_TRACEV(f1.content()); return Polynomial(1)*f1.abs(); diff --git a/Nef_3/examples/Nef_3/comparison.cpp b/Nef_3/examples/Nef_3/comparison.cpp index 79dceebb052..f6c5c40c474 100644 --- a/Nef_3/examples/Nef_3/comparison.cpp +++ b/Nef_3/examples/Nef_3/comparison.cpp @@ -1,6 +1,7 @@ #include #include #include +#include typedef CGAL::Exact_integer NT; typedef CGAL::Extended_homogeneous Kernel; @@ -12,16 +13,16 @@ int main() { Nef_polyhedron N1(Plane_3(2,5,7,11), Nef_polyhedron::INCLUDED); Nef_polyhedron N2(Plane_3(2,5,7,11), Nef_polyhedron::EXCLUDED); - CGAL_assertion(N1 >= N2); - CGAL_assertion(N2 <= N1); - CGAL_assertion(N1 != N2); - CGAL_assertion(N1 > N2); - CGAL_assertion(N2 < N1); + assert(N1 >= N2); + assert(N2 <= N1); + assert(N1 != N2); + assert(N1 > N2); + assert(N2 < N1); N2 = N2.closure(); - CGAL_assertion(N1==N2); - CGAL_assertion(N1>=N2); - CGAL_assertion(N1<=N2); + assert(N1==N2); + assert(N1>=N2); + assert(N1<=N2); return 0; } diff --git a/Nef_3/examples/Nef_3/draw_nef_3.cpp b/Nef_3/examples/Nef_3/draw_nef_3.cpp index f5923ffe451..0ccd07ba6f9 100644 --- a/Nef_3/examples/Nef_3/draw_nef_3.cpp +++ b/Nef_3/examples/Nef_3/draw_nef_3.cpp @@ -13,15 +13,18 @@ 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] : CGAL::data_file_path("meshes/cross_quad.off")); - ifs >> P; + Polyhedron P1, P2; + std::ifstream ifs1((argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cross_quad.off")); + ifs1 >> P1; + std::ifstream ifs2((argc > 1) ? argv[1] : CGAL::data_file_path("meshes/beam.off")); + ifs2 >> P2; // initialize nef from polyhedron - Nef_polyhedron N(P); + Nef_polyhedron N1(P1); + Nef_polyhedron N2(P2); // draw Nef Polyhedron - CGAL::draw(N); + CGAL::draw(N1-N2); return EXIT_SUCCESS; } diff --git a/Nef_3/examples/Nef_3/nef_3_construction.cpp b/Nef_3/examples/Nef_3/nef_3_construction.cpp index c70a1d5dae9..043f8ca8bdc 100644 --- a/Nef_3/examples/Nef_3/nef_3_construction.cpp +++ b/Nef_3/examples/Nef_3/nef_3_construction.cpp @@ -1,6 +1,7 @@ #include #include #include +#include typedef CGAL::Extended_homogeneous Kernel; typedef CGAL::Nef_polyhedron_3 Nef_polyhedron; @@ -14,19 +15,19 @@ int main() { Nef_polyhedron N4(Plane_3( 1, 2, 5,-1), Nef_polyhedron::INCLUDED); Nef_polyhedron N5(Plane_3( 1, 2, 5,-1), Nef_polyhedron::EXCLUDED); - CGAL_assertion(N0 == N1); - CGAL_assertion(N3 == N4); - CGAL_assertion(N0 != N2); - CGAL_assertion(N3 != N5); + assert(N0 == N1); + assert(N3 == N4); + assert(N0 != N2); + assert(N3 != N5); - CGAL_assertion(N4 >= N5); - CGAL_assertion(N5 <= N4); - CGAL_assertion(N4 > N5); - CGAL_assertion(N5 < N4); + assert(N4 >= N5); + assert(N5 <= N4); + assert(N4 > N5); + assert(N5 < N4); N5 = N5.closure(); - CGAL_assertion(N4 >= N5); - CGAL_assertion(N4 <= N5); + assert(N4 >= N5); + assert(N4 <= N5); return 0; } diff --git a/Nef_3/examples/Nef_3/nef_3_simple.cpp b/Nef_3/examples/Nef_3/nef_3_simple.cpp index 5902ad85b20..bd9c1b2099b 100644 --- a/Nef_3/examples/Nef_3/nef_3_simple.cpp +++ b/Nef_3/examples/Nef_3/nef_3_simple.cpp @@ -1,6 +1,7 @@ #include #include #include +#include typedef CGAL::Homogeneous Kernel; typedef CGAL::Nef_polyhedron_3 Nef_polyhedron; @@ -9,7 +10,7 @@ int main() { Nef_polyhedron N0(Nef_polyhedron::EMPTY); Nef_polyhedron N1(Nef_polyhedron::COMPLETE); - CGAL_assertion (N0 == N1.complement()); - CGAL_assertion (N0 != N1); + assert(N0 == N1.complement()); + assert(N0 != N1); return 0; } diff --git a/Nef_3/examples/Nef_3/point_set_operations.cpp b/Nef_3/examples/Nef_3/point_set_operations.cpp index 210ea348cef..82f09cd177d 100644 --- a/Nef_3/examples/Nef_3/point_set_operations.cpp +++ b/Nef_3/examples/Nef_3/point_set_operations.cpp @@ -1,6 +1,7 @@ #include #include #include +#include typedef CGAL::Extended_homogeneous Kernel; typedef CGAL::Nef_polyhedron_3 Nef_polyhedron; @@ -22,11 +23,11 @@ int main() { Cube1 *= !I3; Nef_polyhedron Cube2 = N1 * N2 * N3 * N4 * N5 * N6; - CGAL_assertion(Cube1 == Cube2); // both are closed cube - CGAL_assertion(Cube1 == Cube1.closure()); - CGAL_assertion(Cube1 == Cube1.regularization()); - CGAL_assertion((N1 - N1.boundary()) == N1.interior()); - CGAL_assertion(I1.closure() == I1.complement().interior().complement()); - CGAL_assertion(I1.regularization() == I1.interior().closure()); + assert(Cube1 == Cube2); // both are closed cube + assert(Cube1 == Cube1.closure()); + assert(Cube1 == Cube1.regularization()); + assert((N1 - N1.boundary()) == N1.interior()); + assert(I1.closure() == I1.complement().interior().complement()); + assert(I1.regularization() == I1.interior().closure()); return 0; } diff --git a/Nef_3/examples/Nef_3/set_operations.cpp b/Nef_3/examples/Nef_3/set_operations.cpp index 5efa840cf8e..93a9ac78a96 100644 --- a/Nef_3/examples/Nef_3/set_operations.cpp +++ b/Nef_3/examples/Nef_3/set_operations.cpp @@ -1,6 +1,7 @@ #include #include #include +#include typedef CGAL::Exact_integer NT; typedef CGAL::Extended_homogeneous Kernel; @@ -22,6 +23,6 @@ int main() { Nef_polyhedron Cube1(I2 *!I1); Cube1 *= !I3; Nef_polyhedron Cube2 = N1 * N2 * N3 * N4 * N5 * N6; - CGAL_assertion (Cube1 == Cube2); + assert(Cube1 == Cube2); return 0; } diff --git a/Nef_3/examples/Nef_3/topological_operations.cpp b/Nef_3/examples/Nef_3/topological_operations.cpp index 087d37b4418..d42d7210658 100644 --- a/Nef_3/examples/Nef_3/topological_operations.cpp +++ b/Nef_3/examples/Nef_3/topological_operations.cpp @@ -2,6 +2,7 @@ #include #include #include +#include typedef CGAL::Exact_integer NT; typedef CGAL::Homogeneous Kernel; @@ -12,9 +13,9 @@ int main() { Nef_polyhedron N; std::cin >> N; - CGAL_assertion((N - N.boundary()) == N.interior()); - CGAL_assertion(N.closure() == N.complement().interior().complement()); - CGAL_assertion(N.regularization() == N.interior().closure()); + assert((N - N.boundary()) == N.interior()); + assert(N.closure() == N.complement().interior().complement()); + assert(N.regularization() == N.interior().closure()); return 0; } diff --git a/Nef_3/examples/Nef_3/transformation.cpp b/Nef_3/examples/Nef_3/transformation.cpp index 0e79e62e832..a69de27ee48 100644 --- a/Nef_3/examples/Nef_3/transformation.cpp +++ b/Nef_3/examples/Nef_3/transformation.cpp @@ -2,6 +2,7 @@ #include #include #include +#include typedef CGAL::Extended_homogeneous Kernel; @@ -21,11 +22,11 @@ int main() { Aff_transformation_3 scale(CGAL::SCALING, 3, 2); N.transform(transl); - CGAL_assertion(N == Nef_polyhedron(Plane_3(0,1,0,-7))); + assert(N == Nef_polyhedron(Plane_3(0,1,0,-7))); N.transform(rotx90); - CGAL_assertion(N == Nef_polyhedron(Plane_3(0,0,1,-7))); + assert(N == Nef_polyhedron(Plane_3(0,0,1,-7))); N.transform(scale); - CGAL_assertion(N == Nef_polyhedron(Plane_3(0,0,2,-21))); + assert(N == Nef_polyhedron(Plane_3(0,0,2,-21))); return 0; } diff --git a/Nef_3/include/CGAL/Nef_3/K3_tree.h b/Nef_3/include/CGAL/Nef_3/K3_tree.h index 8329767d8eb..b17768d8353 100644 --- a/Nef_3/include/CGAL/Nef_3/K3_tree.h +++ b/Nef_3/include/CGAL/Nef_3/K3_tree.h @@ -41,8 +41,7 @@ template class K3_tree { -template +template class Smaller_than { public: @@ -59,64 +58,10 @@ public: return false; } - bool operator()( const Object& o1, const Object& o2) { - Vertex v1,v2; - CGAL::assign(v1,o1); - CGAL::assign(v2,o2); - switch(coord) { - case 0: return CGAL::compare_x(v1->point(), v2->point()) == SMALLER; - case 1: return CGAL::compare_y(v1->point(), v2->point()) == SMALLER; - case 2: return CGAL::compare_z(v1->point(), v2->point()) == SMALLER; - default: CGAL_error(); - } - return false; - } private: Coordinate coord; }; - -template - class Smaller_than, Object, Vertex, Coordinate> -{ -public: - Smaller_than(Coordinate c) : coord(c) { - CGAL_assertion( c >= 0 && c <=2); - } - bool operator()( const Vertex& v1, const Vertex& v2) { - switch(coord) { - case 0: return CGAL::to_interval(v1->point().x()).second < - CGAL::to_interval(v2->point().x()).first; - case 1: return CGAL::to_interval(v1->point().y()).second < - CGAL::to_interval(v2->point().y()).first; - case 2: return CGAL::to_interval(v1->point().z()).second < - CGAL::to_interval(v2->point().z()).first; - default: CGAL_error(); - } - return false; - } - - bool operator()( const Object& o1, const Object& o2) { - Vertex v1,v2; - CGAL::assign(v1,o1); - CGAL::assign(v2,o2); - switch(coord) { - case 0: return CGAL::to_interval(v1->point().x()).second < - CGAL::to_interval(v2->point().x()).first; - case 1: return CGAL::to_interval(v1->point().y()).second < - CGAL::to_interval(v2->point().y()).first; - case 2: return CGAL::to_interval(v1->point().z()).second < - CGAL::to_interval(v2->point().z()).first; - default: CGAL_error(); - } - return false; - } -private: - Coordinate coord; -}; - - public: friend class Objects_along_ray; friend class Objects_around_segment; @@ -126,13 +71,17 @@ public: typedef typename Traits::SNC_decorator SNC_decorator; typedef typename Traits::Infimaximal_box Infimaximal_box; typedef typename Traits::Vertex_handle Vertex_handle; +typedef typename Traits::Vertex_list Vertex_list; +typedef typename Vertex_list::iterator Vertex_iterator; +typedef typename Vertex_list::const_iterator Vertex_const_iterator; typedef typename Traits::Halfedge_handle Halfedge_handle; typedef typename Traits::Halffacet_handle Halffacet_handle; typedef typename Traits::Object_handle Object_handle; -typedef std::vector Object_list; -typedef typename Object_list::const_iterator Object_const_iterator; -typedef typename Object_list::iterator Object_iterator; -typedef typename Object_list::size_type size_type; +typedef typename Traits::Object_list Object_list; +typedef typename Traits::Halfedge_list Halfedge_list; +typedef typename Halfedge_list::const_iterator Halfedge_const_iterator; +typedef typename Traits::Halffacet_list Halffacet_list; +typedef typename Halffacet_list::const_iterator Halffacet_const_iterator; typedef typename Traits::Point_3 Point_3; typedef typename Traits::Segment_3 Segment_3; @@ -144,7 +93,6 @@ typedef typename Traits::Aff_transformation_3 Aff_transformation_3; typedef typename Traits::Bounding_box_3 Bounding_box_3; typedef typename Traits::Side_of_plane Side_of_plane; -typedef typename Traits::Objects_bbox Objects_bbox; typedef typename Traits::Kernel Kernel; typedef typename Kernel::RT RT; @@ -152,29 +100,36 @@ typedef typename Kernel::FT FT; typedef Smaller_than< Kernel, - Object_handle, Vertex_handle, - int> Smaller_; + int> Smaller; class Node { friend class K3_tree; public: typedef Node* Node_handle; - - Node( Node_handle p, Node_handle l, Node_handle r, Plane_3 pl, const Object_list& O) : - parent_node(p), left_node(l), right_node(r), splitting_plane(pl), - object_list(O) { - if(l == nullptr) - point_on_plane = Point_3(); - else - point_on_plane = pl.point(); + Node(const Vertex_list& V, const Halfedge_list& E, const Halffacet_list& F) : + left_node(nullptr), right_node(nullptr) + { + object_list.reserve(V.size()+E.size()+F.size()); + for(Vertex_const_iterator vi=V.begin(); vi!=V.end(); ++vi) + object_list.push_back(make_object(*vi)); + for(Halfedge_const_iterator ei=E.begin(); ei!=E.end(); ++ei) + object_list.push_back(make_object(*ei)); + for(Halffacet_const_iterator fi=F.begin(); fi!=F.end(); ++fi) + object_list.push_back(make_object(*fi)); } + + Node(Node_handle l, Node_handle r, const Plane_3& pl) : + left_node(l), right_node(r), splitting_plane(pl) + { + } + bool is_leaf() const { CGAL_assertion( (left_node != nullptr && right_node != nullptr) || (left_node == nullptr && right_node == nullptr)); return (left_node == nullptr && right_node == nullptr); } - Node_handle parent() const { return parent_node; } + Node_handle left() const { return left_node; } Node_handle right() const { return right_node; } const Plane_3& plane() const { return splitting_plane; } @@ -189,45 +144,42 @@ public: } } - template - void add_facet(Halffacet_handle f, Depth depth) { + void add_facet(Halffacet_handle f, int depth) { if(left_node == nullptr) { object_list.push_back(make_object(f)); return; } - Side_of_plane sop; - Oriented_side side = sop(splitting_plane.point(), f, depth); + Side_of_plane sop(splitting_plane.point(), depth%3); + Oriented_side side = sop(f); if( side == ON_NEGATIVE_SIDE || side == ON_ORIENTED_BOUNDARY) left_node->add_facet(f, depth+1); if( side == ON_POSITIVE_SIDE || side == ON_ORIENTED_BOUNDARY) right_node->add_facet(f, depth+1); } - template - void add_edge(Halfedge_handle e, Depth depth) { + void add_edge(Halfedge_handle e, int depth) { if(left_node == nullptr) { object_list.push_back(make_object(e)); return; } - Side_of_plane sop; - Oriented_side side = sop(splitting_plane.point(), e, depth); + Side_of_plane sop(splitting_plane.point(), depth%3); + Oriented_side side = sop(e); if( side == ON_NEGATIVE_SIDE || side == ON_ORIENTED_BOUNDARY) left_node->add_edge(e, depth+1); if( side == ON_POSITIVE_SIDE || side == ON_ORIENTED_BOUNDARY) right_node->add_edge(e, depth+1); } - template - void add_vertex(Vertex_handle v, Depth depth) { + void add_vertex(Vertex_handle v, int depth) { if(left_node == nullptr) { object_list.push_back(make_object(v)); return; } - Side_of_plane sop; - Oriented_side side = sop(splitting_plane.point(), v, depth); + Side_of_plane sop(splitting_plane.point(), depth%3); + Oriented_side side = sop(v); if( side == ON_NEGATIVE_SIDE || side == ON_ORIENTED_BOUNDARY) left_node->add_vertex(v, depth+1); if( side == ON_POSITIVE_SIDE || side == ON_ORIENTED_BOUNDARY) @@ -252,27 +204,11 @@ friend std::ostream& operator<< return os; } - /* -~Node() noexcept(!CGAL_ASSERTIONS_ENABLED) -{ - CGAL_NEF_TRACEN("~Node: deleting node..."); - CGAL_destructor_assertion_catch( - if( !is_leaf()) { - delete left_node; - delete right_node; - } - ); -} - */ private: - - - Node_handle parent_node; Node_handle left_node; Node_handle right_node; Plane_3 splitting_plane; - Point_3 point_on_plane; Object_list object_list; }; @@ -397,17 +333,6 @@ else { return node; } -inline -Node_handle get_child_by_side( const Node_handle node, Oriented_side side) { - CGAL_assertion( node != nullptr); - CGAL_assertion( side != ON_ORIENTED_BOUNDARY); - if( side == ON_NEGATIVE_SIDE) { - return node->left(); - } - CGAL_assertion( side == ON_POSITIVE_SIDE); - return node->right(); -} - void divide_segment_by_plane( Segment_3 s, Plane_3 pl, Segment_3& s1, Segment_3& s2) { Object o = traits.intersect_object()( pl, s); @@ -437,23 +362,15 @@ void divide_segment_by_plane( Segment_3 s, Plane_3 pl, // First of all, we need to find out wheather we are working over an extended kernel or on a standard kernel. As precondition we have that ray is oriented in the minus x axis direction. When having an extended kernel, the ray can be subtituted by a segment with the endpoint on the 'intersection' between the ray and the bounding infimaximal box. In the presence of a standard kernel, the intersection is computed with the bounding box with the vertices of the Nef polyhedron. Point_3 p(r.source()), q; Bounding_box_3 b = k.bounding_box; - int c = (CGAL::abs(vec[0]) > CGAL::abs(vec[1]) ? 0 : 1); - c = (CGAL::abs(vec[2]) > CGAL::abs(vec[c]) ? 2 : c); + typename Kernel::Non_zero_coordinate_index_3 non_zero_coordinate_index_3; + int c = non_zero_coordinate_index_3(vec); Point_3 pt_on_minus_x_plane = vec[c] < 0 ? Point_3(FT(b.min_coord(0)), FT(b.min_coord(1)),FT(b.min_coord(2))) : Point_3(FT(b.max_coord(0)), FT(b.max_coord(1)),FT(b.max_coord(2))); // We compute the intersection between a plane with normal vector in // the minus x direction and located at the minimum point of the bounding box, and the input ray. When the ray does not intersect the bounding volume, there won't be any object hit, so it is safe to construct a segment that simply lay in the unbounded side of the bounding box. This approach is taken instead of somehow (efficiently) report that there was no hit object, in order to mantain a clear interface with the Iterator class. - Plane_3 pl_on_minus_x; - if(c==0) - pl_on_minus_x = Plane_3(pt_on_minus_x_plane, Vector_3( 1, 0, 0)); - else if(c==1) - pl_on_minus_x = Plane_3(pt_on_minus_x_plane, Vector_3( 0, 1, 0)); - else { - CGAL_assertion_msg(c==2, "wrong value"); - pl_on_minus_x = Plane_3(pt_on_minus_x_plane, Vector_3( 0, 0, 1)); - } + Plane_3 pl_on_minus_x = K3_tree::construct_splitting_plane(pt_on_minus_x_plane, c, typename Traits::Kernel::Kernel_tag()); Object o = traits.intersect_object()( pl_on_minus_x, r); if( !CGAL::assign( q, o) || pl_on_minus_x.has_on(p)) q = r.source() + vec; @@ -471,7 +388,7 @@ private: Node_handle root; - boost::container::deque nodes; + Node_range nodes; int max_depth; Bounding_box_3 bounding_box; @@ -488,39 +405,41 @@ public: typedef typename SNC_structure::Halffacet_iterator Halffacet_iterator; CGAL_assertion( W != nullptr); - Object_list objects; + + Vertex_list vertices; + vertices.reserve(W->number_of_vertices()); Vertex_iterator v; + CGAL_forall_vertices(v, *W) + vertices.push_back(v); + + Halfedge_list edges; + edges.reserve(W->number_of_halfedges()); Halfedge_iterator e; + CGAL_forall_edges(e, *W) + edges.push_back(e); + + Halffacet_list facets; + facets.reserve(W->number_of_halffacets()); Halffacet_iterator f; - CGAL_forall_vertices( v, *W) - objects.push_back(make_object(Vertex_handle(v))); - typename Object_list::difference_type v_end = objects.size(); - CGAL_forall_edges( e, *W) - objects.push_back(make_object(Halfedge_handle(e))); - CGAL_forall_facets( f, *W) { - objects.push_back(make_object(Halffacet_handle(f))); - } - Object_iterator oli=objects.begin()+v_end; - root = build_kdtree( objects, oli, 0); - } + CGAL_forall_facets(f, *W) + facets.push_back(f); - K3_tree(Object_list& objects, Object_iterator& v_end) { + CGAL_NEF_TRACEN("K3_tree(): n_vertices = " << vertices.size()); + std::frexp( (double) vertices.size(), &max_depth); -typename Object_list::difference_type n_vertices = std::distance(objects.begin(),v_end); - CGAL_NEF_TRACEN("K3_tree(): n_vertices = " << std::distance(objects.begin(),v_end)); - std::frexp( (double) n_vertices, &max_depth); - - // TODO: in the presence of a infimaximal bounding box, the bounding box does not have to be computed - Objects_bbox objects_bbox = traits.objects_bbox_object(); - bounding_box = objects_bbox(objects); - //CGAL_NEF_TRACEN("bounding box:"<point()); + //CGAL_NEF_TRACEN("bounding box:"< -Node_handle build_kdtree(Object_list& O, Object_iterator v_end, - Depth depth, Node_handle parent=nullptr, int non_efective_splits=0) { +int non_efective_splits; + +Node_handle build_kdtree(Vertex_list& V, Halfedge_list& E, Halffacet_list& F, + int depth) { CGAL_precondition( depth >= 0); - CGAL_NEF_TRACEN( "build_kdtree: "< max_depth) - nodes.push_back(Node( parent, nullptr, nullptr, Plane_3(), O)); + nodes.push_back(Node(V, E, F)); return &(nodes.back()); - } else { - CGAL_NEF_TRACEN("Sizes " << O1.size() << ", " << O2.size() << ", " << O.size()); - CGAL_assertion( O1.size() <= O.size() && O2.size() <= O.size()); - CGAL_assertion( O1.size() + O2.size() >= O.size()); - non_efective_split = ((O1.size() == O.size()) || (O2.size() == O.size())); } - if( non_efective_split) + auto O_size = V.size() + E.size() + F.size(); + auto O1_size = V1.size() + E1.size() + F1.size(); + auto O2_size = V2.size() + E2.size() + F2.size(); + CGAL_NEF_TRACEN("Sizes " << O1_size << ", " << O2_size << ", " << O_size); + CGAL_assertion( O1_size <= O_size && O2_size <= O_size); + CGAL_assertion( O1_size + O2_size >= O_size); + if((O1_size == O_size) || (O2_size == O_size)) non_efective_splits++; else non_efective_splits = 0; - if( non_efective_splits > 2) { + + if(non_efective_splits > 2) { CGAL_NEF_TRACEN("build_kdtree: non efective splits reached maximum"); - nodes.push_back(Node( parent, nullptr, nullptr, Plane_3(), O)); + nodes.push_back(Node(V, E, F)); return &(nodes.back()); } - nodes.push_back(Node( parent, nullptr, nullptr, partition_plane, Object_list())); - Node_handle node = &(nodes.back()); - node->left_node = build_kdtree( O1, O1.begin()+v_end1, depth + 1, node, non_efective_splits); - node->right_node = build_kdtree( O2, O2.begin()+v_end2, depth + 1, node, non_efective_splits); - return node; + + Node_handle left_node = build_kdtree(V1, E1, F1, depth + 1); + Node_handle right_node = build_kdtree(V2, E2, F2, depth + 1); + nodes.push_back(Node(left_node, right_node, construct_splitting_plane(point_on_plane, coord, typename Traits::Kernel::Kernel_tag()))); + return &(nodes.back()); } -template -bool can_set_be_divided(Object_iterator start, Object_iterator end, Depth depth) { +bool can_set_be_divided(int depth, typename Vertex_list::size_type size) { if(depth >= max_depth) return false; - if(std::distance(start,end)<2) + if(size <= 2) return false; return true; } -template -bool classify_objects(Object_iterator start, Object_iterator end, - Plane_3 partition_plane, Side_of_plane& sop, - OutputIterator o1, OutputIterator o2, Depth depth) { - typename Object_list::difference_type on_oriented_boundary = 0; - typename Object_list::const_iterator o; - - Point_3 point_on_plane(partition_plane.point()); - - for( o = start; o != end; ++o) { - Oriented_side side = sop( point_on_plane, *o, depth); - if( side == ON_NEGATIVE_SIDE || side == ON_ORIENTED_BOUNDARY) { - *o1 = *o; - ++o1; +template +static bool classify_objects(const List& l,Side_of_plane& sop, + List& l1, List& l2) { + typename List::size_type on_oriented_boundary = 0; + for(typename List::const_iterator i=l.begin(); i!=l.end(); ++i) { + Oriented_side side = sop(*i); + switch(side) { + case ON_NEGATIVE_SIDE: + l1.push_back(*i); + break; + case ON_POSITIVE_SIDE: + l2.push_back(*i); + break; + case ON_ORIENTED_BOUNDARY: + ++on_oriented_boundary; + l1.push_back(*i); + l2.push_back(*i); } - if( side == ON_POSITIVE_SIDE || side == ON_ORIENTED_BOUNDARY) { - *o2 = *o; - ++o2; - } - if( side == ON_ORIENTED_BOUNDARY) - ++on_oriented_boundary; } - return (on_oriented_boundary != std::distance(start,end)); + return (on_oriented_boundary != l.size()); } +static Point_3 find_median_point(Vertex_list& V, int coord) { + CGAL_assertion(V.size() > 1); -template -Plane_3 construct_splitting_plane(Object_iterator start, Object_iterator end, - Object_iterator& median, Depth depth) { - CGAL_precondition( depth >= 0); - typename Object_list::difference_type n=std::distance(start,end); - CGAL_assertion(n>1); + Smaller smaller(coord); + Vertex_iterator begin = V.begin(); + Vertex_iterator median = begin + V.size()/2; + std::nth_element(begin, median, V.end(), smaller); + Vertex_iterator prev = std::prev(median); + std::nth_element(begin, prev, median, smaller); - std::nth_element(start, start+n/2, end, - Smaller_(depth%3)); + return CGAL::midpoint((*median)->point(), (*prev)->point()); +} - Vertex_handle v; - median = start+n/2; - CGAL::assign(v,*median); - switch( depth % 3) { - case 0: return Plane_3( v->point(), Vector_3( 1, 0, 0)); break; - case 1: return Plane_3( v->point(), Vector_3( 0, 1, 0)); break; - case 2: return Plane_3( v->point(), Vector_3( 0, 0, 1)); break; +static Plane_3 construct_splitting_plane(const Point_3& pt, int coord, const Homogeneous_tag&) +{ + switch(coord) { + case 0: return Plane_3(pt, Vector_3(1, 0, 0)); + case 1: return Plane_3(pt, Vector_3(0, 1, 0)); + case 2: return Plane_3(pt, Vector_3(0, 0, 1)); } CGAL_error_msg( "never reached"); return Plane_3(); } +static Plane_3 construct_splitting_plane(const Point_3& pt, int coord, const Cartesian_tag&) +{ + switch(coord) { + case 0: return Plane_3(1, 0, 0, -pt.x()); + case 1: return Plane_3(0, 1, 0, -pt.y()); + case 2: return Plane_3(0, 0, 1, -pt.z()); + } + + CGAL_error_msg( "never reached"); + return Plane_3(); +} + +static Node_handle get_child_by_side( const Node_handle node, Oriented_side side) { + CGAL_assertion( node != nullptr); + CGAL_assertion( side != ON_ORIENTED_BOUNDARY); + if( side == ON_NEGATIVE_SIDE) { + return node->left(); + } + CGAL_assertion( side == ON_POSITIVE_SIDE); + return node->right(); +} + Node_handle locate_cell_containing( const Point_3& p, const Node_handle node) const { CGAL_precondition( node != nullptr); if( node->is_leaf()) return node; - else { - Oriented_side side = node->plane().oriented_side(p); - if( side == ON_NEGATIVE_SIDE || side == ON_ORIENTED_BOUNDARY) - return locate_cell_containing( p, node->left()); - else { // side == ON_POSITIVE_SIDE - CGAL_assertion( side == ON_POSITIVE_SIDE); - return locate_cell_containing( p, node->right()); - } - } + + Oriented_side side = node->plane().oriented_side(p); + if(side == ON_ORIENTED_BOUNDARY) + side = ON_NEGATIVE_SIDE; + return locate_cell_containing(p, get_child_by_side(node, side)); } const Object_list& locate( const Point_3& p, const Node_handle node) const { diff --git a/Nef_3/include/CGAL/Nef_3/SNC_k3_tree_traits.h b/Nef_3/include/CGAL/Nef_3/SNC_k3_tree_traits.h index ff49f3e7b21..e993d9dd81a 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_k3_tree_traits.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_k3_tree_traits.h @@ -18,6 +18,7 @@ #include #include +#include #include #undef CGAL_NEF_DEBUG @@ -28,11 +29,11 @@ namespace CGAL { template -class ComparePoints { +class Compare_points { typedef typename Kernel::Point_3 Point_3; public: - ComparePoints(Coordinate c) : coord(c) { + Compare_points(Coordinate c) : coord(c) { CGAL_assertion( c >= 0 && c <=2); } CGAL::Comparison_result operator()(const Point_3& p1, const Point_3& p2) { @@ -55,61 +56,15 @@ private: }; -template -class ComparePoints, Coordinate> { - - typedef CGAL::Lazy_kernel Kernel; - typedef typename Kernel::Point_3 Point_3; - public: - ComparePoints(Coordinate c) : coord(c) { - CGAL_assertion( c >= 0 && c <=2); - } - CGAL::Comparison_result operator()( const Point_3 p1, const Point_3 p2) { - switch(coord) { - case 0: - if(CGAL::to_interval(p1.x()).second < - CGAL::to_interval(p2.x()).first) - return CGAL::SMALLER; - else if(CGAL::to_interval(p2.x()).second < - CGAL::to_interval(p1.x()).first) - return CGAL::LARGER; - return CGAL::EQUAL; - case 1: - if(CGAL::to_interval(p1.y()).second < - CGAL::to_interval(p2.y()).first) - return CGAL::SMALLER; - else if(CGAL::to_interval(p2.y()).second < - CGAL::to_interval(p1.y()).first) - return CGAL::LARGER; - return CGAL::EQUAL; - case 2: - if(CGAL::to_interval(p1.z()).second < - CGAL::to_interval(p2.z()).first) - return CGAL::SMALLER; - else if(CGAL::to_interval(p2.z()).second < - CGAL::to_interval(p1.z()).first) - return CGAL::LARGER; - return CGAL::EQUAL; - default: CGAL_error(); - } - return CGAL::EQUAL; - } -private: - Coordinate coord; -}; - template class Side_of_plane { -public: - typedef typename SNC_decorator::SNC_structure SNC_structure; + typedef typename SNC_decorator::Decorator_traits Decorator_traits; typedef typename Decorator_traits::Vertex_handle Vertex_handle; typedef typename Decorator_traits::Halfedge_handle Halfedge_handle; typedef typename Decorator_traits::Halffacet_handle Halffacet_handle; - typedef typename SNC_structure::Object_handle Object_handle; - typedef typename Decorator_traits::Halffacet_cycle_iterator Halffacet_cycle_iterator; typedef typename Decorator_traits::SHalfedge_around_facet_circulator @@ -118,154 +73,34 @@ public: typedef typename SNC_decorator::Kernel Kernel; typedef typename Kernel::Point_3 Point_3; - typedef typename Kernel::Segment_3 Segment_3; - typedef typename Kernel::Plane_3 Plane_3; - typedef typename Kernel::Triangle_3 Triangle_3; - typedef typename Kernel::Vector_3 Vector_3; - typedef typename Kernel::RT RT; - - typedef ComparePoints ComparePoints_; - #ifdef CGAL_NEF_EXPLOIT_REFERENCE_COUNTING - Side_of_plane(bool rc = false) : reference_counted(rc) {} + typedef typename Kernel::RT RT; +#endif + typedef Compare_points Compare; + static constexpr Oriented_side unknown_side = static_cast(-2); + +public: +#ifdef CGAL_NEF_EXPLOIT_REFERENCE_COUNTING + Side_of_plane(const Point_3& p, int c, bool rc = false) : reference_counted(rc), coord(c), pop(p) {} #else - Side_of_plane() {} + Side_of_plane(const Point_3& p, int c) : OnSideMap(unknown_side), coord(c), pop(p) {} #endif - - template Oriented_side operator() - ( const Point_3& pop, Object_handle o, Depth depth); - template Oriented_side operator() - ( const Point_3& pop, Vertex_handle v, Depth depth); - template Oriented_side operator() - ( const Point_3& pop, Halfedge_handle e, Depth depth); - template Oriented_side operator() - ( const Point_3& pop, Halffacet_handle f, Depth depth); -#ifdef CGAL_NEF_EXPLOIT_REFERENCE_COUNTING - bool reference_counted; -#endif - Unique_hash_map OnSideMap; + Oriented_side operator()(Vertex_handle v); + Oriented_side operator()(Halfedge_handle e); + Oriented_side operator()(Halffacet_handle f); +private: + Unique_hash_map OnSideMap; #ifdef CGAL_NEF_EXPLOIT_REFERENCE_COUNTING Unique_hash_map OnSideMapRC; + bool reference_counted; #endif + int coord; + const Point_3 pop; }; template -class Objects_bbox { -public: - typedef typename SNC_decorator::SNC_structure SNC_structure; - typedef typename SNC_decorator::Decorator_traits Decorator_traits; - - typedef typename Decorator_traits::Vertex_handle Vertex_handle; - typedef typename Decorator_traits::Halfedge_handle Halfedge_handle; - typedef typename Decorator_traits::Halffacet_handle Halffacet_handle; - - typedef typename SNC_structure::Halffacet_triangle_handle Halffacet_triangle_handle; - typedef typename SNC_structure::Object_handle Object_handle; - typedef std::vector Object_list; - - typedef typename Decorator_traits::Halffacet_cycle_iterator - Halffacet_cycle_iterator; - typedef typename Decorator_traits::SHalfedge_around_facet_circulator - SHalfedge_around_facet_circulator; - typedef typename Decorator_traits::SHalfedge_handle SHalfedge_handle; - - typedef typename SNC_decorator::Kernel Kernel; - typedef typename Kernel::Plane_3 Plane_3; - typedef typename Kernel::Segment_3 Segment_3; - typedef typename Kernel::Point_3 Point_3; - typedef typename Kernel::Triangle_3 Triangle_3; - - typedef typename Kernel::RT RT; - typedef typename Kernel::FT FT; - typedef typename Kernel::Kernel_tag Kernel_tag; - typedef CGAL::Bounding_box_3 - Bounding_box_3; - // typedef CGAL::Bounding_box_3 - // ::value_type, Kernel> - // Bounding_box_3; - - Bounding_box_3 operator()( const Object_list& O) const { - Bounding_box_3 b; - typename Object_list::const_iterator o = O.begin(); - Vertex_handle v; - while(o != O.end() && !CGAL::assign(v, *o)) ++o; - if(o != O.end()) { - FT q[3]; - q[0] = v->point().x(); - q[1] = v->point().y(); - q[2] = v->point().z(); - Bounding_box_3 b(q); - for(++o; o != O.end(); ++o) { - if( CGAL::assign( v, *o)) { - b.extend(v->point()); - } - } - return b; - } - FT q[3]; - q[0] = q[1] = q[2] = 0; - return Bounding_box_3(q); - } - - /* - Bounding_box_3 operator()(Object_handle o) const { - Vertex_handle v; - Halfedge_handle e; - Halffacet_handle f; - if( CGAL::assign( v, o)) - return operator()(v); - else if( CGAL::assign( e, o)) - return operator()(e); - else if( CGAL::assign( f, o)) - return operator()(f); - else { - Halffacet_triangle_handle t; - if( CGAL::assign( t, o)) - return operator()(t); - else - CGAL_error_msg( "wrong handle"); - } - return Bounding_box_3(); // never reached - } - - Bounding_box_3 operator()(Vertex_handle v) const { - Bounding_box_3 b; - b.extend(v->point()); - return b; - } - - Bounding_box_3 operator()(Halfedge_handle e) const { - Bounding_box_3 b; - b.extend(e->source()->point()); - b.extend(e->twin()->source()->point()); - return b; - } - - Bounding_box_3 operator()(Halffacet_triangle_handle t) const { - Bounding_box_3 bbox; - Triangle_3 tr(t.get_triangle()); - for( int i = 0; i < 3; ++i) - bbox.extend(tr[i]); - return bbox; - } - - Bounding_box_3 operator()(Halffacet_handle f) const { - CGAL_assertion( f->facet_cycles_begin() != - Halffacet_cycle_iterator()); - Halffacet_cycle_iterator fc(f->facet_cycles_begin()); - SHalfedge_handle e; - CGAL_assertion(fc.is_shalfedge()); - e = SHalfedge_handle(fc); - SHalfedge_around_facet_circulator sc(e), send(sc); - CGAL_assertion( !is_empty_range( sc, send)); - Bounding_box_3 b; - CGAL_For_all( sc, send) - b.extend(sc->source()->source()->point()); - return b; - } - */ -}; +constexpr Oriented_side Side_of_plane::unknown_side; template class SNC_k3_tree_traits { @@ -283,6 +118,9 @@ public: typedef typename SNC_structure::Object_handle Object_handle; typedef std::vector Object_list; + typedef std::vector Vertex_list; + typedef std::vector Halfedge_list; + typedef std::vector Halffacet_list; typedef typename Kernel::Point_3 Point_3; typedef typename Kernel::Segment_3 Segment_3; @@ -294,55 +132,24 @@ public: typedef typename Kernel::RT RT; typedef typename Kernel::Kernel_tag Kernel_tag; - // typedef CGAL::Bounding_box_3 - // ::value_type, Kernel> - // Bounding_box_3; - typedef CGAL::Bounding_box_3 - Bounding_box_3; - + typedef CGAL::Bounding_box_3 Bounding_box_3; typedef typename Kernel::Intersect_3 Intersect; - typedef CGAL::Objects_bbox Objects_bbox; typedef CGAL::Side_of_plane Side_of_plane; Intersect intersect_object() const { return Intersect(); } - Objects_bbox objects_bbox_object() const { - return Objects_bbox(); - } }; template -template Oriented_side -Side_of_plane::operator() - (const Point_3& pop, Object_handle o, Depth depth) { - Vertex_handle v; - Halfedge_handle e; - Halffacet_handle f; - if( CGAL::assign( v, o)) - return (*this)(pop, v, depth); - else if( CGAL::assign( e, o)) - return (*this)(pop, e, depth); - else if( CGAL::assign( f, o)) - return (*this)(pop, f, depth); - else - CGAL_error_msg( "wrong handle"); - - return Oriented_side(); // never reached -} - -template -template -Oriented_side -Side_of_plane::operator() -( const Point_3& pop, Vertex_handle v, Depth depth) { - Comparison_result cr; +Side_of_plane::operator()(Vertex_handle v) { +Comparison_result cr; #ifdef CGAL_NEF_EXPLOIT_REFERENCE_COUNTING if(reference_counted) { if(!OnSideMapRC.is_defined(&(v->point().hw()))) - switch(depth%3) { + switch(coord) { case 0: cr = CGAL::compare_x(v->point(), pop); OnSideMapRC[&(v->point().hw())] = cr == LARGER ? ON_POSITIVE_SIDE : @@ -363,13 +170,14 @@ Side_of_plane::operator() return OnSideMapRC[&(v->point().hw())]; } else { #endif - ComparePoints_ compare(depth%3); - if(!OnSideMap.is_defined(v)) { - cr = compare(v->point(), pop); - OnSideMap[v] = cr == LARGER ? ON_POSITIVE_SIDE : - cr == SMALLER ? ON_NEGATIVE_SIDE : ON_ORIENTED_BOUNDARY; - } - return OnSideMap[v]; + Oriented_side& side = OnSideMap[v]; + if(side == unknown_side) { + Compare compare(coord); + cr = compare(v->point(), pop); + side = cr == LARGER ? ON_POSITIVE_SIDE : + cr == SMALLER ? ON_NEGATIVE_SIDE : ON_ORIENTED_BOUNDARY; + } + return side; #ifdef CGAL_NEF_EXPLOIT_REFERENCE_COUNTING } #endif @@ -383,57 +191,13 @@ Side_of_plane::operator() */ template -template Oriented_side -Side_of_plane::operator() -( const Point_3& pop, Halfedge_handle e, Depth depth) { +Side_of_plane::operator()(Halfedge_handle e) { Vertex_handle v = e->source(); Vertex_handle vt = e->twin()->source(); - /* - Comparison_result cr; - if(!OnSideMap.is_defined(v)) - switch(depth%3) { - case 0: - cr = CGAL::compare_x(v->point(), pop); - OnSideMap[v] = cr == LARGER ? ON_POSITIVE_SIDE : - cr == SMALLER ? ON_NEGATIVE_SIDE : ON_ORIENTED_BOUNDARY; - break; - case 1: - cr = CGAL::compare_y(v->point(), pop); - OnSideMap[v] = cr == LARGER ? ON_POSITIVE_SIDE : - cr == SMALLER ? ON_NEGATIVE_SIDE : ON_ORIENTED_BOUNDARY; - break; - case 2: - cr = CGAL::compare_z(v->point(), pop); - OnSideMap[v] = cr == LARGER ? ON_POSITIVE_SIDE : - cr == SMALLER ? ON_NEGATIVE_SIDE : ON_ORIENTED_BOUNDARY; - break; - default: CGAL_error_msg( "wrong value"); - } - if(!OnSideMap.is_defined(vt)) - switch(depth%3) { - case 0: - cr = CGAL::compare_x(vt->point(), pop); - OnSideMap[vt] = cr == LARGER ? ON_POSITIVE_SIDE : - cr == SMALLER ? ON_NEGATIVE_SIDE : ON_ORIENTED_BOUNDARY; - break; - case 1: - cr = CGAL::compare_y(vt->point(), pop); - OnSideMap[vt] = cr == LARGER ? ON_POSITIVE_SIDE : - cr == SMALLER ? ON_NEGATIVE_SIDE : ON_ORIENTED_BOUNDARY; - break; - case 2: - cr = CGAL::compare_z(vt->point(), pop); - OnSideMap[vt] = cr == LARGER ? ON_POSITIVE_SIDE : - cr == SMALLER ? ON_NEGATIVE_SIDE : ON_ORIENTED_BOUNDARY; - break; - default: CGAL_error_msg( "wrong value"); - } - Oriented_side src_side = OnSideMap[v]; - Oriented_side tgt_side = OnSideMap[vt]; -*/ - Oriented_side src_side = (*this) (pop, v, depth); - Oriented_side tgt_side = (*this) (pop, vt, depth); + + Oriented_side src_side = (*this) (v); + Oriented_side tgt_side = (*this) (vt); if( src_side == tgt_side) return src_side; if( src_side == ON_ORIENTED_BOUNDARY) @@ -457,37 +221,10 @@ Side_of_plane::operator() template -template Oriented_side -Side_of_plane::operator() - (const Point_3& pop, Halffacet_handle f, Depth depth) { +Side_of_plane::operator()(Halffacet_handle f) { CGAL_assertion( std::distance( f->facet_cycles_begin(), f->facet_cycles_end()) > 0); - /* -#ifdef CGAL_NEF3_FACET_WITH_BOX - switch(depth%3) { - case 0: - if(f->b.min_coord(0) > pop.x()) - return ON_POSITIVE_SIDE; - if(f->b.max_coord(0) < pop.x()) - return ON_NEGATIVE_SIDE; - break; - case 1: - if(f->b.min_coord(1) > pop.y()) - return ON_POSITIVE_SIDE; - if(f->b.max_coord(1) < pop.y()) - return ON_NEGATIVE_SIDE; - break; - case 2: - if(f->b.min_coord(2) > pop.z()) - return ON_POSITIVE_SIDE; - if(f->b.max_coord(2) < pop.z()) - return ON_NEGATIVE_SIDE; - break; - default: CGAL_error_msg( "wrong value"); - } - return ON_ORIENTED_BOUNDARY; -#else - */ + Halffacet_cycle_iterator fc(f->facet_cycles_begin()); SHalfedge_handle e; CGAL_assertion(fc.is_shalfedge()); @@ -499,7 +236,7 @@ Side_of_plane::operator() Vertex_handle v; do { v = sc->source()->center_vertex(); - facet_side = (*this) (pop, v, depth); + facet_side = (*this) (v); ++sc; } while( facet_side == ON_ORIENTED_BOUNDARY && sc != send); @@ -509,7 +246,7 @@ Side_of_plane::operator() Oriented_side point_side; while( sc != send) { v = sc->source()->center_vertex(); - point_side = (*this) (pop, v, depth); + point_side = (*this) (v); ++sc; if( point_side == ON_ORIENTED_BOUNDARY) continue; 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 9a91e4259d8..0cb23307d66 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h @@ -190,37 +190,13 @@ public: virtual void initialize(SNC_structure* W) { -#ifdef CGAL_NEF_LIST_OF_TRIANGLES - this->set_snc(*W); - candidate_provider = new SNC_candidate_provider(W); -#else // CGAL_NEF_LIST_OF_TRIANGLES - CGAL_NEF_TIMER(ct_t.start()); - this->version_ = std::string("Point Locator by Spatial Subdivision (tm)"); - CGAL_NEF_CLOG(version()); - CGAL_assertion( W != nullptr); -// (Base) *this = SNC_decorator(*W); - this->set_snc(*W); - Object_list objects; - Vertex_iterator v; - Halfedge_iterator e; - Halffacet_iterator f; - CGAL_forall_vertices( v, *this->sncp()) - objects.push_back(make_object(Vertex_handle(v))); - typename Object_list::difference_type v_end = objects.size(); - CGAL_forall_edges( e, *this->sncp()) - objects.push_back(make_object(Halfedge_handle(e))); - CGAL_forall_facets( f, *this->sncp()) { - objects.push_back(make_object(Halffacet_handle(f))); - } + if(initialized) delete candidate_provider; - Object_list_iterator oli=objects.begin()+v_end; - candidate_provider = new SNC_candidate_provider(objects,oli); + this->set_snc(*W); + candidate_provider = new SNC_candidate_provider(W); - // CGAL_NEF_TRACEN(*candidate_provider); - CGAL_NEF_TIMER(ct_t.stop()); -#endif // CGAL_NEF_LIST_OF_TRIANGLES initialized = true; } diff --git a/Nef_3/include/CGAL/Nef_polyhedron_3.h b/Nef_3/include/CGAL/Nef_polyhedron_3.h index 88fb4bf95a0..c4d0e48fa30 100644 --- a/Nef_3/include/CGAL/Nef_polyhedron_3.h +++ b/Nef_3/include/CGAL/Nef_polyhedron_3.h @@ -117,7 +117,7 @@ class Nef_polyhedron_3_rep SNC_point_locator* pl_; public: - Nef_polyhedron_3_rep() : snc_(), pl_() {} + Nef_polyhedron_3_rep() : snc_(), pl_(nullptr) {} ~Nef_polyhedron_3_rep() { CGAL_NEF_TRACEN( "Nef_polyhedron_3_rep: destroying SNC structure "<<&snc_<< ", point locator "< - Nef_polyhedron_3(InputIterator begin, InputIterator end, Polylines_tag) { + Nef_polyhedron_3(InputIterator begin, InputIterator end, Polylines_tag) + : Nef_polyhedron_3(Private_tag{}) + { typedef typename std::iterator_traits::value_type point_iterator_pair; typedef typename point_iterator_pair::first_type point_iterator; - empty_rep(); - set_snc(snc()); initialize_infibox_vertices(EMPTY); point_iterator pbegin, pend, pnext, pprev; @@ -556,9 +562,9 @@ protected: } explicit - Nef_polyhedron_3(const Segment_3& s) { - empty_rep(); - set_snc(snc()); + Nef_polyhedron_3(const Segment_3& s) + : Nef_polyhedron_3(Private_tag{}) + { initialize_infibox_vertices(EMPTY); Sphere_map_creator smc; @@ -573,9 +579,9 @@ protected: } template - Nef_polyhedron_3(InputIterator begin, InputIterator end, Points_tag) { - empty_rep(); - set_snc(snc()); + Nef_polyhedron_3(InputIterator begin, InputIterator end, Points_tag) + : Nef_polyhedron_3(Private_tag{}) + { initialize_infibox_vertices(EMPTY); for(InputIterator it=begin; it!=end;++it) @@ -589,9 +595,9 @@ protected: } explicit - Nef_polyhedron_3(const Point_3& p) { - empty_rep(); - set_snc(snc()); + Nef_polyhedron_3(const Point_3& p) + : Nef_polyhedron_3(Private_tag{}) + { initialize_infibox_vertices(EMPTY); Vertex_handle v(snc().new_vertex(p, true)); @@ -605,30 +611,28 @@ protected: template class T3, class T4 > - Nef_polyhedron_3( CGAL::Polyhedron_3& P) { + Nef_polyhedron_3( CGAL::Polyhedron_3& P) + : Nef_polyhedron_3(Private_tag{}) + { CGAL_NEF_TRACEN("construction from Polyhedron_3"); - SNC_structure rsnc; - *this = Nef_polyhedron_3(rsnc, new SNC_point_locator_default, false); initialize_infibox_vertices(EMPTY); polyhedron_3_to_nef_3 , SNC_structure>( P, snc()); build_external_structure(); mark_bounded_volumes(); simplify(); - set_snc(snc()); } template - explicit Nef_polyhedron_3(const PolygonMesh& pm) { + explicit Nef_polyhedron_3(const PolygonMesh& pm) + : Nef_polyhedron_3(Private_tag{}) + { CGAL_NEF_TRACEN("construction from PolygonMesh with internal index maps"); - SNC_structure rsnc; - *this = Nef_polyhedron_3(rsnc, new SNC_point_locator_default, false); initialize_infibox_vertices(EMPTY); polygon_mesh_to_nef_3(const_cast(pm), snc()); build_external_structure(); mark_bounded_volumes(); simplify(); - set_snc(snc()); } template @@ -638,30 +642,25 @@ protected: typename boost::disable_if < boost::is_same >::type* = nullptr // disambiguate with another constructor - ) + ) : Nef_polyhedron_3(Private_tag{}) { CGAL_NEF_TRACEN("construction from PolygonMesh"); - SNC_structure rsnc; - *this = Nef_polyhedron_3(rsnc, new SNC_point_locator_default, false); initialize_infibox_vertices(EMPTY); polygon_mesh_to_nef_3(const_cast(pm), snc(), fim, him); build_external_structure(); mark_bounded_volumes(); simplify(); - set_snc(snc()); } Nef_polyhedron_3(const Nef_polyhedron& N, SFace_const_iterator sf) + : Nef_polyhedron_3(Private_tag{}) { - SNC_structure rsnc; - *this = Nef_polyhedron_3(rsnc, new SNC_point_locator_default, false); initialize_infibox_vertices(EMPTY); shell_to_nef_3(N, sf, snc()); build_external_structure(); mark_bounded_volumes(); simplify(); - set_snc(snc()); } @@ -1421,8 +1420,7 @@ protected: if (is_space()) return N1; if (N1.is_space()) return *this; AND _and; - SNC_structure rsnc; - Nef_polyhedron_3 res(rsnc, new SNC_point_locator_default, false); + Nef_polyhedron_3 res(Private_tag{}); Binary_operation bo( res.snc()); bo(res.pl(), snc(), pl(), N1.snc(), N1.pl(), _and); return res; @@ -1432,8 +1430,7 @@ protected: intersection(const Plane_3& plane, Intersection_mode im) const { AND _and; - SNC_structure rsnc; - Nef_polyhedron_3 res(rsnc, new SNC_point_locator_default, false); + Nef_polyhedron_3 res(Private_tag{}); Combine_with_halfspace cwh(res.snc(), res.pl()); cwh.combine_with_halfspace(snc(), plane, _and, static_cast(im)); @@ -1450,8 +1447,7 @@ protected: if (N1.is_space()) return N1; OR _or; //CGAL::binop_intersection_tests_allpairs tests_impl; - SNC_structure rsnc; - Nef_polyhedron_3 res(rsnc, new SNC_point_locator_default, false); + Nef_polyhedron_3 res(Private_tag{}); Binary_operation bo(res.snc()); bo(res.pl(), snc(), pl(), N1.snc(), N1.pl(), _or); return res; @@ -1467,8 +1463,7 @@ protected: if (N1.is_space()) return Nef_polyhedron_3(EMPTY); DIFF _diff; //CGAL::binop_intersection_tests_allpairs tests_impl; - SNC_structure rsnc; - Nef_polyhedron_3 res(rsnc, new SNC_point_locator_default, false); + Nef_polyhedron_3 res(Private_tag{}); Binary_operation bo(res.snc()); bo(res.pl(), snc(), pl(), N1.snc(), N1.pl(), _diff); return res; @@ -1485,8 +1480,7 @@ protected: if (N1.is_space()) return Nef_polyhedron_3(EMPTY); XOR _xor; //CGAL::binop_intersection_tests_allpairs tests_impl; - SNC_structure rsnc; - Nef_polyhedron_3 res(rsnc, new SNC_point_locator_default, false); + Nef_polyhedron_3 res(Private_tag{}); Binary_operation bo(res.snc()); bo(res.pl(), snc(), pl(), N1.snc(), N1.pl(), _xor); return res; @@ -2003,10 +1997,10 @@ protected: template Nef_polyhedron_3:: -Nef_polyhedron_3( Content space) { +Nef_polyhedron_3( Content space) + : Nef_polyhedron_3(Private_tag{}) +{ CGAL_NEF_TRACEN("construction from empty or space."); - empty_rep(); - set_snc(snc()); if(Infi_box::extended_kernel()) { initialize_infibox_vertices(space); build_external_structure(); @@ -2018,10 +2012,10 @@ Nef_polyhedron_3( Content space) { template Nef_polyhedron_3:: -Nef_polyhedron_3(const Plane_3& h, Boundary b) { +Nef_polyhedron_3(const Plane_3& h, Boundary b) + : Nef_polyhedron_3(Private_tag{}) +{ CGAL_NEF_TRACEN("construction from plane "< #include #include -#include #include #include #include #include #include +#include namespace CGAL{ @@ -36,7 +36,7 @@ namespace nef_to_pm{ template struct Shell_vertex_index_visitor { - typedef boost::unordered_map< + typedef std::unordered_map< typename Nef_polyhedron::Vertex_const_handle, std::size_t> Vertex_index_map; typedef typename PointRange::value_type Point_3; PointRange& points; @@ -76,7 +76,7 @@ struct FaceInfo2 template struct Shell_polygons_visitor { - typedef boost::unordered_map Vertex_index_map; + typedef std::unordered_map Vertex_index_map; typedef typename PolygonRange::value_type Polygon; Vertex_index_map& vertex_indices; PolygonRange& polygons; diff --git a/Nef_3/include/CGAL/draw_nef_3.h b/Nef_3/include/CGAL/draw_nef_3.h index 5a81d639ea3..e654ea9aae7 100644 --- a/Nef_3/include/CGAL/draw_nef_3.h +++ b/Nef_3/include/CGAL/draw_nef_3.h @@ -22,6 +22,8 @@ #include #include #include +#include + #include namespace CGAL { @@ -101,9 +103,10 @@ protected: return; } + + SHalfedge_const_handle se; - Halffacet_cycle_const_iterator fc; - fc = f->facet_cycles_begin(); + Halffacet_cycle_const_iterator fc=f->facet_cycles_begin(); se = SHalfedge_const_handle(fc); // non-zero if shalfedge is returned if(se == 0) @@ -116,13 +119,35 @@ protected: SHalfedge_around_facet_const_circulator hc_start(se); SHalfedge_around_facet_const_circulator hc_end(hc_start); + Vertex_const_handle lastvh; CGAL_For_all(hc_start, hc_end) { - Vertex_const_handle vh = hc_start->source()->center_vertex(); + Vertex_const_handle vh=hc_start->source()->center_vertex(); + lastvh=vh; viewer.add_point_in_face(vh->point(), viewer.get_vertex_normal(vh)); } + + // Now iterate through holes of the face + ++fc; + while(fc!=f->facet_cycles_end()) + { + se = SHalfedge_const_handle(fc); + hc_start=se; + 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.add_point_in_face(hc_start->source()->center_vertex()->point(), + viewer.get_vertex_normal(hc_start->source()->center_vertex())); + viewer.add_point_in_face(lastvh->point(), + viewer.get_vertex_normal(lastvh)); + ++fc; + } + viewer.face_end(); - facets_done[f] = true; + facets_done[f]=true; n_faces++; } @@ -209,7 +234,7 @@ protected: ++nb; } - assert(nb > 0); + CGAL_assertion(nb > 0); return (typename Local_kernel::Construct_scaled_vector_3()(normal, 1.0 / nb)); } diff --git a/Nef_3/test/Nef_3/test_nef_to_soup.cpp b/Nef_3/test/Nef_3/test_nef_to_soup.cpp index c39e705d502..2774c76d2b2 100644 --- a/Nef_3/test/Nef_3/test_nef_to_soup.cpp +++ b/Nef_3/test/Nef_3/test_nef_to_soup.cpp @@ -7,6 +7,7 @@ #include #include +#include typedef CGAL::Exact_predicates_exact_constructions_kernel EPEC; typedef CGAL::Exact_predicates_inexact_constructions_kernel EPIC; @@ -39,8 +40,8 @@ int main() PolygonRange polygons; std::cout << " convert...\n"; CGAL::convert_nef_polyhedron_to_polygon_soup(nef, points, polygons); - CGAL_assertion(points.size() == 4); - CGAL_assertion(polygons.size() == 4); + assert(points.size() == 4); + assert(polygons.size() == 4); PolygonMesh pm; CGAL::convert_nef_polyhedron_to_polygon_mesh< Nef_polyhedron, diff --git a/Nef_S2/examples/Nef_S2/nef_s2_construction.cpp b/Nef_S2/examples/Nef_S2/nef_s2_construction.cpp index 679f5f0b4bf..e0c28b413e0 100644 --- a/Nef_S2/examples/Nef_S2/nef_s2_construction.cpp +++ b/Nef_S2/examples/Nef_S2/nef_s2_construction.cpp @@ -1,6 +1,7 @@ #include #include #include +#include typedef CGAL::Exact_integer RT; typedef CGAL::Homogeneous Kernel; @@ -16,7 +17,7 @@ int main() { Sphere_circle c(1,1,1); // c : x + y + z = 0 Nef_polyhedron N2(c, Nef_polyhedron::INCLUDED); Nef_polyhedron N3(N2.complement()); - CGAL_assertion(N1 == N2.join(N3)); + assert(N1 == N2.join(N3)); Sphere_point p1(1,0,0), p2(0,1,0), p3(0,0,1); Sphere_segment s1(p1,p2), s2(p2,p3), s3(p3,p1); Sphere_segment triangle[3] = { s1, s2, s3 }; @@ -24,7 +25,7 @@ int main() { Nef_polyhedron N5; N5 += N2; N5 = N5.intersection(N4); - CGAL_assertion(N5 <= N2 && N5 != N4); + assert(N5 <= N2 && N5 != N4); return 0; } diff --git a/Number_types/include/CGAL/NT_converter.h b/Number_types/include/CGAL/NT_converter.h index ac225f1e0cb..37f259abf80 100644 --- a/Number_types/include/CGAL/NT_converter.h +++ b/Number_types/include/CGAL/NT_converter.h @@ -13,16 +13,20 @@ #ifndef CGAL_NT_CONVERTER_H #define CGAL_NT_CONVERTER_H -#include #include #include -template class Interval_nt; +#include namespace CGAL { -// A number type converter usable as default, using the conversion operator. +template +class Interval_nt; +template +class Quotient; + +// A number type converter usable as default, using the conversion operator. template < class NT1, class NT2 > struct NT_converter : public CGAL::cpp98::unary_function< NT1, NT2 > @@ -38,6 +42,7 @@ struct NT_converter // - double to call to_double(). // - Interval_nt<> to call to_interval(). // - NT1 == NT2 to return a reference instead of copying. +// - Quotient conversions template < class NT1 > struct NT_converter < NT1, NT1 > @@ -116,6 +121,29 @@ struct NT_converter < Interval_nt, Interval_nt > } }; +template < class NT > +struct NT_converter < Quotient, Quotient > + : public CGAL::cpp98::unary_function< Quotient, Quotient > +{ + const Quotient& + operator()(const Quotient & q) const + { + return q; + } +}; + +template < class NT1, class NT2 > +struct NT_converter < Quotient, Quotient > + : public CGAL::cpp98::unary_function< Quotient, Quotient > +{ + Quotient + operator()(const Quotient & q) const + { + NT_converter < NT1, NT2 > nt; + return Quotient(nt(q.numerator()), nt(q.denominator())); + } +}; + } //namespace CGAL #endif // CGAL_NT_CONVERTER_H diff --git a/Number_types/include/CGAL/boost_mp.h b/Number_types/include/CGAL/boost_mp.h index 3548fdc249a..b41fa568eb6 100644 --- a/Number_types/include/CGAL/boost_mp.h +++ b/Number_types/include/CGAL/boost_mp.h @@ -438,7 +438,7 @@ struct Fraction_traits // Coercions -namespace internal { namespace boost_mp { BOOST_MPL_HAS_XXX_TRAIT_DEF(type); } } +namespace internal { namespace boost_mp { BOOST_MPL_HAS_XXX_TRAIT_DEF(type) } } template struct Coercion_traits, boost::multiprecision::number > diff --git a/Number_types/test/Number_types/CMakeLists.txt b/Number_types/test/Number_types/CMakeLists.txt index d65fbbcd3b3..046a588e5b0 100644 --- a/Number_types/test/Number_types/CMakeLists.txt +++ b/Number_types/test/Number_types/CMakeLists.txt @@ -12,6 +12,7 @@ include(CGAL_VersionUtils) include_directories(BEFORE include) + create_single_source_cgal_program("bench_interval.cpp") create_single_source_cgal_program("constant.cpp") create_single_source_cgal_program("CORE_BigFloat.cpp") diff --git a/Number_types/test/Number_types/CORE_Expr.cpp b/Number_types/test/Number_types/CORE_Expr.cpp index 379262182ed..74bb4b14350 100644 --- a/Number_types/test/Number_types/CORE_Expr.cpp +++ b/Number_types/test/Number_types/CORE_Expr.cpp @@ -3,7 +3,9 @@ #ifdef CGAL_USE_CORE #include #include +#include #include + #include #include #include @@ -30,7 +32,7 @@ void precision_bug() sqrtD1D2.approx(53,1075); //force evaluation of sqrtD1D2 uz.approx(53,1075); - CGAL_assertion(!uz.isZero()); + assert(!uz.isZero()); } //computation without forced evaluation of sqrtD1D2 { @@ -47,7 +49,7 @@ void precision_bug() FT a1a2b1b2 = a1 * a2 + b1 * b2; FT uz = sqrtD1D2 - a1a2b1b2 ; - CGAL_assertion(!uz.isZero()); + assert(!uz.isZero()); } std::cout << "precision bug OK\n"; } @@ -667,4 +669,3 @@ int main(){ int main() { return 0; } #endif // CGAL_USE_CORE //EOF - diff --git a/Number_types/test/Number_types/Exact_rational.cpp b/Number_types/test/Number_types/Exact_rational.cpp new file mode 100644 index 00000000000..926d092c311 --- /dev/null +++ b/Number_types/test/Number_types/Exact_rational.cpp @@ -0,0 +1,20 @@ +#include +#include + +typedef CGAL::Exact_rational Rational; + +int main() +{ + std::cout << typeid(Rational).name() << std::endl; + + Rational rat(-0.375); + double d = -0.625; + + std::cout << "rat : " << rat << std::endl; + + Rational sub = rat - d; + std::cout << "sub : " << sub << std::endl; + assert(rat != sub); + + return 0; +} diff --git a/Optimal_bounding_box/doc/Optimal_bounding_box/Doxyfile.in b/Optimal_bounding_box/doc/Optimal_bounding_box/Doxyfile.in index 01d0768a767..660c20cc18a 100644 --- a/Optimal_bounding_box/doc/Optimal_bounding_box/Doxyfile.in +++ b/Optimal_bounding_box/doc/Optimal_bounding_box/Doxyfile.in @@ -5,10 +5,6 @@ EXTRACT_ALL = false HIDE_UNDOC_CLASSES = true WARN_IF_UNDOCUMENTED = true -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = YES -EXPAND_AS_DEFINED = CGAL_BGL_NP_TEMPLATE_PARAMETERS \ - CGAL_BGL_NP_CLASS EXCLUDE = ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Optimal_bounding_box/internal EXCLUDE_SYMBOLS += experimental diff --git a/Optimal_bounding_box/include/CGAL/Optimal_bounding_box/oriented_bounding_box.h b/Optimal_bounding_box/include/CGAL/Optimal_bounding_box/oriented_bounding_box.h index 1433ed2fb9f..7ea56c452d8 100644 --- a/Optimal_bounding_box/include/CGAL/Optimal_bounding_box/oriented_bounding_box.h +++ b/Optimal_bounding_box/include/CGAL/Optimal_bounding_box/oriented_bounding_box.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -44,11 +44,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { namespace Optimal_bounding_box { namespace internal { @@ -97,7 +92,7 @@ void construct_oriented_bounding_box(const PointRange& points, obb_points[6] = cp(xmax, ymin, zmax); obb_points[7] = cp(xmax, ymax, zmax); - // Apply the inverse rotation to the rotated axis aligned bounding box + // Apply the inverse rotation to the rotated axis-aligned bounding box for(std::size_t i=0; i<8; ++i) { obb_points[i] = inverse_transformation.transform(obb_points[i]); @@ -146,13 +141,13 @@ void compute_best_transformation(const PointRange& points, rot(1, 0), rot(1, 1), rot(1, 2), rot(2, 0), rot(2, 1), rot(2, 2)); - // inverse transformation is simply the transposed since the matrix is unitary + // the inverse transformation is simply the transposed matrix since the matrix is unitary inverse_transformation = Aff_transformation_3(rot(0, 0), rot(1, 0), rot(2, 0), rot(0, 1), rot(1, 1), rot(2, 1), rot(0, 2), rot(1, 2), rot(2, 2)); } -// Following two functions are overloads to dispatch depending on return type +// The following two functions are overloads to dispatch depending on the return type template void construct_oriented_bounding_box(const PointRange& points, CGAL::Aff_transformation_3& transformation, @@ -317,10 +312,10 @@ void construct_oriented_bounding_box(const PointRange& points, /// template + typename NamedParameters = parameters::Default_named_parameters> void oriented_bounding_box(const PointRange& points, Output& out, - const CGAL_BGL_NP_CLASS& np + const NamedParameters& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if< typename boost::has_range_iterator @@ -330,8 +325,9 @@ void oriented_bounding_box(const PointRange& points, { using CGAL::parameters::choose_parameter; using CGAL::parameters::get_parameter; + using CGAL::parameters::is_default_parameter; - typedef typename CGAL::GetPointMap::type PointMap; + typedef typename CGAL::GetPointMap::type PointMap; #if defined(CGAL_EIGEN3_ENABLED) typedef typename boost::property_traits::value_type Point; @@ -342,7 +338,7 @@ void oriented_bounding_box(const PointRange& points, #endif typedef typename internal_np::Lookup_named_param_def::type Geom_traits; CGAL_static_assertion_msg(!(std::is_same::value), @@ -355,7 +351,8 @@ void oriented_bounding_box(const PointRange& points, const unsigned int seed = choose_parameter(get_parameter(np, internal_np::random_seed), -1); // undocumented CGAL::Random fixed_seed_rng(seed); - CGAL::Random& rng = (seed == unsigned(-1)) ? CGAL::get_default_random() : fixed_seed_rng; + CGAL::Random& rng = is_default_parameter() ? + CGAL::get_default_random() : fixed_seed_rng; #ifdef CGAL_OPTIMAL_BOUNDING_BOX_DEBUG std::cout << "Random seed: " << rng.get_seed() << std::endl; @@ -418,10 +415,10 @@ void oriented_bounding_box(const PointRange& points, /// template + typename NamedParameters = parameters::Default_named_parameters> void oriented_bounding_box(const PolygonMesh& pmesh, Output& out, - const CGAL_BGL_NP_CLASS& np + const NamedParameters& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::disable_if< typename boost::has_range_iterator @@ -432,7 +429,7 @@ void oriented_bounding_box(const PolygonMesh& pmesh, using CGAL::parameters::choose_parameter; using CGAL::parameters::get_parameter; - typedef typename CGAL::GetVertexPointMap::const_type VPM; + typedef typename CGAL::GetVertexPointMap::const_type VPM; VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(vertex_point, pmesh)); @@ -440,20 +437,6 @@ void oriented_bounding_box(const PolygonMesh& pmesh, oriented_bounding_box(vertices(pmesh), out, np.point_map(vpm)); } -/// \cond SKIP_IN_MANUAL - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/// Convenience overloads -///////////////////////////////////////////////////////////////////////////////////////////////// - -template -void oriented_bounding_box(const Input& in, Output& out) -{ - return oriented_bounding_box(in, out, CGAL::parameters::all_default()); -} - -/// \endcond - } // end namespace CGAL #endif // CGAL_OPTIMAL_BOUNDING_BOX_ORIENTED_BOUNDING_BOX_H diff --git a/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies b/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies index 4ba805152f7..34ad48e6a80 100644 --- a/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies +++ b/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies @@ -27,4 +27,3 @@ STL_Extension Solver_interface Stream_support TDS_2 -Triangulation_2 diff --git a/Optimal_transportation_reconstruction_2/include/CGAL/Optimal_transportation_reconstruction_2.h b/Optimal_transportation_reconstruction_2/include/CGAL/Optimal_transportation_reconstruction_2.h index d315957efb9..9617930d52f 100644 --- a/Optimal_transportation_reconstruction_2/include/CGAL/Optimal_transportation_reconstruction_2.h +++ b/Optimal_transportation_reconstruction_2/include/CGAL/Optimal_transportation_reconstruction_2.h @@ -155,6 +155,7 @@ public: typedef typename Triangulation::MultiIndex MultiIndex; + /// \endcond /// @} protected: @@ -173,8 +174,6 @@ protected: PointPMap point_pmap; MassPMap mass_pmap; - /// \endcond - public: /// \name Initialization @@ -313,6 +312,7 @@ public: } FT tolerance() const { return m_tolerance; } + /// \endcond /// @} @@ -1160,10 +1160,6 @@ public: } } - /// \endcond - - - /// \cond SKIP_IN_MANUAL Vector compute_gradient(Vertex_handle vertex) const { Vector grad = m_traits.construct_vector_2_object()(FT(0), FT(0)); Edge_circulator ecirc = m_dt.incident_edges(vertex); @@ -1785,8 +1781,6 @@ public: e_it++; } } - /// \endcond - /// \cond SKIP_IN_MANUAL const Triangulation& tds() const { return m_dt; } 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 f33b9862f3c..504172c56d1 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 @@ -198,8 +198,7 @@ parameters: P2Triangulation2secTraits. The concepts that should be refined are `Periodic_2TriangulationTraits_2` (for `Periodic_2_triangulation_2`) and `Periodic_2DelaunayTriangulationTraits_2` (for - `Periodic_2_Delaunay_triangulation_2`) in the reference manual and -. + `Periodic_2_Delaunay_triangulation_2`). - the triangulation data structure class, which stores the combinatorial structure, described in Section \ref P2Triangulation2sectds and in more detail in Chapter \ref 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 index c99cf2361d0..11bbef2e0f4 100644 --- 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 @@ -23,7 +23,6 @@ int main(int argc, char* argv[]) { while (ifs >> p) { T.insert(p); } - CGAL_assertion(T.is_valid()); if( T.is_triangulation_in_1_sheet()) { T.convert_to_9_sheeted_covering(); } diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_pair_iterator_2.cpp b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_pair_iterator_2.cpp index 921afdc0bd1..3a18d93e99d 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_pair_iterator_2.cpp +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_pair_iterator_2.cpp @@ -31,8 +31,6 @@ int main() Delaunay T; T.insert( points.begin(), points.end() ); - CGAL_assertion( T.number_of_vertices() == 6 ); - // check that the info was correctly set. Delaunay::Finite_vertices_iterator vit; for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_transform_iterator_2.cpp b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_transform_iterator_2.cpp index c67bf9f324c..e416be8bf4f 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_transform_iterator_2.cpp +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_transform_iterator_2.cpp @@ -46,8 +46,6 @@ int main() T.insert( boost::make_transform_iterator(points.begin(), Auto_count()), boost::make_transform_iterator(points.end(), Auto_count() ) ); - CGAL_assertion( T.number_of_vertices() == 6 ); - // check that the info was correctly set. Delaunay::Finite_vertices_iterator vit; for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_zip_iterator_2.cpp b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_zip_iterator_2.cpp index 7862f102373..dabb31388a7 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_zip_iterator_2.cpp +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_zip_iterator_2.cpp @@ -41,9 +41,6 @@ int main() T.insert( boost::make_zip_iterator(boost::make_tuple( points.begin(), indices.begin() )), boost::make_zip_iterator(boost::make_tuple( points.end(), indices.end() ) ) ); - CGAL_assertion( T.number_of_vertices() == 6 ); - - // check that the info was correctly set. Delaunay::Finite_vertices_iterator vit; for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/include/interface_test.h b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/include/interface_test.h index 9e91d900d03..efbd3cf0be4 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/include/interface_test.h +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/include/interface_test.h @@ -16,30 +16,30 @@ void test_constructor() T t; T t2(t); - CGAL_assertion(t == t2); + assert(t == t2); T t3 = t2; - CGAL_assertion(t == t3); + assert(t == t3); T t4(Iso_rectangle(0, 0, 2, 2)); T t5(Iso_rectangle(0, 0, 2, 2), Geom_traits()); t5.clear(); t.insert(Point(0.5, 0.5)); - CGAL_assertion(t != t2); - CGAL_assertion(t != t3); + assert(t != t2); + assert(t != t3); T t6(t); - CGAL_assertion(t == t6); + assert(t == t6); T t7 = t6; - CGAL_assertion(t == t7); + assert(t == t7); t.clear(); - CGAL_assertion(t != t6); - CGAL_assertion(t != t7); + assert(t != t6); + assert(t != t7); t.swap(t7); - CGAL_assertion(t7.empty()); - CGAL_assertion(!t.empty()); - CGAL_assertion(t != t7); + assert(t7.empty()); + assert(!t.empty()); + assert(t != t7); } template @@ -58,28 +58,28 @@ void test_global_access() t_const.dimension(); size_t number_of_vertices = t_const.number_of_vertices(); - CGAL_USE(number_of_vertices); - CGAL_assertion(number_of_vertices == t.number_of_vertices()); + + assert(number_of_vertices == t.number_of_vertices()); size_t number_of_faces = t_const.number_of_faces(); - CGAL_USE(number_of_faces); - CGAL_assertion(number_of_faces == t.number_of_faces()); + + assert(number_of_faces == t.number_of_faces()); size_t number_of_stored_vertices = t_const.number_of_stored_vertices(); - CGAL_USE(number_of_stored_vertices); - CGAL_assertion(number_of_stored_vertices == t.number_of_stored_vertices()); + + assert(number_of_stored_vertices == t.number_of_stored_vertices()); size_t number_of_stored_faces = t_const.number_of_stored_faces(); - CGAL_USE(number_of_stored_faces); - CGAL_assertion(number_of_stored_faces == t.number_of_stored_faces()); + + assert(number_of_stored_faces == t.number_of_stored_faces()); size_t number_of_edges = t_const.number_of_edges(); - CGAL_USE(number_of_edges); - CGAL_assertion(number_of_edges == t.number_of_edges()); + + assert(number_of_edges == t.number_of_edges()); size_t number_of_stored_edges = t_const.number_of_stored_edges(); - CGAL_USE(number_of_stored_edges); - CGAL_assertion(number_of_stored_edges == t.number_of_stored_edges()); + + assert(number_of_stored_edges == t.number_of_stored_edges()); bool is_triang1 = t_const.is_triangulation_in_1_sheet(); - CGAL_USE(is_triang1); - CGAL_assertion(is_triang1 == t.is_triangulation_in_1_sheet()); + + assert(is_triang1 == t.is_triangulation_in_1_sheet()); t.convert_to_1_sheeted_covering(); t.convert_to_9_sheeted_covering(); } @@ -91,11 +91,11 @@ void test_delaunay_global_access() const T &t_const = t; bool ext1 = t_const.is_extensible_triangulation_in_1_sheet_h1(); - CGAL_USE(ext1); - CGAL_assertion(ext1 == t.is_extensible_triangulation_in_1_sheet_h1()); + + assert(ext1 == t.is_extensible_triangulation_in_1_sheet_h1()); bool ext2 = t_const.is_extensible_triangulation_in_1_sheet_h2(); - CGAL_USE(ext2); - CGAL_assertion(ext2 == t.is_extensible_triangulation_in_1_sheet_h2()); + + assert(ext2 == t.is_extensible_triangulation_in_1_sheet_h2()); } template @@ -215,21 +215,21 @@ void test_iterators() { ++size; } - CGAL_assertion(size == t_const.number_of_stored_vertices()); + assert(size == t_const.number_of_stored_vertices()); size = 0; for (typename T::Unique_vertex_iterator uvit = t_const.unique_vertices_begin(); uvit != t_const.unique_vertices_end(); ++uvit) { ++size; } - CGAL_assertion(size == t_const.number_of_vertices()); + assert(size == t_const.number_of_vertices()); size = 0; for (typename T::Vertex_iterator vit = t_const.all_vertices_begin(); vit != t_const.all_vertices_end(); ++vit) { ++size; } - CGAL_assertion(size == t_const.number_of_stored_vertices()); + assert(size == t_const.number_of_stored_vertices()); // edges size = 0; @@ -238,14 +238,14 @@ void test_iterators() { ++size; } - CGAL_assertion(size == t_const.number_of_stored_edges()); + assert(size == t_const.number_of_stored_edges()); size = 0; for (typename T::Edge_iterator eit = t_const.all_edges_begin(); eit != t_const.all_edges_end(); ++eit) { ++size; } - CGAL_assertion(size == t_const.number_of_stored_edges()); + assert(size == t_const.number_of_stored_edges()); // faces size = 0; @@ -254,14 +254,14 @@ void test_iterators() { ++size; } - CGAL_assertion(size == t_const.number_of_stored_faces()); + assert(size == t_const.number_of_stored_faces()); size = 0; for (typename T::All_faces_iterator fit = t_const.all_faces_begin(); fit != t_const.all_faces_end(); ++fit) { ++size; } - CGAL_assertion(size == t_const.number_of_stored_faces()); + assert(size == t_const.number_of_stored_faces()); /// Geometric iterators for (typename T::Periodic_point_iterator ppit = t_const.periodic_points_begin(); @@ -422,10 +422,10 @@ void test_modifiers() vh0 = t.insert_first(p0); fh = t_const.locate(p1, lt, li); - CGAL_assertion(lt == T::FACE); + assert(lt == T::FACE); t.insert_in_face(p1, fh); fh = t_const.locate(p2, lt, li); - CGAL_assertion(lt == T::EDGE); + assert(lt == T::EDGE); t.insert_in_edge(p2, fh, li); for (typename T::Vertex_iterator vit = t_const.vertices_begin(); @@ -465,9 +465,8 @@ void test_miscellaneous() t.set_domain(typename T::Iso_rectangle(0, 0, 2, 2)); int i = t.ccw(0); int j = t.cw(0); - CGAL_USE(i); - CGAL_USE(j); - CGAL_assertion(i + j == 3); + + assert(i + j == 3); t = T(); vh0 = t.insert(p0); @@ -551,7 +550,7 @@ void test_io(bool exact) for (int x = 0; x < 5; ++x) for (int y = 0; y < 5; ++y) t.insert(Point(x / 5.0, y / 5.0)); - CGAL_assertion(t.number_of_vertices() == 25); + assert(t.number_of_vertices() == 25); test_io(t, exact); std::cout << __FILE__ << ", " << __LINE__ << std::endl; @@ -613,18 +612,18 @@ void test_nearest() Vertex_handle vh0, vh1, vh2; T t; - CGAL_assertion(t.nearest_vertex(p0) == Vertex_handle()); + assert(t.nearest_vertex(p0) == Vertex_handle()); vh0 = t.insert(p0); - CGAL_assertion(t.get_original_vertex(t.nearest_vertex(p0)) == vh0); - CGAL_assertion(t.get_original_vertex(t.nearest_vertex(p1)) == vh0); - CGAL_assertion(t.get_original_vertex(t.nearest_vertex(p2)) == vh0); + assert(t.get_original_vertex(t.nearest_vertex(p0)) == vh0); + assert(t.get_original_vertex(t.nearest_vertex(p1)) == vh0); + assert(t.get_original_vertex(t.nearest_vertex(p2)) == vh0); vh1 = t.insert(p1); vh2 = t.insert(p2); - CGAL_assertion(t.get_original_vertex(t.nearest_vertex(p0)) == vh0); - CGAL_assertion(t.get_original_vertex(t.nearest_vertex(p1)) == vh1); - CGAL_assertion(t.get_original_vertex(t.nearest_vertex(p2)) == vh2); + assert(t.get_original_vertex(t.nearest_vertex(p0)) == vh0); + assert(t.get_original_vertex(t.nearest_vertex(p1)) == vh1); + assert(t.get_original_vertex(t.nearest_vertex(p2)) == vh2); } template @@ -651,7 +650,7 @@ void test_locally_delaunay() { for (int i = 0; i < 3; ++i) { - CGAL_assertion(t.locally_Delaunay(fit, i, fit->neighbor(i))); + assert(t.locally_Delaunay(fit, i, fit->neighbor(i))); } } @@ -662,7 +661,7 @@ void test_locally_delaunay() { for (int i = 0; i < 3; ++i) { - CGAL_assertion(t.locally_Delaunay(fit, i, fit->neighbor(i))); + assert(t.locally_Delaunay(fit, i, fit->neighbor(i))); } } diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_insert_degenerate.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_insert_degenerate.cpp index 857a4a8939e..989176fc63a 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_insert_degenerate.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_insert_degenerate.cpp @@ -21,20 +21,20 @@ void test_insertion() } Triangulation pt(pts_rnd1000.begin(), pts_rnd1000.end()); - CGAL_assertion(pt.is_valid()); - CGAL_assertion(pt.number_of_vertices() == 1000); + assert(pt.is_valid()); + assert(pt.number_of_vertices() == 1000); pt.clear(); - CGAL_assertion(pt.is_valid()); - CGAL_assertion(pt.empty()); - CGAL_assertion(pt.number_of_vertices() == 0); + assert(pt.is_valid()); + assert(pt.empty()); + assert(pt.number_of_vertices() == 0); pt.insert(pts_rnd1000.begin(), pts_rnd1000.end()); - CGAL_assertion(pt.is_valid()); - CGAL_assertion(pt.number_of_vertices() == 1000); + assert(pt.is_valid()); + assert(pt.number_of_vertices() == 1000); pt.clear(); - CGAL_assertion(pt.is_valid()); - CGAL_assertion(pt.empty()); - CGAL_assertion(pt.number_of_vertices() == 0); + assert(pt.is_valid()); + assert(pt.empty()); + assert(pt.number_of_vertices() == 0); // Center of the circle around the origin pts_rnd1000.clear(); @@ -45,12 +45,12 @@ void test_insertion() } pt.insert(pts_rnd1000.begin(), pts_rnd1000.end()); - CGAL_assertion(pt.is_valid()); - CGAL_assertion(pt.number_of_vertices() == 1000); + assert(pt.is_valid()); + assert(pt.number_of_vertices() == 1000); pt.clear(); - CGAL_assertion(pt.is_valid()); - CGAL_assertion(pt.empty()); - CGAL_assertion(pt.number_of_vertices() == 0); + assert(pt.is_valid()); + assert(pt.empty()); + assert(pt.number_of_vertices() == 0); } int main() diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_remove.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_remove.cpp index 2d4af155d5f..81728edfc7a 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_remove.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_remove.cpp @@ -16,13 +16,13 @@ int main() Triangulation::Locate_type lt; int i; fh = t.locate(Point(0, 0) + midpoint, lt, i); - CGAL_assertion(lt == Triangulation::EMPTY); + assert(lt == Triangulation::EMPTY); Vertex_handle vh_midpoint = t.insert(Point(0, 0) + midpoint); fh = t.locate(Point(0, 0) + midpoint, lt, i); - CGAL_assertion(lt == Triangulation::VERTEX && fh->vertex(i) == vh_midpoint); + assert(lt == Triangulation::VERTEX && fh->vertex(i) == vh_midpoint); t.remove(vh_midpoint); - CGAL_assertion(t.empty()); + assert(t.empty()); // High degree vertex for (int n = 3; n < 8; ++n) @@ -33,11 +33,11 @@ int main() t.insert(Point(0.3 * sin(i * 1.0 / n * 2 * M_PI), 0.3 * cos(i * 1.0 / n * 2 * M_PI)) + midpoint); } t.remove(vh_midpoint); - CGAL_assertion(t.is_valid(true)); + assert(t.is_valid(true)); while (!t.empty()) { t.remove(t.vertices_begin()); - CGAL_assertion(t.is_valid(true)); + assert(t.is_valid(true)); } } @@ -45,14 +45,14 @@ int main() std::cout << "Seed: " << random.get_seed () << std::endl; Random_points_in_square g(0.495, random); - CGAL_assertion(t.is_valid()); + assert(t.is_valid()); std::cout << "Removing first point" << std::endl; Vertex_handle vh0 = t.insert(Point(0.5, 0.5)); - CGAL_assertion(t.is_valid()); + assert(t.is_valid()); t.remove(vh0); - CGAL_assertion(t.is_valid()); - CGAL_assertion(t.empty()); + assert(t.is_valid()); + assert(t.empty()); { Random random(1284141159); @@ -62,14 +62,14 @@ int main() Vector midpoint(0.5, 0.5); Triangulation t; - CGAL_assertion(t.is_valid()); + assert(t.is_valid()); std::cout << "Removing first point" << std::endl; Vertex_handle vh0 = t.insert(Point(0.5, 0.5)); - CGAL_assertion(t.is_valid()); + assert(t.is_valid()); t.remove(vh0); - CGAL_assertion(t.is_valid()); - CGAL_assertion(t.empty()); + assert(t.is_valid()); + assert(t.empty()); std::cout << "Inserting random points and removing them." << std::endl; @@ -77,7 +77,7 @@ int main() { t.insert(*(++g) + midpoint); } - CGAL_assertion(t.is_valid()); + assert(t.is_valid()); for (int i = 0; i < N_PTS; ++i) { @@ -85,7 +85,7 @@ int main() Vertex_handle vh = t.locate(*(++g) + midpoint)->vertex(0); vh = t.get_original_vertex(vh); t.remove(vh); - CGAL_assertion(t.is_valid()); + assert(t.is_valid()); } } return 0; diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_performance_test.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_performance_test.cpp index 2468e882930..f89d6077247 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_performance_test.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_performance_test.cpp @@ -112,7 +112,7 @@ int main() << periodic_insert_time << ", \t" << periodic_insert_time << std::endl; } } - CGAL_assertion(t.is_valid()); + assert(t.is_valid()); std::cout << std::endl; } diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_test_semi_static_predicates.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_test_semi_static_predicates.cpp index 8cba96b9154..b3936918810 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_test_semi_static_predicates.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_test_semi_static_predicates.cpp @@ -18,37 +18,37 @@ void test_orientation() Point p1(0.5 + (0.4999 / N) * 4, 0.5 + (0.4999 / N) * -4); Point p2(0.5 + (0.4999 / N) * 6, 0.5 + (0.4999 / N) * -3); - CGAL_assertion(traits.orientation_2_object()(p0, p1, p2) == 1); - CGAL_assertion(traits.orientation_2_object()(p2, p0, p1) == 1); - CGAL_assertion(traits.orientation_2_object()(p1, p2, p0) == 1); - CGAL_assertion(traits.orientation_2_object()(p0, p2, p1) == -1); - CGAL_assertion(traits.orientation_2_object()(p1, p0, p2) == -1); - CGAL_assertion(traits.orientation_2_object()(p2, p1, p0) == -1); + assert(traits.orientation_2_object()(p0, p1, p2) == 1); + assert(traits.orientation_2_object()(p2, p0, p1) == 1); + assert(traits.orientation_2_object()(p1, p2, p0) == 1); + assert(traits.orientation_2_object()(p0, p2, p1) == -1); + assert(traits.orientation_2_object()(p1, p0, p2) == -1); + assert(traits.orientation_2_object()(p2, p1, p0) == -1); - CGAL_assertion(traits.orientation_2_object()(p0, p1, p2) == + assert(traits.orientation_2_object()(p0, p1, p2) == traits.orientation_2_object()(p0, p1, p2, o0, o0, o0)); - CGAL_assertion(traits.orientation_2_object()(p2, p0, p1) == + assert(traits.orientation_2_object()(p2, p0, p1) == traits.orientation_2_object()(p2, p0, p1, o0, o0, o0)); - CGAL_assertion(traits.orientation_2_object()(p1, p2, p0) == + assert(traits.orientation_2_object()(p1, p2, p0) == traits.orientation_2_object()(p1, p2, p0, o0, o0, o0)); - CGAL_assertion(traits.orientation_2_object()(p0, p2, p1) == + assert(traits.orientation_2_object()(p0, p2, p1) == traits.orientation_2_object()(p0, p2, p1, o0, o0, o0)); - CGAL_assertion(traits.orientation_2_object()(p1, p0, p2) == + assert(traits.orientation_2_object()(p1, p0, p2) == traits.orientation_2_object()(p1, p0, p2, o0, o0, o0)); - CGAL_assertion(traits.orientation_2_object()(p2, p1, p0) == + assert(traits.orientation_2_object()(p2, p1, p0) == traits.orientation_2_object()(p2, p1, p0, o0, o0, o0)); - CGAL_assertion(traits.orientation_2_object()(p0, p1, p2) == + assert(traits.orientation_2_object()(p0, p1, p2) == traits.orientation_2_object()(p0, p1, p2, o1, o1, o1)); - CGAL_assertion(traits.orientation_2_object()(p2, p0, p1) == + assert(traits.orientation_2_object()(p2, p0, p1) == traits.orientation_2_object()(p2, p0, p1, o1, o1, o1)); - CGAL_assertion(traits.orientation_2_object()(p1, p2, p0) == + assert(traits.orientation_2_object()(p1, p2, p0) == traits.orientation_2_object()(p1, p2, p0, o1, o1, o1)); - CGAL_assertion(traits.orientation_2_object()(p0, p2, p1) == + assert(traits.orientation_2_object()(p0, p2, p1) == traits.orientation_2_object()(p0, p2, p1, o1, o1, o1)); - CGAL_assertion(traits.orientation_2_object()(p1, p0, p2) == + assert(traits.orientation_2_object()(p1, p0, p2) == traits.orientation_2_object()(p1, p0, p2, o1, o1, o1)); - CGAL_assertion(traits.orientation_2_object()(p2, p1, p0) == + assert(traits.orientation_2_object()(p2, p1, p0) == traits.orientation_2_object()(p2, p1, p0, o1, o1, o1)); } @@ -67,37 +67,37 @@ void test_in_circle() Point p2(-4 - 0.4999, 3 - 0.4999); Point p3( 4 - 0.4999, -3 - 0.4999); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3) == 1); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3) == 1); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p1, p2, p0, p3) == 1); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p0, p2, p1, p3) == -1); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p1, p0, p2, p3) == -1); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3) == -1); + assert(traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3) == 1); + assert(traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3) == 1); + assert(traits.side_of_oriented_circle_2_object()(p1, p2, p0, p3) == 1); + assert(traits.side_of_oriented_circle_2_object()(p0, p2, p1, p3) == -1); + assert(traits.side_of_oriented_circle_2_object()(p1, p0, p2, p3) == -1); + assert(traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3) == -1); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3) == + assert(traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3) == traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3, o0, o0, o0, o0)); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3) == + assert(traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3) == traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3, o0, o0, o0, o0)); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p1, p2, p0, p3) == + assert(traits.side_of_oriented_circle_2_object()(p1, p2, p0, p3) == traits.side_of_oriented_circle_2_object()(p1, p2, p0, p3, o0, o0, o0, o0)); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p0, p2, p1, p3) == + assert(traits.side_of_oriented_circle_2_object()(p0, p2, p1, p3) == traits.side_of_oriented_circle_2_object()(p0, p2, p1, p3, o0, o0, o0, o0)); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p1, p0, p2, p3) == + assert(traits.side_of_oriented_circle_2_object()(p1, p0, p2, p3) == traits.side_of_oriented_circle_2_object()(p1, p0, p2, p3, o0, o0, o0, o0)); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3) == + assert(traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3) == traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3, o0, o0, o0, o0)); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3) == + assert(traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3) == traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3, o1, o1, o1, o1)); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3) == + assert(traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3) == traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3, o1, o1, o1, o1)); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p1, p2, p0, p3) == + assert(traits.side_of_oriented_circle_2_object()(p1, p2, p0, p3) == traits.side_of_oriented_circle_2_object()(p1, p2, p0, p3, o1, o1, o1, o1)); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p0, p2, p1, p3) == + assert(traits.side_of_oriented_circle_2_object()(p0, p2, p1, p3) == traits.side_of_oriented_circle_2_object()(p0, p2, p1, p3, o1, o1, o1, o1)); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p1, p0, p2, p3) == + assert(traits.side_of_oriented_circle_2_object()(p1, p0, p2, p3) == traits.side_of_oriented_circle_2_object()(p1, p0, p2, p3, o1, o1, o1, o1)); - CGAL_assertion(traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3) == + assert(traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3) == traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3, o1, o1, o1, o1)); } diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_flip.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_flip.cpp index 3e223ea181c..657c11d59e6 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_flip.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_flip.cpp @@ -65,7 +65,7 @@ int main() greedy_flip_long_edges(t); greedy_flip_long_edges(t); - CGAL_assertion(t.is_valid()); + assert(t.is_valid()); size_t n_vertices = t.number_of_vertices(); size_t n_faces = t.number_of_faces(); @@ -75,26 +75,26 @@ int main() std::cout << "Converting to 1 cover" << std::endl; t.convert_to_1_sheeted_covering(); std::cout << "... done" << std::endl; - CGAL_assertion(t.is_1_cover()); - CGAL_assertion(t.is_valid()); - CGAL_assertion(t.number_of_vertices() == n_vertices); - CGAL_assertion(t.number_of_faces() == n_faces); + assert(t.is_1_cover()); + assert(t.is_valid()); + assert(t.number_of_vertices() == n_vertices); + assert(t.number_of_faces() == n_faces); std::cout << "Converting to 9 cover" << std::endl; t.convert_to_9_sheeted_covering(); std::cout << "... done" << std::endl; - CGAL_assertion(!t.is_1_cover()); - CGAL_assertion(t.is_valid()); - CGAL_assertion(t.number_of_vertices() == n_vertices); - CGAL_assertion(t.number_of_faces() == n_faces); + assert(!t.is_1_cover()); + assert(t.is_valid()); + assert(t.number_of_vertices() == n_vertices); + assert(t.number_of_faces() == n_faces); std::cout << "Converting to 1 cover" << std::endl; t.convert_to_1_sheeted_covering(); std::cout << "... done" << std::endl; - CGAL_assertion(t.is_1_cover()); - CGAL_assertion(t.is_valid()); - CGAL_assertion(t.number_of_vertices() == n_vertices); - CGAL_assertion(t.number_of_faces() == n_faces); + assert(t.is_1_cover()); + assert(t.is_valid()); + assert(t.number_of_vertices() == n_vertices); + assert(t.number_of_faces() == n_faces); return 0; } diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_insert_edge.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_insert_edge.cpp index 0509aa59994..4d79b443503 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_insert_edge.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_insert_edge.cpp @@ -8,9 +8,9 @@ void insert_in_edge(Triangulation &t, const Point &p) int li; Face_handle fh = t.locate(p, lt, li); - CGAL_assertion(lt == Triangulation::EDGE); + assert(lt == Triangulation::EDGE); t.insert(p, fh); - CGAL_assertion(t.is_valid()); + assert(t.is_valid()); } int main() diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_insert_grid.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_insert_grid.cpp index f34480a5775..5426a739345 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_insert_grid.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_insert_grid.cpp @@ -21,7 +21,7 @@ void test_insertion_xy(int x_order, int y_order) t.insert(p); } } - CGAL_assertion(t.is_valid()); + assert(t.is_valid()); } void test_insertion_yx(int x_order, int y_order) @@ -38,7 +38,7 @@ void test_insertion_yx(int x_order, int y_order) t.insert(p); } } - CGAL_assertion(t.is_valid()); + assert(t.is_valid()); } int main() diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_insert_vertex.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_insert_vertex.cpp index d642069fb3f..b61cf7449d0 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_insert_vertex.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_insert_vertex.cpp @@ -7,47 +7,43 @@ int main() Point p; Triangulation t; - CGAL_assertion(t.is_valid()); + assert(t.is_valid()); Point p0(0.5, 0.5); - CGAL_assertion_code(Vertex_handle vh0 = ) - t.insert(p0); - CGAL_assertion(t.is_valid()); + Vertex_handle vh0 = t.insert(p0); + assert(t.is_valid()); - CGAL_assertion(t.number_of_vertices() == 1); - CGAL_assertion(vh0 == t.insert(p0)); - CGAL_assertion(t.is_valid()); + assert(t.number_of_vertices() == 1); + assert(vh0 == t.insert(p0)); + assert(t.is_valid()); Point p1(0.6, 0.5); - CGAL_assertion_code(Vertex_handle vh1 = ) - t.insert(p1); - CGAL_assertion(t.is_valid()); - CGAL_assertion(t.number_of_vertices() == 2); - CGAL_assertion(vh0 != vh1); - CGAL_assertion(vh0 == t.insert(p0)); - CGAL_assertion(vh1 == t.insert(p1)); - CGAL_assertion(t.is_valid()); + Vertex_handle vh1 = t.insert(p1); + assert(t.is_valid()); + assert(t.number_of_vertices() == 2); + assert(vh0 != vh1); + assert(vh0 == t.insert(p0)); + assert(vh1 == t.insert(p1)); + assert(t.is_valid()); Point p2(0.5, 0.7); - CGAL_assertion_code(Vertex_handle vh2 = ) - t.insert(p2); - CGAL_assertion(t.is_valid()); - CGAL_assertion(t.number_of_vertices() == 3); - CGAL_assertion(vh0 == t.insert(p0)); - CGAL_assertion(vh1 == t.insert(p1)); - CGAL_assertion(vh2 == t.insert(p2)); - CGAL_assertion(t.is_valid()); + Vertex_handle vh2 = t.insert(p2); + assert(t.is_valid()); + assert(t.number_of_vertices() == 3); + assert(vh0 == t.insert(p0)); + assert(vh1 == t.insert(p1)); + assert(vh2 == t.insert(p2)); + assert(t.is_valid()); Point p3(0.3, 0.4); - CGAL_assertion_code(Vertex_handle vh3 = ) - t.insert(p3); - CGAL_assertion(t.is_valid()); - CGAL_assertion(t.number_of_vertices() == 4); - CGAL_assertion(vh0 == t.insert(p0)); - CGAL_assertion(vh1 == t.insert(p1)); - CGAL_assertion(vh2 == t.insert(p2)); - CGAL_assertion(vh3 == t.insert(p3)); - CGAL_assertion(t.is_valid()); + Vertex_handle vh3 = t.insert(p3); + assert(t.is_valid()); + assert(t.number_of_vertices() == 4); + assert(vh0 == t.insert(p0)); + assert(vh1 == t.insert(p1)); + assert(vh2 == t.insert(p2)); + assert(vh3 == t.insert(p3)); + assert(t.is_valid()); return 0; } diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_point_location.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_point_location.cpp index beeb6931dbe..d0469031f6a 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_point_location.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_point_location.cpp @@ -13,9 +13,9 @@ Face_handle test_point_location(const Triangulation &t, CGAL::Oriented_side os; fh = t.locate(query, lt, li); - CGAL_assertion(lt == lt_in); + assert(lt == lt_in); if (lt_in == Triangulation::EMPTY) { - CGAL_assertion(fh == Face_handle()); + assert(fh == Face_handle()); return fh; } @@ -24,31 +24,31 @@ Face_handle test_point_location(const Triangulation &t, CGAL_USE(bs); CGAL_USE(os); - CGAL_assertion(lt2 == lt_in); + assert(lt2 == lt_in); switch (lt_in) { case Triangulation::VERTEX: case Triangulation::EDGE: { - CGAL_assertion(fh != Face_handle()); - CGAL_assertion(bs == CGAL::ON_BOUNDARY); - CGAL_assertion(os == CGAL::ON_ORIENTED_BOUNDARY); + assert(fh != Face_handle()); + assert(bs == CGAL::ON_BOUNDARY); + assert(os == CGAL::ON_ORIENTED_BOUNDARY); - CGAL_assertion(li == li2); + assert(li == li2); break; } case Triangulation::FACE: { - CGAL_assertion(fh != Face_handle()); - CGAL_assertion(bs == CGAL::ON_BOUNDED_SIDE); - CGAL_assertion(os == CGAL::ON_POSITIVE_SIDE); + assert(fh != Face_handle()); + assert(bs == CGAL::ON_BOUNDED_SIDE); + assert(os == CGAL::ON_POSITIVE_SIDE); break; } default: { // Handled above - CGAL_assertion(false); + assert(false); break; } } @@ -63,76 +63,76 @@ int main() // Check the empty triangulation fh = test_point_location(t, Point(0.5, 0.5), Triangulation::EMPTY); - CGAL_assertion(fh == Face_handle()); + assert(fh == Face_handle()); // Insert the first point Point p0(0.5, 0.5); Vertex_handle vh0 = t.insert(p0); - CGAL_assertion(t.is_valid(true)); + assert(t.is_valid(true)); CGAL_USE(vh0); fh = test_point_location(t, p0, Triangulation::VERTEX); - CGAL_assertion(fh->has_vertex(vh0)); + assert(fh->has_vertex(vh0)); fh = test_point_location(t, p0 + Vector(0.1, 0.1), Triangulation::EDGE); - CGAL_assertion(fh->has_vertex(vh0)); + assert(fh->has_vertex(vh0)); fh = test_point_location(t, p0 + Vector(-0.1, -0.1), Triangulation::EDGE); - CGAL_assertion(fh->has_vertex(vh0)); + assert(fh->has_vertex(vh0)); fh = test_point_location(t, p0 + Vector(-0.2, -0.3), Triangulation::FACE); - CGAL_assertion(fh->has_vertex(vh0)); + assert(fh->has_vertex(vh0)); - CGAL_assertion(t.is_valid(true)); + assert(t.is_valid(true)); // Insert the second point on an edge Point p1(0.7, 0.7); Vertex_handle vh1 = t.insert(p1); CGAL_USE(vh1); - CGAL_assertion(t.is_valid(true)); + assert(t.is_valid(true)); fh = test_point_location(t, p0, Triangulation::VERTEX); - CGAL_assertion(fh->has_vertex(vh0)); + assert(fh->has_vertex(vh0)); fh = test_point_location(t, p1, Triangulation::VERTEX); - CGAL_assertion(fh->has_vertex(vh1)); + assert(fh->has_vertex(vh1)); fh = test_point_location(t, p0 + Vector(0.1, 0.1), Triangulation::EDGE); - CGAL_assertion(fh->has_vertex(vh0)); - CGAL_assertion(fh->has_vertex(vh1)); + assert(fh->has_vertex(vh0)); + assert(fh->has_vertex(vh1)); fh = test_point_location(t, p0 + Vector(-0.1, -0.1), Triangulation::EDGE); - CGAL_assertion(fh->has_vertex(vh0)); - CGAL_assertion(!fh->has_vertex(vh1)); + assert(fh->has_vertex(vh0)); + assert(!fh->has_vertex(vh1)); fh = test_point_location(t, p1 + Vector(0.1, 0.1), Triangulation::EDGE); - CGAL_assertion(!fh->has_vertex(vh0)); - CGAL_assertion(fh->has_vertex(vh1)); + assert(!fh->has_vertex(vh0)); + assert(fh->has_vertex(vh1)); fh = test_point_location(t, p0 + Vector(-0.02, -0.03), Triangulation::FACE); - CGAL_assertion(fh->has_vertex(vh0)); + assert(fh->has_vertex(vh0)); fh = test_point_location(t, p1 + Vector(-0.02, -0.03), Triangulation::FACE); - CGAL_assertion(fh->has_vertex(vh1)); + assert(fh->has_vertex(vh1)); - CGAL_assertion(t.is_valid(true)); + assert(t.is_valid(true)); // Insert the third point in a face Point p2(0.8, 0.6); Vertex_handle vh2 = t.insert(p2); CGAL_USE(vh2); - CGAL_assertion(t.is_valid(true)); + assert(t.is_valid(true)); fh = test_point_location(t, p0, Triangulation::VERTEX); - CGAL_assertion(fh->has_vertex(vh0)); + assert(fh->has_vertex(vh0)); fh = test_point_location(t, p1, Triangulation::VERTEX); - CGAL_assertion(fh->has_vertex(vh1)); + assert(fh->has_vertex(vh1)); fh = test_point_location(t, p2, Triangulation::VERTEX); - CGAL_assertion(fh->has_vertex(vh2)); + assert(fh->has_vertex(vh2)); fh = test_point_location(t, Point(0.6, 0.6), Triangulation::EDGE); - CGAL_assertion(fh->has_vertex(vh0)); - CGAL_assertion(fh->has_vertex(vh1)); + assert(fh->has_vertex(vh0)); + assert(fh->has_vertex(vh1)); test_point_location(t, Point(0.7, 0.6), Triangulation::FACE); test_point_location(t, p0 + Vector(-0.02, -0.03), Triangulation::FACE); diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_prog1.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_prog1.cpp index 95c88de8b96..2f508b86385 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_prog1.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_prog1.cpp @@ -21,7 +21,7 @@ typedef Triangulation::Periodic_triangle_iterator Periodic_triangle_iterator; void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t) { - CGAL_assertion(t.number_of_vertices() == 1); + assert(t.number_of_vertices() == 1); Point &p = t.vertices_begin()->point(); Triangulation::Locate_type lt; @@ -47,7 +47,7 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t CGAL::Bounded_side side = t.side_of_face(p, offset, triang_it.get_face(), lt, li); if (side != CGAL::ON_UNBOUNDED_SIDE) { - CGAL_assertion(lt == Triangulation::VERTEX); + assert(lt == Triangulation::VERTEX); } on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0); on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0); @@ -55,8 +55,8 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t triangle.vertex(0); // Avoid warning ++triang_it; } - CGAL_assertion(on_boundary == 6); - CGAL_assertion(on_inside == 0); + assert(on_boundary == 6); + assert(on_inside == 0); } { // Locate point on an edge @@ -68,7 +68,7 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t CGAL::Bounded_side side = t.side_of_face(p + Vector(0.0, 0.1), offset, triang_it.get_face(), lt, li); if (side != CGAL::ON_UNBOUNDED_SIDE) { - CGAL_assertion(lt == Triangulation::EDGE); + assert(lt == Triangulation::EDGE); } on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0); on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0); @@ -76,8 +76,8 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t triangle.vertex(0); // Avoid warning ++triang_it; } - CGAL_assertion(on_boundary == 2); - CGAL_assertion(on_inside == 0); + assert(on_boundary == 2); + assert(on_inside == 0); } { // Locate point inside a face @@ -89,7 +89,7 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t CGAL::Bounded_side side = t.side_of_face(p + Vector(0.1, 0.2), offset, triang_it.get_face(), lt, li); if (side != CGAL::ON_UNBOUNDED_SIDE) { - CGAL_assertion(lt == Triangulation::FACE); + assert(lt == Triangulation::FACE); } on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0); on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0); @@ -97,8 +97,8 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t triangle.vertex(0); // Avoid warning ++triang_it; } - CGAL_assertion(on_boundary == 0); - CGAL_assertion(on_inside == 1); + assert(on_boundary == 0); + assert(on_inside == 1); } } { @@ -116,14 +116,14 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t CGAL::Bounded_side side = t.side_of_face(p, offset, face_it, lt, li); if (side != CGAL::ON_UNBOUNDED_SIDE) { - CGAL_assertion(lt == Triangulation::VERTEX); + assert(lt == Triangulation::VERTEX); } on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0); on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0); ++face_it; } - CGAL_assertion(on_boundary == 6); - CGAL_assertion(on_inside == 0); + assert(on_boundary == 6); + assert(on_inside == 0); } { // Locate point on an edge @@ -135,14 +135,14 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t CGAL::Bounded_side side = t.side_of_face(p + Vector(0.1, 0.0), offset, face_it, lt, li); if (side != CGAL::ON_UNBOUNDED_SIDE) { - CGAL_assertion(lt == Triangulation::EDGE); + assert(lt == Triangulation::EDGE); } on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0); on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0); ++face_it; } - CGAL_assertion(on_boundary == 2); - CGAL_assertion(on_inside == 0); + assert(on_boundary == 2); + assert(on_inside == 0); } { // Locate point inside a face @@ -154,14 +154,14 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t CGAL::Bounded_side side = t.side_of_face(p + Vector(0.1, 0.2), offset, face_it, lt, li); if (side != CGAL::ON_UNBOUNDED_SIDE) { - CGAL_assertion(lt == Triangulation::FACE); + assert(lt == Triangulation::FACE); } on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0); on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0); ++face_it; } - CGAL_assertion(on_boundary == 0); - CGAL_assertion(on_inside == 1); + assert(on_boundary == 0); + assert(on_inside == 1); } } } @@ -175,13 +175,13 @@ int main() // Insert the first point Point first_point(0.5, 0.5); t.insert(first_point); - CGAL_assertion(t.is_valid(true)); + assert(t.is_valid(true)); { // Testing the point iterator Periodic_point_iterator it = t.periodic_points_begin(); Periodic_point_iterator beyond = t.periodic_points_end(); - CGAL_assertion(std::distance(it, beyond) == 9); + assert(std::distance(it, beyond) == 9); while(it != beyond) { Point p = t.point(*it); @@ -193,7 +193,7 @@ int main() // Testing the segment iterator Periodic_segment_iterator it = t.periodic_segments_begin(); Periodic_segment_iterator beyond = t.periodic_segments_end(); - CGAL_assertion(std::distance(it, beyond) == 27); + assert(std::distance(it, beyond) == 27); while(it != beyond) { Segment s = t.segment(*it); @@ -205,7 +205,7 @@ int main() // Testing the triangle iterator Periodic_triangle_iterator it = t.periodic_triangles_begin(); Periodic_triangle_iterator beyond = t.periodic_triangles_end(); - CGAL_assertion(std::distance(it, beyond) == 18); + assert(std::distance(it, beyond) == 18); while(it != beyond) { Triangle triangle = t.triangle(*it); diff --git a/Periodic_3_mesh_3/include/CGAL/optimize_periodic_3_mesh_3.h b/Periodic_3_mesh_3/include/CGAL/optimize_periodic_3_mesh_3.h index 3c3367718a5..8b3d75cbfe4 100644 --- a/Periodic_3_mesh_3/include/CGAL/optimize_periodic_3_mesh_3.h +++ b/Periodic_3_mesh_3/include/CGAL/optimize_periodic_3_mesh_3.h @@ -43,8 +43,8 @@ BOOST_PARAMETER_FUNCTION( (required (in_out(c3t3),*) (domain,*)) (optional (time_limit_, *, 0) - (sliver_bound_, *, parameters::default_values::perturb_sliver_bound) - (sliver_criterion_, *, parameters::default_values::default_sliver_criterion(c3t3, sliver_bound_)) + (sliver_bound_, *, parameters::default_values_for_mesh_3::perturb_sliver_bound) + (sliver_criterion_, *, parameters::default_values_for_mesh_3::default_sliver_criterion(c3t3, sliver_bound_)) (perturbation_vector_, *, default_perturbation_vector(c3t3,domain,sliver_criterion_)) ) ) @@ -63,7 +63,7 @@ BOOST_PARAMETER_FUNCTION( (required (in_out(c3t3),*)) (optional (time_limit_, *, 0) - (sliver_bound_, *, parameters::default_values::exude_sliver_bound) + (sliver_bound_, *, parameters::default_values_for_mesh_3::exude_sliver_bound) ) ) { @@ -81,9 +81,9 @@ BOOST_PARAMETER_FUNCTION( (optional (time_limit_, *, 0) (max_iteration_number_, *, 0) - (convergence_, *, parameters::default_values::odt_convergence_ratio) - (freeze_bound_, *, parameters::default_values::odt_freeze_ratio) - (do_freeze_, *, parameters::default_values::do_freeze) + (convergence_, *, parameters::default_values_for_mesh_3::odt_convergence_ratio) + (freeze_bound_, *, parameters::default_values_for_mesh_3::odt_freeze_ratio) + (do_freeze_, *, parameters::default_values_for_mesh_3::do_freeze) ) ) { @@ -103,9 +103,9 @@ BOOST_PARAMETER_FUNCTION( (optional (time_limit_, *, 0) (max_iteration_number_, *, 0) - (convergence_, *, parameters::default_values::lloyd_convergence_ratio) - (freeze_bound_, *, parameters::default_values::lloyd_freeze_ratio) - (do_freeze_, *, parameters::default_values::do_freeze) + (convergence_, *, parameters::default_values_for_mesh_3::lloyd_convergence_ratio) + (freeze_bound_, *, parameters::default_values_for_mesh_3::lloyd_freeze_ratio) + (do_freeze_, *, parameters::default_values_for_mesh_3::do_freeze) ) ) { diff --git a/Periodic_3_triangulation_3/test/Periodic_3_triangulation_3/test_p3rt3_versus_rt3.cpp b/Periodic_3_triangulation_3/test/Periodic_3_triangulation_3/test_p3rt3_versus_rt3.cpp index 4d4ad594cf3..93eecea63e7 100644 --- a/Periodic_3_triangulation_3/test/Periodic_3_triangulation_3/test_p3rt3_versus_rt3.cpp +++ b/Periodic_3_triangulation_3/test/Periodic_3_triangulation_3/test_p3rt3_versus_rt3.cpp @@ -112,7 +112,7 @@ int main (int, char**) std::cout << unique_vertices_from_rt3.size() << " unique vertices (rt3)" << std::endl; std::cout << p3rt3.number_of_vertices() << " unique vertices (p3rt3)" << std::endl; - CGAL_assertion(unique_vertices_from_rt3.size() == p3rt3.number_of_vertices()); + assert(unique_vertices_from_rt3.size() == p3rt3.number_of_vertices()); // compare cells std::set > unique_cells_from_rt3; @@ -138,7 +138,7 @@ int main (int, char**) std::cout << unique_cells_from_rt3.size() << " unique cells (rt3)" << std::endl; std::cout << p3rt3.number_of_cells() << " unique cells (p3rt3)" << std::endl; - CGAL_assertion(unique_cells_from_rt3.size() == p3rt3.number_of_cells()); + assert(unique_cells_from_rt3.size() == p3rt3.number_of_cells()); std::cout << t.time() << " sec." << std::endl; std::cout << "EXIT SUCCESS" << std::endl; diff --git a/Point_set_3/doc/Point_set_3/Doxyfile.in b/Point_set_3/doc/Point_set_3/Doxyfile.in index 2980feeb5a8..7b3039d1612 100644 --- a/Point_set_3/doc/Point_set_3/Doxyfile.in +++ b/Point_set_3/doc/Point_set_3/Doxyfile.in @@ -1,8 +1,2 @@ @INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS} PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 3D Point Set" - -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = YES -EXPAND_AS_DEFINED = CGAL_BGL_NP_TEMPLATE_PARAMETERS \ - CGAL_BGL_NP_CLASS \ - CGAL_DEPRECATED diff --git a/Point_set_3/include/CGAL/Point_set_3.h b/Point_set_3/include/CGAL/Point_set_3.h index 61c0567b1c8..528d0d161af 100644 --- a/Point_set_3/include/CGAL/Point_set_3.h +++ b/Point_set_3/include/CGAL/Point_set_3.h @@ -21,9 +21,10 @@ #include -#include +#include #include #include +#include #include #include @@ -475,7 +476,7 @@ public: iterator insert (const Point& p, const Vector& n) { iterator out = insert (p); - assert (has_normal_map()); + CGAL_assertion(has_normal_map()); m_normals[size()-1] = n; return out; } @@ -1294,36 +1295,68 @@ Point_set_3& operator+=(Point_set_3& ps, return ps; } - - /// \cond SKIP_IN_MANUAL -namespace Point_set_processing_3 +// specialization for default named parameters +template +struct Point_set_processing_3_np_helper, NamedParameters, NP_TAG> { - template - class GetFT > - { - public: - typedef typename Kernel_traits::Kernel::FT type; - }; + typedef typename std::iterator_traits::iterator>::value_type Value_type; - namespace parameters + typedef typename Kernel_traits::Kernel Default_geom_traits; + typedef typename Point_set_3::template Property_map DefaultNMap; + typedef typename Point_set_3::template Property_map DefaultPMap; + typedef const typename Point_set_3::template Property_map DefaultConstPMap; + + typedef typename internal_np::Lookup_named_param_def ::type Point_map; // public + typedef typename internal_np::Lookup_named_param_def ::type Const_point_map; // public + + typedef typename internal_np::Lookup_named_param_def < + internal_np::geom_traits_t, + NamedParameters, + Default_geom_traits + > ::type Geom_traits; // public + + typedef typename Geom_traits::FT FT; // public + + typedef typename internal_np::Lookup_named_param_def< + internal_np::normal_t, + NamedParameters, + DefaultNMap + > ::type Normal_map; // public + + static Point_map get_point_map(Point_set_3& ps, const NamedParameters& np) { - template - Named_function_parameters - ::Kernel, - internal_np::geom_traits_t, - Named_function_parameters - ::template Property_map, - internal_np::normal_t, - Named_function_parameters - ::template Property_map, - internal_np::point_t> > > - inline all_default(const CGAL::Point_set_3& ps) - { - return ps.parameters(); - } + return parameters::choose_parameter(parameters::get_parameter(np, internal_np::point_map), ps.point_map()); } -} + + static Const_point_map get_const_point_map(const Point_set_3& ps, const NamedParameters& np) + { + return parameters::choose_parameter(parameters::get_parameter(np, internal_np::point_map), ps.point_map()); + } + + static const Normal_map get_normal_map(const Point_set_3& ps, const NamedParameters& np) + { + return parameters::choose_parameter(parameters::get_parameter(np, internal_np::normal_map), ps.normal_map()); + } + + static Normal_map get_normal_map(Point_set_3& ps, const NamedParameters& np) + { + return parameters::choose_parameter(parameters::get_parameter(np, internal_np::normal_map), ps.normal_map()); + } + + static Geom_traits get_geom_traits(const Point_set_3&, const NamedParameters& np) + { + return parameters::choose_parameter(parameters::get_parameter(np, internal_np::geom_traits)); + } + + static constexpr bool has_normal_map() + { + return true; + } + +}; /// \endcond } // namespace CGAL diff --git a/Point_set_3/include/CGAL/Point_set_3/IO.h b/Point_set_3/include/CGAL/Point_set_3/IO.h index 6d5e5b1f9a3..2e680a744f8 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO.h @@ -24,11 +24,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { template @@ -123,10 +118,10 @@ namespace IO { \return `true` if the reading was successful, `false` otherwise. */ -template +template bool read_point_set(const std::string& fname, CGAL::Point_set_3& ps, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { const std::string ext = internal::get_file_extension(fname); @@ -144,15 +139,6 @@ bool read_point_set(const std::string& fname, return false; } -/// \cond SKIP_IN_MANUAL - -template -bool read_point_set(const std::string& fname, CGAL::Point_set_3& ps) -{ - return read_point_set(fname, ps, parameters::all_default()); -} -/// \endcond - } // namespace IO @@ -225,10 +211,10 @@ namespace IO { \return `true` if the writing was successful, `false` otherwise. */ -template +template bool write_point_set(const std::string& fname, CGAL::Point_set_3& ps, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { const std::string ext = internal::get_file_extension(fname); @@ -246,16 +232,6 @@ bool write_point_set(const std::string& fname, return false; } -/// \cond SKIP_IN_MANUAL - -template -bool write_point_set(const std::string& fname, CGAL::Point_set_3& ps) -{ - return write_point_set(fname, ps, parameters::all_default()); -} - -/// \endcond - } // namespace IO } // namespace CGAL diff --git a/Point_set_3/include/CGAL/Point_set_3/IO/OFF.h b/Point_set_3/include/CGAL/Point_set_3/IO/OFF.h index 873ddf0593f..5bd35941615 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO/OFF.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO/OFF.h @@ -13,7 +13,7 @@ #include -#include +#include #include #include #include @@ -22,12 +22,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { template @@ -146,10 +140,10 @@ namespace IO { \return `true` if the writing was successful, `false` otherwise. */ -template +template bool write_OFF(std::ostream& os, const CGAL::Point_set_3& point_set, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { if(point_set.has_normal_map()) return Point_set_processing_3::internal::write_OFF_PSP(os, point_set, @@ -160,16 +154,6 @@ bool write_OFF(std::ostream& os, np.point_map(point_set.point_map())); } -/// \cond SKIP_IN_MANUAL - -template -bool write_OFF(std::ostream& os, const CGAL::Point_set_3& point_set) -{ - return write_OFF(os, point_set, parameters::all_default()); -} - -/// \endcond - /*! \ingroup PkgPointSet3IOOFF @@ -195,24 +179,13 @@ bool write_OFF(std::ostream& os, const CGAL::Point_set_3& point_s \return `true` if the writing was successful, `false` otherwise. */ -template -bool write_OFF(const std::string& fname, const CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) +template +bool write_OFF(const std::string& fname, const CGAL::Point_set_3& point_set, const CGAL_NP_CLASS& np = parameters::default_values()) { std::ofstream os(fname); return write_OFF(os, point_set, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_OFF(const std::string& fname, const CGAL::Point_set_3& point_set) -{ - std::ofstream os(fname); - return write_OFF(os, point_set, parameters::all_default()); -} - -/// \endcond - } // namespace IO #ifndef CGAL_NO_DEPRECATED_CODE diff --git a/Point_set_3/include/CGAL/Point_set_3/IO/PLY.h b/Point_set_3/include/CGAL/Point_set_3/IO/PLY.h index aaab12817f4..725d15ff120 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO/PLY.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO/PLY.h @@ -13,7 +13,7 @@ #include -#include +#include #include #include #include @@ -22,12 +22,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { template @@ -339,11 +333,11 @@ bool read_PLY(std::istream& is, CGAL::Point_set_3& point_set) \return `true` if the reading was successful, `false` otherwise. */ -template +template bool read_PLY(const std::string& fname, CGAL::Point_set_3& point_set, std::string& comments, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true); if(binary) @@ -361,27 +355,12 @@ bool read_PLY(const std::string& fname, } /// \cond SKIP_IN_MANUAL - -template -bool read_PLY(const std::string& fname, CGAL::Point_set_3& point_set, std::string& comments) -{ - return read_PLY(fname, point_set, comments, parameters::all_default()); -} - -template -bool read_PLY(const std::string& fname, CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) +template +bool read_PLY(const std::string& fname, CGAL::Point_set_3& point_set, const CGAL_NP_CLASS& np = parameters::default_values()) { std::string unused_comments; return read_PLY(fname, point_set, unused_comments, np); } - -template -bool read_PLY(const std::string& fname, CGAL::Point_set_3& point_set) -{ - std::string unused_comments; - return read_PLY(fname, point_set, unused_comments, parameters::all_default()); -} - /// \endcond } // namespace IO @@ -467,11 +446,11 @@ namespace IO { \return `true` if the reading was successful, `false` otherwise. */ -template +template bool write_PLY(std::ostream& os, const CGAL::Point_set_3& point_set, const std::string& comments, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { typedef CGAL::Point_set_3 Point_set; typedef typename Point_set::Index Index; @@ -684,24 +663,12 @@ bool write_PLY(std::ostream& os, /// \cond SKIP_IN_MANUAL -template -bool write_PLY(std::ostream& os, const CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) +template +bool write_PLY(std::ostream& os, const CGAL::Point_set_3& point_set, const CGAL_NP_CLASS& np = parameters::default_values()) { return write_PLY(os, point_set, std::string(), np); } -template -bool write_PLY(std::ostream& os, const CGAL::Point_set_3& point_set, const std::string& comments) -{ - return write_PLY(os, point_set, comments, parameters::all_default()); -} - -template -bool write_PLY(std::ostream& os, const CGAL::Point_set_3& point_set) -{ - return write_PLY(os, point_set, std::string(), parameters::all_default()); -} - /// \endcond /*! @@ -742,11 +709,11 @@ bool write_PLY(std::ostream& os, const CGAL::Point_set_3& point_s \return `true` if the reading was successful, `false` otherwise. */ -template +template bool write_PLY(const std::string& fname, const CGAL::Point_set_3& point_set, const std::string& comments, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) { const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true); if(binary) @@ -765,25 +732,12 @@ bool write_PLY(const std::string& fname, /// \cond SKIP_IN_MANUAL -template -bool write_PLY(const std::string& fname, const CGAL::Point_set_3& point_set, - const std::string& comments) -{ - return write_PLY(fname, point_set, comments, parameters::all_default()); -} - -template -bool write_PLY(const std::string& fname, const CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) +template +bool write_PLY(const std::string& fname, const CGAL::Point_set_3& point_set, const CGAL_NP_CLASS& np = parameters::default_values()) { return write_PLY(fname, point_set, std::string(), np); } -template -bool write_PLY(const std::string& fname, const CGAL::Point_set_3& point_set) -{ - return write_PLY(fname, point_set, std::string(), parameters::all_default()); -} - /// \endcond } // namespace IO diff --git a/Point_set_3/include/CGAL/Point_set_3/IO/XYZ.h b/Point_set_3/include/CGAL/Point_set_3/IO/XYZ.h index f4d8f98b734..72c00bd528e 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO/XYZ.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO/XYZ.h @@ -13,7 +13,7 @@ #include -#include +#include #include #include #include @@ -21,12 +21,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { template @@ -144,10 +138,10 @@ namespace IO { \return `true` if the writing was successful, `false` otherwise. */ -template +template bool write_XYZ(std::ostream& os, const CGAL::Point_set_3& point_set, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { if(point_set.has_normal_map()) return Point_set_processing_3::internal::write_XYZ_PSP(os, point_set, @@ -157,16 +151,6 @@ bool write_XYZ(std::ostream& os, return Point_set_processing_3::internal::write_XYZ_PSP(os, point_set, np.point_map(point_set.point_map())); } -/// \cond SKIP_IN_MANUAL - -template -bool write_XYZ(std::ostream& os, const CGAL::Point_set_3& point_set) -{ - return write_XYZ(os, point_set, parameters::all_default()); -} - -/// \endcond - /*! \ingroup PkgPointSet3IOXYZ @@ -192,24 +176,13 @@ bool write_XYZ(std::ostream& os, const CGAL::Point_set_3& point_s \return `true` if the writing was successful, `false` otherwise. */ -template -bool write_XYZ(const std::string& fname, const CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) +template +bool write_XYZ(const std::string& fname, const CGAL::Point_set_3& point_set, const CGAL_NP_CLASS& np = parameters::default_values()) { std::ofstream os(fname); return write_XYZ(os, point_set, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_XYZ(const std::string& fname, const CGAL::Point_set_3& point_set) -{ - std::ofstream os(fname); - return write_XYZ(os, point_set, parameters::all_default()); -} - -/// \endcond - } // namespace IO #ifndef CGAL_NO_DEPRECATED_CODE diff --git a/Point_set_processing_3/doc/Point_set_processing_3/Doxyfile.in b/Point_set_processing_3/doc/Point_set_processing_3/Doxyfile.in index ea5bd5e9ac4..ed80f86b484 100644 --- a/Point_set_processing_3/doc/Point_set_processing_3/Doxyfile.in +++ b/Point_set_processing_3/doc/Point_set_processing_3/Doxyfile.in @@ -2,9 +2,3 @@ PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - Point Set Processing" EXCLUDE_PATTERNS += property_map.h - -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = YES -EXPAND_AS_DEFINED = CGAL_BGL_NP_TEMPLATE_PARAMETERS \ - CGAL_BGL_NP_CLASS \ - CGAL_DEPRECATED diff --git a/Point_set_processing_3/doc/Point_set_processing_3/Point_set_processing_3.txt b/Point_set_processing_3/doc/Point_set_processing_3/Point_set_processing_3.txt index 0f9732536f6..f68a1a8eca3 100644 --- a/Point_set_processing_3/doc/Point_set_processing_3/Point_set_processing_3.txt +++ b/Point_set_processing_3/doc/Point_set_processing_3/Point_set_processing_3.txt @@ -654,13 +654,15 @@ Four simplification functions are devised to reduce an input point set. Function `random_simplify_point_set()` randomly deletes a user-specified fraction of points from the input point set. This -algorithm is fast. +algorithm is the fastest. -Function `grid_simplify_point_set()` considers a regular grid -covering the bounding box of the input point set, and clusters all -points sharing the same cell of the grid by picking as representant -one arbitrarily chosen point. This algorithm is slower than -`random_simplify_point_set()`. +Function `grid_simplify_point_set()` considers a regular grid covering +the bounding box of the input point set, and clusters all points +sharing the same cell of the grid by picking as representative one +arbitrarily chosen point: representatives may only be retained in cells +that have more than a user-defined minimum number of points in order +to also filter out low density areas and outliers. This algorithm is +still fast, although slower than `random_simplify_point_set()`. Function `hierarchy_simplify_point_set()` provides an adaptive simplification of the point set through local clusters @@ -675,7 +677,9 @@ the Weighted Locally Optimal Projection (WLOP) algorithm \cgalCite{wlop-2009}. \subsection Point_set_processing_3Example_grid_simplification Grid Simplification Example -The following example reads a point set and simplifies it by clustering. +The following example reads a point set and simplifies it by +clustering. To filter out outliers, at least 3 points must lie in a +cell so that a point from this cell is kept. \cgalExample{Point_set_processing_3/grid_simplification_example.cpp} \cgalFigureBegin{Point_set_processing_3figgrid_simplification,grid_simplification.jpg} diff --git a/Point_set_processing_3/examples/Point_set_processing_3/grid_simplification_example.cpp b/Point_set_processing_3/examples/Point_set_processing_3/grid_simplification_example.cpp index ebb7ad58d03..3031f240df2 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/grid_simplification_example.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/grid_simplification_example.cpp @@ -23,11 +23,18 @@ int main(int argc, char*argv[]) } // simplification by clustering using erase-remove idiom - double cell_size = 0.001; - points.erase(CGAL::grid_simplify_point_set(points, cell_size), points.end()); + double cell_size = 0.03; + unsigned int min_points_per_cell = 3; - // Optional: after erase(), use Scott Meyer's "swap trick" to trim excess capacity - std::vector(points).swap(points); + auto iterator_to_first_to_remove + = CGAL::grid_simplify_point_set + (points, cell_size, + CGAL::parameters::min_points_per_cell(min_points_per_cell)); // optional + + points.erase(iterator_to_first_to_remove, points.end()); + + // Optional: after erase(), shrink_to_fit to trim excess capacity + points.shrink_to_fit(); return EXIT_SUCCESS; } diff --git a/Point_set_processing_3/include/CGAL/IO/read_las_points.h b/Point_set_processing_3/include/CGAL/IO/read_las_points.h index 45c9a02e1d3..beb35f44355 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_las_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_las_points.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -56,12 +56,6 @@ # pragma warning(pop) #endif -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { namespace IO { @@ -462,17 +456,17 @@ bool read_LAS_with_properties(std::istream& is, */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_LAS(std::istream& is, PointOutputIterator output, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; typedef Point_set_processing_3::Fake_point_range PointRange; - typedef typename CGAL::GetPointMap::type PointMap; + typedef typename CGAL::GetPointMap::type PointMap; PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); return read_LAS_with_properties(is, output, make_las_point_reader(point_map)); @@ -480,27 +474,13 @@ bool read_LAS(std::istream& is, /// \cond SKIP_IN_MANUAL -template -bool read_LAS(std::istream& is, OutputIterator output, const CGAL_BGL_NP_CLASS& np, +template +bool read_LAS(std::istream& is, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values(), typename std::enable_if::value>::type* = nullptr) { return read_LAS::type>(is, output, np); } -template -bool read_LAS(std::istream& is, OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_LAS(is, output, CGAL::parameters::all_default()); -} - -template -bool read_LAS(std::istream& is, OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_LAS::type>(is, output, parameters::all_default()); -} - /// \endcond /** @@ -540,10 +520,10 @@ bool read_LAS(std::istream& is, OutputIterator output, */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_LAS(const std::string& filename, PointOutputIterator output, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { std::ifstream is(filename, std::ios::binary); CGAL::IO::set_mode(is, CGAL::IO::BINARY); @@ -552,26 +532,14 @@ bool read_LAS(const std::string& filename, /// \cond SKIP_IN_MANUAL -template -bool read_LAS(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np) +template +bool read_LAS(const std::string& fname, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values()) { std::ifstream is(fname, std::ios::binary); CGAL::IO::set_mode(is, CGAL::IO::BINARY); return read_LAS::type>(is, output, np); } -template -bool read_LAS(const std::string& fname, OutputIterator output) -{ - return read_LAS(fname, output, parameters::all_default()); -} - -template -bool read_LAS(const std::string& fname, OutputIterator output) -{ - return read_LAS::type>(fname, output, parameters::all_default()); -} - /// \endcond } // namespace IO @@ -642,43 +610,30 @@ CGAL_DEPRECATED bool read_las_points_with_properties(std::istream& is, */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> CGAL_DEPRECATED bool read_las_points(std::istream& is, OutputIterator output, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; - typename CGAL::GetPointMap, CGAL_BGL_NP_CLASS>::type point_map = - choose_parameter, CGAL_BGL_NP_CLASS>::type>(get_parameter(np, internal_np::point_map)); + typename CGAL::GetPointMap, CGAL_NP_CLASS>::type point_map = + choose_parameter, CGAL_NP_CLASS>::type>(get_parameter(np, internal_np::point_map)); return IO::read_LAS(is, output, make_las_point_reader(point_map)); } /// \cond SKIP_IN_MANUAL -// variant with default NP -template -CGAL_DEPRECATED bool read_las_points(std::istream& is, OutputIterator output) -{ - return IO::read_LAS(is, output, CGAL::parameters::all_default()); -} // variant with default output iterator value type -template -CGAL_DEPRECATED bool read_las_points(std::istream& is, OutputIterator output, const CGAL_BGL_NP_CLASS& np) +template +CGAL_DEPRECATED bool read_las_points(std::istream& is, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::read_LAS::type>(is, output, np); } -// variant with default NP and output iterator value type -template -CGAL_DEPRECATED bool read_las_points(std::istream& is, OutputIterator output) -{ - return IO::read_LAS::type>(is, output, CGAL::parameters::all_default()); -} - /// \endcond #endif // CGAL_NO_DEPRECATED_CODE diff --git a/Point_set_processing_3/include/CGAL/IO/read_off_points.h b/Point_set_processing_3/include/CGAL/IO/read_off_points.h index 1a459a48a56..783fd20c1fc 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_off_points.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -32,12 +32,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { namespace IO { @@ -83,10 +77,10 @@ namespace IO { */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_OFF(std::istream& is, PointOutputIterator output, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename std::enable_if::value>::type* = nullptr #endif @@ -98,16 +92,16 @@ bool read_OFF(std::istream& is, typedef Point_set_processing_3::Fake_point_range PointRange; // basic geometric types - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetNormalMap::type NormalMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; - typedef typename Kernel::FT FT; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Point_map PointMap; + typedef typename NP_helper::Normal_map NormalMap; + typedef typename NP_helper::Geom_traits Kernel; + typedef typename Kernel::FT FT; - bool has_normals = !(boost::is_same::NoMap>::value); + bool has_normals = NP_helper::has_normal_map(); - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - NormalMap normal_map = choose_parameter(get_parameter(np, internal_np::normal_map)); + PointMap point_map = NP_helper::get_point_map(np); + NormalMap normal_map = NP_helper::get_normal_map(np); // value_type_traits is a workaround as back_insert_iterator's value_type is void // typedef typename value_type_traits::type Enriched_point; @@ -123,6 +117,7 @@ bool read_OFF(std::istream& is, } // scan points + std::string signature; long pointsCount = 0, facesCount = 0, edgesCount = 0; // number of items in file int pointsRead = 0; // current number of points read int lineNumber = 0; // current line number @@ -137,27 +132,24 @@ bool read_OFF(std::istream& is, if (line.empty () || line[0] == '#') continue; - lineNumber++; + ++lineNumber; // Reads file signature on first line if (lineNumber == 1) { - std::string signature; - if ( !(iss >> signature) - || (signature != "OFF" && signature != "NOFF") ) + if ( !(iss >> signature) || (signature != "OFF" && signature != "NOFF") ) { // if wrong file format - std::cerr << "Incorrect file format line " << lineNumber << " of file" << std::endl; + std::cerr << "Error line " << lineNumber << " of file (unexpected header)" << std::endl; return false; } } - // Reads number of points on 2nd line else if (lineNumber == 2) { if ( !(iss >> pointsCount >> facesCount >> edgesCount) ) { - std::cerr << "Error line " << lineNumber << " of file" << std::endl; + std::cerr << "Error line " << lineNumber << " of file (incorrect header format)" << std::endl; return false; } } @@ -170,8 +162,7 @@ bool read_OFF(std::istream& is, double nx,ny,nz; if (iss >> IO::iformat(x) >> IO::iformat(y) >> IO::iformat(z)) { - //the extra `()` seem to fix a very strange bug. Without them, the put() won't compile. - Point point((FT(x)), (FT(y)), (FT(z))); + Point point{FT(x), FT(y), FT(z)}; Vector normal = CGAL::NULL_VECTOR; // ... + normal... if (iss >> IO::iformat(nx)) @@ -180,25 +171,30 @@ bool read_OFF(std::istream& is, if(iss >> IO::iformat(ny) >> IO::iformat(nz)){ normal = Vector(FT(nx),FT(ny),FT(nz)); } else { - std::cerr << "Error line " << lineNumber << " of file" << std::endl; + std::cerr << "Error line " << lineNumber << " of file (incomplete normal coordinates)" << std::endl; return false; } } + else if (signature == "NOFF") + { + std::cerr << "Error line " << lineNumber << " of file (expected normal coordinates)" << std::endl; + return false; + } + Enriched_point pwn; put(point_map, pwn, point); // point_map[&pwn] = point if (has_normals) put(normal_map, pwn, normal); // normal_map[&pwn] = normal - *output++ = pwn; - pointsRead++; + *output++ = pwn; + ++pointsRead; } - // ...or skip comment line } - // Skip remaining lines } - if(is.eof()) { + + if(is.eof()) is.clear(is.rdstate() & ~std::ios_base::failbit); // set by getline - } + return true; } @@ -243,10 +239,10 @@ bool read_OFF(std::istream& is, */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_OFF(const std::string& fname, PointOutputIterator output, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename std::enable_if::value>::type* = nullptr #endif @@ -258,54 +254,23 @@ bool read_OFF(const std::string& fname, /// \cond SKIP_IN_MANUAL -// variants with default NP -template -bool read_OFF(std::istream& is, OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_OFF(is, output, CGAL::parameters::all_default()); -} - -template -bool read_OFF(const std::string& fname, OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_OFF(fname, output, parameters::all_default()); -} - // variants with default output iterator value type template -bool read_OFF(std::istream& is, OutputIterator output, const CGAL_BGL_NP_CLASS& np, + typename CGAL_NP_TEMPLATE_PARAMETERS> +bool read_OFF(std::istream& is, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values(), typename std::enable_if::value>::type* = nullptr) { return read_OFF::type>(is, output, np); } -template -bool read_OFF(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np, +template +bool read_OFF(const std::string& fname, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values(), typename std::enable_if::value>::type* = nullptr) { std::ifstream is(fname); return read_OFF::type>(is, output, np); } -// variants with default NP and output iterator value type -template -bool read_OFF(std::istream& is, OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_OFF::type>(is, output, CGAL::parameters::all_default()); -} - -template -bool read_OFF(const std::string& fname, OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_OFF::type>(fname, output, parameters::all_default()); -} - /// \endcond } // namespace IO @@ -457,10 +422,10 @@ bool read_off_points(std::istream& is, ///< input stream. */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> CGAL_DEPRECATED bool read_off_points(std::istream& is, OutputIterator output, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::read_OFF(is, output, np); } @@ -474,19 +439,12 @@ CGAL_DEPRECATED bool read_off_points(std::istream& is, OutputIterator output) } // variant with default output iterator value type -template -CGAL_DEPRECATED bool read_off_points(std::istream& is, OutputIterator output, const CGAL_BGL_NP_CLASS& np) +template +CGAL_DEPRECATED bool read_off_points(std::istream& is, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::read_OFF(is, output, np); } -// variant with default NP and output iterator value type -template -CGAL_DEPRECATED bool read_off_points(std::istream& is, OutputIterator output) -{ - return IO::read_OFF(is, output, CGAL::parameters::all_default()); -} - /// \endcond #endif //CGAL_NO_DEPRECATED_CODE diff --git a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h index 7ef8d18806e..1a0f7ed547b 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -35,12 +35,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { namespace IO { @@ -245,10 +239,10 @@ bool read_PLY_with_properties(std::istream& is, */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_PLY(std::istream& is, PointOutputIterator output, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename std::enable_if::value>::type* = nullptr #endif @@ -260,14 +254,14 @@ bool read_PLY(std::istream& is, typedef Point_set_processing_3::Fake_point_range PointRange; // basic geometric types - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetNormalMap::type NormalMap; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Point_map PointMap; + typedef typename NP_helper::Normal_map NormalMap; - bool has_normals = !(boost::is_same::NoMap>::value); + bool has_normals = NP_helper::has_normal_map(); - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - NormalMap normal_map = choose_parameter(get_parameter(np, internal_np::normal_map)); + PointMap point_map = NP_helper::get_point_map(np); + NormalMap normal_map = NP_helper::get_normal_map(np); if(has_normals) return read_PLY_with_properties(is, output, @@ -327,10 +321,10 @@ bool read_PLY(std::istream& is, */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_PLY(const std::string& fname, PointOutputIterator output, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename std::enable_if::value>::type* = nullptr #endif @@ -353,51 +347,21 @@ bool read_PLY(const std::string& fname, /// \cond SKIP_IN_MANUAL -// variants with default NP -template -bool read_PLY(std::istream& is, OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_PLY(is, output, parameters::all_default()); -} - -template -bool read_PLY(const std::string& fname, OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_PLY(fname, output, parameters::all_default()); -} - // variants with default output iterator value type -template -bool read_PLY(std::istream& is, OutputIterator output, const CGAL_BGL_NP_CLASS& np, +template +bool read_PLY(std::istream& is, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values(), typename std::enable_if::value>::type* = nullptr) { return read_PLY::type>(is, output, np); } -template -bool read_PLY(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np, +template +bool read_PLY(const std::string& fname, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values(), typename std::enable_if::value>::type* = nullptr) { return read_PLY::type>(fname, output, np); } -// variants with default NP and output iterator value type -template -bool read_PLY(std::istream& is, OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_PLY::type>(is, output, parameters::all_default()); -} - -template -bool read_PLY(const std::string& fname, OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_PLY::type>(fname, output, parameters::all_default()); -} - /// \endcond } // namespace IO @@ -494,8 +458,8 @@ CGAL_DEPRECATED bool read_ply_points_with_properties(std::istream& is, OutputIte \deprecated This function is deprecated since \cgal 5.3, \link PkgPointSetProcessing3IOPly `CGAL::IO::read_PLY()` \endlink should be used instead. */ -template -CGAL_DEPRECATED bool read_ply_points(std::istream& is, OutputIterator output, const CGAL_BGL_NP_CLASS& np) +template +CGAL_DEPRECATED bool read_ply_points(std::istream& is, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::read_PLY(is, output, np); } @@ -509,28 +473,14 @@ CGAL_DEPRECATED bool read_ply_points_with_properties(std::istream& is, OutputIte return IO::read_PLY_with_properties::type>(is, output, std::forward(properties)...); } -template -CGAL_DEPRECATED bool read_ply_points(std::istream& is, OutputIterator output) -{ - return IO::read_PLY(is, output, parameters::all_default()); -} - // variant with default output iterator value type template -CGAL_DEPRECATED bool read_ply_points(std::istream& is, OutputIterator output, const CGAL_BGL_NP_CLASS& np) + typename CGAL_NP_TEMPLATE_PARAMETERS> +CGAL_DEPRECATED bool read_ply_points(std::istream& is, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::read_PLY::type>(is, output, np); } -// variant with default NP and output iterator value type -template -CGAL_DEPRECATED bool read_ply_points(std::istream& is, OutputIterator output) -{ - return IO::read_PLY::type>(is, output, parameters::all_default()); -} - /// \endcond #endif // CGAL_NO_DEPRECATED_CODE diff --git a/Point_set_processing_3/include/CGAL/IO/read_points.h b/Point_set_processing_3/include/CGAL/IO/read_points.h index 1547b95f19a..b9ca990d21a 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_points.h @@ -85,10 +85,10 @@ namespace IO { */ template + typename NamedParameters = parameters::Default_named_parameters> bool read_points(const std::string& fname, PointOutputIterator output, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { const std::string ext = internal::get_file_extension(fname); @@ -109,24 +109,12 @@ bool read_points(const std::string& fname, /// \cond SKIP_IN_MANUAL // variant with default OutputIteratorType -template -bool read_points(const std::string& fname, OutputIterator output, const NamedParameters& np) +template +bool read_points(const std::string& fname, OutputIterator output, const NamedParameters& np = parameters::default_values()) { return read_points::type>(fname, output, np); } -template -bool read_points(const std::string& fname, OutputIterator output) -{ - return read_points(fname, output, parameters::all_default()); -} - -// variant with all default -template -bool read_points(const std::string& fname, OutputIterator output) -{ - return read_points::type>(fname, output, parameters::all_default()); -} /// \endcond diff --git a/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h b/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h index 0de735fadf8..793c7e2e85f 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -29,12 +29,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { namespace IO { @@ -80,10 +74,10 @@ namespace IO { */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_XYZ(std::istream& is, OutputIterator output, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -91,15 +85,15 @@ bool read_XYZ(std::istream& is, typedef Point_set_processing_3::Fake_point_range PointRange; // basic geometric types - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetNormalMap::type NormalMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Point_map PointMap; + typedef typename NP_helper::Normal_map NormalMap; + typedef typename NP_helper::Geom_traits Kernel; - bool has_normals = !(boost::is_same::NoMap>::value); + bool has_normals = NP_helper::has_normal_map(); - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - NormalMap normal_map = choose_parameter(get_parameter(np, internal_np::normal_map)); + PointMap point_map = NP_helper::get_point_map(np); + NormalMap normal_map = NP_helper::get_normal_map(np); // value_type_traits is a workaround as back_insert_iterator's value_type is void //typedef typename value_type_traits::type Enriched_point; @@ -139,35 +133,37 @@ bool read_XYZ(std::istream& is, continue; } // ...or reads position... - else { + else + { iss.clear(); iss.str(line); if (iss >> iformat(x) >> iformat(y) >> iformat(z)) + { + Point point(x,y,z); + Vector normal = CGAL::NULL_VECTOR; + // ... + normal... + if (iss >> iformat(nx)) { - Point point(x,y,z); - Vector normal = CGAL::NULL_VECTOR; - // ... + normal... - if (iss >> iformat(nx)) - { - // In case we could read one number, we expect that there are two more - if(iss >> iformat(ny) >> iformat(nz)){ - normal = Vector(nx,ny,nz); - } else { - std::cerr << "Error line " << lineNumber << " of file" << std::endl; - return false; - } - } - Enriched_point pwn; - put(point_map, pwn, point); // point_map[pwn] = point - - if (has_normals) - put(normal_map, pwn, normal); // normal_map[pwn] = normal - - *output++ = pwn; - continue; + // In case we could read one number, we expect that there are two more + if(iss >> iformat(ny) >> iformat(nz)){ + normal = Vector(nx,ny,nz); + } else { + std::cerr << "Error line " << lineNumber << " of file (incomplete normal coordinates)" << std::endl; + return false; + } } + Enriched_point pwn; + put(point_map, pwn, point); // point_map[pwn] = point + + if (has_normals) + put(normal_map, pwn, normal); // normal_map[pwn] = normal + + *output++ = pwn; + continue; + } } + // ...or skips number of points on first line (optional) if (lineNumber == 1 && std::istringstream(line) >> pointsCount) { @@ -175,13 +171,13 @@ bool read_XYZ(std::istream& is, } else // if wrong file format { - std::cerr << "Error line " << lineNumber << " of file" << std::endl; + std::cerr << "Error line " << lineNumber << " of file (expected point coordinates)" << std::endl; return false; } } - if(is.eof()) { + + if(is.eof()) is.clear(is.rdstate() & ~std::ios_base::failbit); // set by getline - } return true; } @@ -227,10 +223,10 @@ bool read_XYZ(std::istream& is, */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_XYZ(const std::string& fname, OutputIterator output, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { std::ifstream is(fname); return read_XYZ(is, output, np); @@ -238,48 +234,21 @@ bool read_XYZ(const std::string& fname, /// \cond SKIP_IN_MANUAL -// variants with default NP -template -bool read_XYZ(std::istream& is, OutputIterator output) -{ - return read_XYZ(is, output, parameters::all_default()); -} - -template -bool read_XYZ(const std::string& fname, OutputIterator output) -{ - return read_XYZ(fname, output, parameters::all_default()); -} - // variants with default output iterator value type -template -bool read_XYZ(std::istream& is, OutputIterator output, const CGAL_BGL_NP_CLASS& np) +template +bool read_XYZ(std::istream& is, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values(), + typename std::enable_if::value>::type* = nullptr) { return read_XYZ::type>(is, output, np); } -template -bool read_XYZ(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np) +template +bool read_XYZ(const std::string& fname, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values()) { std::ifstream is(fname); return read_XYZ::type>(is, output, np); } -// variants with default NP and output iterator value type -template -bool read_XYZ(std::istream& is, - OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_XYZ::type>(is, output, parameters::all_default()); -} - -template -bool read_XYZ(const std::string& fname, OutputIterator output) -{ - return read_XYZ::type>(fname, output, parameters::all_default()); -} - } // namespace IO /// \endcond @@ -437,40 +406,23 @@ bool read_xyz_points(std::istream& is, ///< input stream. */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> CGAL_DEPRECATED bool read_xyz_points(std::istream& is, OutputIterator output, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::read_XYZ(is, output, np); } /// \cond SKIP_IN_MANUAL - -template -CGAL_DEPRECATED bool read_xyz_points(std::istream& is, - OutputIterator output) -{ - return IO::read_XYZ(is, output, parameters::all_default()); -} - template + typename CGAL_NP_TEMPLATE_PARAMETERS> CGAL_DEPRECATED bool read_xyz_points(std::istream& is, OutputIterator output, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::read_XYZ::type>(is, output, np); } - -template -CGAL_DEPRECATED bool read_xyz_points(std::istream& is, - OutputIterator output) -{ - return IO::read_XYZ::type>(is, output, parameters::all_default()); -} - /// \endcond #endif //CGAL_NO_DEPRECATED_CODE diff --git a/Point_set_processing_3/include/CGAL/IO/write_las_points.h b/Point_set_processing_3/include/CGAL/IO/write_las_points.h index 2fbb8d09af7..aa153ec4c44 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_las_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_las_points.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -58,12 +58,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { namespace IO { @@ -283,10 +277,10 @@ bool write_LAS_with_properties(std::ostream& os, ///< output stream. \sa \ref IOStreamLAS \sa `write_LAS_with_properties()` */ -template +template bool write_LAS(std::ostream& os, const PointRange& points, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -295,7 +289,7 @@ bool write_LAS(std::ostream& os, using parameters::choose_parameter; using parameters::get_parameter; - typedef typename CGAL::GetPointMap::type PointMap; + typedef typename CGAL::GetPointMap::type PointMap; PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); if(!os) @@ -338,10 +332,10 @@ bool write_LAS(std::ostream& os, \sa `write_LAS_with_properties()` */ -template +template bool write_LAS(const std::string& filename, const PointRange& points, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -352,27 +346,6 @@ bool write_LAS(const std::string& filename, return write_LAS(os, points, np); } -/// \cond SKIP_IN_MANUAL - -// variant with default NP -template -bool write_LAS(std::ostream& os, const PointRange& points, - typename boost::enable_if >::type* = nullptr) -{ - return write_LAS(os, points, CGAL::Point_set_processing_3::parameters::all_default(points)); -} - -template -bool write_LAS(const std::string& filename, const PointRange& points, - typename boost::enable_if >::type* = nullptr) -{ - std::ofstream os(filename, std::ios::binary); - CGAL::IO::set_mode(os, CGAL::IO::BINARY); - return write_LAS(os, points, parameters::all_default()); -} - -/// \endcond - } // namespace IO #ifndef CGAL_NO_DEPRECATED_CODE @@ -429,8 +402,8 @@ CGAL_DEPRECATED bool write_las_points_with_properties(std::ostream& os, \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::write_LAS()` should be used instead. */ -template -bool write_las_points(std::ostream& os, const PointRange& points, const CGAL_BGL_NP_CLASS& np) +template +bool write_las_points(std::ostream& os, const PointRange& points, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::write_LAS(os, points, np); } diff --git a/Point_set_processing_3/include/CGAL/IO/write_off_points.h b/Point_set_processing_3/include/CGAL/IO/write_off_points.h index e9e1737ee38..99daf882ac2 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_off_points.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -30,33 +30,28 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { namespace Point_set_processing_3 { namespace internal { -template +template bool write_OFF_PSP(std::ostream& os, const PointRange& points, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = CGAL::parameters::default_values()) { using CGAL::parameters::choose_parameter; using CGAL::parameters::get_parameter; + using CGAL::parameters::is_default_parameter; // basic geometric types - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetNormalMap::type NormalMap; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Const_point_map PointMap; + typedef typename NP_helper::Normal_map NormalMap; - bool has_normals = !(std::is_same::NoMap>::value); + const bool has_normals = !(is_default_parameter()); - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - NormalMap normal_map = choose_parameter(get_parameter(np, internal_np::normal_map)); + PointMap point_map = NP_helper::get_const_point_map(points, np); + NormalMap normal_map = NP_helper::get_normal_map(points, np); CGAL_point_set_processing_precondition(points.begin() != points.end()); @@ -69,7 +64,10 @@ bool write_OFF_PSP(std::ostream& os, set_stream_precision_from_NP(os, np); // Write header - os << "NOFF" << std::endl; + if (has_normals) + os << "NOFF" << std::endl; + else + os << "OFF" << std::endl; os << points.size() << " 0 0" << std::endl; // Write positions + normals @@ -132,10 +130,10 @@ namespace IO { \returns `true` if writing was successful, `false` otherwise. */ -template +template bool write_OFF(std::ostream& os, const PointRange& points, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -144,17 +142,6 @@ bool write_OFF(std::ostream& os, return Point_set_processing_3::internal::write_OFF_PSP(os, points, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_OFF(std::ostream& os, const PointRange& points, - typename boost::enable_if >::type* = nullptr) -{ - return write_OFF(os, points, parameters::all_default()); -} - -/// \endcond - /** \ingroup PkgPointSetProcessing3IOOff @@ -199,10 +186,10 @@ bool write_OFF(std::ostream& os, const PointRange& points, \sa \ref IOStreamOFF */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_OFF(const std::string& filename, const PointRange& points, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -213,18 +200,6 @@ bool write_OFF(const std::string& filename, return write_OFF(os, points, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_OFF(const std::string& filename, const PointRange& points, - typename boost::enable_if >::type* = nullptr) -{ - std::ofstream os(filename); - return write_OFF(os, points, parameters::all_default()); -} - -/// \endcond - } // IO namespace #ifndef CGAL_NO_DEPRECATED_CODE @@ -326,23 +301,12 @@ bool write_off_points(std::ostream& os, ///< output stream. \deprecated This function is deprecated since \cgal 5.3, \link PkgPointSetProcessing3IOOff `CGAL::IO::write_OFF()` \endlink should be used instead. */ -template -CGAL_DEPRECATED bool write_off_points(std::ostream& os, const PointRange& points, const CGAL_BGL_NP_CLASS& np) +template +CGAL_DEPRECATED bool write_off_points(std::ostream& os, const PointRange& points, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::write_OFF(os, points, np); } -/// \cond SKIP_IN_MANUAL - -// variant with default NP -template -CGAL_DEPRECATED bool write_off_points(std::ostream& os, const PointRange& points) -{ - return IO::write_OFF(os, points, parameters::all_default()); -} - -/// \endcond - #endif // CGAL_NO_DEPRECATED_CODE } // namespace CGAL diff --git a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h index 27dfe372ba9..38b361ff779 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -32,12 +32,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { namespace IO { @@ -190,10 +184,10 @@ template +template bool write_PLY(std::ostream& os, const PointRange& points, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -203,14 +197,14 @@ bool write_PLY(std::ostream& os, using parameters::get_parameter; // basic geometric types - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetNormalMap::type NormalMap; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Const_point_map PointMap; + typedef typename NP_helper::Normal_map NormalMap; - bool has_normals = !(boost::is_same::NoMap>::value); + bool has_normals = NP_helper::has_normal_map(); - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - NormalMap normal_map = choose_parameter(get_parameter(np, internal_np::normal_map)); + PointMap point_map = NP_helper::get_const_point_map(points, np); + NormalMap normal_map = NP_helper::get_normal_map(points, np); if(!os) { @@ -228,17 +222,6 @@ bool write_PLY(std::ostream& os, return write_PLY_with_properties(os, points, make_ply_point_writer(point_map)); } -/// \cond SKIP_IN_MANUAL - -template -bool write_PLY(std::ostream& os, const PointRange& points, - typename boost::enable_if >::type* = nullptr) -{ - return write_PLY(os, points, parameters::all_default()); -} - -/// \endcond - /** \ingroup PkgPointSetProcessing3IOPly @@ -289,10 +272,10 @@ bool write_PLY(std::ostream& os, const PointRange& points, \sa `write_PLY_with_properties()` */ -template +template bool write_PLY(const std::string& filename, const PointRange& points, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -313,17 +296,6 @@ bool write_PLY(const std::string& filename, } } -/// \cond SKIP_IN_MANUAL - -template -bool write_PLY(const std::string& filename, const PointRange& points, - typename boost::enable_if >::type* = nullptr) -{ - return write_PLY(filename, points, parameters::all_default()); -} - -/// \endcond - } // namespace IO #ifndef CGAL_NO_DEPRECATED_CODE @@ -402,22 +374,12 @@ CGAL_DEPRECATED bool write_ply_points_with_properties(std::ostream& os, ///< out \deprecated This function is deprecated since \cgal 5.3, \link PkgPointSetProcessing3IOPly `CGAL::IO::write_PLY()` \endlink should be used instead. */ -template -CGAL_DEPRECATED bool write_ply_points(std::ostream& os, const PointRange& points, const CGAL_BGL_NP_CLASS& np) +template +CGAL_DEPRECATED bool write_ply_points(std::ostream& os, const PointRange& points, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::write_PLY(os, points, np); } -/// \cond SKIP_IN_MANUAL - -template -CGAL_DEPRECATED bool write_ply_points(std::ostream& os, const PointRange& points) -{ - return IO::write_PLY(os, points, parameters::all_default()); -} - -/// \endcond - #endif // CGAL_NO_DEPRECATED_CODE } // namespace CGAL diff --git a/Point_set_processing_3/include/CGAL/IO/write_points.h b/Point_set_processing_3/include/CGAL/IO/write_points.h index 292617db646..712c03e03a6 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_points.h @@ -26,11 +26,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { namespace IO { @@ -93,10 +88,10 @@ namespace IO { \returns `true` if writing was successful, `false` otherwise. */ -template +template bool write_points(const std::string& fname, const PointRange& points, - const CGAL_BGL_NP_CLASS& np, + const CGAL_NP_CLASS& np = parameters::default_values(), #ifndef DOXYGEN_RUNNING typename boost::enable_if >::type* = nullptr #endif @@ -118,17 +113,6 @@ bool write_points(const std::string& fname, return false; } -/// \cond SKIP_IN_MANUAL - -template -bool write_points(const std::string& fname,const PointRange& points, - typename boost::enable_if >::type* = nullptr) -{ - return write_points(fname, points, parameters::all_default()); -} - -/// \endcond - } } // namespace CGAL::IO #endif // CGAL_POINT_SET_PROCESSING_WRITE_POINTS_H diff --git a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h index e1fd219b4ae..73610c9545f 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -30,34 +30,27 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { namespace Point_set_processing_3 { namespace internal { -template +template bool write_XYZ_PSP(std::ostream& os, const PointRange& points, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = CGAL::parameters::default_values()) { using CGAL::parameters::choose_parameter; using CGAL::parameters::get_parameter; // basic geometric types - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetNormalMap::type NormalMap; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Const_point_map PointMap; + typedef typename NP_helper::Normal_map NormalMap; - bool has_normals = !(std::is_same::NoMap>::value); + bool has_normals = NP_helper::has_normal_map(); - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - NormalMap normal_map = choose_parameter(get_parameter(np, internal_np::normal_map)); + PointMap point_map = NP_helper::get_const_point_map(points, np); + NormalMap normal_map = NP_helper::get_normal_map(points, np); CGAL_point_set_processing_precondition(points.begin() != points.end()); @@ -129,10 +122,10 @@ namespace IO { \returns `true` if writing was successful, `false` otherwise. */ -template +template bool write_XYZ(std::ostream& os, const PointRange& points, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -141,17 +134,6 @@ bool write_XYZ(std::ostream& os, return Point_set_processing_3::internal::write_XYZ_PSP(os, points, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_XYZ(std::ostream& os, const PointRange& points, - typename boost::enable_if >::type* = nullptr) -{ - return write_XYZ(os, points, parameters::all_default()); -} - -/// \endcond - /** \ingroup PkgPointSetProcessing3IOXyz @@ -193,10 +175,10 @@ bool write_XYZ(std::ostream& os, const PointRange& points, \returns `true` if writing was successful, `false` otherwise. */ -template +template bool write_XYZ(const std::string& filename, const PointRange& points, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -206,18 +188,6 @@ bool write_XYZ(const std::string& filename, return write_XYZ(os, points, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_XYZ(const std::string& filename, const PointRange& points, - typename boost::enable_if >::type* = nullptr) -{ - std::ofstream os(filename); - return write_XYZ(os, points, parameters::all_default()); -} - -/// \endcond - } // namespace IO #ifndef CGAL_NO_DEPRECATED_CODE @@ -317,22 +287,12 @@ bool write_xyz_points(std::ostream& os, ///< output stream. \deprecated This function is deprecated since \cgal 5.3, \link PkgPointSetProcessing3IOXyz `CGAL::write_XYZ()` \endlink should be used instead. */ -template -CGAL_DEPRECATED bool write_xyz_points(std::ostream& os, const PointRange& points, const CGAL_BGL_NP_CLASS& np) +template +CGAL_DEPRECATED bool write_xyz_points(std::ostream& os, const PointRange& points, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::write_XYZ(os, points, np); } -/// \cond SKIP_IN_MANUAL - -template -CGAL_DEPRECATED bool write_xyz_points(std::ostream& os, const PointRange& points) -{ - return IO::write_XYZ(os, points, parameters::all_default()); -} - -/// \endcond - #endif // CGAL_NO_DEPRECATED_CODE } // namespace CGAL diff --git a/Point_set_processing_3/include/CGAL/OpenGR/compute_registration_transformation.h b/Point_set_processing_3/include/CGAL/OpenGR/compute_registration_transformation.h index 70ae12f7217..7a439b3e0c9 100644 --- a/Point_set_processing_3/include/CGAL/OpenGR/compute_registration_transformation.h +++ b/Point_set_processing_3/include/CGAL/OpenGR/compute_registration_transformation.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -287,40 +287,43 @@ compute_registration_transformation(const PointRange1& range1, const PointRan registration score. */ template + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters> #ifdef DOXYGEN_RUNNING std::pair #else -std::pair - ::Kernel::Aff_transformation_3, double> +std::pair + ::Geom_traits::Aff_transformation_3, double> #endif compute_registration_transformation (const PointRange1& point_set_1, const PointRange2& point_set_2, - const NamedParameters1& np1, const NamedParameters2& np2) + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values()) { - namespace PSP = CGAL::Point_set_processing_3; namespace GR = gr; using parameters::choose_parameter; using parameters::get_parameter; // property map types - typedef typename CGAL::GetPointMap::type PointMap1; - typedef typename CGAL::GetPointMap::type PointMap2; + typedef Point_set_processing_3_np_helper NP_helper1; + typedef Point_set_processing_3_np_helper NP_helper2; + typedef typename NP_helper1::Const_point_map PointMap1; + typedef typename NP_helper2::Const_point_map PointMap2; CGAL_static_assertion_msg((boost::is_same< typename boost::property_traits::value_type, typename boost::property_traits::value_type> ::value), "The point type of input ranges must be the same"); - typedef typename PSP::GetNormalMap::type NormalMap1; - typedef typename PSP::GetNormalMap::type NormalMap2; + typedef typename NP_helper1::Normal_map NormalMap1; + typedef typename NP_helper2::Normal_map NormalMap2; CGAL_static_assertion_msg((boost::is_same< typename boost::property_traits::value_type, typename boost::property_traits::value_type> ::value), "The vector type of input ranges must be the same"); - typedef typename PSP::GetK::Kernel Kernel; + typedef typename NP_helper1::Geom_traits Kernel; - PointMap1 point_map1 = choose_parameter(get_parameter(np1, internal_np::point_map), PointMap1()); - NormalMap1 normal_map1 = choose_parameter(get_parameter(np1, internal_np::normal_map), NormalMap1()); - PointMap2 point_map2 = choose_parameter(get_parameter(np2, internal_np::point_map), PointMap2()); - NormalMap2 normal_map2 = choose_parameter(get_parameter(np2, internal_np::normal_map), NormalMap2()); + PointMap1 point_map1 = NP_helper1::get_const_point_map(point_set_1, np1); + NormalMap1 normal_map1 = NP_helper2::get_normal_map(point_set_1, np1); + PointMap2 point_map2 = NP_helper2::get_const_point_map(point_set_2, np2); + NormalMap2 normal_map2 = NP_helper2::get_normal_map(point_set_2, np2); Options options; options.sample_size = choose_parameter(get_parameter(np1, internal_np::number_of_samples), 200); @@ -339,30 +342,6 @@ compute_registration_transformation (const PointRange1& point_set_1, const Point } -// convenience overloads -template -std::pair - ::Kernel::Aff_transformation_3, double> -compute_registration_transformation(const PointRange1& point_set_1, PointRange2& point_set_2, - const NamedParameters1& np1) -{ - namespace params = CGAL::Point_set_processing_3::parameters; - return compute_registration_transformation(point_set_1, point_set_2, np1, params::all_default(point_set_1)); -} - -template -std::pair > - ::Kernel::Aff_transformation_3, double> -compute_registration_transformation(const PointRange1& point_set_1, PointRange2& point_set_2) -{ - namespace params = CGAL::Point_set_processing_3::parameters; - return compute_registration_transformation(point_set_1, point_set_2, - params::all_default(point_set_1), - params::all_default(point_set_2)); -} - } } // end of namespace CGAL::OpenGR #endif // CGAL_LINKED_WITH_OPENGR diff --git a/Point_set_processing_3/include/CGAL/OpenGR/register_point_sets.h b/Point_set_processing_3/include/CGAL/OpenGR/register_point_sets.h index 4fbbb195882..345eaa650d2 100644 --- a/Point_set_processing_3/include/CGAL/OpenGR/register_point_sets.h +++ b/Point_set_processing_3/include/CGAL/OpenGR/register_point_sets.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -206,35 +206,38 @@ register_point_sets(const PointRange1& range1, PointRange2& range2, \return the registration score. */ template + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters> double register_point_sets (const PointRange1& point_set_1, PointRange2& point_set_2, - const NamedParameters1& np1, const NamedParameters2& np2) + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values()) { - namespace PSP = CGAL::Point_set_processing_3; namespace GR = gr; using parameters::choose_parameter; using parameters::get_parameter; // property map types - typedef typename CGAL::GetPointMap::type PointMap1; - typedef typename CGAL::GetPointMap::type PointMap2; + typedef Point_set_processing_3_np_helper NP_helper1; + typedef Point_set_processing_3_np_helper NP_helper2; + typedef typename NP_helper1::Const_point_map PointMap1; + typedef typename NP_helper2::Const_point_map PointMap2; CGAL_static_assertion_msg((boost::is_same< typename boost::property_traits::value_type, typename boost::property_traits::value_type> ::value), "The point type of input ranges must be the same"); - typedef typename PSP::GetNormalMap::type NormalMap1; - typedef typename PSP::GetNormalMap::type NormalMap2; + typedef typename NP_helper1::Normal_map NormalMap1; + typedef typename NP_helper2::Normal_map NormalMap2; CGAL_static_assertion_msg((boost::is_same< typename boost::property_traits::value_type, typename boost::property_traits::value_type> ::value), "The vector type of input ranges must be the same"); - typedef typename PSP::GetK::Kernel Kernel; + typedef typename NP_helper1::Geom_traits Kernel; - PointMap1 point_map1 = choose_parameter(get_parameter(np1, internal_np::point_map), PointMap1()); - NormalMap1 normal_map1 = choose_parameter(get_parameter(np1, internal_np::normal_map), NormalMap1()); - PointMap1 point_map2 = choose_parameter(get_parameter(np2, internal_np::point_map), PointMap2()); - NormalMap2 normal_map2 = choose_parameter(get_parameter(np2, internal_np::normal_map), NormalMap2()); + PointMap1 point_map1 = NP_helper1::get_const_point_map(point_set_1, np1); + NormalMap1 normal_map1 = NP_helper1::get_normal_map(point_set_1, np1); + PointMap2 point_map2 = NP_helper2::get_const_point_map(point_set_2, np2); + NormalMap2 normal_map2 = NP_helper2::get_normal_map(point_set_2, np2); Options options; options.sample_size = choose_parameter(get_parameter(np1, internal_np::number_of_samples), 200); @@ -252,27 +255,6 @@ register_point_sets (const PointRange1& point_set_1, PointRange2& point_set_2, options); } -// convenience overloads -template -double -register_point_sets(const PointRange1& point_set_1, PointRange2& point_set_2, - const NamedParameters1& np1) -{ - namespace params = CGAL::Point_set_processing_3::parameters; - return register_point_sets(point_set_1, point_set_2, np1, params::all_default(point_set_1)); -} - -template -double -register_point_sets(const PointRange1& point_set_1, PointRange2& point_set_2) -{ - namespace params = CGAL::Point_set_processing_3::parameters; - return register_point_sets(point_set_1, point_set_2, - params::all_default(point_set_1), - params::all_default(point_set_2)); -} - } } // end of namespace CGAL::OpenGR #endif // CGAL_LINKED_WITH_OPENGR diff --git a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h index ee20c62e1b5..86fa5d23b19 100644 --- a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include @@ -258,12 +258,12 @@ compute_max_spacing( */ template + typename NamedParameters = parameters::Default_named_parameters> double bilateral_smooth_point_set( PointRange& points, unsigned int k, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -271,15 +271,14 @@ bilateral_smooth_point_set( // basic geometric types typedef typename PointRange::iterator iterator; typedef typename iterator::value_type value_type; - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetNormalMap::type NormalMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Point_map PointMap; + typedef typename NP_helper::Normal_map NormalMap; + typedef typename NP_helper::Geom_traits Kernel; typedef typename Kernel::Point_3 Point_3; typedef typename Kernel::Vector_3 Vector_3; - CGAL_static_assertion_msg(!(boost::is_same::NoMap>::value), - "Error: no normal map"); + CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); typedef typename Kernel::FT FT; @@ -293,8 +292,8 @@ bilateral_smooth_point_set( // types for K nearest neighbors search structure typedef Point_set_processing_3::internal::Neighbor_query Neighbor_query; - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - NormalMap normal_map = choose_parameter(get_parameter(np, internal_np::normal_map)); + PointMap point_map = NP_helper::get_point_map(points, np); + NormalMap normal_map = NP_helper::get_normal_map(points, np); FT neighbor_radius = choose_parameter(get_parameter(np, internal_np::neighbor_radius), FT(0)); std::size_t nb_points = points.size(); @@ -439,22 +438,6 @@ bilateral_smooth_point_set( return sum_move_error / nb_points; } -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -double -bilateral_smooth_point_set( - PointRange& points, - unsigned int k) ///< size of the neighborhood for the implicit surface patch fitting. - ///< The larger the value is, the smoother the result will be. -{ - return bilateral_smooth_point_set - (points, k, CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - - } //namespace CGAL #include diff --git a/Point_set_processing_3/include/CGAL/cluster_point_set.h b/Point_set_processing_3/include/CGAL/cluster_point_set.h index a90b983e86e..a7c516a5e5f 100644 --- a/Point_set_processing_3/include/CGAL/cluster_point_set.h +++ b/Point_set_processing_3/include/CGAL/cluster_point_set.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include @@ -128,10 +128,10 @@ CGAL::Emptyset_iterator get_adjacencies (const NamedParameters&, CGAL::Emptyset_ \return the number of clusters identified. */ -template +template std::size_t cluster_point_set (PointRange& points, ClusterMap cluster_map, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -140,15 +140,16 @@ std::size_t cluster_point_set (PointRange& points, typedef typename PointRange::iterator iterator; typedef typename iterator::value_type value_type; typedef typename boost::property_traits::value_type Cluster_index_t; - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Point_map PointMap; + typedef typename NP_helper::Geom_traits Kernel; typedef typename Point_set_processing_3::GetAdjacencies::type Adjacencies; CGAL_static_assertion_msg(!(boost::is_same::type, typename GetSvdTraits::NoTraits>::value), "Error: no SVD traits"); - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map), PointMap()); + PointMap point_map = NP_helper::get_point_map(points, np); typename Kernel::FT neighbor_radius = choose_parameter(get_parameter(np, internal_np::neighbor_radius), typename Kernel::FT(-1)); typename Kernel::FT factor = choose_parameter(get_parameter(np, internal_np::attraction_factor), @@ -259,18 +260,6 @@ std::size_t cluster_point_set (PointRange& points, return nb_clusters; } -/// \cond SKIP_IN_MANUAL -// overload with default NP -template -std::size_t cluster_point_set (PointRange& points, - ClusterMap cluster_map, - unsigned int k) -{ - return cluster_point_set (points, cluster_map, k, - CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - } // namespace CGAL diff --git a/Point_set_processing_3/include/CGAL/compute_average_spacing.h b/Point_set_processing_3/include/CGAL/compute_average_spacing.h index 0f98e72c863..3b9c0f206c6 100644 --- a/Point_set_processing_3/include/CGAL/compute_average_spacing.h +++ b/Point_set_processing_3/include/CGAL/compute_average_spacing.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include @@ -34,13 +34,6 @@ #include #include - - -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { @@ -152,27 +145,28 @@ compute_average_spacing(const typename NeighborQuery::Kernel::Point_3& query, // */ template #ifdef DOXYGEN_RUNNING FT #else - typename Point_set_processing_3::GetK::Kernel::FT + typename Point_set_processing_3_np_helper::FT #endif compute_average_spacing( const PointRange& points, unsigned int k, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; // basic geometric types typedef typename PointRange::const_iterator iterator; - typedef typename CGAL::GetPointMap::const_type PointMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Const_point_map PointMap; + typedef typename NP_helper::Geom_traits Kernel; - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map), PointMap()); + PointMap point_map = NP_helper::get_const_point_map(points, np); const std::function& callback = choose_parameter(get_parameter(np, internal_np::callback), std::function()); @@ -231,21 +225,6 @@ compute_average_spacing( return sum_spacings / (FT)(nb); } -/// \cond SKIP_IN_MANUAL - -// variant with default NP -template -typename Point_set_processing_3::GetFT::type -compute_average_spacing( - const PointRange& points, - unsigned int k) ///< number of neighbors. -{ - return compute_average_spacing - (points, k, CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - - } //namespace CGAL #include diff --git a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h index 0a6445492ad..507418d45b8 100644 --- a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h +++ b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -350,32 +350,32 @@ update_new_point( template + typename NamedParameters = parameters::Default_named_parameters> OutputIterator edge_aware_upsample_point_set( const PointRange& points, OutputIterator output, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; // basic geometric types - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetNormalMap::type NormalMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Const_point_map PointMap; + typedef typename NP_helper::Normal_map NormalMap; + typedef typename NP_helper::Geom_traits Kernel; - CGAL_static_assertion_msg(!(boost::is_same::NoMap>::value), - "Error: no normal map"); + + CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); typedef typename Kernel::Point_3 Point; typedef typename Kernel::Vector_3 Vector; typedef typename Kernel::FT FT; typedef typename rich_grid_internal::Rich_point Rich_point; - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - NormalMap normal_map = choose_parameter(get_parameter(np, internal_np::normal_map)); + PointMap point_map = NP_helper::get_const_point_map(points, np); + NormalMap normal_map = NP_helper::get_normal_map(points, np); double sharpness_angle = choose_parameter(get_parameter(np, internal_np::sharpness_angle), 30.); double edge_sensitivity = choose_parameter(get_parameter(np, internal_np::edge_sensitivity), 1); double neighbor_radius = choose_parameter(get_parameter(np, internal_np::neighbor_radius), -1); @@ -613,22 +613,6 @@ edge_aware_upsample_point_set( return output; } - -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -OutputIterator -edge_aware_upsample_point_set( - const PointRange& points, - OutputIterator output) -{ - return edge_aware_upsample_point_set - (points, output, CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - } //namespace CGAL #include diff --git a/Point_set_processing_3/include/CGAL/estimate_scale.h b/Point_set_processing_3/include/CGAL/estimate_scale.h index f6eb57c4217..3bb7db74e5a 100644 --- a/Point_set_processing_3/include/CGAL/estimate_scale.h +++ b/Point_set_processing_3/include/CGAL/estimate_scale.h @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include @@ -482,25 +482,26 @@ public: template OutputIterator estimate_local_k_neighbor_scales( const PointRange& points, const QueryPointRange& queries, OutputIterator output, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; - typedef typename CGAL::GetPointMap::const_type PointMap; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Const_point_map PointMap; + typedef typename NP_helper::Geom_traits Kernel; typedef typename CGAL::GetPointMap::const_type QueryPointMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; typedef typename boost::property_traits::value_type Point_d; - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); + PointMap point_map = NP_helper::get_const_point_map(points, np); QueryPointMap query_point_map = choose_parameter(get_parameter(np, internal_np::query_point_map)); // Build multi-scale KD-tree @@ -516,23 +517,6 @@ estimate_local_k_neighbor_scales( return output; } -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -OutputIterator -estimate_local_k_neighbor_scales( - const PointRange& points, - const QueryPointRange& queries, - OutputIterator output) -{ - return estimate_local_k_neighbor_scales - (points, queries, output, CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - /** \ingroup PkgPointSetProcessing3Algorithms @@ -569,35 +553,25 @@ estimate_local_k_neighbor_scales( \return The estimated scale in the K nearest neighbors sense. */ template std::size_t estimate_global_k_neighbor_scale( const PointRange& points, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; - typedef typename CGAL::GetPointMap::const_type PointMap; - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Const_point_map PointMap; + PointMap point_map = NP_helper::get_const_point_map(points, np); std::vector scales; estimate_local_k_neighbor_scales (points, points, std::back_inserter (scales), np.query_point_map(point_map)); std::sort (scales.begin(), scales.end()); return scales[scales.size() / 2]; } -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -std::size_t -estimate_global_k_neighbor_scale(const PointRange& points) -{ - return estimate_global_k_neighbor_scale - (points, CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - /** \ingroup PkgPointSetProcessing3Algorithms @@ -650,25 +624,26 @@ estimate_global_k_neighbor_scale(const PointRange& points) template OutputIterator estimate_local_range_scales( const PointRange& points, const QueryPointRange& queries, OutputIterator output, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; - typedef typename CGAL::GetPointMap::const_type PointMap; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Const_point_map PointMap; + typedef typename NP_helper::Geom_traits Kernel; typedef typename CGAL::GetPointMap::const_type QueryPointMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; typedef typename boost::property_traits::value_type Point_d; - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); + PointMap point_map = NP_helper::get_const_point_map(points, np); QueryPointMap query_point_map = choose_parameter(get_parameter(np, internal_np::query_point_map)); // Build multi-scale KD-tree @@ -683,23 +658,6 @@ estimate_local_range_scales( return output; } -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -OutputIterator -estimate_local_range_scales( - const PointRange& points, - const QueryPointRange& queries, - OutputIterator output) -{ - return estimate_local_range_scales - (points, queries, output, CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - /** \ingroup PkgPointSetProcessing3Algorithms @@ -740,39 +698,29 @@ estimate_local_range_scales( of `points`. */ template #ifdef DOXYGEN_RUNNING FT #else - typename Point_set_processing_3::GetK::Kernel::FT + typename Point_set_processing_3_np_helper::FT #endif estimate_global_range_scale( const PointRange& points, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; std::vector scales; - typedef typename CGAL::GetPointMap::const_type PointMap; - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Const_point_map PointMap; + PointMap point_map = NP_helper::get_const_point_map(points, np); estimate_local_range_scales (points, points, std::back_inserter (scales), np.query_point_map(point_map)); std::sort (scales.begin(), scales.end()); return std::sqrt (scales[scales.size() / 2]); } -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -typename Point_set_processing_3::GetFT::type -estimate_global_range_scale(const PointRange& points) -{ - return estimate_global_range_scale - (points, CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - } //namespace CGAL #include diff --git a/Point_set_processing_3/include/CGAL/grid_simplify_point_set.h b/Point_set_processing_3/include/CGAL/grid_simplify_point_set.h index 15e467d61fa..86cfca10156 100644 --- a/Point_set_processing_3/include/CGAL/grid_simplify_point_set.h +++ b/Point_set_processing_3/include/CGAL/grid_simplify_point_set.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -31,6 +31,7 @@ #include #include #include +#include namespace CGAL { @@ -117,43 +118,68 @@ public: } }; - -} /* namespace internal */ - +template +using Epsilon_point_set_3_base += typename std::conditional + , + internal::Equal_epsilon_points_3 >, + std::unordered_set, + internal::Equal_epsilon_points_3 > >::type; /// Utility class for grid_simplify_point_set(): -/// 3D points set which allows at most 1 point per cell +/// 3D points set which allows at most 1 (or N) point per cell /// of a grid of cell size = epsilon. /// /// Warning: /// This class is a container sorted wrt points position /// => you should not modify directly the order or the position of points. -template -class Epsilon_point_set_3 - : public std::unordered_set, - internal::Equal_epsilon_points_3 > +template +class Epsilon_point_set_3 : public internal::Epsilon_point_set_3_base + { private: - // superclass - typedef std::unordered_set, - internal::Equal_epsilon_points_3 > Base; + // superclass + using Base = internal::Epsilon_point_set_3_base; + + unsigned int min_points_per_cell; public: - Epsilon_point_set_3 (double epsilon, PointMap point_map) - : Base(10, internal::Hash_epsilon_points_3(epsilon, point_map), - internal::Equal_epsilon_points_3(epsilon, point_map)) - { - CGAL_point_set_processing_precondition(epsilon > 0); - } + Epsilon_point_set_3 (double epsilon, PointMap point_map, unsigned int min_points_per_cell = 1) + : Base(10, internal::Hash_epsilon_points_3(epsilon, point_map), + internal::Equal_epsilon_points_3(epsilon, point_map)) + , min_points_per_cell (min_points_per_cell) + { + CGAL_point_set_processing_precondition(epsilon > 0); + } - // default copy constructor, operator =() and destructor are fine. + bool insert (const Point_3& p) + { + return insert (p, UseMap()); + } + +private: + + bool insert (const Point_3& p, const Tag_true&) + { + auto iter = Base::insert(std::make_pair (p, 0)); + iter.first->second ++; + return iter.first->second == min_points_per_cell; + } + + bool insert (const Point_3& p, const Tag_false&) + { + return Base::insert (p).second; + } }; +} /* namespace internal */ + /// \endcond // ---------------------------------------------------------------------------- @@ -185,17 +211,14 @@ public: \cgalParamDefault{`CGAL::Identity_property_map`} \cgalParamNEnd - \cgalParamNBegin{callback} - \cgalParamDescription{a mechanism to get feedback on the advancement of the algorithm - while it's running and to interrupt it if needed} - \cgalParamType{an instance of `std::function`.} - \cgalParamDefault{unused} - \cgalParamExtra{It is called regularly when the - algorithm is running: the current advancement (between 0. and - 1.) is passed as parameter. If it returns `true`, then the - algorithm continues its execution normally; if it returns - `false`, the algorithm is stopped and simplification stops with no guarantee on the output. } - \cgalParamExtra{The callback will be copied and therefore needs to be lightweight.} + \cgalParamNBegin{min_points_per_cell} + \cgalParamDescription{minimum number of points in a cell such + that a point in this cell is kept after simplification} + \cgalParamType{unsigned int} + \cgalParamDefault{1} + \cgalParamExtra{If a value greater than 1 is used, the + algorithm also acts as an outlier filtering algorithm, by removing + low-density areas.} \cgalParamNEnd \cgalParamNBegin{geom_traits} @@ -207,61 +230,41 @@ public: \return iterator over the first point to remove. */ -template +template typename PointRange::iterator grid_simplify_point_set( PointRange& points, double epsilon, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; - typedef typename CGAL::GetPointMap::const_type PointMap; - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - const std::function& callback = choose_parameter(get_parameter(np, internal_np::callback), - std::function()); + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Point_map PointMap; + PointMap point_map = NP_helper::get_point_map(points, np); + + unsigned int min_points_per_cell = choose_parameter(get_parameter(np, internal_np::min_points_per_cell), 1); // actual type of input points typedef typename std::iterator_traits::value_type Enriched_point; CGAL_point_set_processing_precondition(epsilon > 0); - // Merges points which belong to the same cell of a grid of cell size = epsilon. - // points_to_keep[] will contain 1 point per cell; the others will be in points_to_remove[]. - Epsilon_point_set_3 points_to_keep(epsilon, point_map); - std::deque points_to_remove; - std::size_t nb = 0, nb_points = points.size(); - for (typename PointRange::iterator it = points.begin(); it != points.end(); it++, ++ nb) + if (min_points_per_cell == 1) { - std::pair::iterator,bool> result; - result = points_to_keep.insert(*it); - if (!result.second) // if not inserted - points_to_remove.push_back(*it); - if (callback && !callback ((nb+1) / double(nb_points))) - break; + // Merges points which belong to the same cell of a grid of cell size = epsilon. + // Keep 1 point per occupied cell + internal::Epsilon_point_set_3 point_set(epsilon, point_map); + return std::partition (points.begin(), points.end(), [&](const auto& p) -> bool { return point_set.insert(p); }); } - - // Replaces `[first, beyond)` range by the content of points_to_keep, then points_to_remove. - typename PointRange::iterator first_point_to_remove = - std::copy(points_to_keep.begin(), points_to_keep.end(), points.begin()); - std::copy(points_to_remove.begin(), points_to_remove.end(), first_point_to_remove); - - return first_point_to_remove; + // else + // Merges points which belong to the same cell of a grid of cell size = epsilon. + // Keep 1 point per cell occupied by at least `min_points_per_cell` points + internal::Epsilon_point_set_3 point_set(epsilon, point_map, min_points_per_cell); + return std::partition (points.begin(), points.end(), [&](const auto& p) -> bool { return point_set.insert(p); }); } -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -typename PointRange::iterator -grid_simplify_point_set(PointRange& points, double epsilon) -{ - return grid_simplify_point_set - (points, epsilon, CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - - } //namespace CGAL #include diff --git a/Point_set_processing_3/include/CGAL/hierarchy_simplify_point_set.h b/Point_set_processing_3/include/CGAL/hierarchy_simplify_point_set.h index 5a115be66c8..2d6c60c9245 100644 --- a/Point_set_processing_3/include/CGAL/hierarchy_simplify_point_set.h +++ b/Point_set_processing_3/include/CGAL/hierarchy_simplify_point_set.h @@ -32,7 +32,7 @@ #include #include -#include +#include #include namespace CGAL { @@ -116,7 +116,7 @@ namespace CGAL { and returns an iterator over the first point to remove (see erase-remove idiom). For this reason it should not be called on sorted containers. - \pre `0 < maximum_variation < 1/3` + \pre `0 < maximum_variation <= 1/3` \pre `size > 0` \tparam PointRange is a model of `Range`. The value type of @@ -176,24 +176,25 @@ namespace CGAL { \return iterator over the first point to remove. */ template + typename NamedParameters = parameters::Default_named_parameters> typename PointRange::iterator hierarchy_simplify_point_set (PointRange& points, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; // basic geometric types - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Point_map PointMap; + typedef typename NP_helper::Geom_traits Kernel; typedef typename GetDiagonalizeTraits::type DiagonalizeTraits; typedef typename Kernel::Point_3 Point; typedef typename Kernel::Vector_3 Vector; typedef typename Kernel::FT FT; - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); + PointMap point_map = NP_helper::get_point_map(points, np); unsigned int size = choose_parameter(get_parameter(np, internal_np::size), 10); double var_max = choose_parameter(get_parameter(np, internal_np::maximum_variation), 1./3.); const std::function& callback = choose_parameter(get_parameter(np, internal_np::callback), @@ -372,18 +373,6 @@ namespace CGAL { } - - /// \cond SKIP_IN_MANUAL - // variant with default NP - template - typename PointRange::iterator - hierarchy_simplify_point_set (PointRange& points) - { - return hierarchy_simplify_point_set - (points, CGAL::Point_set_processing_3::parameters::all_default(points)); - } - /// \endcond - } // namespace CGAL #include diff --git a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h index 7f8e26fc3ab..da74d6e93ee 100644 --- a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include @@ -173,13 +173,13 @@ jet_estimate_normal(const typename NeighborQuery::Point_3& query, ///< point to */ template void jet_estimate_normals( PointRange& points, unsigned int k, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -189,21 +189,20 @@ jet_estimate_normals( // basic geometric types typedef typename PointRange::iterator iterator; typedef typename iterator::value_type value_type; - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetNormalMap::type NormalMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Point_map PointMap; + typedef typename NP_helper::Normal_map NormalMap; + typedef typename NP_helper::Geom_traits Kernel; typedef typename Kernel::FT FT; typedef typename GetSvdTraits::type SvdTraits; - CGAL_static_assertion_msg(!(boost::is_same::NoMap>::value), - "Error: no normal map"); + CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); CGAL_static_assertion_msg(!(boost::is_same::NoTraits>::value), "Error: no SVD traits"); - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - NormalMap normal_map = choose_parameter(get_parameter(np, internal_np::normal_map)); + PointMap point_map = NP_helper::get_point_map(points, np); + NormalMap normal_map = NP_helper::get_normal_map(points, np); unsigned int degree_fitting = choose_parameter(get_parameter(np, internal_np::degree_fitting), 2); FT neighbor_radius = choose_parameter(get_parameter(np, internal_np::neighbor_radius), FT(0)); @@ -258,21 +257,6 @@ jet_estimate_normals( CGAL_TRACE_STREAM << "End of jet_estimate_normals()\n"; } - -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -void -jet_estimate_normals( - PointRange& points, - unsigned int k) ///< number of neighbors. -{ - jet_estimate_normals - (points, k, CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - } //namespace CGAL #include diff --git a/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h b/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h index a6397928b26..50e8a9ad49d 100644 --- a/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include @@ -182,28 +182,29 @@ jet_smooth_point( */ template void jet_smooth_point_set( PointRange& points, unsigned int k, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; // basic geometric types typedef typename PointRange::iterator iterator; - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Point_map PointMap; + typedef typename NP_helper::Geom_traits Kernel; typedef typename GetSvdTraits::type SvdTraits; CGAL_static_assertion_msg(!(boost::is_same::NoTraits>::value), "Error: no SVD traits"); - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); + PointMap point_map = NP_helper::get_point_map(points, np); typename Kernel::FT neighbor_radius = choose_parameter(get_parameter(np, internal_np::neighbor_radius), typename Kernel::FT(0)); unsigned int degree_fitting = choose_parameter(get_parameter(np, internal_np::degree_fitting), 2); @@ -271,22 +272,6 @@ jet_smooth_point_set( }); } - -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -void -jet_smooth_point_set( - PointRange& points, - unsigned int k) ///< number of neighbors. -{ - jet_smooth_point_set - (points, k, CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - - } //namespace CGAL #include diff --git a/Point_set_processing_3/include/CGAL/mst_orient_normals.h b/Point_set_processing_3/include/CGAL/mst_orient_normals.h index 2b760dba0ac..438e7ce0598 100644 --- a/Point_set_processing_3/include/CGAL/mst_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/mst_orient_normals.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include @@ -598,30 +598,30 @@ create_mst_graph( \return iterator over the first point with an unoriented normal. */ template typename PointRange::iterator mst_orient_normals( PointRange& points, unsigned int k, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; + using parameters::is_default_parameter; CGAL_TRACE_STREAM << "Calls mst_orient_normals()\n"; - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetNormalMap::type NormalMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Point_map PointMap; + typedef typename NP_helper::Normal_map NormalMap; + typedef typename NP_helper::Geom_traits Kernel; typedef typename Point_set_processing_3::GetIsConstrainedMap::type ConstrainedMap; - CGAL_static_assertion_msg(!(boost::is_same::NoMap>::value), - "Error: no normal map"); + CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - NormalMap normal_map = choose_parameter(get_parameter(np, internal_np::normal_map)); + PointMap point_map = NP_helper::get_point_map(points, np); + NormalMap normal_map = NP_helper::get_normal_map(points, np); typename Kernel::FT neighbor_radius = choose_parameter(get_parameter(np, internal_np::neighbor_radius), typename Kernel::FT(0)); ConstrainedMap constrained_map = choose_parameter(get_parameter(np, internal_np::point_is_constrained)); @@ -665,8 +665,7 @@ mst_orient_normals( // or vertex j is in the k-neighborhood of vertex i. Riemannian_graph riemannian_graph; - if (boost::is_same::NoMap>::value) + if (is_default_parameter()) riemannian_graph = create_riemannian_graph(points, point_map, normal_map, index_map, Default_constrained_map @@ -732,20 +731,6 @@ mst_orient_normals( return first_unoriented_point; } -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -typename PointRange::iterator -mst_orient_normals( - PointRange& points, - unsigned int k) ///< number of neighbors - -{ - return mst_orient_normals (points, k, CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - - } //namespace CGAL #include diff --git a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h index 5979f11086e..8447ae952ff 100644 --- a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include @@ -148,13 +148,13 @@ pca_estimate_normal(const typename NeighborQuery::Kernel::Point_3& query, ///< p */ template void pca_estimate_normals( PointRange& points, unsigned int k, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -162,17 +162,16 @@ pca_estimate_normals( CGAL_TRACE_STREAM << "Calls pca_estimate_normals()\n"; // basic geometric types - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetNormalMap::type NormalMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Point_map PointMap; + typedef typename NP_helper::Normal_map NormalMap; + typedef typename NP_helper::Geom_traits Kernel; typedef typename Kernel::FT FT; - CGAL_static_assertion_msg(!(boost::is_same::NoMap>::value), - "Error: no normal map"); + CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - NormalMap normal_map = choose_parameter(get_parameter(np, internal_np::normal_map)); + PointMap point_map = NP_helper::get_point_map(points, np); + NormalMap normal_map = NP_helper::get_normal_map(points, np); FT neighbor_radius = choose_parameter(get_parameter(np, internal_np::neighbor_radius), FT(0)); const std::function& callback = choose_parameter(get_parameter(np, internal_np::callback), std::function()); @@ -230,22 +229,6 @@ pca_estimate_normals( CGAL_TRACE_STREAM << "End of pca_estimate_normals()\n"; } -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -void -pca_estimate_normals( - PointRange& points, - unsigned int k) ///< number of neighbors. -{ - return pca_estimate_normals - (points, k, CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - - } //namespace CGAL #include diff --git a/Point_set_processing_3/include/CGAL/pointmatcher/compute_registration_transformation.h b/Point_set_processing_3/include/CGAL/pointmatcher/compute_registration_transformation.h index 066d233cede..56f70239750 100644 --- a/Point_set_processing_3/include/CGAL/pointmatcher/compute_registration_transformation.h +++ b/Point_set_processing_3/include/CGAL/pointmatcher/compute_registration_transformation.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -583,35 +583,37 @@ compute_registration_transformation(const PointRange1& range1, const PointRange2 converge is written to `std::cerr` if the registration cannot converge. */ template + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters> #ifdef DOXYGEN_RUNNING std::pair #else -std::pair - ::Kernel::Aff_transformation_3, bool> +std::pair + ::Geom_traits::Aff_transformation_3, bool> #endif compute_registration_transformation (const PointRange1& point_set_1, const PointRange2& point_set_2, - const NamedParameters1& np1, const NamedParameters2& np2) + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; - namespace PSP = CGAL::Point_set_processing_3; - // basic types - typedef typename PSP::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper1; + typedef Point_set_processing_3_np_helper NP_helper2; + typedef typename NP_helper1::Geom_traits Kernel; typedef typename Kernel::FT Scalar; typedef typename Kernel::Aff_transformation_3 Transformation; // property map types - typedef typename CGAL::GetPointMap::type PointMap1; - typedef typename CGAL::GetPointMap::type PointMap2; + typedef typename NP_helper1::Const_point_map PointMap1; + typedef typename NP_helper2::Const_point_map PointMap2; CGAL_static_assertion_msg((boost::is_same< typename boost::property_traits::value_type, typename boost::property_traits::value_type> ::value), "The point type of input ranges must be the same"); - typedef typename PSP::GetNormalMap::type NormalMap1; - typedef typename PSP::GetNormalMap::type NormalMap2; + typedef typename NP_helper1::Normal_map NormalMap1; + typedef typename NP_helper2::Normal_map NormalMap2; CGAL_static_assertion_msg((boost::is_same< typename boost::property_traits::value_type, typename boost::property_traits::value_type> ::value), "The vector type of input ranges must be the same"); @@ -622,11 +624,11 @@ compute_registration_transformation (const PointRange1& point_set_1, const Point typedef typename CGAL::Constant_property_map DefaultWeightMap1; typedef typename CGAL::Constant_property_map DefaultWeightMap2; - PointMap1 point_map1 = choose_parameter(get_parameter(np1, internal_np::point_map), PointMap1()); - NormalMap1 normal_map1 = choose_parameter(get_parameter(np1, internal_np::normal_map), NormalMap1()); + PointMap1 point_map1 = NP_helper1::get_const_point_map(point_set_1, np1); + NormalMap1 normal_map1 = NP_helper1::get_normal_map(point_set_1, np1); auto weight_map1 = choose_parameter(get_parameter(np1, internal_np::scalar_map), DefaultWeightMap1(Scalar(1))); - PointMap2 point_map2 = choose_parameter(get_parameter(np2, internal_np::point_map), PointMap2()); - NormalMap2 normal_map2 = choose_parameter(get_parameter(np2, internal_np::normal_map), NormalMap2()); + PointMap2 point_map2 = NP_helper2::get_const_point_map(point_set_2, np2); + NormalMap2 normal_map2 = NP_helper2::get_normal_map(point_set_2, np2); auto weight_map2 = choose_parameter(get_parameter(np2, internal_np::scalar_map), DefaultWeightMap2(Scalar(1))); CGAL_static_assertion_msg((boost::is_same< typename boost::property_traits::value_type, @@ -645,31 +647,6 @@ compute_registration_transformation (const PointRange1& point_set_1, const Point internal::construct_icp(np1, np2)); } -// convenience overloads -template -std::pair - ::Kernel::Aff_transformation_3, bool> -compute_registration_transformation(const PointRange1& point_set_1, const PointRange2& point_set_2, - const NamedParameters1& np1) -{ - namespace params = CGAL::Point_set_processing_3::parameters; - return compute_registration_transformation(point_set_1, point_set_2, np1, params::all_default(point_set_1)); -} - -template -std::pair > - ::Kernel::Aff_transformation_3, bool> -compute_registration_transformation(const PointRange1& point_set_1, const PointRange2& point_set_2) -{ - namespace params = CGAL::Point_set_processing_3::parameters; - return compute_registration_transformation(point_set_1, point_set_2, - params::all_default(point_set_1), - params::all_default(point_set_2)); -} - - } } // end of namespace CGAL::pointmatcher #endif // CGAL_LINKED_WITH_POINTMATCHER diff --git a/Point_set_processing_3/include/CGAL/pointmatcher/register_point_sets.h b/Point_set_processing_3/include/CGAL/pointmatcher/register_point_sets.h index a9bfe6a75bb..a20733c1ea5 100644 --- a/Point_set_processing_3/include/CGAL/pointmatcher/register_point_sets.h +++ b/Point_set_processing_3/include/CGAL/pointmatcher/register_point_sets.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -225,24 +225,23 @@ namespace pointmatcher { failed to converge is written to `std::cerr` if the registration cannot converge. */ template + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters> bool register_point_sets (const PointRange1& point_set_1, PointRange2& point_set_2, - const NamedParameters1& np1, const NamedParameters2& np2) + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values()) { - using parameters::choose_parameter; - using parameters::get_parameter; - - namespace PSP = CGAL::Point_set_processing_3; - typedef typename PSP::GetK::Kernel Kernel; + typedef typename Point_set_processing_3_np_helper::Geom_traits Kernel; // compute registration transformation std::pair res = compute_registration_transformation(point_set_1, point_set_2, np1, np2); // property map type of point_set_2 - typedef typename CGAL::GetPointMap::type PointMap2; - PointMap2 point_map2 = choose_parameter(get_parameter(np2, internal_np::point_map), PointMap2()); + typedef Point_set_processing_3_np_helper NP_helper2; + typedef typename NP_helper2::Const_point_map PointMap2; + PointMap2 point_map2 = NP_helper2::get_const_point_map(point_set_2, np2); // update CGAL points for (typename PointRange2::iterator it=point_set_2.begin(), @@ -254,27 +253,6 @@ register_point_sets (const PointRange1& point_set_1, PointRange2& point_set_2, return res.second; } -// convenience overloads -template -bool -register_point_sets(const PointRange1& point_set_1, PointRange2& point_set_2, - const NamedParameters1& np1) -{ - namespace params = CGAL::Point_set_processing_3::parameters; - return register_point_sets(point_set_1, point_set_2, np1, params::all_default(point_set_1)); -} - -template -bool -register_point_sets(const PointRange1& point_set_1, PointRange2& point_set_2) -{ - namespace params = CGAL::Point_set_processing_3::parameters; - return register_point_sets(point_set_1, point_set_2, - params::all_default(point_set_1), - params::all_default(point_set_2)); -} - } } // end of namespace CGAL::pointmatcher #endif // CGAL_LINKED_WITH_POINTMATCHER diff --git a/Point_set_processing_3/include/CGAL/random_simplify_point_set.h b/Point_set_processing_3/include/CGAL/random_simplify_point_set.h index aa86e2ae1c3..50e71a2dc62 100644 --- a/Point_set_processing_3/include/CGAL/random_simplify_point_set.h +++ b/Point_set_processing_3/include/CGAL/random_simplify_point_set.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include diff --git a/Point_set_processing_3/include/CGAL/remove_outliers.h b/Point_set_processing_3/include/CGAL/remove_outliers.h index aac07b43296..2b28e1e4c7b 100644 --- a/Point_set_processing_3/include/CGAL/remove_outliers.h +++ b/Point_set_processing_3/include/CGAL/remove_outliers.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -170,22 +170,23 @@ compute_avg_knn_sq_distance_3( */ template typename PointRange::iterator remove_outliers( PointRange& points, unsigned int k, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; // geometric types - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Point_map PointMap; + typedef typename NP_helper::Geom_traits Kernel; - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); + PointMap point_map = NP_helper::get_point_map(points, np); typename Kernel::FT neighbor_radius = choose_parameter(get_parameter(np, internal_np::neighbor_radius), typename Kernel::FT(0)); double threshold_percent = choose_parameter(get_parameter(np, internal_np::threshold_percent), 10.); @@ -286,19 +287,6 @@ remove_outliers( return out; } -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -typename PointRange::iterator -remove_outliers( - PointRange& points, - unsigned int k) ///< number of neighbors. -{ - return remove_outliers (points, k, CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - - } //namespace CGAL #include diff --git a/Point_set_processing_3/include/CGAL/scanline_orient_normals.h b/Point_set_processing_3/include/CGAL/scanline_orient_normals.h index 41cfbc15bfa..02f956f2416 100644 --- a/Point_set_processing_3/include/CGAL/scanline_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/scanline_orient_normals.h @@ -16,7 +16,7 @@ #include -#include +#include #include #include @@ -456,16 +456,17 @@ void orient_scanline (Iterator begin, Iterator end, \cgalParamNEnd \cgalNamedParamsEnd */ -template -void scanline_orient_normals (PointRange& points, const NamedParameters& np) +template +void scanline_orient_normals (PointRange& points, const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; using Iterator = typename PointRange::iterator; using Value_type = typename std::iterator_traits::value_type; - using PointMap = typename CGAL::GetPointMap::type; - using NormalMap = typename Point_set_processing_3::GetNormalMap::type; + using NP_helper = Point_set_processing_3_np_helper; + using PointMap = typename NP_helper::Point_map; + using NormalMap = typename NP_helper::Normal_map; using No_map = Constant_property_map; @@ -477,13 +478,10 @@ void scanline_orient_normals (PointRange& points, const NamedParameters& np) ::type; using Fallback_scanline_ID = Boolean_tag::value>; - CGAL_static_assertion_msg(!(std::is_same::NoMap>::value), - "Error: no normal map"); + CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - NormalMap normal_map = choose_parameter(get_parameter(np, internal_np::normal_map)); + PointMap point_map = NP_helper::get_point_map(points, np); + NormalMap normal_map = NP_helper::get_normal_map(points, np); ScanAngleMap scan_angle_map = choose_parameter (get_parameter(np, internal_np::scan_angle_map)); ScanlineIDMap scanline_id_map = choose_parameter @@ -550,13 +548,6 @@ void scanline_orient_normals (PointRange& points, const NamedParameters& np) #endif } -template -void scanline_orient_normals (PointRange& points) -{ - return scanline_orient_normals (points, - CGAL::Point_set_processing_3::parameters::all_default(points)); -} - } // namespace CGAL #endif // CGAL_EIGEN3_ENABLED diff --git a/Point_set_processing_3/include/CGAL/structure_point_set.h b/Point_set_processing_3/include/CGAL/structure_point_set.h index 8087981e786..00222956e44 100644 --- a/Point_set_processing_3/include/CGAL/structure_point_set.h +++ b/Point_set_processing_3/include/CGAL/structure_point_set.h @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include @@ -165,7 +165,7 @@ public: \param points input point range \param planes input plane range. \param epsilon size parameter. - \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below + \param np a sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below: \cgalNamedParamsBegin \cgalParamNBegin{point_map} @@ -185,7 +185,7 @@ public: \cgalParamDescription{a property map associating the index of a point in the input range to the index of plane (`-1` if the point is not assigned to a plane)} \cgalParamType{a class model of `ReadablePropertyMap` with `std::size_t` as key type and `int` as value type} - \cgalParamDefault{unused} + \cgalParamDefault{There is no default, this parameters is mandatory.} \cgalParamNEnd \cgalParamNBegin{plane_map} @@ -225,22 +225,21 @@ public: { using parameters::choose_parameter; using parameters::get_parameter; + using parameters::is_default_parameter; // basic geometric types - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetNormalMap::type NormalMap; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Const_point_map PointMap; + typedef typename NP_helper::Normal_map NormalMap; typedef typename Point_set_processing_3::GetPlaneMap::type PlaneMap; typedef typename Point_set_processing_3::GetPlaneIndexMap::type PlaneIndexMap; - CGAL_static_assertion_msg(!(boost::is_same::NoMap>::value), - "Error: no normal map"); - CGAL_static_assertion_msg(!(boost::is_same::NoMap>::value), + CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_static_assertion_msg((!is_default_parameter()), "Error: no plane index map"); - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - NormalMap normal_map = choose_parameter(get_parameter(np, internal_np::normal_map)); + PointMap point_map = NP_helper::get_const_point_map(points, np); + NormalMap normal_map = NP_helper::get_normal_map(points, np); PlaneMap plane_map = choose_parameter(get_parameter(np, internal_np::plane_map)); PlaneIndexMap index_map = choose_parameter(get_parameter(np, internal_np::plane_index_map)); double attraction_factor = choose_parameter(get_parameter(np, internal_np::attraction_factor), 3.); @@ -1505,7 +1504,7 @@ private: \param planes input plane range. \param output output iterator where output points are written \param epsilon size parameter. - \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below + \param np a sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below \cgalNamedParamsBegin \cgalParamNBegin{point_map} @@ -1525,8 +1524,7 @@ private: \cgalParamDescription{a property map associating the index of a point in the input range to the index of plane (`-1` if the point is not assigned to a plane)} \cgalParamType{a class model of `ReadablePropertyMap` with `std::size_t` as key type and `int` as value type} - \cgalParamDefault{unused} - \cgalParamNEnd + \cgalParamDefault{There is no default, this parameters is mandatory.} \cgalParamNBegin{plane_map} \cgalParamDescription{a property map containing the planes associated to the elements of the plane range `planes`} @@ -1564,7 +1562,8 @@ structure_point_set (const PointRange& points, using parameters::choose_parameter; using parameters::get_parameter; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Geom_traits Kernel; Point_set_with_structure pss (points, planes, epsilon, np); @@ -1574,24 +1573,6 @@ structure_point_set (const PointRange& points, return output; } -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -OutputIterator -structure_point_set (const PointRange& points, ///< range of points. - const PlaneRange& planes, ///< range of planes. - OutputIterator output, ///< output iterator where output points are written. - double epsilon) ///< size parameter. -{ - return structure_point_set - (points, planes, output, epsilon, - CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - - } //namespace CGAL #include diff --git a/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h b/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h index c4ba372f492..5b69f3ef0f9 100644 --- a/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include @@ -257,23 +257,24 @@ vcm_convolve (ForwardIterator first, */ template + typename NamedParameters = parameters::Default_named_parameters> void compute_vcm (const PointRange& points, std::vector< std::array > &ccov, double offset_radius, double convolution_radius, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; // basic geometric types - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Const_point_map PointMap; + typedef typename NP_helper::Geom_traits Kernel; - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - Kernel kernel; + PointMap point_map = NP_helper::get_const_point_map(points, np); + Kernel kernel = NP_helper::get_geom_traits(points, np); // First, compute the VCM for each point std::vector< std::array > cov; @@ -298,21 +299,6 @@ compute_vcm (const PointRange& points, } } -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -void -compute_vcm (const PointRange& points, - std::vector< std::array > &ccov, - double offset_radius, - double convolution_radius) -{ - compute_vcm (points, ccov, offset_radius, convolution_radius, - CGAL::Point_set_processing_3::parameters::all_default (points)); -} - -/// \endcond - /// \cond SKIP_IN_MANUAL template ::type PointMap; - typedef typename Point_set_processing_3::GetNormalMap::type NormalMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Point_map PointMap; + typedef typename NP_helper::Normal_map NormalMap; + typedef typename NP_helper::Geom_traits Kernel; typedef typename GetDiagonalizeTraits::type DiagonalizeTraits; - CGAL_static_assertion_msg(!(boost::is_same::NoMap>::value), - "Error: no normal map"); + CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); - NormalMap normal_map = choose_parameter(get_parameter(np, internal_np::normal_map)); + PointMap point_map = NP_helper::get_point_map(points, np); + NormalMap normal_map = NP_helper::get_normal_map(points, np); typedef std::array Covariance; @@ -439,34 +424,18 @@ vcm_estimate_normals_internal (PointRange& points, \cgalNamedParamsEnd */ template void vcm_estimate_normals (PointRange& points, double offset_radius, double convolution_radius, - const NamedParameters& np + const NamedParameters& np = parameters::default_values() ) { vcm_estimate_normals_internal(points, offset_radius, convolution_radius, np); } -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -void -vcm_estimate_normals (PointRange& points, - double offset_radius, ///< offset radius. - double convolution_radius) ///< convolution radius. -{ - return vcm_estimate_normals - (points, offset_radius, convolution_radius, - CGAL::Point_set_processing_3::parameters::all_default(points)); -} - -/// \endcond - - /** \ingroup PkgPointSetProcessing3Algorithms Estimates normal directions of the range of `points` @@ -514,34 +483,18 @@ vcm_estimate_normals (PointRange& points, \cgalNamedParamsEnd */ template < typename PointRange, - typename NamedParameters + typename NamedParameters = parameters::Default_named_parameters > void vcm_estimate_normals (PointRange& points, double offset_radius, unsigned int k, - const NamedParameters& np + const NamedParameters& np = parameters::default_values() ) { vcm_estimate_normals_internal(points, offset_radius, 0, np, k); } -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -void -vcm_estimate_normals (PointRange& points, - double offset_radius, ///< offset radius. - unsigned int k) -{ - return vcm_estimate_normals - (points, offset_radius, k, - CGAL::Point_set_processing_3::parameters::all_default(points)); -} - - -/// \endcond - } // namespace CGAL #include diff --git a/Point_set_processing_3/include/CGAL/wlop_simplify_and_regularize_point_set.h b/Point_set_processing_3/include/CGAL/wlop_simplify_and_regularize_point_set.h index c791eaff5ff..7e4b86cdebe 100644 --- a/Point_set_processing_3/include/CGAL/wlop_simplify_and_regularize_point_set.h +++ b/Point_set_processing_3/include/CGAL/wlop_simplify_and_regularize_point_set.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -429,22 +429,23 @@ compute_density_weight_for_sample_point( template + typename NamedParameters = parameters::Default_named_parameters> OutputIterator wlop_simplify_and_regularize_point_set( PointRange& points, OutputIterator output, - const NamedParameters& np + const NamedParameters& np = parameters::default_values() ) { using parameters::choose_parameter; using parameters::get_parameter; // basic geometric types - typedef typename CGAL::GetPointMap::type PointMap; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef CGAL::Point_set_processing_3_np_helper NP_helper; + typedef typename NP_helper::Point_map PointMap; + typedef typename NP_helper::Geom_traits Kernel; - PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); + PointMap point_map = NP_helper::get_point_map(points, np); double select_percentage = choose_parameter(get_parameter(np, internal_np::select_percentage), 5.); double radius = choose_parameter(get_parameter(np, internal_np::neighbor_radius), -1); unsigned int iter_number = choose_parameter(get_parameter(np, internal_np::number_of_iterations), 35); @@ -612,22 +613,6 @@ wlop_simplify_and_regularize_point_set( return output; } - -/// \cond SKIP_IN_MANUAL -// variant with default NP -template -OutputIterator -wlop_simplify_and_regularize_point_set( - PointRange& points, - OutputIterator output) ///< output iterator where output points are put. -{ - return wlop_simplify_and_regularize_point_set - (points, output, CGAL::Point_set_processing_3::parameters::all_default(points)); -} -/// \endcond - } //namespace CGAL #include diff --git a/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp b/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp index 218f4f42b63..35c6e5b0e6f 100644 --- a/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp +++ b/Point_set_processing_3/test/Point_set_processing_3/test_deprecated_io_point_set.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point_3; @@ -24,7 +24,8 @@ typedef std::array Color; typedef std::pair PointWithColor; typedef CGAL::Nth_of_tuple_property_map<1, PointWithColor> Color_map; -struct GetRedMap{ +struct GetRedMap +{ typedef PointWithColor key_type; typedef unsigned short value_type; typedef const value_type& reference; @@ -35,7 +36,8 @@ unsigned short get(const GetRedMap&, const PointWithColor& p) return p.second[0]; } -struct GetGreenMap{ +struct GetGreenMap +{ typedef PointWithColor key_type; typedef unsigned short value_type; typedef const value_type& reference; @@ -46,7 +48,8 @@ unsigned short get(const GetGreenMap&, const PointWithColor& p) return p.second[1]; } -struct GetBlueMap{ +struct GetBlueMap +{ typedef PointWithColor key_type; typedef unsigned short value_type; typedef const value_type& reference; @@ -57,12 +60,14 @@ unsigned short get(const GetBlueMap&, const PointWithColor& p) return p.second[2]; } -struct GetAlphaMap{ +struct GetAlphaMap +{ typedef PointWithColor key_type; typedef unsigned short value_type; typedef const value_type& reference; typedef boost::lvalue_property_map_tag category; }; + unsigned short get(const GetAlphaMap&, const PointWithColor& p) { return p.second[3]; @@ -70,157 +75,167 @@ unsigned short get(const GetAlphaMap&, const PointWithColor& p) int main() { + std::vector points(3); + points[0] = std::make_pair(Point_3(1,0,0), Color{255,0,0,255}); + points[1] = std::make_pair(Point_3(0,1,0), Color{0,255,0,255}); + points[2] = std::make_pair(Point_3(0,0,1), Color{0,0,255,255}); -std::vector points(3); -points[0] = std::make_pair(Point_3(1,0,0), Color{255,0,0,255}); -points[1] = std::make_pair(Point_3(0,1,0), Color{0,255,0,255}); -points[2] = std::make_pair(Point_3(0,0,1), Color{0,0,255,255}); + bool ok; + std::vector ps; + ps.push_back(Point_3(1,0,0)); + ps.push_back(Point_3(0,1,0)); + ps.push_back(Point_3(0,0,1)); + std::string input; -bool ok; -std::vector ps; -ps.push_back(Point_3(1,0,0)); -ps.push_back(Point_3(0,1,0)); -ps.push_back(Point_3(0,0,1)); - - -//LAS + //LAS #ifdef CGAL_LINKED_WITH_LASLIB - { - std::ofstream os("tmp1.las", std::ios::binary); - ok = CGAL::write_las_points_with_properties(os, points, - CGAL::make_las_point_writer(CGAL::First_of_pair_property_map()), - std::make_pair(GetRedMap(),CGAL::LAS_property::R()), - std::make_pair(GetGreenMap(), CGAL::LAS_property::G()), - std::make_pair(GetBlueMap(), CGAL::LAS_property::B()), - std::make_pair(GetAlphaMap(), CGAL::LAS_property::I()) - ); - assert(ok); + { + std::ostringstream os(std::ios::binary); + ok = CGAL::write_las_points_with_properties(os, points, + CGAL::make_las_point_writer(CGAL::First_of_pair_property_map()), + std::make_pair(GetRedMap(),CGAL::LAS_property::R()), + std::make_pair(GetGreenMap(), CGAL::LAS_property::G()), + std::make_pair(GetBlueMap(), CGAL::LAS_property::B()), + std::make_pair(GetAlphaMap(), CGAL::LAS_property::I()) + ); + assert(ok); + os.flush(); + input = os.str(); - } + } - { - points.clear(); - std::ifstream is("tmp1.las", std::ios::binary); - ok = CGAL::read_las_points_with_properties(is, std::back_inserter (points), - CGAL::make_las_point_reader(CGAL::First_of_pair_property_map()), - std::make_tuple(CGAL::Second_of_pair_property_map(), - CGAL::Construct_array(), - CGAL::LAS_property::R(), - CGAL::LAS_property::G(), - CGAL::LAS_property::B(), - CGAL::LAS_property::I())); - assert(ok); - assert(points.size() == 3); - assert(points[1].second[1] == 255); - } + { + points.clear(); + std::istringstream is(input, std::ios::binary); + ok = CGAL::read_las_points_with_properties(is, std::back_inserter (points), + CGAL::make_las_point_reader(CGAL::First_of_pair_property_map()), + std::make_tuple(CGAL::Second_of_pair_property_map(), + CGAL::Construct_array(), + CGAL::LAS_property::R(), + CGAL::LAS_property::G(), + CGAL::LAS_property::B(), + CGAL::LAS_property::I())); + assert(ok); + assert(points.size() == 3); + assert(points[1].second[1] == 255); + } - { - std::ofstream os("tmp2.las", std::ios_base::binary); - CGAL::write_las_points(os, ps, CGAL::parameters::all_default()); - assert(ok); - } + { + std::ostringstream os(std::ios_base::binary); + CGAL::write_las_points(os, ps); + assert(ok); + os.flush(); + input = os.str(); + } - { - ps.clear(); - std::ifstream is("tmp2.las", std::ios::binary); - ok = CGAL::read_las_points(is, std::back_inserter (ps),CGAL::parameters::all_default()); - assert(ok); - assert(ps.size() == 3); - } + { + ps.clear(); + std::istringstream is(input, std::ios::binary); + ok = CGAL::read_las_points(is, std::back_inserter (ps)); + assert(ok); + assert(ps.size() == 3); + } #endif + //PLY + { + std::ostringstream os; + assert(os.good()); + ok = CGAL::write_ply_points_with_properties(os, points, + CGAL::make_ply_point_writer (CGAL::First_of_pair_property_map()), + std::make_pair(GetRedMap(),CGAL::PLY_property("red")), + std::make_pair(GetGreenMap(), CGAL::PLY_property("green")), + std::make_pair(GetBlueMap(), CGAL::PLY_property("blue")), + std::make_pair(GetAlphaMap(), CGAL::PLY_property("alpha")) + ); + assert(! os.fail()); + assert(ok); + os.flush(); + input = os.str(); + } -//PLY - { - std::ofstream os("tmp1.ply"); - assert(os.good()); - ok = CGAL::write_ply_points_with_properties(os, points, - CGAL::make_ply_point_writer (CGAL::First_of_pair_property_map()), - std::make_pair(GetRedMap(),CGAL::PLY_property("red")), - std::make_pair(GetGreenMap(), CGAL::PLY_property("green")), - std::make_pair(GetBlueMap(), CGAL::PLY_property("blue")), - std::make_pair(GetAlphaMap(), CGAL::PLY_property("alpha")) - ); - assert(! os.fail()); - assert(ok); - } + { + std::istringstream is(input); + assert(is.good()); + points.clear(); + ok = CGAL::read_ply_points_with_properties(is, std::back_inserter (points), + CGAL::make_ply_point_reader(CGAL::First_of_pair_property_map()), + std::make_tuple(CGAL::Second_of_pair_property_map(), + CGAL::Construct_array(), + CGAL::PLY_property("red"), + CGAL::PLY_property("green"), + CGAL::PLY_property("blue"), + CGAL::PLY_property("alpha"))); + assert(! is.fail()); + assert(ok); + assert(points.size() == 3); + assert(points[1].second[1] == 255); + } - { - std::ifstream is("tmp1.ply"); - assert(is.good()); - points.clear(); - ok = CGAL::read_ply_points_with_properties(is, std::back_inserter (points), - CGAL::make_ply_point_reader(CGAL::First_of_pair_property_map()), - std::make_tuple(CGAL::Second_of_pair_property_map(), - CGAL::Construct_array(), - CGAL::PLY_property("red"), - CGAL::PLY_property("green"), - CGAL::PLY_property("blue"), - CGAL::PLY_property("alpha"))); - assert(! is.fail()); - assert(ok); - assert(points.size() == 3); - assert(points[1].second[1] == 255); - } + { + std::ostringstream os; + assert(os.good()); + ok = CGAL::write_ply_points(os, ps); + assert(! os.fail()); + assert(ok); + os.flush(); + input = os.str(); + } - { - std::ofstream os("tmp2.ply"); - assert(os.good()); - ok = CGAL::write_ply_points(os, ps, CGAL::parameters::all_default()); - assert(! os.fail()); - assert(ok); - } + { + std::istringstream is(input); + assert(is.good()); + ps.clear(); + ok = CGAL::read_ply_points(is, std::back_inserter (ps)); + assert(! is.fail()); + assert(ok); + assert(ps.size() == 3); + } - { - std::ifstream is("tmp2.ply"); - assert(is.good()); - ps.clear(); - ok = CGAL::read_ply_points(is, std::back_inserter (ps), - CGAL::parameters::all_default()); - assert(! is.fail()); - assert(ok); - assert(ps.size() == 3); - } + //OFF + { + std::ostringstream os; + assert(os.good()); + ok = CGAL::write_off_points(os, ps); + assert(! os.fail()); + assert(ok); + os.flush(); + input = os.str(); + } -//OFF - { - std::ofstream os("tmp.off"); - assert(os.good()); - ok = CGAL::write_off_points(os, ps, CGAL::parameters::all_default()); - assert(! os.fail()); - assert(ok); - } + { + std::istringstream is(input); + assert(is.good()); + ps.clear(); + ok = CGAL::read_off_points(is, std::back_inserter (ps)); + assert(! is.fail()); + assert(ok); + assert(ps.size() == 3); + } - { - std::ifstream is("tmp.off"); - assert(is.good()); - ps.clear(); - ok = CGAL::read_off_points(is, std::back_inserter (ps), - CGAL::parameters::all_default()); - assert(! is.fail()); - assert(ok); - assert(ps.size() == 3); - } + //XYZ + { + std::ostringstream os; + assert(os.good()); + ok = CGAL::write_xyz_points(os, ps); + assert(! os.fail()); + assert(ok); + os.flush(); + input = os.str(); + } -//XYZ - { - std::ofstream os("tmp.xyz"); - assert(os.good()); - ok = CGAL::write_xyz_points(os, ps, CGAL::parameters::all_default()); - assert(! os.fail()); - assert(ok); - } + { + std::istringstream is(input); + assert(is.good()); + ps.clear(); + ok = CGAL::read_xyz_points(is, std::back_inserter (ps)); + assert(! is.fail()); + assert(ok); + assert(ps.size() == 3); + } - { - std::ifstream is("tmp.xyz"); - assert(is.good()); - ps.clear(); - ok = CGAL::read_xyz_points(is, std::back_inserter (ps), - CGAL::parameters::all_default()); - assert(! is.fail()); - assert(ok); - assert(ps.size() == 3); - } + std::cout << "Done" << std::endl; + return EXIT_SUCCESS; } diff --git a/Point_set_processing_3/test/Point_set_processing_3/test_read_write_point_set.cpp b/Point_set_processing_3/test/Point_set_processing_3/test_read_write_point_set.cpp index 0dd90f9623d..abcbcf01747 100644 --- a/Point_set_processing_3/test/Point_set_processing_3/test_read_write_point_set.cpp +++ b/Point_set_processing_3/test/Point_set_processing_3/test_read_write_point_set.cpp @@ -79,6 +79,8 @@ bool points_are_equal(const std::vector& ps, bool test_points_with_np(std::string s) { + std::cout << "test_points_with_np(" << s << ")" << std::endl; + std::vector points; points.push_back(std::make_pair(Point_3(0,0,0), Vector_3(0,0,0))); points.push_back(std::make_pair(Point_3(1,0,0), Vector_3(1,0,0))); @@ -109,50 +111,50 @@ void test_##TYPE(const std::string& s) { \ std::cout << "Test Point_set_3: " << s << " extension: " << #TYPE << std::endl; \ CGAL::Point_set_3 ps; \ - bool ok = CGAL::IO::read_##TYPE(s, ps); \ + bool ok = CGAL::IO::read_##TYPE(s, ps); \ assert(ok); \ ps.clear(); \ - ok = CGAL::IO::read_##TYPE(s.c_str(), ps); \ + ok = CGAL::IO::read_##TYPE(s.c_str(), ps); \ assert(ok); \ ps.clear(); \ std::ifstream in(s); \ - ok = CGAL::IO::read_##TYPE(in, ps); \ + ok = CGAL::IO::read_##TYPE(in, ps); \ assert(ok); \ const char* ext = type; \ std::string fname = "tmp."; \ fname.append(ext); \ - ok = CGAL::IO::write_##TYPE(fname, ps); \ + ok = CGAL::IO::write_##TYPE(fname, ps); \ assert(ok); \ - ok = CGAL::IO::write_##TYPE(fname, ps, CGAL::parameters::stream_precision(10)); \ + ok = CGAL::IO::write_##TYPE(fname, ps, CGAL::parameters::stream_precision(10)); \ assert(ok); \ - ok = CGAL::IO::write_##TYPE(fname.c_str(), ps); \ + ok = CGAL::IO::write_##TYPE(fname.c_str(), ps); \ assert(ok); \ - ok = CGAL::IO::write_##TYPE(fname.c_str(), ps, CGAL::parameters::stream_precision(10)); \ + ok = CGAL::IO::write_##TYPE(fname.c_str(), ps, CGAL::parameters::stream_precision(10)); \ assert(ok); \ std::ofstream out(fname); \ - ok = CGAL::IO::write_##TYPE(out, ps); \ + ok = CGAL::IO::write_##TYPE(out, ps); \ assert(ok); \ std::ofstream out2(fname); \ - ok = CGAL::IO::write_##TYPE(out2, ps, CGAL::parameters::stream_precision(10)); \ + ok = CGAL::IO::write_##TYPE(out2, ps, CGAL::parameters::stream_precision(10)); \ assert(ok); \ CGAL::Point_set_3 ps2; \ std::ifstream is(fname); \ - ok = CGAL::IO::read_##TYPE(is, ps2); \ + ok = CGAL::IO::read_##TYPE(is, ps2); \ assert(ok); \ assert(ps_are_equal(ps, ps2)); \ - ok = CGAL::IO::write_point_set(fname, ps2); \ + ok = CGAL::IO::write_point_set(fname, ps2); \ assert(ok); \ - ok = CGAL::IO::write_point_set(fname, ps2, CGAL::parameters::stream_precision(10)); \ + ok = CGAL::IO::write_point_set(fname, ps2, CGAL::parameters::stream_precision(10)); \ assert(ok); \ - ok = CGAL::IO::write_point_set(fname.c_str(), ps2); \ + ok = CGAL::IO::write_point_set(fname.c_str(), ps2); \ assert(ok); \ - ok = CGAL::IO::write_point_set(fname.c_str(), ps2, CGAL::parameters::stream_precision(10)); \ + ok = CGAL::IO::write_point_set(fname.c_str(), ps2, CGAL::parameters::stream_precision(10)); \ assert(ok); \ ps2.clear(); \ - ok = CGAL::IO::read_point_set(fname, ps2); \ + ok = CGAL::IO::read_point_set(fname, ps2); \ assert(ok); \ assert(ps_are_equal(ps, ps2)); \ - } +} CGAL_DEF_TEST_POINT_SET_3_FUNCTION(XYZ, "xyz") CGAL_DEF_TEST_POINT_SET_3_FUNCTION(OFF, "off") @@ -212,44 +214,55 @@ void test_points_##TYPE(const std::string& s) { \ std::cout << "Test points: " << s << " extension: " << #TYPE << std::endl; \ std::vector ps; \ - bool ok = CGAL::IO::read_##TYPE(s, std::back_inserter(ps)); \ + std::cout << " Reading string..." << std::endl; \ + bool ok = CGAL::IO::read_##TYPE(s, std::back_inserter(ps)); \ assert(ok); \ ps.clear(); \ - ok = CGAL::IO::read_##TYPE(s.c_str(), std::back_inserter(ps)); \ + std::cout << " Reading const string..." << std::endl; \ + ok = CGAL::IO::read_##TYPE(s.c_str(), std::back_inserter(ps)); \ assert(ok); \ ps.clear(); \ + std::cout << " Reading stream..." << std::endl; \ std::ifstream in(s); \ - ok = CGAL::IO::read_##TYPE(in, std::back_inserter(ps)); \ + ok = CGAL::IO::read_##TYPE(in, std::back_inserter(ps)); \ assert(ok); \ const char* ext = type; \ std::string fname = "tmp."; \ fname.append(ext); \ - ok = CGAL::IO::write_##TYPE(fname, ps); \ + std::cout << " Writing string..." << fname << std::endl; \ + ok = CGAL::IO::write_##TYPE(fname, ps); \ assert(ok); \ - ok = CGAL::IO::write_##TYPE(fname, ps, CGAL::parameters::stream_precision(10)); \ + std::cout << " Writing string with NP..." << std::endl; \ + ok = CGAL::IO::write_##TYPE(fname, ps, CGAL::parameters::stream_precision(10)); \ assert(ok); \ - ok = CGAL::IO::write_##TYPE(fname.c_str(), ps); \ + std::cout << " Writing const string..." << std::endl; \ + ok = CGAL::IO::write_##TYPE(fname.c_str(), ps); \ assert(ok); \ - ok = CGAL::IO::write_##TYPE(fname.c_str(), ps, CGAL::parameters::stream_precision(10)); \ + std::cout << " Writing const string with NP..." << std::endl; \ + ok = CGAL::IO::write_##TYPE(fname.c_str(), ps, CGAL::parameters::stream_precision(10)); \ assert(ok); \ + std::cout << " Writing stream..." << std::endl; \ std::ofstream out(fname); \ - ok = CGAL::IO::write_##TYPE(out, ps); \ + ok = CGAL::IO::write_##TYPE(out, ps); \ assert(ok); \ + std::cout << " Writing stream with NP..." << std::endl; \ std::ofstream out2(fname); \ - ok = CGAL::IO::write_##TYPE(out2, ps, CGAL::parameters::stream_precision(10)); \ + ok = CGAL::IO::write_##TYPE(out2, ps, CGAL::parameters::stream_precision(10)); \ assert(ok); \ + std::cout << " Reading previous output..." << std::endl; \ std::vector ps2; \ std::ifstream is(fname); \ - ok = CGAL::IO::read_##TYPE(is, std::back_inserter(ps2)); \ + ok = CGAL::IO::read_##TYPE(is, std::back_inserter(ps2)); \ assert(ok); \ assert(points_are_equal(ps, ps2)); \ - ok = CGAL::IO::write_points(fname, ps2); \ + std::cout << " Last iteration... " << fname << std::endl; \ + ok = CGAL::IO::write_points(fname, ps2); \ assert(ok); \ ps2.clear(); \ - ok = CGAL::IO::read_points(fname, std::back_inserter(ps2)); \ + ok = CGAL::IO::read_points(fname, std::back_inserter(ps2)); \ assert(ok); \ assert(points_are_equal(ps, ps2)); \ - } +} CGAL_DEF_TEST_POINTS_FUNCTION(XYZ, "xyz") CGAL_DEF_TEST_POINTS_FUNCTION(OFF, "off") diff --git a/Poisson_surface_reconstruction_3/include/CGAL/poisson_surface_reconstruction.h b/Poisson_surface_reconstruction_3/include/CGAL/poisson_surface_reconstruction.h index 3a79d458803..d926f3d1172 100644 --- a/Poisson_surface_reconstruction_3/include/CGAL/poisson_surface_reconstruction.h +++ b/Poisson_surface_reconstruction_3/include/CGAL/poisson_surface_reconstruction.h @@ -40,7 +40,7 @@ namespace CGAL { This function relies mainly on the size parameter `spacing`. A reasonable solution is to use the average spacing of the input - point set (using `compute_average_spacing()` for example). Higher + point set (using `compute_average_spacing()` for example). Smaller values increase the precision of the output mesh at the cost of higher computation time. diff --git a/Polygon/doc/Polygon/Polygon.txt b/Polygon/doc/Polygon/Polygon.txt index 824b0d9fbb0..b21d57325e7 100644 --- a/Polygon/doc/Polygon/Polygon.txt +++ b/Polygon/doc/Polygon/Polygon.txt @@ -70,6 +70,16 @@ and 3D Linear Geometric %Kernel. \cgalExample{Polygon/projected_polygon.cpp} + +\subsection subsecPolygonIterate Iterating over Vertices and Edges + +The polygon class provides member functions such as `Polygon_2::vertices_begin()` and `Polygon_2::vertices_end()` to iterate over the +vertices. It additionally provides a member function `Polygon_2::vertices()` that returns a range, mainly to be used with modern +`for` loops. The same holds for edges and for the holes of the class `Polygon_with_holes_2`. + +\cgalExample{Polygon/ranges.cpp} + + \subsection subsecPolygonDraw Draw a Polygon A polygon can be visualized by calling the \link PkgDrawPolygon2 CGAL::draw

      () \endlink function as shown in the following example. This function opens a new window showing the given polygon. A call to this function is blocking, that is the program continues as soon as the user closes the window (a version exists for polygon with holes, cf. \link PkgDrawPolygonWithHoles2 CGAL::draw() \endlink). diff --git a/Polygon/doc/Polygon/examples.txt b/Polygon/doc/Polygon/examples.txt index d176af36d0a..3a608da09f4 100644 --- a/Polygon/doc/Polygon/examples.txt +++ b/Polygon/doc/Polygon/examples.txt @@ -1,5 +1,6 @@ /*! \example Polygon/Example.cpp +\example Polygon/ranges.cpp \example Polygon/polygon_algorithms.cpp \example Polygon/Polygon.cpp \example Polygon/projected_polygon.cpp diff --git a/Polygon/examples/Polygon/ranges.cpp b/Polygon/examples/Polygon/ranges.cpp new file mode 100644 index 00000000000..2eaf38a97bf --- /dev/null +++ b/Polygon/examples/Polygon/ranges.cpp @@ -0,0 +1,36 @@ +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Polygon_2 Polygon_2; +typedef K::Point_2 Point_2; +typedef K::Segment_2 Segment_2; + + +int main() +{ + // create a polygon and put some points in it + Polygon_2 p; + + p.push_back(Point_2(0,0)); + p.push_back(Point_2(4,0)); + p.push_back(Point_2(4,4)); + + + for(const Point_2& p : p.vertices()){ + std::cout << p << std::endl; + } + + // As the range is not light weight, we have to use a reference + const Polygon_2::Vertices& range = p.vertices(); + + for(auto it = range.begin(); it!= range.end(); ++it){ + std::cout << *it << std::endl; + } + + for(const Segment_2& e : p.edges()){ + std::cout << e << std::endl; + } + + return EXIT_SUCCESS; +} diff --git a/Polygon/include/CGAL/Polygon_2.h b/Polygon/include/CGAL/Polygon_2.h index 85c03cb74b5..987215691ac 100644 --- a/Polygon/include/CGAL/Polygon_2.h +++ b/Polygon/include/CGAL/Polygon_2.h @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -117,16 +118,25 @@ class Polygon_2 { /// vertex iterator type typedef typename Container::iterator Vertex_iterator; + /// a range type to iterate over the vertices + typedef Container Vertices; //typedef typename Container::const_iterator Vertex_const_iterator; ?? #ifdef DOXYGEN_RUNNING /// vertex circulator type typedef unspecified_type Vertex_circulator; - /// edge circulator type + + /// edge iterator type typedef unspecified_type Edge_const_iterator; + + /// a range type to iterate over the vertices + typedef unspecified_type Edges; + /// edge circular type typedef unspecified_type Edge_const_circulator; + + // #else typedef Vertex_const_circulator Vertex_circulator; typedef Polygon_2_edge_iterator Edge_const_iterator; @@ -135,6 +145,8 @@ class Polygon_2 { typedef Polygon_2_edge_iterator Vertex_pair_iterator; + + typedef Iterator_range Edges; #endif // DOXYGEN_RUNNING /// @} @@ -157,11 +169,8 @@ class Polygon_2 { template Polygon_2(InputIterator first, InputIterator last, Traits p_traits = Traits()) - : d_container(), traits(p_traits) - { - // Sun STL switches off member templates for binary backward compat. - std::copy(first, last, std::back_inserter(d_container)); - } + : d_container(first,last), traits(p_traits) + {} #ifndef DOXYGEN_RUNNING Polygon_2& operator=(const Polygon_2&)=default; @@ -265,22 +274,28 @@ class Polygon_2 { /// Returns a constant iterator that allows to traverse the /// vertices of the polygon. - Vertex_const_iterator vertices_begin() const + Vertex_iterator vertices_begin() const { return const_cast(*this).d_container.begin(); } /// Returns the corresponding past-the-end iterator. - Vertex_const_iterator vertices_end() const + Vertex_iterator vertices_end() const { return const_cast(*this).d_container.end(); } + /// returns the range of vertices. + const Vertices& vertices() const + { + return d_container; + } + // Vertex_const_circulator vertices_circulator() const // { return Vertex_const_circulator(&d_container, d_container.begin()); } - /// Returns a mutable circulator that allows to traverse the + /// Returns a constant circulator that allows to traverse the /// vertices of the polygon. - Vertex_const_circulator vertices_circulator() const + Vertex_circulator vertices_circulator() const { Polygon_2& self = const_cast(*this); - return Vertex_const_circulator(&self.d_container, + return Vertex_circulator(&self.d_container, self.d_container.begin()); } @@ -293,6 +308,12 @@ class Polygon_2 { Edge_const_iterator edges_end() const { return Edge_const_iterator(&d_container, d_container.end()); } + /// returns the range of edges. + Edges edges() const + { + return make_range(edges_begin(),edges_end()); + } + /// Returns a non-mutable circulator that allows to traverse the /// edges of the polygon. Edge_const_circulator edges_circulator() const @@ -383,7 +404,7 @@ class Polygon_2 { self.d_container.end(), traits); } - /// Returns topmost vertex of the polygon with the largest + /// Returns the topmost vertex of the polygon with the largest /// `y`-coordinate. Vertex_const_iterator top_vertex() const { diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Doxyfile.in b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Doxyfile.in index 6d2633d9143..4f0c8360bbf 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Doxyfile.in +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Doxyfile.in @@ -13,12 +13,6 @@ ALIASES += "cgalDescribePolylineType=A polyline is defined as a sequence of poin EXAMPLE_PATH += ${CGAL_Poisson_surface_reconstruction_3_EXAMPLE_DIR} -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = YES -EXPAND_AS_DEFINED = CGAL_PMP_NP_TEMPLATE_PARAMETERS \ - CGAL_PMP_NP_CLASS \ - CGAL_DEPRECATED - EXCLUDE = ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Polygon_mesh_processing/internal EXCLUDE_SYMBOLS += experimental 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 8757bba98d4..90c62b0fd66 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 @@ -185,6 +185,14 @@ Shape smoothing of the devil model, using the mean curvature flow with a time st constraining border vertices (located at the neck, where the mesh is open). \cgalFigureCaptionEnd + +\subsubsection Extrusion + +This package provides two functions to extrude a triangle mesh with boundaries. A first one extrudes by offsetting each vertex by a user provided vector. +A second one is more general: It takes two users provided functors which extrude "up" and "down". In both cases the boundaries are connected by a triangle strip. +Note that the extrusion may generate self intersecting surfaces. + + \subsection MeshingExamples Meshing Examples \subsubsection MeshingExample_1 Refine and Fair a Region on a Triangle Mesh @@ -218,6 +226,17 @@ Once this is done, remeshing is run on all the surface, with protection of const \cgalExample{Polygon_mesh_processing/isotropic_remeshing_example.cpp} + +\subsubsection ExtrusionExample Extrusion of a Triangle Mesh + +The following example extrudes in both directions by projecting points along the vertex normal. +In case the function `Bottom` was the identity this would have been a one-sided extrusion. + +\cgalExample{Polygon_mesh_processing/extrude.cpp} + + + + \section Coref_section Corefinement and Boolean Operations \subsection coref_def_subsec Definitions diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt index 496897e2349..1b053016791 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt @@ -1,5 +1,6 @@ /*! +\example Polygon_mesh_processing/extrude.cpp \example Polygon_mesh_processing/polyhedral_envelope.cpp \example Polygon_mesh_processing/polyhedral_envelope_of_triangle_soup.cpp \example Polygon_mesh_processing/polyhedral_envelope_mesh_containment.cpp diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index 03d04019afd..1a70c77eab4 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -54,6 +54,7 @@ if(TARGET CGAL::Eigen3_support) target_link_libraries(mesh_smoothing_example PUBLIC CGAL::Eigen3_support) endif() +create_single_source_cgal_program( "extrude.cpp" ) create_single_source_cgal_program( "polyhedral_envelope.cpp" ) create_single_source_cgal_program( "polyhedral_envelope_of_triangle_soup.cpp" ) create_single_source_cgal_program( "polyhedral_envelope_mesh_containment.cpp" ) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/connected_components_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/connected_components_example.cpp index ef100be277f..a5bfd86e560 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/connected_components_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/connected_components_example.cpp @@ -112,7 +112,7 @@ int main(int argc, char* argv[]) mesh.add_property_map("f:CC").first; std::size_t num = PMP::connected_components(mesh, fccmap, - PMP::parameters::edge_is_constrained_map(Constraint(mesh, bound))); + CGAL::parameters::edge_is_constrained_map(Constraint(mesh, bound))); std::cerr << "- The graph has " << num << " connected components (face connectivity)" << std::endl; typedef std::map Components_size; @@ -128,12 +128,12 @@ int main(int argc, char* argv[]) std::cerr << "- We keep only components which have at least 4 faces" << std::endl; PMP::keep_large_connected_components(mesh, 4, - PMP::parameters::edge_is_constrained_map(Constraint(mesh, bound))); + CGAL::parameters::edge_is_constrained_map(Constraint(mesh, bound))); std::cerr << "- We keep the two largest components" << std::endl; PMP::keep_largest_connected_components(mesh, 2, - PMP::parameters::edge_is_constrained_map(Constraint(mesh, bound))); + CGAL::parameters::edge_is_constrained_map(Constraint(mesh, bound))); return 0; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_consecutive_bool_op.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_consecutive_bool_op.cpp index 9ed4a28e4cb..418fb4605a5 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_consecutive_bool_op.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_consecutive_bool_op.cpp @@ -15,7 +15,7 @@ typedef boost::graph_traits::vertex_descriptor vertex_descriptor; typedef Mesh::Property_map Exact_point_map; namespace PMP = CGAL::Polygon_mesh_processing; -namespace params = PMP::parameters; +namespace params = CGAL::parameters; struct Exact_vertex_point_map { diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_difference_remeshed.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_difference_remeshed.cpp index ab216b4cdea..b679f7bf5ae 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_difference_remeshed.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_difference_remeshed.cpp @@ -18,7 +18,7 @@ typedef boost::graph_traits::edge_descriptor edge_descriptor; typedef boost::graph_traits::face_descriptor face_descriptor; namespace PMP = CGAL::Polygon_mesh_processing; -namespace params = PMP::parameters; +namespace params = CGAL::parameters; struct Vector_pmap_wrapper { @@ -56,8 +56,8 @@ int main(int argc, char* argv[]) PMP::corefine_and_compute_difference(mesh1, mesh2, mesh1, - params::all_default(), // default parameters for mesh1 - params::all_default(), // default parameters for mesh2 + params::default_values(), // default parameters for mesh1 + params::default_values(), // default parameters for mesh2 params::edge_is_constrained_map(is_constrained_map)); if (valid_difference) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_and_intersection.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_and_intersection.cpp index 557152b5635..8cf8216190c 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_and_intersection.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_and_intersection.cpp @@ -11,7 +11,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Surface_mesh Mesh; namespace PMP = CGAL::Polygon_mesh_processing; -namespace params = CGAL::Polygon_mesh_processing::parameters; +namespace params = CGAL::parameters; int main(int argc, char* argv[]) { @@ -36,13 +36,13 @@ int main(int argc, char* argv[]) PMP::corefine_and_compute_boolean_operations( mesh1, mesh2, output, - params::all_default(), // mesh1 named parameters - params::all_default(), // mesh2 named parameters + params::default_values(), // mesh1 named parameters + params::default_values(), // mesh2 named parameters std::make_tuple( params::vertex_point_map(get(boost::vertex_point, out_union)), // named parameters for out_union params::vertex_point_map(get(boost::vertex_point, out_intersection)), // named parameters for out_intersection - params::all_default(), // named parameters for mesh1-mesh2 not used - params::all_default() )// named parameters for mesh2-mesh1 not used) + params::default_values(), // named parameters for mesh1-mesh2 not used + params::default_values() )// named parameters for mesh2-mesh1 not used) ); if (res[PMP::Corefinement::UNION]) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_with_attributes.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_with_attributes.cpp index ef16a88b3d6..b88cdc39e83 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_with_attributes.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_with_attributes.cpp @@ -77,7 +77,7 @@ int main(int argc, char* argv[]) visitor.properties[&mesh2] = mesh2_id; visitor.properties[&out] = out_id; - bool valid_union = PMP::corefine_and_compute_union(mesh1, mesh2, out, PMP::parameters::visitor(visitor)); + bool valid_union = PMP::corefine_and_compute_union(mesh1, mesh2, out, CGAL::parameters::visitor(visitor)); for(Mesh::Face_index f : faces(mesh1)) assert( mesh1_id[f] == 1 ); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/detect_features_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/detect_features_example.cpp index 2ce2341c0b8..7d1a074b84e 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/detect_features_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/detect_features_example.cpp @@ -34,7 +34,7 @@ int main(int argc, char* argv[]) std::size_t number_of_patches = PMP::sharp_edges_segmentation(mesh, 90, eif, pid, - PMP::parameters::vertex_incident_patches_map(vip)); + CGAL::parameters::vertex_incident_patches_map(vip)); std::size_t nb_sharp_edges = 0; for(boost::graph_traits::edge_descriptor e : edges(mesh)) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/extrude.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/extrude.cpp new file mode 100644 index 00000000000..aa7c2bd40ea --- /dev/null +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/extrude.cpp @@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include + +#include +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef CGAL::Surface_mesh SM; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + +typedef Kernel::Vector_3 Vector; +typedef boost::property_map::type VPMap; +typedef SM::template Property_map VNMap; + +struct Bottom +{ + Bottom(VPMap pmap, VNMap nmap, double vlen) + : pmap(pmap), nmap(nmap), vlen(vlen) + {} + + + void operator()(const vertex_descriptor& vin, const vertex_descriptor vout) const + { + put(pmap, vout, get(pmap, vout) - vlen* get(nmap, vin)); + } + + VPMap pmap; + VNMap nmap; + double vlen; +}; + +struct Top +{ + Top(VPMap pmap, VNMap nmap, double vlen) + : pmap(pmap), nmap(nmap), vlen(vlen) + {} + + + void operator()(const vertex_descriptor& vin, const vertex_descriptor vout) const + { + put(pmap, vout, get(pmap, vout) + vlen* get(nmap, vin)); + } + + VPMap pmap; + VNMap nmap; + double vlen; +}; + +int main(int argc, char* argv[]) +{ + SM in, out; + + std::string filename = (argc > 1) ? std::string(argv[1]) : CGAL::data_file_path("meshes/cube-ouvert.off"); + double vlen = (argc > 2) ? std::stod(argv[2]) : 0.1; + + CGAL::IO::read_polygon_mesh(filename, in); + + VNMap vnormals = in.template add_property_map("v:normals", CGAL::NULL_VECTOR).first; + + CGAL::Polygon_mesh_processing::compute_vertex_normals(in, vnormals); + Bottom bottom(get(CGAL::vertex_point,out), vnormals, vlen); + Top top(get(CGAL::vertex_point,out), vnormals, vlen); + CGAL::Polygon_mesh_processing::extrude_mesh(in, out, bottom, top); + + + filename = filename.substr(filename.find_last_of("/") + 1, filename.length() - 1); + filename = filename.substr(0, filename.find_last_of(".")); + filename = filename + "_" + std::to_string(vlen) + ".off"; + CGAL::IO::write_polygon_mesh(filename, out, CGAL::parameters::stream_precision(17)); + return 0; +} diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_bounded_error_distance_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_bounded_error_distance_example.cpp index 9b246c672b4..44f1944be0b 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_bounded_error_distance_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_bounded_error_distance_example.cpp @@ -42,7 +42,7 @@ int main(int argc, char** argv) { const double target_edge_length = 0.05; PMP::isotropic_remeshing( mesh2.faces(), target_edge_length, mesh2, - PMP::parameters::edge_is_constrained_map(is_constrained_map)); + CGAL::parameters::edge_is_constrained_map(is_constrained_map)); std::cout << "* one-sided bounded-error Hausdorff distance: " << PMP::bounded_error_Hausdorff_distance(mesh1, mesh2, error_bound) << std::endl; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_distance_remeshing_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_distance_remeshing_example.cpp index 0ef14cfaf3f..6a0a945f3b3 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_distance_remeshing_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_distance_remeshing_example.cpp @@ -25,7 +25,7 @@ int main(int, char**) std::cout << "Approximated Hausdorff distance: " << CGAL::Polygon_mesh_processing::approximate_Hausdorff_distance - (tm1, tm2, PMP::parameters::number_of_points_per_area_unit(4000)) + (tm1, tm2, CGAL::parameters::number_of_points_per_area_unit(4000)) << std::endl; return 0; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example.cpp index a146b93fa50..5a5d0d16277 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example.cpp @@ -41,8 +41,8 @@ int main(int argc, char* argv[]) h, std::back_inserter(patch_facets), std::back_inserter(patch_vertices), - PMP::parameters::vertex_point_map(get(CGAL::vertex_point, poly)) - .geom_traits(Kernel()))); + CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, poly)) + .geom_traits(Kernel()))); std::cout << " Number of facets in constructed patch: " << patch_facets.size() << std::endl; std::cout << " Number of vertices in constructed patch: " << patch_vertices.size() << std::endl; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_LCC.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_LCC.cpp index 63af68d1eda..68d129febef 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_LCC.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_LCC.cpp @@ -43,8 +43,8 @@ int main(int argc, char* argv[]) h, std::back_inserter(patch_facets), std::back_inserter(patch_vertices), - PMP::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)) - .geom_traits(Kernel()))); + CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)) + .geom_traits(Kernel()))); std::cout << "* Number of facets in constructed patch: " << patch_facets.size() << std::endl; std::cout << " Number of vertices in constructed patch: " << patch_vertices.size() << std::endl; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_OM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_OM.cpp index 1ebd95c650d..cc8dd4d54f4 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_OM.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_OM.cpp @@ -10,6 +10,7 @@ #include #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; @@ -42,7 +43,7 @@ int main(int argc, char* argv[]) CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)) .geom_traits(Kernel()))); - CGAL_assertion(CGAL::is_valid_polygon_mesh(mesh)); + assert(CGAL::is_valid_polygon_mesh(mesh)); std::cout << "* FILL HOLE NUMBER " << ++nb_holes << std::endl; std::cout << " Number of facets in constructed patch: " << patch_facets.size() << std::endl; @@ -51,7 +52,7 @@ int main(int argc, char* argv[]) } } - CGAL_assertion(CGAL::is_valid_polygon_mesh(mesh)); + assert(CGAL::is_valid_polygon_mesh(mesh)); std::cout << std::endl; std::cout << nb_holes << " holes have been filled" << std::endl; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp index 9db3996b581..e957fe8842a 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) << " (" << num_faces(mesh) << " faces)..." << std::endl; PMP::isotropic_remeshing(faces(mesh), target_edge_length, mesh, - PMP::parameters::number_of_iterations(nb_iter) + CGAL::parameters::number_of_iterations(nb_iter) .protect_constraints(true)); //i.e. protect border, here std::cout << "Remeshing done." << std::endl; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_of_patch_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_of_patch_example.cpp index d5919a6848f..b73a2b4c416 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_of_patch_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_of_patch_example.cpp @@ -70,7 +70,7 @@ int main(int argc, char* argv[]) PMP::isotropic_remeshing(patch, target_edge_length, mesh, - PMP::parameters::number_of_iterations(nb_iter) + CGAL::parameters::number_of_iterations(nb_iter) .face_patch_map(selected) .protect_constraints(true)//i.e. protect border, here ); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/match_faces.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/match_faces.cpp index 48afef6c1d1..5589e638c3d 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/match_faces.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/match_faces.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_smoothing_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_smoothing_example.cpp index ddef9403a42..31049f606a0 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_smoothing_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_smoothing_example.cpp @@ -43,9 +43,9 @@ int main(int argc, char** argv) std::cout << "Smoothing mesh... (" << nb_iterations << " iterations)" << std::endl; // Smooth with both angle and area criteria + Delaunay flips - PMP::smooth_mesh(mesh, PMP::parameters::number_of_iterations(nb_iterations) - .use_safety_constraints(false) // authorize all moves - .edge_is_constrained_map(eif)); + PMP::smooth_mesh(mesh, CGAL::parameters::number_of_iterations(nb_iterations) + .use_safety_constraints(false) // authorize all moves + .edge_is_constrained_map(eif)); CGAL::IO::write_polygon_mesh("mesh_smoothed.off", mesh, CGAL::parameters::stream_precision(17)); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/shape_smoothing_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/shape_smoothing_example.cpp index 4308c558d7a..1e7f99e8461 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/shape_smoothing_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/shape_smoothing_example.cpp @@ -37,8 +37,8 @@ int main(int argc, char* argv[]) CGAL::Boolean_property_map > vcmap(constrained_vertices); std::cout << "Smoothing shape... (" << nb_iterations << " iterations)" << std::endl; - PMP::smooth_shape(mesh, time, PMP::parameters::number_of_iterations(nb_iterations) - .vertex_is_constrained_map(vcmap)); + PMP::smooth_shape(mesh, time, CGAL::parameters::number_of_iterations(nb_iterations) + .vertex_is_constrained_map(vcmap)); CGAL::IO::write_polygon_mesh("mesh_shape_smoothed.off", mesh, CGAL::parameters::stream_precision(17)); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_split_visitor_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_split_visitor_example.cpp index 293b3ed5fc3..70396e350d1 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_split_visitor_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_split_visitor_example.cpp @@ -4,9 +4,7 @@ #include #include -#include -#include - +#include #include #include @@ -19,7 +17,7 @@ typedef boost::graph_traits::face_descriptor face_descriptor; class Insert_iterator { - typedef boost::unordered_map Container; + typedef std::unordered_map Container; Container& container; public: @@ -44,7 +42,7 @@ public: struct Visitor { - typedef boost::unordered_map Container; + typedef std::unordered_map Container; Container& container; face_descriptor qfd; @@ -86,7 +84,7 @@ int main(int argc, char* argv[]) return 1; } - boost::unordered_map t2q; + std::unordered_map t2q; Surface_mesh copy; @@ -94,10 +92,10 @@ int main(int argc, char* argv[]) Visitor v(t2q); CGAL::Polygon_mesh_processing::triangulate_faces(copy, - CGAL::Polygon_mesh_processing::parameters::visitor(v)); + CGAL::parameters::visitor(v)); - for(boost::unordered_map::iterator it = t2q.begin(); it != t2q.end(); ++it){ + for(std::unordered_map::iterator it = t2q.begin(); it != t2q.end(); ++it){ std::cout << it->first << " " << it->second << std::endl; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_polyline_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_polyline_example.cpp index 204dd3e2ed5..5133aa1ffcc 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_polyline_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_polyline_example.cpp @@ -5,6 +5,7 @@ #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef Kernel::Point_3 Point; @@ -44,7 +45,7 @@ int main() std::vector patch_will_be_empty; CGAL::Polygon_mesh_processing::triangulate_hole_polyline(polyline_collinear, back_inserter(patch_will_be_empty)); - CGAL_assertion(patch_will_be_empty.empty()); + assert(patch_will_be_empty.empty()); return 0; } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h index 4fe8a9deaf0..7435f6fcc64 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -84,10 +84,10 @@ namespace IO { * * \sa \link PkgBGLIOFct `CGAL::IO::write_polygon_mesh()` \endlink */ -template +template bool read_polygon_mesh(const std::string& fname, PolygonMesh& g, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { namespace PMP = CGAL::Polygon_mesh_processing; @@ -125,21 +125,11 @@ bool read_polygon_mesh(const std::string& fname, return false; } - PMP::polygon_soup_to_polygon_mesh(points, faces, g, parameters::all_default(), np); + PMP::polygon_soup_to_polygon_mesh(points, faces, g, parameters::default_values(), np); return true; } -/// \cond SKIP_IN_MANUAL - -template -bool read_polygon_mesh(const std::string& fname, PolygonMesh& g) -{ - return CGAL::Polygon_mesh_processing::IO::read_polygon_mesh(fname, g, parameters::all_default()); -} - -/// \endcond - } // namespace IO } // namespace Polygon_mesh_processing } // namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/bbox.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/bbox.h index 2552c903e87..21a1cab9a62 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/bbox.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/bbox.h @@ -20,16 +20,9 @@ #include -#include +#include #include - -#ifdef DOXYGEN_RUNNING -#define CGAL_PMP_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_PMP_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { namespace Polygon_mesh_processing { @@ -64,18 +57,18 @@ namespace CGAL { * * @return a bounding box of `pmesh` */ - template + template CGAL::Bbox_3 bbox(const PolygonMesh& pmesh, - const CGAL_PMP_NP_CLASS& np) + const NamedParameters& np = parameters::default_values()) { - using parameters::choose_parameter; - using parameters::get_parameter; + using CGAL::parameters::choose_parameter; + using CGAL::parameters::get_parameter; - typename GetVertexPointMap::const_type + typename GetVertexPointMap::const_type vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(CGAL::vertex_point, pmesh)); - typedef typename GetGeomTraits::type GT; + typedef typename GetGeomTraits::type GT; GT gt = choose_parameter(get_parameter(np, internal_np::geom_traits)); typename GT::Construct_bbox_3 get_bbox = gt.construct_bbox_3_object(); @@ -120,10 +113,10 @@ namespace CGAL { * * @return a bounding box of `pmesh` */ - template + template CGAL::Bbox_3 vertex_bbox(typename boost::graph_traits::vertex_descriptor vd, const PolygonMesh& pmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -169,10 +162,10 @@ namespace CGAL { * * @return a bounding box of `pmesh` */ - template + template CGAL::Bbox_3 edge_bbox(typename boost::graph_traits::edge_descriptor ed, const PolygonMesh& pmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -221,10 +214,10 @@ namespace CGAL { * * @return a bounding box of `pmesh` */ - template + template CGAL::Bbox_3 face_bbox(typename boost::graph_traits::face_descriptor fd, const PolygonMesh& pmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -247,55 +240,6 @@ namespace CGAL { } return bb; } - - template - CGAL::Bbox_3 vertex_bbox(typename boost::graph_traits::vertex_descriptor vd, - const PolygonMesh& pmesh) - { - return vertex_bbox(vd, pmesh, - CGAL::Polygon_mesh_processing::parameters::all_default()); - } - template - CGAL::Bbox_3 edge_bbox(typename boost::graph_traits::edge_descriptor ed, - const PolygonMesh& pmesh) - { - return edge_bbox(ed, pmesh, - CGAL::Polygon_mesh_processing::parameters::all_default()); - } - template - CGAL::Bbox_3 face_bbox(typename boost::graph_traits::face_descriptor fd, - const PolygonMesh& pmesh) - { - return face_bbox(fd, pmesh, - CGAL::Polygon_mesh_processing::parameters::all_default()); - } - - template - CGAL::Bbox_3 bbox(const PolygonMesh& pmesh) - { - return bbox(pmesh, - CGAL::Polygon_mesh_processing::parameters::all_default()); - } - - // deprecated function - #ifndef CGAL_NO_DEPRECATED_CODE - /*! - * \ingroup PkgPolygonMeshProcessingRef - * \deprecated This function is deprecated since \cgal 4.10, `CGAL::Polygon_mesh_processing::bbox()` should be used instead. - */ - template - CGAL_DEPRECATED CGAL::Bbox_3 bbox_3(const PolygonMesh& pmesh, - const CGAL_PMP_NP_CLASS& np) - { - return bbox(pmesh, np); - } - - template - CGAL_DEPRECATED CGAL::Bbox_3 bbox_3(const PolygonMesh& pmesh) - { - return bbox(pmesh); - } - #endif // CGAL_NO_DEPRECATED_CODE } } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h index 6f8c0cb9081..4d23f1c86b2 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h @@ -18,13 +18,13 @@ #include #include #include -#include +#include #include #include #include -#include +#include #include namespace CGAL{ @@ -177,11 +177,11 @@ std::size_t border_size(typename boost::graph_traits::halfedge_desc template + , typename NamedParameters = parameters::Default_named_parameters> HalfedgeOutputIterator border_halfedges(const FaceRange& face_range , const PolygonMesh& pmesh , HalfedgeOutputIterator out - , const NamedParameters& np) + , const NamedParameters& np = parameters::default_values()) { if (face_range.empty()) return out; @@ -205,18 +205,6 @@ std::size_t border_size(typename boost::graph_traits::halfedge_desc return out; } - template - HalfedgeOutputIterator border_halfedges(const FaceRange& face_range - , const PolygonMesh& pmesh - , HalfedgeOutputIterator out) - { - return border_halfedges(face_range, pmesh, out, - CGAL::Polygon_mesh_processing::parameters::all_default()); - } - - // counts the number of connected components of the boundary of the mesh. // // @tparam PolygonMesh model of `HalfedgeGraph`. @@ -229,7 +217,7 @@ std::size_t border_size(typename boost::graph_traits::halfedge_desc typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; unsigned int border_counter = 0; - boost::unordered_set visited; + std::unordered_set visited; for(halfedge_descriptor h : halfedges(pmesh)){ if(visited.find(h)== visited.end()){ if(is_border(h,pmesh)){ @@ -262,7 +250,7 @@ std::size_t border_size(typename boost::graph_traits::halfedge_desc { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - boost::unordered_set hedge_handled; + std::unordered_set hedge_handled; for(halfedge_descriptor h : halfedges(pm)) { if(is_border(h, pm) && hedge_handled.insert(h).second) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h index e3adbbd72f1..2a793ba1e4c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h @@ -87,7 +87,7 @@ clip_to_bbox(const Plane_3& plane, }}; // description of faces of the bbox - constexpr std::array face_indices + static constexpr std::array face_indices { { 0, 1, 2, 3, 2, 1, 5, 6, 3, 2, 6, 7, @@ -95,7 +95,7 @@ clip_to_bbox(const Plane_3& plane, 4, 0, 3, 7, 6, 5, 4, 7 } }; - constexpr std::array edge_indices + static constexpr std::array edge_indices { { 0, 1, 2, 3, 1, 4, 5, 6, 2, 6, 7, 8, @@ -595,13 +595,13 @@ generic_clip_impl( * If `false` is returned `tm` and `clipper` are only corefined. */ template + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters> bool clip(TriangleMesh& tm, TriangleMesh& clipper, - const NamedParameters1& np_tm, - const NamedParameters2& np_c) + const NamedParameters1& np_tm = parameters::default_values(), + const NamedParameters2& np_c = parameters::default_values()) { if (parameters::choose_parameter(parameters::get_parameter(np_c, internal_np::do_not_modify), false)) { @@ -693,19 +693,21 @@ clip(TriangleMesh& tm, * If `false` is returned `tm` is only refined by the intersection with `plane`. */ template + class NamedParameters = parameters::Default_named_parameters> bool clip(TriangleMesh& tm, #ifdef DOXYGEN_RUNNING const Plane_3& plane, #else const typename GetGeomTraits::type::Plane_3& plane, #endif - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { - using parameters::get_parameter; - using parameters::choose_parameter; namespace PMP = CGAL::Polygon_mesh_processing; - namespace params = PMP::parameters; + namespace params = CGAL::parameters; + + using params::get_parameter; + using params::choose_parameter; + if(boost::begin(faces(tm))==boost::end(faces(tm))) return true; CGAL::Bbox_3 bbox = ::CGAL::Polygon_mesh_processing::bbox(tm); @@ -717,7 +719,7 @@ bool clip(TriangleMesh& tm, bbox=CGAL::Bbox_3(bbox.xmin()-xd, bbox.ymin()-yd, bbox.zmin()-zd, bbox.xmax()+xd, bbox.ymax()+yd, bbox.zmax()+zd); TriangleMesh clipper; - Oriented_side os = internal::clip_to_bbox(plane, bbox, clipper, parameters::all_default()); + Oriented_side os = internal::clip_to_bbox(plane, bbox, clipper, parameters::default_values()); switch(os) { case ON_NEGATIVE_SIDE: @@ -796,19 +798,20 @@ bool clip(TriangleMesh& tm, * If `false` is returned `tm` is only refined by the intersection with `iso_cuboid`. */ template + class NamedParameters = parameters::Default_named_parameters> bool clip(TriangleMesh& tm, #ifdef DOXYGEN_RUNNING const Iso_cuboid_3& iso_cuboid, #else const typename GetGeomTraits::type::Iso_cuboid_3& iso_cuboid, #endif - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { - using parameters::get_parameter; - using parameters::choose_parameter; namespace PMP = CGAL::Polygon_mesh_processing; - namespace params = PMP::parameters; + namespace params = CGAL::parameters; + + using params::get_parameter; + using params::choose_parameter; if(boost::begin(faces(tm))==boost::end(faces(tm))) return true; TriangleMesh clipper; @@ -876,12 +879,12 @@ bool clip(TriangleMesh& tm, * \cgalNamedParamsEnd */ template + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters> void split(TriangleMesh& tm, TriangleMesh& splitter, - const NamedParameters1& np_tm, - const NamedParameters2& np_s) + const NamedParameters1& np_tm = parameters::default_values(), + const NamedParameters2& np_s = parameters::default_values()) { namespace PMP = CGAL::Polygon_mesh_processing; @@ -964,19 +967,20 @@ void split(TriangleMesh& tm, * \cgalNamedParamsEnd */ template + class NamedParameters = parameters::Default_named_parameters> void split(TriangleMesh& tm, #ifdef DOXYGEN_RUNNING const Plane_3& plane, #else const typename GetGeomTraits::type::Plane_3& plane, #endif - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { - using parameters::get_parameter; - using parameters::choose_parameter; namespace PMP = CGAL::Polygon_mesh_processing; - namespace params = PMP::parameters; + namespace params = CGAL::parameters; + + using params::get_parameter; + using params::choose_parameter; // create a splitter mesh for the splitting plane using an internal CGAL function CGAL::Bbox_3 bbox = ::CGAL::Polygon_mesh_processing::bbox(tm, np); @@ -987,11 +991,10 @@ void split(TriangleMesh& tm, bbox.xmax()+xd, bbox.ymax()+yd, bbox.zmax()+zd); TriangleMesh splitter; - CGAL::Oriented_side os = PMP::internal::clip_to_bbox(plane, bbox, splitter, PMP::parameters::all_default()); + CGAL::Oriented_side os = PMP::internal::clip_to_bbox(plane, bbox, splitter, params::default_values()); if(os == CGAL::ON_ORIENTED_BOUNDARY) { - const bool do_not_modify = choose_parameter(get_parameter(np, internal_np::allow_self_intersections), false); return split(tm, splitter, np, params::do_not_modify(do_not_modify)); } @@ -1067,19 +1070,21 @@ void split(TriangleMesh& tm, * \cgalNamedParamsEnd */ template + class NamedParameters = parameters::Default_named_parameters> void split(TriangleMesh& tm, #ifdef DOXYGEN_RUNNING const Iso_cuboid_3& iso_cuboid, #else const typename GetGeomTraits::type::Iso_cuboid_3& iso_cuboid, #endif - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { - using parameters::get_parameter; - using parameters::choose_parameter; namespace PMP = CGAL::Polygon_mesh_processing; - namespace params = PMP::parameters; + namespace params = CGAL::parameters; + + using params::get_parameter; + using params::choose_parameter; + TriangleMesh splitter; make_hexahedron(iso_cuboid[0], iso_cuboid[1], iso_cuboid[2], iso_cuboid[3], @@ -1090,81 +1095,6 @@ void split(TriangleMesh& tm, return split(tm, splitter, np, params::do_not_modify(do_not_modify)); } -/// \cond SKIP_IN_MANUAL - -// convenience overloads -template -bool clip(TriangleMesh& tm, - const typename GetGeomTraits::type::Plane_3& plane) -{ - return clip(tm, plane, parameters::all_default()); -} - -// convenience overloads -template -bool clip(TriangleMesh& tm, - const typename GetGeomTraits::type::Iso_cuboid_3& iso_cuboid) -{ - return clip(tm, iso_cuboid, parameters::all_default()); -} - -// convenience overload -template -bool -clip(TriangleMesh& tm, - TriangleMesh& clipper, - const NamedParameters1& np_tm) -{ - return clip(tm, clipper, np_tm, parameters::all_default()); -} - -// convenience overload -template -bool -clip(TriangleMesh& tm, - TriangleMesh& clipper) -{ - return clip(tm, clipper, parameters::all_default()); -} - - -// convenience overload -template -void -split(TriangleMesh& tm, - TriangleMesh& splitter, - const NamedParameters1& np_tm) -{ - split(tm, splitter, np_tm, parameters::all_default()); -} - -// convenience overload -template -void -split(TriangleMesh& tm, - TriangleMesh& splitter) -{ - split(tm, splitter, parameters::all_default()); -} - -template -void split(TriangleMesh& tm, - const typename GetGeomTraits::type::Plane_3& plane) -{ - split(tm, plane, parameters::all_default()); -} - -template -void split(TriangleMesh& tm, - const typename GetGeomTraits::type::Iso_cuboid_3& iso_cuboid) -{ - split(tm, iso_cuboid, parameters::all_default()); -} - -/// \endcond - } } //end of namespace CGAL::Polygon_mesh_processing #endif // CGAL_POLYGON_MESH_PROCESSING_CLIP_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h index 0f5840f6667..4fabb08700f 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h @@ -16,7 +16,7 @@ #include -#include +#include #include #include @@ -156,7 +156,7 @@ void sum_normals(const PM& pmesh, * If the field type (`FT`) of the traits does not support the `sqrt()` operation, * the square root computation will be performed approximately. */ -template +template #ifdef DOXYGEN_RUNNING Vector_3 #else @@ -164,7 +164,7 @@ typename GetGeomTraits::type::Vector_3 #endif compute_face_normal(typename boost::graph_traits::face_descriptor f, const PolygonMesh& pmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -188,14 +188,6 @@ compute_face_normal(typename boost::graph_traits::face_descriptor f return normal; } -template -typename GetGeomTraits::type::Vector_3 -compute_face_normal(typename boost::graph_traits::face_descriptor f, - const PolygonMesh& pmesh) -{ - return compute_face_normal(f, pmesh, CGAL::parameters::all_default()); -} - /** * \ingroup PMP_normal_grp * computes the outward unit vector normal for all faces of the polygon mesh. @@ -230,10 +222,10 @@ compute_face_normal(typename boost::graph_traits::face_descriptor f * If the field type (`FT`) of the traits does not support the `sqrt()` operation, * the square root computation will be performed approximately. */ -template +template void compute_face_normals(const PolygonMesh& pmesh, Face_normal_map face_normals, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename GetGeomTraits::type Kernel; @@ -247,12 +239,6 @@ void compute_face_normals(const PolygonMesh& pmesh, } } -template -void compute_face_normals(const PolygonMesh& pmesh, Face_normal_map face_normals) -{ - compute_face_normals(pmesh, face_normals, CGAL::parameters::all_default()); -} - namespace internal { enum Vertex_normal_type { @@ -652,7 +638,7 @@ compute_vertex_normal_as_sum_of_weighted_normals(typename boost::graph_traits +template #ifdef DOXYGEN_RUNNING Vector_3 #else @@ -660,7 +646,7 @@ typename GetGeomTraits::type::Vector_3 #endif compute_vertex_normal(typename boost::graph_traits::vertex_descriptor v, const PolygonMesh& pmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::is_default_parameter; @@ -686,7 +672,7 @@ compute_vertex_normal(typename boost::graph_traits::vertex_descript Face_vector_map default_fvmap; Face_normal_map face_normals = choose_parameter(get_parameter(np, internal_np::face_normal), Default_map(default_fvmap)); - const bool must_compute_face_normals = is_default_parameter(get_parameter(np, internal_np::face_normal)); + const bool must_compute_face_normals = is_default_parameter(); #ifdef CGAL_PMP_COMPUTE_NORMAL_DEBUG_PP std::cout << "<----- compute vertex normal at " << get(vpmap, v) @@ -734,13 +720,6 @@ compute_vertex_normal(typename boost::graph_traits::vertex_descript return normal; } -template -typename GetGeomTraits::type::Vector_3 -compute_vertex_normal(typename boost::graph_traits::vertex_descriptor v, - const PolygonMesh& pmesh) -{ - return compute_vertex_normal(v, pmesh, CGAL::parameters::all_default()); -} /** * \ingroup PMP_normal_grp @@ -777,10 +756,10 @@ compute_vertex_normal(typename boost::graph_traits::vertex_descript * If the field type (`FT`) of the traits does not support the `sqrt()` operation, * the square root computation will be performed approximately. */ -template +template void compute_vertex_normals(const PolygonMesh& pmesh, VertexNormalMap vertex_normals, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::is_default_parameter; @@ -807,7 +786,7 @@ void compute_vertex_normals(const PolygonMesh& pmesh, Face_normal_dmap>::type Face_normal_map; Face_normal_map face_normals = choose_parameter(get_parameter(np, internal_np::face_normal), get(Face_normal_tag(), pmesh)); - const bool must_compute_face_normals = is_default_parameter(get_parameter(np, internal_np::face_normal)); + const bool must_compute_face_normals = is_default_parameter(); if(must_compute_face_normals) compute_face_normals(pmesh, face_normals, np); @@ -832,12 +811,6 @@ void compute_vertex_normals(const PolygonMesh& pmesh, } } -template -void compute_vertex_normals(const PolygonMesh& pmesh, VertexNormalMap vertex_normals) -{ - compute_vertex_normals(pmesh, vertex_normals, CGAL::parameters::all_default()); -} - /** * \ingroup PMP_normal_grp * computes the outward unit vector normal for all vertices and faces of the polygon mesh. @@ -879,23 +852,16 @@ void compute_vertex_normals(const PolygonMesh& pmesh, VertexNormalMap vertex_nor */ template + typename NamedParameters = parameters::Default_named_parameters> void compute_normals(const PolygonMesh& pmesh, VertexNormalMap vertex_normals, FaceNormalMap face_normals, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { compute_face_normals(pmesh, face_normals, np); compute_vertex_normals(pmesh, vertex_normals, np.face_normal_map(face_normals)); } -template -void compute_normals(const PolygonMesh& pmesh, - VertexNormalMap vertex_normals, - FaceNormalMap face_normals) -{ - compute_normals(pmesh, vertex_normals, face_normals, CGAL::parameters::all_default()); -} } // namespace Polygon_mesh_processing } // namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 581afe1978d..4cfd8557554 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include @@ -41,15 +41,9 @@ #include #include -#include +#include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_PMP_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_PMP_NP_CLASS NamedParameters -#endif - - namespace CGAL { namespace Polygon_mesh_processing{ namespace internal { @@ -123,13 +117,13 @@ namespace internal { */ template FaceOutputIterator connected_component(typename boost::graph_traits::face_descriptor seed_face , const PolygonMesh& pmesh , FaceOutputIterator out - , const NamedParameters& np) + , const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -166,16 +160,6 @@ connected_component(typename boost::graph_traits::face_descriptor s return out; } -template -OutputIterator -connected_component(typename boost::graph_traits::face_descriptor seed_face, - const PolygonMesh& pmesh, - OutputIterator out) -{ - return connected_component(seed_face, pmesh, out, - CGAL::Polygon_mesh_processing::parameters::all_default()); -} - /*! * \ingroup keep_connected_components_grp * computes for each face the index of the corresponding connected component. @@ -211,12 +195,12 @@ connected_component(typename boost::graph_traits::face_descriptor s template typename boost::property_traits::value_type connected_components(const PolygonMesh& pmesh, FaceComponentMap fcm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -269,22 +253,15 @@ connected_components(const PolygonMesh& pmesh, return i; } -template -typename boost::property_traits::value_type -connected_components(const PolygonMesh& pmesh, - FaceComponentMap fcm) -{ - return CGAL::Polygon_mesh_processing::connected_components(pmesh, fcm, CGAL::parameters::all_default()); -} template + , typename NamedParameters = parameters::Default_named_parameters> void keep_connected_components(PolygonMesh& pmesh , const ComponentRange& components_to_keep , const FaceComponentMap& fcm - , const NamedParameters& np); + , const NamedParameters& np = parameters::default_values()); namespace internal { @@ -321,9 +298,9 @@ namespace internal { // * // */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> std::size_t number_of_connected_components(const PolygonMesh& pmesh, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { typedef typename boost::graph_traits::faces_size_type faces_size_type; typedef CGAL::dynamic_face_property_t Face_property_tag; @@ -334,12 +311,6 @@ std::size_t number_of_connected_components(const PolygonMesh& pmesh, return CGAL::Polygon_mesh_processing::connected_components(pmesh, patch_ids_map, np); } -template -std::size_t number_of_connected_components(const PolygonMesh& pmesh) -{ - return internal::number_of_connected_components(pmesh, CGAL::parameters::all_default()); -} - } // end namespace internal /*! @@ -406,10 +377,10 @@ std::size_t number_of_connected_components(const PolygonMesh& pmesh) * \return the number of connected components removed (ignoring isolated vertices). */ template + typename NamedParameters = parameters::Default_named_parameters> std::size_t keep_largest_connected_components(PolygonMesh& pmesh, std::size_t nb_components_to_keep, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef PolygonMesh PM; typedef typename boost::graph_traits::face_descriptor face_descriptor; @@ -486,15 +457,6 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, return num - nb_components_to_keep; } -template -std::size_t keep_largest_connected_components(PolygonMesh& pmesh, - std::size_t nb_components_to_keep) -{ - return keep_largest_connected_components(pmesh, - nb_components_to_keep, - CGAL::Polygon_mesh_processing::parameters::all_default()); -} - /*! * \ingroup keep_connected_components_grp * removes connected components whose size is (strictly) smaller than a given threshold value, @@ -562,10 +524,10 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, */ template + typename NamedParameters = parameters::Default_named_parameters> std::size_t keep_large_connected_components(PolygonMesh& pmesh, const ThresholdValueType threshold_value, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef PolygonMesh PM; typedef typename boost::graph_traits::face_descriptor face_descriptor; @@ -633,25 +595,17 @@ std::size_t keep_large_connected_components(PolygonMesh& pmesh, return num - res; } -template -std::size_t keep_large_connected_components(PolygonMesh& pmesh, - std::size_t threshold_components_to_keep) -{ - return keep_large_connected_components(pmesh, - threshold_components_to_keep, - CGAL::Polygon_mesh_processing::parameters::all_default()); -} template + , typename CGAL_NP_TEMPLATE_PARAMETERS> void keep_or_remove_connected_components(PolygonMesh& pmesh , const ComponentRange& components_to_keep , const FaceComponentMap& fcm , bool keep - , const NamedParameters& np) + , const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -662,7 +616,7 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::edge_descriptor edge_descriptor; - typedef typename GetInitializedVertexIndexMap::type VertexIndexMap; + typedef typename GetInitializedVertexIndexMap::type VertexIndexMap; VertexIndexMap vim = get_initialized_vertex_index_map(pmesh, np); std::set cc_to_keep; @@ -766,13 +720,13 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh for(vertex_descriptor v: vertices(pmesh)) if (!keep_vertex[v]) vertices_to_remove.push_back(v); - if ( is_default_parameter(get_parameter(np, internal_np::vertex_is_constrained)) ) + if ( is_default_parameter() ) for (vertex_descriptor v : vertices_to_remove) remove_vertex(v, pmesh); else { typedef typename internal_np::Lookup_named_param_def // default (not used) >::type Vertex_map; Vertex_map is_cst = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), @@ -864,11 +818,11 @@ void keep_connected_components(PolygonMesh& pmesh template + , typename NamedParameters = parameters::Default_named_parameters> void remove_connected_components(PolygonMesh& pmesh , const ComponentRange& components_to_remove , const FaceComponentMap& fcm - , const NamedParameters& np) + , const NamedParameters& np = parameters::default_values()) { if (components_to_remove.empty()) return; keep_or_remove_connected_components(pmesh, components_to_remove, fcm, false, np); @@ -917,10 +871,10 @@ void remove_connected_components(PolygonMesh& pmesh */ template + , typename CGAL_NP_TEMPLATE_PARAMETERS> void remove_connected_components(PolygonMesh& pmesh , const FaceRange& components_to_remove - , const CGAL_PMP_NP_CLASS& np) + , const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -931,7 +885,7 @@ void remove_connected_components(PolygonMesh& pmesh typedef PolygonMesh PM; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap; + typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap; FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np); boost::vector_property_map face_cc(static_cast(num_faces(pmesh)), fim); @@ -987,10 +941,10 @@ void remove_connected_components(PolygonMesh& pmesh */ template + , typename CGAL_NP_TEMPLATE_PARAMETERS> void keep_connected_components(PolygonMesh& pmesh , const FaceRange& components_to_keep - , const CGAL_PMP_NP_CLASS& np) + , const CGAL_NP_CLASS& np = parameters::default_values()) { typedef PolygonMesh PM; typedef typename boost::graph_traits::face_descriptor face_descriptor; @@ -998,7 +952,7 @@ void keep_connected_components(PolygonMesh& pmesh using parameters::choose_parameter; using parameters::get_parameter; - typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap; + typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap; FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np); boost::vector_property_map face_cc(static_cast(num_faces(pmesh)), fim); @@ -1011,45 +965,6 @@ void keep_connected_components(PolygonMesh& pmesh keep_connected_components(pmesh, cc_to_keep, face_cc, np); } -// non-documented overloads so that named parameters can be omitted - -template -void remove_connected_components(PolygonMesh& pmesh - , const FaceRange& components_to_remove) -{ - remove_connected_components(pmesh, components_to_remove, - CGAL::Polygon_mesh_processing::parameters::all_default()); -} - -template -void keep_connected_components(PolygonMesh& pmesh - , const ComponentRange& components_to_keep - , const FaceComponentMap& fcm) -{ - keep_connected_components(pmesh, components_to_keep, fcm, - CGAL::Polygon_mesh_processing::parameters::all_default()); -} - -template -void remove_connected_components(PolygonMesh& pmesh - , const ComponentRange& components_to_remove - , const FaceComponentMap& fcm ) -{ - remove_connected_components(pmesh, components_to_remove, fcm, - CGAL::Polygon_mesh_processing::parameters::all_default()); -} - -template -void keep_connected_components(PolygonMesh& pmesh - , const FaceRange& components_to_keep) -{ - keep_connected_components(pmesh, components_to_keep, - CGAL::Polygon_mesh_processing::parameters::all_default()); -} namespace internal { @@ -1080,7 +995,7 @@ void split_connected_components_impl(FIMap fim, get(CGAL::dynamic_face_property_t(), tm)); faces_size_type nb_patches = 0; - if(is_default_parameter(get_parameter(np, internal_np::face_patch))) + if(is_default_parameter()) { nb_patches = CGAL::Polygon_mesh_processing::connected_components( tm, pidmap, CGAL::parameters::face_index_map(fim) @@ -1166,10 +1081,10 @@ void split_connected_components_impl(FIMap fim, * \cgalNamedParamsEnd * */ -template +template void split_connected_components(const PolygonMesh& pmesh, PolygonMeshRange& cc_meshes, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef Static_boolean_property_map< typename boost::graph_traits::edge_descriptor, false> Default_ecm; @@ -1191,13 +1106,6 @@ void split_connected_components(const PolygonMesh& pmesh, ecm, cc_meshes, pmesh, np); } -template -void split_connected_components(const PolygonMesh& pmesh, - PolygonMeshRange& cc_meshes) -{ - split_connected_components(pmesh, cc_meshes, parameters::all_default()); -} - } // namespace Polygon_mesh_processing } // namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h index 14a84753f10..79b16912735 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h @@ -175,23 +175,24 @@ enum Boolean_operation_type {UNION = 0, INTERSECTION=1, * will only be corefined. */ template + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters, + class NamedParametersOut0 = parameters::Default_named_parameters, + class NamedParametersOut1 = parameters::Default_named_parameters, + class NamedParametersOut2 = parameters::Default_named_parameters, + class NamedParametersOut3 = parameters::Default_named_parameters> std::array corefine_and_compute_boolean_operations( TriangleMesh& tm1, TriangleMesh& tm2, const std::array< boost::optional,4>& output, - const NamedParameters1& np1, - const NamedParameters2& np2, + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values(), const std::tuple& nps_out) + NamedParametersOut1, + NamedParametersOut2, + NamedParametersOut3>& nps_out + = std::tuple()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -412,51 +413,6 @@ corefine_and_compute_boolean_operations( ob.tm2_minus_tm1_is_valid()); } -template -std::array -corefine_and_compute_boolean_operations( - TriangleMesh& tm1, - TriangleMesh& tm2, - const std::array< boost::optional,4>& output) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - return corefine_and_compute_boolean_operations(tm1, tm2, output, - all_default(), all_default(), - std::make_tuple(all_default(), all_default(), - all_default(), all_default())); -} - -template -std::array -corefine_and_compute_boolean_operations( - TriangleMesh& tm1, - TriangleMesh& tm2, - const std::array< boost::optional,4>& output, - const NamedParameters1& np1) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - return corefine_and_compute_boolean_operations(tm1, tm2, output, - np1, all_default(), - std::make_tuple(all_default(), all_default(), - all_default(), all_default())); -} - -template -std::array -corefine_and_compute_boolean_operations( - TriangleMesh& tm1, - TriangleMesh& tm2, - const std::array< boost::optional,4>& output, - const NamedParameters1& np1, - const NamedParameters2& np2) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - return corefine_and_compute_boolean_operations(tm1, tm2, output, - np1, np2, - std::make_tuple(all_default(), all_default(), - all_default(), all_default())); -} - #undef CGAL_COREF_SET_OUTPUT_VERTEX_POINT_MAP #undef CGAL_COREF_SET_OUTPUT_EDGE_MARK_MAP @@ -554,27 +510,27 @@ corefine_and_compute_boolean_operations( * If `false` is returned and if `tm_out` is one of the input surface meshes, * then `tm_out` is only corefined. */ template + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters, + class NamedParametersOut = parameters::Default_named_parameters> bool corefine_and_compute_union( TriangleMesh& tm1, TriangleMesh& tm2, TriangleMesh& tm_out, - const NamedParameters1& np1, - const NamedParameters2& np2, - const NamedParametersOut& np_out) + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values(), + const NamedParametersOut& np_out = parameters::default_values()) { - using namespace CGAL::Polygon_mesh_processing::parameters; + using namespace CGAL::parameters; std::array< boost::optional,4> output; output[Corefinement::UNION]=&tm_out; return corefine_and_compute_boolean_operations(tm1, tm2, output, np1, np2, std::make_tuple(np_out, - all_default(), - all_default(), - all_default())) + parameters::default_values(), + parameters::default_values(), + parameters::default_values())) [Corefinement::UNION]; } @@ -586,27 +542,27 @@ corefine_and_compute_union( TriangleMesh& tm1, * \copydetails CGAL::Polygon_mesh_processing::corefine_and_compute_union() */ template + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters, + class NamedParametersOut = parameters::Default_named_parameters> bool corefine_and_compute_intersection( TriangleMesh& tm1, TriangleMesh& tm2, TriangleMesh& tm_out, - const NamedParameters1& np1, - const NamedParameters2& np2, - const NamedParametersOut& np_out) + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values(), + const NamedParametersOut& np_out = parameters::default_values()) { - using namespace CGAL::Polygon_mesh_processing::parameters; + using namespace CGAL::parameters; std::array< boost::optional,4> output; output[Corefinement::INTERSECTION]=&tm_out; return corefine_and_compute_boolean_operations(tm1, tm2, output, np1, np2, - std::make_tuple(all_default(), + std::make_tuple(parameters::default_values(), np_out, - all_default(), - all_default())) + parameters::default_values(), + parameters::default_values())) [Corefinement::INTERSECTION]; } @@ -618,28 +574,28 @@ corefine_and_compute_intersection( TriangleMesh& tm1, * \copydetails CGAL::Polygon_mesh_processing::corefine_and_compute_union() */ template + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters, + class NamedParametersOut = parameters::Default_named_parameters> bool corefine_and_compute_difference( TriangleMesh& tm1, TriangleMesh& tm2, TriangleMesh& tm_out, - const NamedParameters1& np1, - const NamedParameters2& np2, - const NamedParametersOut& np_out) + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values(), + const NamedParametersOut& np_out = parameters::default_values()) { - using namespace CGAL::Polygon_mesh_processing::parameters; + using namespace CGAL::parameters; using namespace CGAL::Polygon_mesh_processing::Corefinement; std::array< boost::optional,4> output; output[TM1_MINUS_TM2]=&tm_out; return corefine_and_compute_boolean_operations(tm1, tm2, output, np1, np2, - std::make_tuple(all_default(), - all_default(), + std::make_tuple(parameters::default_values(), + parameters::default_values(), np_out, - all_default())) + parameters::default_values())) [TM1_MINUS_TM2]; } @@ -706,13 +662,13 @@ corefine_and_compute_difference( TriangleMesh& tm1, * */ template + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters> void corefine( TriangleMesh& tm1, TriangleMesh& tm2, - const NamedParameters1& np1, - const NamedParameters2& np2) + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -849,10 +805,10 @@ namespace experimental { * */ template + class NamedParameters = parameters::Default_named_parameters> void autorefine( TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -942,10 +898,10 @@ autorefine( TriangleMesh& tm, * */ template + class NamedParameters = parameters::Default_named_parameters> bool autorefine_and_remove_self_intersections( TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -997,208 +953,6 @@ autorefine_and_remove_self_intersections( TriangleMesh& tm, }// end of namespace experimental -// overload with default named parameters -///// corefine_and_compute_union ///// -template -bool -corefine_and_compute_union( TriangleMesh& tm1, - TriangleMesh& tm2, - TriangleMesh& tm_out, - const NamedParameters1& np1, - const NamedParameters2& np2) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - return corefine_and_compute_union(tm1, tm2, tm_out, - np1, np2, all_default()); -} - -template -bool -corefine_and_compute_union( TriangleMesh& tm1, - TriangleMesh& tm2, - TriangleMesh& tm_out, - const NamedParameters1& np1) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - return corefine_and_compute_union(tm1, tm2, tm_out, - np1, all_default(), all_default()); -} - -template -bool -corefine_and_compute_union(TriangleMesh& tm1, - TriangleMesh& tm2, - TriangleMesh& tm_out) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - return corefine_and_compute_union(tm1, tm2, tm_out, - all_default(), all_default(), all_default()); -} - -///// corefine_and_compute_intersection ///// -template -bool -corefine_and_compute_intersection( TriangleMesh& tm1, - TriangleMesh& tm2, - TriangleMesh& tm_out, - const NamedParameters1& np1, - const NamedParameters2& np2) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - return corefine_and_compute_intersection(tm1, tm2, tm_out, - np1, np2, all_default()); -} - -template -bool -corefine_and_compute_intersection( TriangleMesh& tm1, - TriangleMesh& tm2, - TriangleMesh& tm_out, - const NamedParameters1& np1) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - return corefine_and_compute_intersection(tm1, tm2, tm_out, - np1, all_default(), all_default()); -} - -template -bool -corefine_and_compute_intersection(TriangleMesh& tm1, - TriangleMesh& tm2, - TriangleMesh& tm_out) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - return corefine_and_compute_intersection(tm1, tm2, tm_out, - all_default(), all_default(), all_default()); -} - -///// difference ///// -template -bool -corefine_and_compute_difference( TriangleMesh& tm1, - TriangleMesh& tm2, - TriangleMesh& tm_out, - const NamedParameters1& np1, - const NamedParameters2& np2) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - return corefine_and_compute_difference(tm1, tm2, tm_out, - np1, np2, all_default()); -} - -template -bool -corefine_and_compute_difference( TriangleMesh& tm1, - TriangleMesh& tm2, - TriangleMesh& tm_out, - const NamedParameters1& np1) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - return corefine_and_compute_difference(tm1, tm2, tm_out, - np1, all_default(), all_default()); -} - -template -bool -corefine_and_compute_difference(TriangleMesh& tm1, - TriangleMesh& tm2, - TriangleMesh& tm_out) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - return corefine_and_compute_difference(tm1, tm2, tm_out, - all_default(), all_default(), all_default()); -} - -///// corefine ///// -template -void -corefine( TriangleMesh& tm1, - TriangleMesh& tm2, - const NamedParameters1& np1) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - corefine(tm1, tm2, np1, all_default()); -} - -template -void -corefine( TriangleMesh& tm1, - TriangleMesh& tm2) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - corefine(tm1, tm2, all_default(), all_default()); -} - -#ifndef CGAL_NO_DEPRECATED_CODE - template - void - corefine( TriangleMesh& tm1, - TriangleMesh& tm2, - const NamedParameters1& np1, - const NamedParameters2& np2, - const bool throw_on_self_intersection) -{ - corefine(tm1, tm2, np1.throw_on_self_intersection(throw_on_self_intersection), np2); -} - -template -void -corefine( TriangleMesh& tm1, - TriangleMesh& tm2, - const NamedParameters1& np1, - const bool throw_on_self_intersection) -{ - namespace params = CGAL::Polygon_mesh_processing::parameters; - corefine(tm1, tm2, - np1.throw_on_self_intersection(throw_on_self_intersection), - params::all_default()); -} - -template -void -corefine( TriangleMesh& tm1, - TriangleMesh& tm2, - const bool throw_on_self_intersection) -{ - namespace params = CGAL::Polygon_mesh_processing::parameters; - corefine(tm1, tm2, - params::throw_on_self_intersection(throw_on_self_intersection), - params::all_default()); -} -#endif - -///// autorefine ///// -namespace experimental { -template -void -autorefine(TriangleMesh& tm) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - autorefine(tm, all_default()); -} - -///// autorefine_and_remove_self_intersections ///// -template -bool -autorefine_and_remove_self_intersections(TriangleMesh& tm) -{ - using namespace CGAL::Polygon_mesh_processing::parameters; - return autorefine_and_remove_self_intersections(tm, all_default()); -} - -} // end of namespace experimental - } } // end of namespace CGAL::Polygon_mesh_processing #include diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h index 7cc05d49b48..1a8610b9572 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h @@ -144,12 +144,12 @@ void put(PatchIdMapWrapper >& map, Handle_type h } template + typename EdgeIsFeatureMap, typename NamedParameters = parameters::Default_named_parameters> typename boost::graph_traits::faces_size_type detect_surface_patches(const PolygonMesh& p, PatchIdMap patch_id_map, EdgeIsFeatureMap eif, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { int offset = static_cast( parameters::choose_parameter(parameters::get_parameter(np, internal_np::first_index), 1)); @@ -163,16 +163,6 @@ detect_surface_patches(const PolygonMesh& p, .face_index_map(CGAL::get_initialized_face_index_map(p, np))); } -template -typename boost::graph_traits::faces_size_type -detect_surface_patches(const PolygonMesh& p, - PatchIdMap patch_id_map, - EdgeIsFeatureMap eif) -{ - return detect_surface_patches(p, patch_id_map, eif, parameters::all_default()); -} - - template void sharp_call(const FT angle_in_deg, const PolygonMesh& pmesh, @@ -276,7 +266,7 @@ void sharp_call(const FT angle_in_deg, template #else -template +template #endif void detect_sharp_edges(const PolygonMesh& pmesh, #ifdef DOXYGEN_RUNNING @@ -285,7 +275,7 @@ void detect_sharp_edges(const PolygonMesh& pmesh, typename GetGeomTraits::type::FT angle_in_deg, #endif EdgeIsFeatureMap edge_is_feature_map, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -452,7 +442,7 @@ template #else template + typename EdgeIsFeatureMap, typename PatchIdMap, typename NamedParameters = parameters::Default_named_parameters> #endif typename boost::graph_traits::faces_size_type sharp_edges_segmentation(const PolygonMesh& pmesh, @@ -463,7 +453,7 @@ sharp_edges_segmentation(const PolygonMesh& pmesh, #endif EdgeIsFeatureMap edge_is_feature_map, PatchIdMap patch_id_map, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { detect_sharp_edges(pmesh, angle_in_deg, edge_is_feature_map, np); @@ -476,28 +466,6 @@ sharp_edges_segmentation(const PolygonMesh& pmesh, return result; } -//Convenient overrides -template -void detect_sharp_edges(const PolygonMesh& p, - FT angle_in_deg, - EdgeIsFeatureMap edge_is_feature_map) -{ - detect_sharp_edges(p, angle_in_deg, edge_is_feature_map, - parameters::all_default()); -} - -template -typename boost::graph_traits::faces_size_type -sharp_edges_segmentation(const PolygonMesh& p, - FT angle_in_deg, - EdgeIsFeatureMap edge_is_feature_map, - PatchIdMap patch_id_map) -{ - return sharp_edges_segmentation(p, angle_in_deg, edge_is_feature_map, patch_id_map, - parameters::all_default()); -} - } // end namespace PMP } // end namespace CGAL 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 8d561e377f2..e01fbe48515 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -41,17 +41,22 @@ #ifdef CGAL_LINKED_WITH_TBB #include #include -#include #endif // CGAL_LINKED_WITH_TBB -#include #include +#include #include #include #include #include +#ifdef CGAL_HAUSDORFF_DEBUG_PP + #ifndef CGAL_HAUSDORFF_DEBUG + #define CGAL_HAUSDORFF_DEBUG + #endif +#endif + namespace CGAL { namespace Polygon_mesh_processing { namespace internal { @@ -65,20 +70,21 @@ triangle_grid_sampling(const typename Kernel::Point_3& p0, PointOutputIterator out) { typename Kernel::Compute_squared_distance_3 squared_distance; - const double d_p0p1 = to_double(approximate_sqrt( squared_distance(p0, p1) )); - const double d_p0p2 = to_double(approximate_sqrt( squared_distance(p0, p2) )); - const double n = (std::max)(std::ceil( d_p0p1 / distance ), - std::ceil( d_p0p2 / distance )); + const double d_p0p1 = to_double(approximate_sqrt(squared_distance(p0, p1))); + const double d_p0p2 = to_double(approximate_sqrt(squared_distance(p0, p2))); + + const double n = (std::max)(std::ceil(d_p0p1 / distance), + std::ceil(d_p0p2 / distance)); for(double i=1; i -struct Distance_computation{ +template +struct Distance_computation +{ + typedef typename Kernel::FT FT; typedef typename PointRange::const_iterator::value_type Point_3; const AABB_tree& tree; const PointRange& sample_points; Point_3 initial_hint; - double distance; + FT sq_distance; + //constructor - Distance_computation( - const AABB_tree& tree, - const Point_3& p, - const PointRange& sample_points) - : tree(tree) - , sample_points(sample_points) - , initial_hint(p) - , distance(-1) - {} - //split constructor - Distance_computation(Distance_computation& s, tbb::split ) - : tree(s.tree) - , sample_points(s.sample_points) - , initial_hint(s.initial_hint) - , distance(-1) + Distance_computation(const AABB_tree& tree, + const Point_3& p, + const PointRange& sample_points) + : tree(tree), + sample_points(sample_points), + initial_hint(p), + sq_distance(-1) {} - void - operator()(const tbb::blocked_range& range) + //split constructor + Distance_computation(Distance_computation& s, tbb::split) + : tree(s.tree), + sample_points(s.sample_points), + initial_hint(s.initial_hint), + sq_distance(-1) + {} + + void operator()(const tbb::blocked_range& range) { Point_3 hint = initial_hint; - double hdist = 0; - for( std::size_t i = range.begin(); i != range.end(); ++i) + FT sq_hdist = 0; + typename Kernel_traits::Kernel::Compute_squared_distance_3 squared_distance; + + for(std::size_t i = range.begin(); i != range.end(); ++i) { hint = tree.closest_point(*(sample_points.begin() + i), hint); - typename Kernel_traits::Kernel::Compute_squared_distance_3 squared_distance; - double d = to_double(CGAL::approximate_sqrt( squared_distance(hint,*(sample_points.begin() + i)) )); - if(d > hdist) - hdist=d; + FT sq_d = squared_distance(hint,*(sample_points.begin() + i)); + if(sq_d > sq_hdist) + sq_hdist = sq_d; } - if(hdist > distance) - distance = hdist; + + if(sq_hdist > sq_distance) + sq_distance = sq_hdist; } - void join( Distance_computation& rhs ) {distance = (std::max)(rhs.distance, distance); } + void join(Distance_computation& rhs) { sq_distance = (std::max)(rhs.sq_distance, sq_distance); } }; #endif @@ -137,37 +147,37 @@ template -double approximate_Hausdorff_distance_impl( - const PointRange& sample_points, - const AABBTree& tree, - typename Kernel::Point_3 hint) +double approximate_Hausdorff_distance_impl(const PointRange& sample_points, + const AABBTree& tree, + typename Kernel::Point_3 hint) { + using FT = typename Kernel::FT; + #if !defined(CGAL_LINKED_WITH_TBB) CGAL_static_assertion_msg (!(boost::is_convertible::value), "Parallel_tag is enabled but TBB is unavailable."); #else if(boost::is_convertible::value) { - std::atomic distance; - distance=0; - Distance_computation f(tree, hint, sample_points); + Distance_computation f(tree, hint, sample_points); tbb::parallel_reduce(tbb::blocked_range(0, sample_points.size()), f); - return f.distance; + return to_double(approximate_sqrt(f.sq_distance)); } else #endif { - double hdist = 0; + FT sq_hdist = 0; + typename Kernel::Compute_squared_distance_3 squared_distance; + for(const typename Kernel::Point_3& pt : sample_points) { hint = tree.closest_point(pt, hint); - typename Kernel::Compute_squared_distance_3 squared_distance; - typename Kernel::FT dist = squared_distance(hint,pt); - double d = to_double(CGAL::approximate_sqrt(dist)); - if(d>hdist) - hdist=d; + FT sq_d = squared_distance(hint, pt); + if(sq_d > sq_hdist) + sq_hdist = sq_d; } - return hdist; + + return to_double(approximate_sqrt(sq_hdist)); } } @@ -190,7 +200,7 @@ struct Triangle_structure_sampler_base {} void sample_points(); - double get_minimum_edge_length(); + double get_squared_minimum_edge_length(); template double get_tr_area(const Tr&); @@ -214,14 +224,15 @@ struct Triangle_structure_sampler_base gt = choose_parameter(get_parameter(np, internal_np::geom_traits)); - bool use_rs = choose_parameter(get_parameter(np, internal_np::random_uniform_sampling), true); bool use_gs = choose_parameter(get_parameter(np, internal_np::grid_sampling), false); bool use_ms = choose_parameter(get_parameter(np, internal_np::monte_carlo_sampling), false); if(use_gs || use_ms) - if(is_default_parameter(get_parameter(np, internal_np::random_uniform_sampling))) + { + if(is_default_parameter()) use_rs = false; + } bool smpl_vrtcs = choose_parameter(get_parameter(np, internal_np::do_sample_vertices), true); bool smpl_dgs = choose_parameter(get_parameter(np, internal_np::do_sample_edges), true); @@ -238,11 +249,9 @@ struct Triangle_structure_sampler_base { double grid_spacing_ = choose_parameter(get_parameter(np, internal_np::grid_spacing), 0.); + // set grid spacing to the shortest edge length if(grid_spacing_ == 0.) - { - // set grid spacing to the shortest edge length - grid_spacing_ = static_cast(this)->get_minimum_edge_length(); - } + grid_spacing_ = std::sqrt(static_cast(this)->get_squared_minimum_edge_length()); static_cast(this)->internal_sample_triangles(grid_spacing_, smpl_fcs, smpl_dgs); } @@ -261,7 +270,7 @@ struct Triangle_structure_sampler_base if((nb_points_per_face == 0 && nb_pts_a_u == 0.) || (nb_points_per_edge == 0 && nb_pts_l_u == 0.)) { - min_sq_edge_length = static_cast(this)->get_minimum_edge_length(); + min_sq_edge_length = static_cast(this)->get_squared_minimum_edge_length(); } // sample faces @@ -283,7 +292,7 @@ struct Triangle_structure_sampler_base } // extract triangle face points - std::arraypoints = static_cast(this)->get_tr_points(tr); + std::array points = static_cast(this)->get_tr_points(tr); Random_points_in_triangle_3 g(points[0], points[1], points[2]); out = std::copy_n(g, nb_points, out); @@ -345,8 +354,8 @@ sample_triangles(const FaceRange& triangles, typedef typename GT::face_descriptor face_descriptor; typedef typename GT::halfedge_descriptor halfedge_descriptor; - boost::unordered_set sampled_edges; - boost::unordered_set endpoints; + std::unordered_set sampled_edges; + std::unordered_set endpoints; for(face_descriptor fd : triangles) { @@ -354,14 +363,14 @@ sample_triangles(const FaceRange& triangles, halfedge_descriptor hd = halfedge(fd, tm); for(int i=0;i<3; ++i) { - if(sample_edges && sampled_edges.insert(edge(hd, tm)).second ) + if(sample_edges && sampled_edges.insert(edge(hd, tm)).second) { Point_ref p0 = get(vpm, source(hd, tm)); Point_ref p1 = get(vpm, target(hd, tm)); typename Kernel::Compute_squared_distance_3 squared_distance; const double d_p0p1 = to_double(approximate_sqrt(squared_distance(p0, p1))); - const double nb_pts = std::ceil( d_p0p1 / distance ); + const double nb_pts = std::ceil(d_p0p1 / distance); const Vector_3 step_vec = typename Kernel::Construct_scaled_vector_3()( typename Kernel::Construct_vector_3()(p0, p1), typename Kernel::FT(1)/typename Kernel::FT(nb_pts)); @@ -432,12 +441,15 @@ struct Triangle_structure_sampler_for_triangle_mesh typedef typename GT::edge_descriptor edge_descriptor; typedef typename GT::face_descriptor face_descriptor; + typedef typename GeomTraits::FT FT; + typedef Random_points_in_triangle_mesh_3 Randomizer; typedef typename boost::graph_traits::face_iterator TriangleIterator; Vpm pmap; double min_sq_edge_length; const Mesh& tm; + CGAL::Random rnd; Triangle_structure_sampler_for_triangle_mesh(const Mesh& m, PointOutputIterator& out, @@ -446,9 +458,14 @@ struct Triangle_structure_sampler_for_triangle_mesh { using parameters::choose_parameter; using parameters::get_parameter; + using parameters::is_default_parameter; pmap = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(vertex_point, tm)); + + if(!(is_default_parameter())) + rnd = CGAL::Random(choose_parameter(get_parameter(np, internal_np::random_seed),0)); + min_sq_edge_length = (std::numeric_limits::max)(); } @@ -465,29 +482,30 @@ struct Triangle_structure_sampler_for_triangle_mesh this->out); } - double get_minimum_edge_length() + double get_squared_minimum_edge_length() { typedef typename boost::graph_traits::edge_descriptor edge_descriptor; if(min_sq_edge_length != (std::numeric_limits::max)()) return min_sq_edge_length; + FT m_sq_el = min_sq_edge_length; for(edge_descriptor ed : edges(tm)) { - const double sq_el = CGAL::to_double( - typename GeomTraits::Compute_squared_distance_3()(get(pmap, source(ed, tm)), - get(pmap, target(ed, tm)))); + const FT sq_el = this->gt.compute_squared_distance_3_object()(get(pmap, source(ed, tm)), + get(pmap, target(ed, tm))); - if(sq_el > 0. && sq_el < min_sq_edge_length) - min_sq_edge_length = sq_el; + if(sq_el < m_sq_el) + m_sq_el = sq_el; } + min_sq_edge_length = to_double(m_sq_el); return min_sq_edge_length; } double get_tr_area(const typename boost::graph_traits::face_descriptor& tr) { - return to_double(face_area(tr,tm,parameters::geom_traits(this->gt))); + return to_double(face_area(tr, tm, parameters::geom_traits(this->gt))); } template//tr = face_descriptor here @@ -509,7 +527,7 @@ struct Triangle_structure_sampler_for_triangle_mesh typename GeomTraits::Compute_squared_distance_3 squared_distance = this->gt.compute_squared_distance_3_object(); if(nb_points_per_edge == 0 && nb_pts_l_u == 0.) - nb_pts_l_u = 1. / CGAL::sqrt(min_sq_edge_length); + nb_pts_l_u = 1. / std::sqrt(min_sq_edge_length); for(edge_descriptor ed : edges(tm)) { @@ -529,6 +547,7 @@ struct Triangle_structure_sampler_for_triangle_mesh this->out = std::copy_n(g, nb_points, this->out); } } + void ru_edges_sample(double nb_pts_l_u, double nb_pts_a_u) { @@ -544,17 +563,19 @@ struct Triangle_structure_sampler_for_triangle_mesh else nb_points = static_cast(std::ceil(g.mesh_length() * nb_pts_a_u)); } + this->out = std::copy_n(g, nb_points, this->out); } Randomizer get_randomizer() { - return Randomizer(tm, pmap); + return Randomizer(tm, pmap, rnd); } void internal_sample_triangles(double grid_spacing_, bool smpl_fcs, bool smpl_dgs) { - this->out = sample_triangles(faces(tm), tm, pmap, grid_spacing_, this->out, smpl_fcs, smpl_dgs, false); + this->out = sample_triangles(faces(tm), tm, pmap, grid_spacing_, + this->out, smpl_fcs, smpl_dgs, false); } std::size_t get_points_size() @@ -601,6 +622,7 @@ struct Triangle_structure_sampler_for_triangle_soup Creator, Self> Base; + typedef typename GeomTraits::FT FT; typedef typename GeomTraits::Point_3 Point_3; typedef Random_points_in_triangle_soup Randomizer; @@ -609,6 +631,7 @@ struct Triangle_structure_sampler_for_triangle_soup double min_sq_edge_length; const PointRange& points; const TriangleRange& triangles; + Random rnd; Triangle_structure_sampler_for_triangle_soup(const PointRange& pts, const TriangleRange& trs, @@ -616,7 +639,13 @@ struct Triangle_structure_sampler_for_triangle_soup const NamedParameters& np) : Base(out, np), points(pts), triangles(trs) { + using parameters::choose_parameter; + using parameters::get_parameter; + using parameters::is_default_parameter; + min_sq_edge_length = (std::numeric_limits::max)(); + if(!(is_default_parameter())) + rnd = CGAL::Random(choose_parameter(get_parameter(np, internal_np::random_seed),0)); } std::pair get_range() @@ -629,11 +658,12 @@ struct Triangle_structure_sampler_for_triangle_soup this->out = std::copy(points.begin(), points.end(), this->out); } - double get_minimum_edge_length() + double get_squared_minimum_edge_length() { if(min_sq_edge_length != (std::numeric_limits::max)()) return min_sq_edge_length; + FT m_sq_el = min_sq_edge_length; for(const auto& tr : triangles) { for(std::size_t i = 0; i< 3; ++i) @@ -641,18 +671,20 @@ struct Triangle_structure_sampler_for_triangle_soup const Point_3& a = points[tr[i]]; const Point_3& b = points[tr[(i+1)%3]]; - const double sq_el = CGAL::to_double(typename GeomTraits::Compute_squared_distance_3()(a, b)); - if(sq_el > 0. && sq_el < min_sq_edge_length) - min_sq_edge_length = sq_el; + const FT sq_el = this->gt.compute_squared_distance_3_object()(a, b); + if(sq_el < m_sq_el) + m_sq_el = sq_el; } } + min_sq_edge_length = to_double(m_sq_el); return min_sq_edge_length; } template double get_tr_area(const Tr& tr) { + // Kernel_3::Compute_area_3 uses `sqrt()` return to_double(approximate_sqrt( this->gt.compute_squared_area_3_object()( points[tr[0]], points[tr[1]], points[tr[2]]))); @@ -663,9 +695,8 @@ struct Triangle_structure_sampler_for_triangle_soup { std::array points; for(int i=0; i<3; ++i) - { points[i] = this->points[tr[i]]; - } + return points; } @@ -681,7 +712,7 @@ struct Triangle_structure_sampler_for_triangle_soup Randomizer get_randomizer() { - return Randomizer(triangles, points); + return Randomizer(triangles, points, rnd); } void internal_sample_triangles(double distance, bool, bool) @@ -737,6 +768,12 @@ struct Triangle_structure_sampler_for_triangle_soup * \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} * \cgalParamNEnd * + * \cgalParamNBegin{random_seed} + * \cgalParamDescription{a value to seed the random number generator} + * \cgalParamType{unsigned int} + * \cgalParamDefault{a value generated with `std::time()`} + * \cgalParamNEnd + * * \cgalParamNBegin{use_random_uniform_sampling} * \cgalParamDescription{If `true` is passed, points are generated uniformly at random on faces and/or edges of `tm`. If `do_sample_faces` is `true`, random points will be iteratively generated uniformly at random in the triangle of a face @@ -852,20 +889,21 @@ struct Triangle_structure_sampler_for_triangle_soup * * @see `CGAL::Polygon_mesh_processing::sample_triangle_soup()` */ -template +template PointOutputIterator sample_triangle_mesh(const TriangleMesh& tm, PointOutputIterator out, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename GetGeomTraits::type GeomTraits; typedef typename GetVertexPointMap::const_type Vpm; - internal::Triangle_structure_sampler_for_triangle_mesh, + Creator_uniform_3, Vpm, NamedParameters> performer(tm, out, np); performer.procede(); @@ -898,6 +936,12 @@ sample_triangle_mesh(const TriangleMesh& tm, * \cgalParamExtra{The geometric traits class must be compatible with the point range's point type.} * \cgalParamNEnd * + * \cgalParamNBegin{random_seed} + * \cgalParamDescription{a value to seed the random number generator} + * \cgalParamType{unsigned int} + * \cgalParamDefault{a value generated with `std::time()`} + * \cgalParamNEnd + * * \cgalParamNBegin{use_random_uniform_sampling} * \cgalParamDescription{If `true` is passed, points are generated in a random and uniform way * over the triangles of the soup.} @@ -977,90 +1021,68 @@ sample_triangle_mesh(const TriangleMesh& tm, template + class NamedParameters = parameters::Default_named_parameters> PointOutputIterator sample_triangle_soup(const PointRange& points, const TriangleRange& triangles, PointOutputIterator out, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename PointRange::value_type Point_3; typedef typename Kernel_traits::Kernel GeomTraits; static_assert(std::is_same::value, "Wrong point type."); - internal::Triangle_structure_sampler_for_triangle_soup, + Creator_uniform_3, NamedParameters> performer(points, triangles, out, np); performer.procede(); return performer.out; } -template -PointOutputIterator -sample_triangle_mesh(const TriangleMesh& tm, - PointOutputIterator out) -{ - return sample_triangle_mesh(tm, out, parameters::all_default()); -} - -template -PointOutputIterator -sample_triangle_soup(const PointRange& points, - const TriangleRange& triangles, - PointOutputIterator out) -{ - return sample_triangle_soup(points, triangles, out, parameters::all_default()); -} - template -double approximate_Hausdorff_distance( - const PointRange& original_sample_points, - const TriangleMesh& tm, - VertexPointMap vpm) +double approximate_Hausdorff_distance(const PointRange& original_sample_points, + const TriangleMesh& tm, + VertexPointMap vpm) { - CGAL_assertion_code( bool is_triangle = is_triangle_mesh(tm) ); - CGAL_assertion_msg (is_triangle, - "Mesh is not triangulated. Distance computing impossible."); + CGAL_assertion(is_triangle_mesh(tm)); + typedef typename Kernel::Point_3 Point_3; - std::vector sample_points - (boost::begin(original_sample_points), boost::end(original_sample_points) ); - #ifdef CGAL_HAUSDORFF_DEBUG + + std::vector sample_points(std::begin(original_sample_points), std::end(original_sample_points)); +#ifdef CGAL_HAUSDORFF_DEBUG std::cout << "Nb sample points " << sample_points.size() << "\n"; - #endif +#endif spatial_sort(sample_points.begin(), sample_points.end()); typedef AABB_face_graph_triangle_primitive Primitive; typedef AABB_tree< AABB_traits > Tree; - Tree tree( faces(tm).first, faces(tm).second, tm); + Tree tree(faces(tm).first, faces(tm).second, tm); tree.build(); + Point_3 hint = get(vpm, *vertices(tm).first); - return internal::approximate_Hausdorff_distance_impl - (sample_points, tree, hint); + return internal::approximate_Hausdorff_distance_impl(sample_points, tree, hint); } template -double approximate_Hausdorff_distance( - const TriangleMesh& tm1, - const TriangleMesh& tm2, - const NamedParameters& np, - VertexPointMap vpm_2) + class VertexPointMap> +double approximate_Hausdorff_distance(const TriangleMesh& tm1, + const TriangleMesh& tm2, + const NamedParameters& np, + VertexPointMap vpm_2) { std::vector sample_points; sample_triangle_mesh(tm1, std::back_inserter(sample_points), np); @@ -1106,24 +1128,24 @@ double approximate_Hausdorff_distance( * \cgalParamNEnd * \cgalNamedParamsEnd * - * The function `CGAL::parameters::all_default()` can be used to indicate to use the default values + * The function `CGAL::parameters::default_values()` can be used to indicate to use the default values * for `np1` and specify custom values for `np2`. */ template< class Concurrency_tag, class TriangleMesh, - class NamedParameters1, - class NamedParameters2> -double approximate_Hausdorff_distance( const TriangleMesh& tm1, - const TriangleMesh& tm2, - const NamedParameters1& np1, - const NamedParameters2& np2) + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters> +double approximate_Hausdorff_distance(const TriangleMesh& tm1, + const TriangleMesh& tm2, + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values()) { - typedef typename GetGeomTraits::type GeomTraits; + typedef typename GetGeomTraits::type GeomTraits; return approximate_Hausdorff_distance( - tm1, tm2, np1, parameters::choose_parameter(parameters::get_parameter(np2, internal_np::vertex_point), - get_const_property_map(vertex_point, tm2))); + tm1, tm2, np1, + parameters::choose_parameter(parameters::get_parameter(np2, internal_np::vertex_point), + get_const_property_map(vertex_point, tm2))); } /** @@ -1132,20 +1154,17 @@ double approximate_Hausdorff_distance( const TriangleMesh& tm1, * It returns the maximum of `approximate_Hausdorff_distance(tm1, tm2, np1, np2)` * and `approximate_Hausdorff_distance(tm2, tm1, np2, np1)`. */ -template< class Concurrency_tag, +template -double approximate_symmetric_Hausdorff_distance( - const TriangleMesh& tm1, - const TriangleMesh& tm2, - const NamedParameters1& np1, - const NamedParameters2& np2) + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters> +double approximate_symmetric_Hausdorff_distance(const TriangleMesh& tm1, + const TriangleMesh& tm2, + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values()) { - return (std::max)( - approximate_Hausdorff_distance(tm1,tm2,np1,np2), - approximate_Hausdorff_distance(tm2,tm1,np2,np1) - ); + return (std::max)(approximate_Hausdorff_distance(tm1,tm2,np1,np2), + approximate_Hausdorff_distance(tm2,tm1,np2,np1)); } /** @@ -1181,24 +1200,24 @@ double approximate_symmetric_Hausdorff_distance( template< class Concurrency_tag, class TriangleMesh, class PointRange, - class NamedParameters> + class NamedParameters = parameters::Default_named_parameters> double max_distance_to_triangle_mesh(const PointRange& points, const TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { - typedef typename GetGeomTraits::type GeomTraits; + typedef typename GetGeomTraits::type GeomTraits; - return approximate_Hausdorff_distance - (points,tm,parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_point), - get_const_property_map(vertex_point, tm))); + return approximate_Hausdorff_distance( + points, tm, + parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_point), + get_const_property_map(vertex_point, tm))); } /*! *\ingroup PMP_distance_grp - * returns an approximation of the distance between `points` and the point lying on `tm` that is the farthest from `points` + * returns an approximation of the distance between `points` and the point lying on `tm` that is the farthest from `points`. * - * @tparam PointRange a range of `Point_3`, model of `Range`. + * @tparam PointRange a range of `Point_3`, model of `Range` * @tparam TriangleMesh a model of the concept `FaceListGraph` * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" * @@ -1229,11 +1248,11 @@ double max_distance_to_triangle_mesh(const PointRange& points, */ template< class TriangleMesh, class PointRange, - class NamedParameters> + class NamedParameters = parameters::Default_named_parameters> double approximate_max_distance_to_point_set(const TriangleMesh& tm, const PointRange& points, const double precision, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename GetGeomTraits::type GeomTraits; @@ -1256,85 +1275,18 @@ double approximate_max_distance_to_point_set(const TriangleMesh& tm, } ref.add(points[0], points[1], points[2], tree); } + return to_double(ref.refine(precision, tree)); } -// convenience functions with default parameters - -template< class Concurrency_tag, - class TriangleMesh, - class PointRange> -double max_distance_to_triangle_mesh(const PointRange& points, - const TriangleMesh& tm) -{ - return max_distance_to_triangle_mesh - (points, tm, parameters::all_default()); -} - -template< class TriangleMesh, - class PointRange> -double approximate_max_distance_to_point_set(const TriangleMesh& tm, - const PointRange& points, - const double precision) -{ - return approximate_max_distance_to_point_set(tm, points, precision, - parameters::all_default()); -} - -template< class Concurrency_tag, - class TriangleMesh, - class NamedParameters> -double approximate_Hausdorff_distance(const TriangleMesh& tm1, - const TriangleMesh& tm2, - const NamedParameters& np) -{ - return approximate_Hausdorff_distance( - tm1, tm2, np, parameters::all_default()); -} - -template< class Concurrency_tag, - class TriangleMesh> -double approximate_Hausdorff_distance(const TriangleMesh& tm1, - const TriangleMesh& tm2) -{ - return approximate_Hausdorff_distance( - tm1, tm2, parameters::all_default(), parameters::all_default()); -} - - -template< class Concurrency_tag, - class TriangleMesh, - class NamedParameters> -double approximate_symmetric_Hausdorff_distance(const TriangleMesh& tm1, - const TriangleMesh& tm2, - const NamedParameters& np) -{ - return approximate_symmetric_Hausdorff_distance( - tm1, tm2, np, parameters::all_default()); -} - -template< class Concurrency_tag, - class TriangleMesh> -double approximate_symmetric_Hausdorff_distance(const TriangleMesh& tm1, - const TriangleMesh& tm2) -{ - return approximate_symmetric_Hausdorff_distance( - tm1, tm2, parameters::all_default(), parameters::all_default()); -} - //////////////////////////////////////////////////////////////////////// // Use this def in order to get back the parallel version of the one-sided Hausdorff code! // #define USE_PARALLEL_BEHD -// Use this def in order to get all DEBUG info related to the bounded-error Hausdorff code! -// #define CGAL_HAUSDORFF_DEBUG - namespace internal { -template< class Kernel, +template -std::pair preprocess_bounded_error_Hausdorff_impl( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const bool compare_meshes, - const VPM1& vpm1, - const VPM2& vpm2, - const bool is_one_sided_distance, - const NamedParameters1& np1, - const NamedParameters2& np2, - TM1Tree& tm1_tree, - TM2Tree& tm2_tree, - std::vector& tm1_only, - std::vector& tm2_only) + class FaceHandle2> +std::pair +preprocess_bounded_error_squared_Hausdorff_distance_impl(const TriangleMesh1& tm1, + const TriangleMesh2& tm2, + const bool compare_meshes, + const VPM1 vpm1, + const VPM2 vpm2, + const bool is_one_sided_distance, + const NamedParameters1& np1, + const NamedParameters2& np2, + TM1Tree& tm1_tree, + TM2Tree& tm2_tree, + std::vector& tm1_only, + std::vector& tm2_only) { - using FT = typename Kernel::FT; - using Point_3 = typename Kernel::Point_3; + using FT = typename Kernel::FT; - #ifdef CGAL_HAUSDORFF_DEBUG +#ifdef CGAL_HAUSDORFF_DEBUG using Timer = CGAL::Real_timer; Timer timer; timer.start(); std::cout << "* preprocessing begin ...." << std::endl; std::cout.precision(17); - #endif +#endif // Compute the max value that is used as infinity value for the given meshes. // In our case, it is twice the length of the diagonal of the bbox of two input meshes. - const auto bbox1 = bbox(tm1); - const auto bbox2 = bbox(tm2); - const auto bb = bbox1 + bbox2; - const FT sq_dist = CGAL::squared_distance( - Point_3(bb.xmin(), bb.ymin(), bb.zmin()), - Point_3(bb.xmax(), bb.ymax(), bb.zmax())); - FT infinity_value = CGAL::approximate_sqrt(sq_dist) * FT(2); + const Bbox_3 bbox1 = bbox(tm1); + const Bbox_3 bbox2 = bbox(tm2); + const Bbox_3 bb = bbox1 + bbox2; + const FT sq_dist = square(bb.xmax() - bb.xmin()) + + square(bb.ymax() - bb.ymin()) + + square(bb.zmax() - bb.zmin()); + + FT infinity_value = FT(4) * sq_dist; CGAL_assertion(infinity_value >= FT(0)); // Compare meshes and build trees. tm1_only.clear(); tm2_only.clear(); - std::vector< std::pair > common; + std::vector > common; const auto faces1 = faces(tm1); const auto faces2 = faces(tm2); @@ -1394,44 +1346,57 @@ std::pair preprocess_bounded_error_Hausdorff_impl( // Compare meshes. bool rebuild = false; - if (compare_meshes) { // exact check + if(compare_meshes) // exact check + { match_faces(tm1, tm2, std::back_inserter(common), - std::back_inserter(tm1_only), std::back_inserter(tm2_only), np1, np2); + std::back_inserter(tm1_only), std::back_inserter(tm2_only), np1, np2); - #ifdef CGAL_HAUSDORFF_DEBUG +#ifdef CGAL_HAUSDORFF_DEBUG std::cout << "- common: " << common.size() << std::endl; std::cout << "- tm1 only: " << tm1_only.size() << std::endl; std::cout << "- tm2 only: " << tm2_only.size() << std::endl; - #endif +#endif - if (is_one_sided_distance) { // one-sided distance - - if (tm1_only.size() > 0) { // create TM1 and and full TM2 + if(is_one_sided_distance) // one-sided distance + { + if(tm1_only.size() > 0) // create TM1 and and full TM2 + { tm1_tree.insert(tm1_only.begin(), tm1_only.end(), tm1, vpm1); tm2_tree.insert(faces2.begin(), faces2.end(), tm2, vpm2); - } else { // do not create trees - CGAL_assertion(tm1_only.size() == 0); - infinity_value = -FT(1); } - - } else { // symmetric distance - - if (tm1_only.size() == 0 && tm2_only.size() == 0) { // do not create trees - infinity_value = -FT(1); - } else if (common.size() == 0) { // create full TM1 and TM2 + else // do not create trees + { + CGAL_assertion(tm1_only.size() == 0); + infinity_value = FT(-1); + } + } + else // symmetric distance + { + if(tm1_only.size() == 0 && tm2_only.size() == 0) // do not create trees + { + infinity_value = FT(-1); + } + else if(common.size() == 0) // create full TM1 and TM2 + { tm1_tree.insert(faces1.begin(), faces1.end(), tm1, vpm1); tm2_tree.insert(faces2.begin(), faces2.end(), tm2, vpm2); - } else if (tm1_only.size() == 0) { // create TM2 and full TM1 + } + else if(tm1_only.size() == 0) // create TM2 and full TM1 + { CGAL_assertion(tm2_only.size() > 0); CGAL_assertion(tm2_only.size() < faces2.size()); tm1_tree.insert(faces1.begin(), faces1.end(), tm1, vpm1); tm2_tree.insert(tm2_only.begin(), tm2_only.end(), tm2, vpm2); - } else if (tm2_only.size() == 0) { // create TM1 and full TM2 + } + else if(tm2_only.size() == 0) // create TM1 and full TM2 + { CGAL_assertion(tm1_only.size() > 0); CGAL_assertion(tm1_only.size() < faces1.size()); tm1_tree.insert(tm1_only.begin(), tm1_only.end(), tm1, vpm1); tm2_tree.insert(faces2.begin(), faces2.end(), tm2, vpm2); - } else { // create TM1 and full TM2 and set tag to rebuild them later + } + else // create TM1 and full TM2 and set tag to rebuild them later + { CGAL_assertion(tm1_only.size() > 0); CGAL_assertion(tm1_only.size() < faces1.size()); tm1_tree.insert(tm1_only.begin(), tm1_only.end(), tm1, vpm1); @@ -1439,75 +1404,72 @@ std::pair preprocess_bounded_error_Hausdorff_impl( rebuild = true; } } - } else { // create full TM1 and TM2 + } + else // create full TM1 and TM2 + { tm1_tree.insert(faces1.begin(), faces1.end(), tm1, vpm1); tm2_tree.insert(faces2.begin(), faces2.end(), tm2, vpm2); } - #ifdef CGAL_HAUSDORFF_DEBUG +#ifdef CGAL_HAUSDORFF_DEBUG timer.stop(); std::cout << "* .... end preprocessing" << std::endl; std::cout << "* preprocessing time (sec.): " << timer.time() << std::endl; - #endif +#endif + return std::make_pair(infinity_value, rebuild); } -template< class Kernel, +template -double bounded_error_Hausdorff_impl( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const typename Kernel::FT error_bound, - const VPM1& vpm1, - const VPM2& vpm2, - const typename Kernel::FT infinity_value, - const typename Kernel::FT initial_bound, - const typename Kernel::FT distance_bound, - const TM1Tree& tm1_tree, - const TM2Tree& tm2_tree, - OutputIterator& out) + class OutputIterator> +typename Kernel::FT +bounded_error_squared_Hausdorff_distance_impl(const TriangleMesh1& tm1, + const TriangleMesh2& tm2, + const VPM1 vpm1, + const VPM2 vpm2, + const TM1Tree& tm1_tree, + const TM2Tree& tm2_tree, + const typename Kernel::FT sq_error_bound, + const typename Kernel::FT sq_initial_bound, + const typename Kernel::FT sq_distance_bound, + const typename Kernel::FT infinity_value, + OutputIterator& out) { - using FT = typename Kernel::FT; - using Point_3 = typename Kernel::Point_3; + using FT = typename Kernel::FT; + using Point_3 = typename Kernel::Point_3; using Triangle_3 = typename Kernel::Triangle_3; - using TM1_tree = TM1Tree; - using TM2_tree = TM2Tree; - - using TM1_traits = typename TM1_tree::AABB_traits; - using TM2_traits = typename TM2_tree::AABB_traits; - - using TM1_hd_traits = Hausdorff_primitive_traits_tm1; - using TM2_hd_traits = Hausdorff_primitive_traits_tm2; + using TM1_hd_traits = Hausdorff_primitive_traits_tm1; + using TM2_hd_traits = Hausdorff_primitive_traits_tm2; using Face_handle_1 = typename boost::graph_traits::face_descriptor; using Face_handle_2 = typename boost::graph_traits::face_descriptor; using Candidate = Candidate_triangle; - CGAL_precondition(error_bound >= FT(0)); + CGAL_precondition(sq_distance_bound != FT(0)); // value is -1 if unused + CGAL_precondition(sq_error_bound >= FT(0)); CGAL_precondition(tm1_tree.size() > 0); CGAL_precondition(tm2_tree.size() > 0); // First, we apply culling. - #ifdef CGAL_HAUSDORFF_DEBUG +#ifdef CGAL_HAUSDORFF_DEBUG using Timer = CGAL::Real_timer; Timer timer; timer.start(); std::cout << "- applying culling" << std::endl; std::cout.precision(17); - #endif +#endif // Build traversal traits for tm1_tree. - TM1_hd_traits traversal_traits_tm1( - tm1_tree.traits(), tm2_tree, tm1, tm2, vpm1, vpm2, - error_bound, infinity_value, initial_bound, distance_bound); + TM1_hd_traits traversal_traits_tm1(tm2_tree, tm1, tm2, vpm1, vpm2, + sq_error_bound, infinity_value, sq_initial_bound, sq_distance_bound); // Find candidate triangles in TM1, which might realise the Hausdorff bound. // We build a sorted structure while collecting the candidates. @@ -1515,174 +1477,271 @@ double bounded_error_Hausdorff_impl( tm1_tree.traversal_with_priority(stub, traversal_traits_tm1); auto& candidate_triangles = traversal_traits_tm1.get_candidate_triangles(); - auto global_bounds = traversal_traits_tm1.get_global_bounds(); + Global_bounds global_bounds = traversal_traits_tm1.get_global_bounds(); - #ifdef CGAL_HAUSDORFF_DEBUG +#ifdef CGAL_HAUSDORFF_DEBUG + std::cout << "- bounds post traversal: " << global_bounds.lower << " " << global_bounds.upper << std::endl; std::cout << "- number of candidate triangles: " << candidate_triangles.size() << std::endl; const FT culling_rate = FT(100) - (FT(candidate_triangles.size()) / FT(tm1_tree.size()) * FT(100)); std::cout << "- culling rate: " << culling_rate << "%" << std::endl; - #endif - #ifdef CGAL_HAUSDORFF_DEBUG timer.stop(); std::cout << "* culling (sec.): " << timer.time() << std::endl; - #endif +#endif CGAL_assertion(global_bounds.lower >= FT(0)); - CGAL_assertion(global_bounds.upper >= FT(0)); CGAL_assertion(global_bounds.upper >= global_bounds.lower); + CGAL_assertion(global_bounds.lpair.first != boost::graph_traits::null_face()); + CGAL_assertion(global_bounds.lpair.second != boost::graph_traits::null_face()); + CGAL_assertion(global_bounds.upair.first != boost::graph_traits::null_face()); + CGAL_assertion(global_bounds.upair.second != boost::graph_traits::null_face()); // If we already reached the user-defined max distance bound, we quit. - if (traversal_traits_tm1.early_quit()) { - CGAL_assertion(distance_bound >= FT(0)); - const double hdist = CGAL::to_double((global_bounds.lower + global_bounds.upper) / FT(2)); - return hdist; + if(traversal_traits_tm1.early_exit()) + { +#ifdef CGAL_HAUSDORFF_DEBUG + std::cout << "Quitting early (TM1 traversal): temporary distance " << global_bounds.lower + << " is already greater than user-defined bound " << sq_distance_bound << std::endl; +#endif + + CGAL_assertion(global_bounds.lower > sq_distance_bound); + return global_bounds.lower; } - CGAL_assertion(!traversal_traits_tm1.early_quit()); // Second, we apply subdivision. - #ifdef CGAL_HAUSDORFF_DEBUG +#ifdef CGAL_HAUSDORFF_DEBUG timer.reset(); timer.start(); std::cout << "- applying subdivision" << std::endl; - #endif + std::size_t explored_candidates_count = 0; +#endif // See Section 5.1 in the paper. - const FT squared_error_bound = error_bound * error_bound; - while ( - (global_bounds.upper - global_bounds.lower > error_bound) && - !candidate_triangles.empty()) { + while(!candidate_triangles.empty()) + { +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "===" << std::endl; + std::cout << candidate_triangles.size() << " candidates" << std::endl; + std::cout << "- infinity_value: " << infinity_value << std::endl; + std::cout << "- initial_bound: " << sq_initial_bound << std::endl; + std::cout << "- distance_bound: " << sq_distance_bound << std::endl; + std::cout << "- global_bounds.lower: " << global_bounds.lower << std::endl; + std::cout << "- global_bounds.upper: " << global_bounds.upper << std::endl; + std::cout << "- diff = " << (global_bounds.upper - global_bounds.lower) << ", below bound? " + << ((global_bounds.upper - global_bounds.lower) <= sq_error_bound) << std::endl; +#endif + + if((global_bounds.upper - global_bounds.lower <= sq_error_bound)) + break; // Check if we can early quit. - if (distance_bound >= FT(0)) { - const FT hdist = (global_bounds.lower + global_bounds.upper) / FT(2); - const bool early_quit = (hdist >= distance_bound); - if (early_quit) break; + if(is_positive(sq_distance_bound)) // empty distance bound is FT(-1) + { + const bool early_quit = (sq_distance_bound <= global_bounds.lower); + if(early_quit) + { +#ifdef CGAL_HAUSDORFF_DEBUG + std::cout << "Quitting early with lower bound: " << global_bounds.lower << std::endl; +#endif + break; + } } - // Get the first triangle and its Hausdorff bounds from the candidate set. - const Candidate triangle_and_bound = candidate_triangles.top(); - // Remove it from the candidate set as it will be processed now. + const Candidate triangle_and_bounds = candidate_triangles.top(); candidate_triangles.pop(); // Only process the triangle if it can contribute to the Hausdorff distance, // i.e. if its upper bound is higher than the currently known best lower bound // and the difference between the bounds to be obtained is larger than the - // user given error. - const auto& triangle_bounds = triangle_and_bound.bounds; + // user-given error. + const auto& triangle_bounds = triangle_and_bounds.bounds; + +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Candidate:" << std::endl; + std::cout << triangle_and_bounds.triangle.vertex(0) << std::endl; + std::cout << triangle_and_bounds.triangle.vertex(1) << std::endl; + std::cout << triangle_and_bounds.triangle.vertex(2) << std::endl; + std::cout << "triangle_bounds.lower: " << triangle_bounds.lower << std::endl; + std::cout << "triangle_bounds.upper: " << triangle_bounds.upper << std::endl; +#endif CGAL_assertion(triangle_bounds.lower >= FT(0)); - CGAL_assertion(triangle_bounds.upper >= FT(0)); CGAL_assertion(triangle_bounds.upper >= triangle_bounds.lower); - if ( - (triangle_bounds.upper > global_bounds.lower) && - (triangle_bounds.upper - triangle_bounds.lower > error_bound)) { + // @todo implement the enclosing-based end criterion (Section 5.1, optional step for TM1 & TM2 closed) - // Get the triangle that is to be subdivided and read its vertices. - const Triangle_3& triangle_for_subdivision = triangle_and_bound.triangle; - const Point_3 v0 = triangle_for_subdivision.vertex(0); - const Point_3 v1 = triangle_for_subdivision.vertex(1); - const Point_3 v2 = triangle_for_subdivision.vertex(2); + // Might have been a good candidate when added to the queue, but rendered useless by later insertions + if(triangle_bounds.upper < global_bounds.lower) + continue; - // Check second stopping condition: All three vertices of the triangle - // are projected onto the same triangle in TM2. - const auto closest_triangle_v0 = tm2_tree.closest_point_and_primitive(v0); - const auto closest_triangle_v1 = tm2_tree.closest_point_and_primitive(v1); - const auto closest_triangle_v2 = tm2_tree.closest_point_and_primitive(v2); - CGAL_assertion(closest_triangle_v0.second != boost::graph_traits::null_face()); - CGAL_assertion(closest_triangle_v1.second != boost::graph_traits::null_face()); - CGAL_assertion(closest_triangle_v2.second != boost::graph_traits::null_face()); - if ( - (closest_triangle_v0.second == closest_triangle_v1.second) && - (closest_triangle_v1.second == closest_triangle_v2.second)) { - - // The upper bound of this triangle is the actual Hausdorff distance of - // the triangle to the second mesh. Use it as new global lower bound. - // Here, we update the reference to the realizing triangle as this is the best current guess. - global_bounds.lower = triangle_bounds.upper; - global_bounds.lpair.second = triangle_bounds.tm2_uface; - continue; - } - - // Check third stopping condition: All edge lengths of the triangle are - // smaller than the given error bound, we cannot get results beyond this bound. - if ( - CGAL::squared_distance(v0, v1) < squared_error_bound && - CGAL::squared_distance(v0, v2) < squared_error_bound && - CGAL::squared_distance(v1, v2) < squared_error_bound) { - - // The upper bound of this triangle is within error tolerance of - // the actual upper bound, use it. - global_bounds.lower = triangle_bounds.upper; - global_bounds.lpair.second = triangle_bounds.tm2_uface; - continue; - } - - // Subdivide the triangle into four smaller triangles. - const Point_3 v01 = CGAL::midpoint(v0, v1); - const Point_3 v02 = CGAL::midpoint(v0, v2); - const Point_3 v12 = CGAL::midpoint(v1, v2); - const std::array sub_triangles = { - Triangle_3(v0, v01, v02), Triangle_3(v1 , v01, v12), - Triangle_3(v2, v02, v12), Triangle_3(v01, v02, v12) }; - - // Send each of the four triangles to culling on B with the bounds of the parent triangle. - for (std::size_t i = 0; i < 4; ++i) { - - // Call culling on B with the single triangle found. - TM2_hd_traits traversal_traits_tm2( - tm2_tree.traits(), tm2, vpm2, - triangle_bounds, - infinity_value, - infinity_value, - infinity_value); - tm2_tree.traversal_with_priority(sub_triangles[i], traversal_traits_tm2); - - // Update global lower Hausdorff bound according to the obtained local bounds. - const auto local_bounds = traversal_traits_tm2.get_local_bounds(); - - CGAL_assertion(local_bounds.lower >= FT(0)); - CGAL_assertion(local_bounds.upper >= FT(0)); - CGAL_assertion(local_bounds.upper >= local_bounds.lower); - - CGAL_assertion(local_bounds.lpair == local_bounds.default_face_pair()); - CGAL_assertion(local_bounds.upair == local_bounds.default_face_pair()); - - if (local_bounds.lower > global_bounds.lower) { - global_bounds.lower = local_bounds.lower; - global_bounds.lpair.second = local_bounds.tm2_lface; - } - - // Add the subtriangle to the candidate list. - candidate_triangles.push( - Candidate(sub_triangles[i], local_bounds, triangle_and_bound.tm1_face)); - } - - // Update global upper Hausdorff bound after subdivision. - const FT current_max = candidate_triangles.top().bounds.upper; - CGAL_assertion(current_max >= FT(0)); - - if (current_max > global_bounds.lower) { - global_bounds.upper = current_max; - global_bounds.upair.second = candidate_triangles.top().bounds.tm2_uface; - } else { - global_bounds.upper = global_bounds.lower; - global_bounds.upair.second = global_bounds.lpair.second; - } + if((triangle_bounds.upper - triangle_bounds.lower) <= sq_error_bound) + { +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Candidate triangle bounds are tight enough: " << triangle_bounds.lower << " " << triangle_bounds.upper << std::endl; +#endif + continue; } + +#ifdef CGAL_HAUSDORFF_DEBUG + ++explored_candidates_count; +#endif + + // Triangle to be subdivided + const Triangle_3& triangle_for_subdivision = triangle_and_bounds.triangle; + const Point_3& v0 = triangle_for_subdivision.vertex(0); + const Point_3& v1 = triangle_for_subdivision.vertex(1); + const Point_3& v2 = triangle_for_subdivision.vertex(2); + + // Third stopping condition: all edge lengths of the triangle are smaller than the given error bound + // @todo can we even be here considering it implies the triangle bounds are within the error bound, + // and thus we would have already continue'd? + if(CGAL::squared_distance(v0, v1) < sq_error_bound && + CGAL::squared_distance(v0, v2) < sq_error_bound && + CGAL::squared_distance(v1, v2) < sq_error_bound) + { +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Third stopping condition, small triangle" << std::endl; +#endif + + // By definition, lower_bound(t1, TM2) is smaller than h(t1, TM2). + // Let `v` is the vertex of t1 and `p_l` the point on TM2 realizing the lower bound, i.e., + // d(v, p_l) = max_{v in t1} min_{t2 in TM2) d(v, t2). + // Let `p` be the pair of points resp. on t1 and TM2 realizing the Hausdorff distance, i.e., + // h(t1, TM2) = d(p.first, p.second), + // Since we are here: + // d(p.first, v) < error_bound (1) + // From the lower bound + // d(v, p_l) <= d(p.first, p.second) + // Because d(p.first, p.second) is the min distance from p.first to TM2, + // d(p.first, p.second) <= d(p.first, p_l) + // And by triangular inequality + // d(p.first, p.second) <= d(v, p_l) + d(p.first, v) <= d(v, p_l) + error_bound = lower_bound + epsilon + continue; + } + + // Subdivide the triangle into four smaller triangles. + const Point_3 v01 = CGAL::midpoint(v0, v1); + const Point_3 v02 = CGAL::midpoint(v0, v2); + const Point_3 v12 = CGAL::midpoint(v1, v2); + const std::array sub_triangles = { Triangle_3(v0, v01, v02), Triangle_3(v1 , v01, v12), + Triangle_3(v2, v02, v12), Triangle_3(v01, v02, v12) }; + + // Send each of the four triangles to culling on B + for(std::size_t i=0; i<4; ++i) + { + // Call culling on B with the single triangle found. +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "\nSubface #" << i << "\n" + << "Geometry: " << sub_triangles[i] << std::endl; +#endif + + // Checking as in during TM1 culling is expensive + + // @todo? For each sub-triangle `ts1` that has a vertex of `v` of the triangle `t1` being subdivided, + // we have a lower bound on `h(ts1, TM2)` because: + // h_t1_lower = max_{vi in t1} min_{t2 in TM2} d(vi, t2) + // and + // h_ts1_lower = max_{vi in ts1} min_{t2 in TM2} d(vi, t2) > min_{t2 in TM2} d(v, t2) + // But: + // - we don't keep that in memory (not very hard to change, simply put `m_hi_lower` + // from the TM2 traversal traits into the candidate + // - what's the point? TM2 culling is performed on the local upper bound, so is there + // a benefit from providing this value? + // + // (We also have that error_bound is a lower bound.) + const Bbox_3 sub_t1_bbox = sub_triangles[i].bbox(); + + // Because: + // h_lower(t1, TM2) := max_{v in t1} min_{t2 in TM2} d(v, t2) + // adding more vertices can only increase the max (and the lower bound). + // + // The upper bound is: + // h_upper(t1, TM2) := min_{t2 in TM2} max_{v in t1} d(v, t2) + // If t2m is the face of TM2 realizing the minimum of max_{v in t1} d(v, t2), + // then subdividing t1 can only decrease this upper bound: let v' be a new vertex v' + // of a triangle subdividing t1 is such that + // min_{t2 in TM2} d(v', t2) > h_upper(t1, TM2) + // Because the maximum of the distance over t1 is necessarily reached at a vertex, + // there must exist a vertex v1 in t1 such that d(v1, t2) > d(v', t2), which contradicts + // the definition of v'. + // Thus, subdivision can only decrease the upper bound. + // @FIXME using 'triangle_bounds' actually create bugs?... + Local_bounds bounds(infinity_value); + TM2_hd_traits traversal_traits_tm2(sub_t1_bbox, tm2, vpm2, bounds, global_bounds, infinity_value); + tm2_tree.traversal_with_priority(sub_triangles[i], traversal_traits_tm2); + + // Update global lower Hausdorff bound according to the obtained local bounds. + const auto& sub_triangle_bounds = traversal_traits_tm2.get_local_bounds(); +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Subdivided triangle bounds: " << sub_triangle_bounds.lower << " " << sub_triangle_bounds.upper << std::endl; +#endif + + CGAL_assertion(sub_triangle_bounds.lower >= FT(0)); + CGAL_assertion(sub_triangle_bounds.upper >= sub_triangle_bounds.lower); + + // The global lower bound is the max of the per-face lower bounds + if(sub_triangle_bounds.lower > global_bounds.lower) + { + global_bounds.lower = sub_triangle_bounds.lower; + global_bounds.lpair.first = triangle_and_bounds.tm1_face; + global_bounds.lpair.second = sub_triangle_bounds.tm2_lface; + } + + // The global upper bound is: + // max_{query in TM1} min_{primitive in TM2} max_{v in query} (d(v, primitive)) + // which can go down, so it is only recomputed once splitting is finished, + // using the top value of the PQ + + // Add the subtriangle to the candidate list. + candidate_triangles.emplace(sub_triangles[i], sub_triangle_bounds, triangle_and_bounds.tm1_face); + } + + // Update global upper Hausdorff bound after subdivision. + const Candidate& top_candidate = candidate_triangles.top(); + const FT current_upmost = top_candidate.bounds.upper; +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "current candidates count: " << candidate_triangles.size() << std::endl; + std::cout << "current upper bound = " << current_upmost << std::endl; +#endif + CGAL_assertion(is_positive(current_upmost)); + + // Below can happen if the subtriangle returned something like [l;u], + // with l and u both below the global error bound. The lowest bound will not have been updated + // since it has been initialized with the error bound. + if(current_upmost < global_bounds.lower) + { +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "upmost is below lowest, end." << std::endl; +#endif + + global_bounds.upper = global_bounds.lower; // not really needed since lower is returned but doesn't hurt + global_bounds.upair.first = global_bounds.lpair.first; + global_bounds.upair.second = global_bounds.lpair.second; + + // Current upmost being equal to the lower is fine, but if it's strictly below, it must + // be because we crossed the error bound, or there is some issue... + CGAL_assertion(global_bounds.lower == sq_error_bound); + + break; + } + + global_bounds.upper = current_upmost; + global_bounds.upair.first = top_candidate.tm1_face; + global_bounds.upair.second = top_candidate.bounds.tm2_uface; + +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Global bounds post subdi: " << global_bounds.lower << " " << global_bounds.upper << std::endl; +#endif + + CGAL_assertion(global_bounds.lower >= FT(0)); + CGAL_assertion(global_bounds.upper >= global_bounds.lower); } - #ifdef CGAL_HAUSDORFF_DEBUG +#ifdef CGAL_HAUSDORFF_DEBUG timer.stop(); std::cout << "* subdivision (sec.): " << timer.time() << std::endl; - #endif - - // Compute linear interpolation between the found lower and upper bounds. - CGAL_assertion(global_bounds.lower >= FT(0)); - CGAL_assertion(global_bounds.upper >= FT(0)); - CGAL_assertion(global_bounds.upper >= global_bounds.lower); - const double hdist = CGAL::to_double((global_bounds.lower + global_bounds.upper) / FT(2)); + std::cout << "Explored " << explored_candidates_count << " candidates" << std::endl; +#endif // Get realizing triangles. CGAL_assertion(global_bounds.lpair.first != boost::graph_traits::null_face()); @@ -1694,172 +1753,196 @@ double bounded_error_Hausdorff_impl( *out++ = global_bounds.lpair; *out++ = global_bounds.upair; - return hdist; + // Return the lower bound because if the correct value is in [0; lower_bound[, the result + // must still be within the error bound (we have set lower_bound to error_bound initially) + return global_bounds.lower; } #if defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) && defined(USE_PARALLEL_BEHD) template -struct Triangle_mesh_wrapper { - +struct Triangle_mesh_wrapper +{ const TriangleMesh& tm; const VPM& vpm; const bool is_tm2; TMTree& tm_tree; - Triangle_mesh_wrapper( - const TriangleMesh& tm, const VPM& vpm, - const bool is_tm2, TMTree& tm_tree) : - tm(tm), vpm(vpm), is_tm2(is_tm2), tm_tree(tm_tree) { } + Triangle_mesh_wrapper(const TriangleMesh& tm, const VPM& vpm, + const bool is_tm2, TMTree& tm_tree) + : tm(tm), vpm(vpm), is_tm2(is_tm2), tm_tree(tm_tree) + { } - void build_tree() { + void build_tree() + { tm_tree.insert(faces(tm).begin(), faces(tm).end(), tm, vpm); tm_tree.build(); - if (is_tm2) tm_tree.accelerate_distance_queries(); - else tm_tree.do_not_accelerate_distance_queries(); + if(is_tm2) + tm_tree.accelerate_distance_queries(); + else + tm_tree.do_not_accelerate_distance_queries(); } }; template -struct Bounded_error_preprocessing { - - #ifdef CGAL_HAUSDORFF_DEBUG +struct Bounded_error_preprocessing +{ +#ifdef CGAL_HAUSDORFF_DEBUG using Timer = CGAL::Real_timer; - #endif +#endif std::vector& tm_wrappers; // Constructor. - Bounded_error_preprocessing( - std::vector& tm_wrappers) : - tm_wrappers(tm_wrappers) { } + Bounded_error_preprocessing(std::vector& tm_wrappers) + : tm_wrappers(tm_wrappers) + { } // Split constructor. - Bounded_error_preprocessing( - Bounded_error_preprocessing& s, tbb::split) : - tm_wrappers(s.tm_wrappers) { } + Bounded_error_preprocessing(Bounded_error_preprocessing& s, tbb::split) + : tm_wrappers(s.tm_wrappers) + { } - bool is_tm1_wrapper(const boost::any& operand) const { - return operand.type() == typeid(TM1Wrapper); - } - - bool is_tm2_wrapper(const boost::any& operand) const { - return operand.type() == typeid(TM2Wrapper); - } + bool is_tm1_wrapper(const boost::any& operand) const { return operand.type() == typeid(TM1Wrapper); } + bool is_tm2_wrapper(const boost::any& operand) const { return operand.type() == typeid(TM2Wrapper); } // TODO: make AABB tree build parallel! - void operator()(const tbb::blocked_range& range) { - - #ifdef CGAL_HAUSDORFF_DEBUG + void operator()(const tbb::blocked_range& range) + { +#ifdef CGAL_HAUSDORFF_DEBUG Timer timer; timer.reset(); timer.start(); std::cout.precision(17); - #endif +#endif - for (std::size_t i = range.begin(); i != range.end(); ++i) { + for(std::size_t i = range.begin(); i != range.end(); ++i) + { CGAL_assertion(i < tm_wrappers.size()); auto& tm_wrapper = tm_wrappers[i]; - if (is_tm1_wrapper(tm_wrapper)) { + if(is_tm1_wrapper(tm_wrapper)) + { TM1Wrapper& object = boost::any_cast(tm_wrapper); object.build_tree(); - } else if (is_tm2_wrapper(tm_wrapper)) { + } + else if(is_tm2_wrapper(tm_wrapper)) + { TM2Wrapper& object = boost::any_cast(tm_wrapper); object.build_tree(); - } else { + } + else + { CGAL_assertion_msg(false, "Error: wrong boost any type!"); } } - #ifdef CGAL_HAUSDORFF_DEBUG +#ifdef CGAL_HAUSDORFF_DEBUG timer.stop(); std::cout << "* time operator() preprocessing (sec.): " << timer.time() << std::endl; - #endif +#endif } void join(Bounded_error_preprocessing&) { } }; -template< class TriangleMesh1, +template -struct Bounded_error_distance_computation { - + class Kernel> +struct Bounded_error_squared_distance_computation +{ using FT = typename Kernel::FT; - #ifdef CGAL_HAUSDORFF_DEBUG +#ifdef CGAL_HAUSDORFF_DEBUG using Timer = CGAL::Real_timer; - #endif +#endif - const std::vector& tm1_parts; const TriangleMesh2& tm2; - const FT error_bound; const VPM1& vpm1; const VPM2& vpm2; - const FT infinity_value; const FT initial_bound; - const std::vector& tm1_trees; const TM2Tree& tm2_tree; - double distance; + const std::vector& tm1_parts; + const TriangleMesh2& tm2; + const FT sq_error_bound; + const VPM1 vpm1; const VPM2 vpm2; + const FT infinity_value; + const FT sq_initial_bound; + const std::vector& tm1_trees; + const TM2Tree& tm2_tree; + FT sq_hdist; // Constructor. - Bounded_error_distance_computation( - const std::vector& tm1_parts, const TriangleMesh2& tm2, - const FT error_bound, const VPM1& vpm1, const VPM2& vpm2, - const FT infinity_value, const FT initial_bound, - const std::vector& tm1_trees, const TM2Tree& tm2_tree) : - tm1_parts(tm1_parts), tm2(tm2), - error_bound(error_bound), vpm1(vpm1), vpm2(vpm2), - infinity_value(infinity_value), initial_bound(initial_bound), - tm1_trees(tm1_trees), tm2_tree(tm2_tree), distance(-1.0) { + Bounded_error_squared_distance_computation(const std::vector& tm1_parts, + const TriangleMesh2& tm2, + const FT sq_error_bound, + const VPM1 vpm1, const VPM2 vpm2, + const FT infinity_value, + const FT sq_initial_bound, + const std::vector& tm1_trees, + const TM2Tree& tm2_tree) + : tm1_parts(tm1_parts), tm2(tm2), + sq_error_bound(sq_error_bound), + vpm1(vpm1), vpm2(vpm2), + infinity_value(infinity_value), sq_initial_bound(sq_initial_bound), + tm1_trees(tm1_trees), tm2_tree(tm2_tree), + sq_hdist(-1) + { CGAL_assertion(tm1_parts.size() == tm1_trees.size()); } // Split constructor. - Bounded_error_distance_computation( - Bounded_error_distance_computation& s, tbb::split) : - tm1_parts(s.tm1_parts), tm2(s.tm2), - error_bound(s.error_bound), vpm1(s.vpm1), vpm2(s.vpm2), - infinity_value(s.infinity_value), initial_bound(s.initial_bound), - tm1_trees(s.tm1_trees), tm2_tree(s.tm2_tree), distance(-1.0) { + Bounded_error_squared_distance_computation(Bounded_error_squared_distance_computation& s, tbb::split) + : tm1_parts(s.tm1_parts), tm2(s.tm2), + sq_error_bound(s.sq_error_bound), + vpm1(s.vpm1), vpm2(s.vpm2), + infinity_value(s.infinity_value), sq_initial_bound(s.sq_initial_bound), + tm1_trees(s.tm1_trees), tm2_tree(s.tm2_tree), + sq_hdist(-1) + { CGAL_assertion(tm1_parts.size() == tm1_trees.size()); } - void operator()(const tbb::blocked_range& range) { - - #ifdef CGAL_HAUSDORFF_DEBUG + void operator()(const tbb::blocked_range& range) + { +#ifdef CGAL_HAUSDORFF_DEBUG Timer timer; timer.reset(); timer.start(); std::cout.precision(17); - #endif +#endif - double hdist = -1.0; + FT sq_dist = FT(-1); auto stub = CGAL::Emptyset_iterator(); - for (std::size_t i = range.begin(); i != range.end(); ++i) { + for(std::size_t i = range.begin(); i != range.end(); ++i) + { CGAL_assertion(i < tm1_parts.size()); CGAL_assertion(i < tm1_trees.size()); const auto& tm1 = tm1_parts[i]; const auto& tm1_tree = tm1_trees[i]; - // TODO: add distance_bound (now it is -FT(1)) in case we use parallel - // for checking if two meshes are close. - const double dist = bounded_error_Hausdorff_impl( - tm1, tm2, error_bound, vpm1, vpm2, - infinity_value, initial_bound, -FT(1), - tm1_tree, tm2_tree, stub); - if (dist > hdist) hdist = dist; - } - if (hdist > distance) distance = hdist; - #ifdef CGAL_HAUSDORFF_DEBUG + // TODO: add distance_bound (now it is FT(-1)) in case we use parallel + // for checking if two meshes are close. + const FT sqd = bounded_error_squared_Hausdorff_distance_impl( + tm1, tm2, vpm1, vpm2, tm1_tree, tm2_tree, + sq_error_bound, sq_initial_bound, FT(-1) /*sq_distance_bound*/, infinity_value, + stub); + if(sqd > sq_dist) + sq_dist = sqd; + } + + if(sq_dist > sq_hdist) + sq_hdist = sq_dist; + +#ifdef CGAL_HAUSDORFF_DEBUG timer.stop(); std::cout << "* time operator() computation (sec.): " << timer.time() << std::endl; - #endif +#endif } - void join(Bounded_error_distance_computation& rhs) { - distance = (CGAL::max)(rhs.distance, distance); + void join(Bounded_error_squared_distance_computation& rhs) + { + sq_hdist = (CGAL::max)(rhs.sq_hdist, sq_hdist); } }; #endif // defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) -template< class Concurrency_tag, +template -double bounded_error_one_sided_Hausdorff_impl( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const typename Kernel::FT error_bound, - const typename Kernel::FT distance_bound, - const bool compare_meshes, - const VPM1& vpm1, - const VPM2& vpm2, - const NamedParameters1& np1, - const NamedParameters2& np2, - OutputIterator& out) + class OutputIterator> +typename Kernel::FT +bounded_error_squared_one_sided_Hausdorff_distance_impl(const TriangleMesh1& tm1, + const TriangleMesh2& tm2, + const typename Kernel::FT sq_error_bound, + const typename Kernel::FT sq_distance_bound, + const bool compare_meshes, + const VPM1 vpm1, + const VPM2 vpm2, + const NamedParameters1& np1, + const NamedParameters2& np2, + OutputIterator& out) { - #if !defined(CGAL_LINKED_WITH_TBB) || !defined(CGAL_METIS_ENABLED) - CGAL_static_assertion_msg( - !(boost::is_convertible::value), - "Parallel_tag is enabled but at least TBB or METIS is unavailable."); - #endif +#if !defined(CGAL_LINKED_WITH_TBB) || !defined(CGAL_METIS_ENABLED) + CGAL_static_assertion_msg(!(boost::is_convertible::value), + "Parallel_tag is enabled but at least TBB or METIS is unavailable."); +#endif using FT = typename Kernel::FT; @@ -1908,8 +1990,7 @@ double bounded_error_one_sided_Hausdorff_impl( // between BHDs computed for these parts with respect to tm2. // This is off by default because the parallel version does not show much of runtime improvement. // The slowest part is building AABB trees and this is what should be accelerated in the future. - #if defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) && defined(USE_PARALLEL_BEHD) - using Point_3 = typename Kernel::Point_3; +#if defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) && defined(USE_PARALLEL_BEHD) using TMF = CGAL::Face_filtered_graph; using TMF_primitive = AABB_face_graph_triangle_primitive; using TMF_traits = AABB_traits; @@ -1920,198 +2001,221 @@ double bounded_error_one_sided_Hausdorff_impl( std::vector tm1_parts; std::vector tm1_trees; std::vector tm_wrappers; - #endif // defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) +#endif // defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) - #ifdef CGAL_HAUSDORFF_DEBUG +#ifdef CGAL_HAUSDORFF_DEBUG using Timer = CGAL::Real_timer; Timer timer; std::cout.precision(17); - #endif +#endif TM1_tree tm1_tree; TM2_tree tm2_tree; - FT infinity_value = -FT(1); - #if defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) && defined(USE_PARALLEL_BEHD) + FT infinity_value = FT(-1); + +#if defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) && defined(USE_PARALLEL_BEHD) // TODO: add to NP! const int nb_cores = 4; const std::size_t min_nb_faces_to_split = 100; // TODO: increase this number? - #ifdef CGAL_HAUSDORFF_DEBUG + #ifdef CGAL_HAUSDORFF_DEBUG std::cout << "* num cores: " << nb_cores << std::endl; - #endif - - if ( - boost::is_convertible::value && - nb_cores > 1 && faces(tm1).size() >= min_nb_faces_to_split) { + #endif + if(boost::is_convertible::value && + nb_cores > 1 && + faces(tm1).size() >= min_nb_faces_to_split) + { // (0) -- Compute infinity value. - #ifdef CGAL_HAUSDORFF_DEBUG + #ifdef CGAL_HAUSDORFF_DEBUG timer.reset(); timer.start(); - #endif - const auto bbox1 = bbox(tm1); - const auto bbox2 = bbox(tm2); - const auto bb = bbox1 + bbox2; - const FT sq_dist = CGAL::squared_distance( - Point_3(bb.xmin(), bb.ymin(), bb.zmin()), - Point_3(bb.xmax(), bb.ymax(), bb.zmax())); - infinity_value = CGAL::approximate_sqrt(sq_dist) * FT(2); + #endif + + const Bbox_3 bbox1 = bbox(tm1); + const Bbox_3 bbox2 = bbox(tm2); + const Bbox_3 bb = bbox1 + bbox2; + const FT sq_dist = square(bb.xmax() - bb.xmin()) + + square(bb.ymax() - bb.ymin()) + + square(bb.zmax() - bb.zmin()); + infinity_value = FT(4) * sq_dist; CGAL_assertion(infinity_value >= FT(0)); - #ifdef CGAL_HAUSDORFF_DEBUG + + #ifdef CGAL_HAUSDORFF_DEBUG timer.stop(); const double time0 = timer.time(); std::cout << "- computing infinity (sec.): " << time0 << std::endl; - #endif + #endif // (1) -- Create partition of tm1. - #ifdef CGAL_HAUSDORFF_DEBUG + #ifdef CGAL_HAUSDORFF_DEBUG timer.reset(); timer.start(); - #endif + #endif + using Face_property_tag = CGAL::dynamic_face_property_t; auto face_pid_map = get(Face_property_tag(), tm1); - CGAL::METIS::partition_graph( - tm1, nb_cores, CGAL::parameters:: - face_partition_id_map(face_pid_map)); - #ifdef CGAL_HAUSDORFF_DEBUG + CGAL::METIS::partition_graph(tm1, nb_cores, CGAL::parameters::face_partition_id_map(face_pid_map)); + + #ifdef CGAL_HAUSDORFF_DEBUG timer.stop(); const double time1 = timer.time(); std::cout << "- computing partition time (sec.): " << time1 << std::endl; - #endif + #endif // (2) -- Create a filtered face graph for each part. - #ifdef CGAL_HAUSDORFF_DEBUG + #ifdef CGAL_HAUSDORFF_DEBUG timer.reset(); timer.start(); - #endif + #endif + tm1_parts.reserve(nb_cores); - for (int i = 0; i < nb_cores; ++i) { + for(int i = 0; i < nb_cores; ++i) + { tm1_parts.emplace_back(tm1, i, face_pid_map); // TODO: why is it triggered sometimes? // CGAL_assertion(tm1_parts.back().is_selection_valid()); - #ifdef CGAL_HAUSDORFF_DEBUG + #ifdef CGAL_HAUSDORFF_DEBUG std::cout << "- part " << i << " size: " << tm1_parts.back().number_of_faces() << std::endl; - #endif + #endif } + CGAL_assertion(tm1_parts.size() == nb_cores); - #ifdef CGAL_HAUSDORFF_DEBUG + #ifdef CGAL_HAUSDORFF_DEBUG timer.stop(); const double time2 = timer.time(); std::cout << "- creating graphs time (sec.): " << time2 << std::endl; - #endif + #endif // (3) -- Preprocess all input data. - #ifdef CGAL_HAUSDORFF_DEBUG + #ifdef CGAL_HAUSDORFF_DEBUG timer.reset(); timer.start(); - #endif + #endif + tm1_trees.resize(tm1_parts.size()); tm_wrappers.reserve(tm1_parts.size() + 1); - for (std::size_t i = 0; i < tm1_parts.size(); ++i) { + for(std::size_t i = 0; i < tm1_parts.size(); ++i) tm_wrappers.push_back(TM1_wrapper(tm1_parts[i], vpm1, false, tm1_trees[i])); - } + tm_wrappers.push_back(TM2_wrapper(tm2, vpm2, true, tm2_tree)); CGAL_assertion(tm_wrappers.size() == tm1_parts.size() + 1); + Bounded_error_preprocessing bep(tm_wrappers); tbb::parallel_reduce(tbb::blocked_range(0, tm_wrappers.size()), bep); - #ifdef CGAL_HAUSDORFF_DEBUG + + #ifdef CGAL_HAUSDORFF_DEBUG timer.stop(); const double time3 = timer.time(); std::cout << "- creating trees time (sec.) " << time3 << std::endl; - #endif + #endif - // Final timing. - #ifdef CGAL_HAUSDORFF_DEBUG - std::cout << "* preprocessing parallel time (sec.) " << - time0 + time1 + time2 + time3 << std::endl; - #endif + #ifdef CGAL_HAUSDORFF_DEBUG + // Final timing + std::cout << "* preprocessing parallel time (sec.) " << time0 + time1 + time2 + time3 << std::endl; + #endif } else // sequential version - #endif // defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) +#endif // defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) { - #ifdef CGAL_HAUSDORFF_DEBUG +#ifdef CGAL_HAUSDORFF_DEBUG timer.reset(); timer.start(); std::cout << "* preprocessing sequential version " << std::endl; - #endif +#endif + bool rebuild = false; std::vector tm1_only; std::vector tm2_only; - std::tie(infinity_value, rebuild) = preprocess_bounded_error_Hausdorff_impl( - tm1, tm2, compare_meshes, vpm1, vpm2, true, np1, np2, - tm1_tree, tm2_tree, tm1_only, tm2_only); + std::tie(infinity_value, rebuild) = + preprocess_bounded_error_squared_Hausdorff_distance_impl( + tm1, tm2, compare_meshes, vpm1, vpm2, true /*is_one_sided_distance*/, np1, np2, + tm1_tree, tm2_tree, tm1_only, tm2_only); + CGAL_assertion(!rebuild); - if (infinity_value >= FT(0)) { + + if(infinity_value >= FT(0)) + { tm1_tree.build(); tm2_tree.build(); tm1_tree.do_not_accelerate_distance_queries(); tm2_tree.accelerate_distance_queries(); } - #ifdef CGAL_HAUSDORFF_DEBUG + +#ifdef CGAL_HAUSDORFF_DEBUG timer.stop(); std::cout << "* preprocessing sequential time (sec.) " << timer.time() << std::endl; - #endif +#endif } - #ifdef CGAL_HAUSDORFF_DEBUG +#ifdef CGAL_HAUSDORFF_DEBUG std::cout << "* infinity_value: " << infinity_value << std::endl; - #endif - if (infinity_value < FT(0)) { - #ifdef CGAL_HAUSDORFF_DEBUG +#endif + + if(is_negative(infinity_value)) + { +#ifdef CGAL_HAUSDORFF_DEBUG std::cout << "* culling rate: 100%" << std::endl; - #endif +#endif const auto face1 = *(faces(tm1).begin()); const auto face2 = *(faces(tm2).begin()); *out++ = std::make_pair(face1, face2); *out++ = std::make_pair(face1, face2); - return 0.0; // TM1 is part of TM2 so the distance is zero + return 0.; // TM1 is part of TM2 so the distance is zero } - CGAL_assertion(error_bound >= FT(0)); - CGAL_assertion(infinity_value > FT(0)); - const FT initial_bound = error_bound; - std::atomic hdist; - #ifdef CGAL_HAUSDORFF_DEBUG + CGAL_assertion(infinity_value > FT(0)); + CGAL_assertion(sq_error_bound >= FT(0)); + + const FT sq_initial_bound = sq_error_bound; + FT sq_hdist = FT(-1); + +#ifdef CGAL_HAUSDORFF_DEBUG timer.reset(); timer.start(); - #endif +#endif - #if defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) && defined(USE_PARALLEL_BEHD) - if ( - boost::is_convertible::value && - nb_cores > 1 && faces(tm1).size() >= min_nb_faces_to_split) { - - #ifdef CGAL_HAUSDORFF_DEBUG - std::cout << "* executing parallel version " << std::endl; - #endif - Bounded_error_distance_computation bedc( - tm1_parts, tm2, error_bound, vpm1, vpm2, - infinity_value, initial_bound, tm1_trees, tm2_tree); - tbb::parallel_reduce(tbb::blocked_range(0, tm1_parts.size()), bedc); - hdist = bedc.distance; - - } else // sequential version - #endif // defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) +#if defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) && defined(USE_PARALLEL_BEHD) + if(boost::is_convertible::value && + nb_cores > 1 && + faces(tm1).size() >= min_nb_faces_to_split) { - #ifdef CGAL_HAUSDORFF_DEBUG +#ifdef CGAL_HAUSDORFF_DEBUG + std::cout << "* executing parallel version " << std::endl; +#endif + + using Comp = Bounded_error_squared_distance_computation; + + Comp bedc(tm1_parts, tm2, sq_error_bound, vpm1, vpm2, + infinity_value, sq_initial_bound, tm1_trees, tm2_tree); + tbb::parallel_reduce(tbb::blocked_range(0, tm1_parts.size()), bedc); + + sq_hdist = bedc.sq_hdist; + } + else // sequential version +#endif // defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) + { +#ifdef CGAL_HAUSDORFF_DEBUG std::cout << "* executing sequential version " << std::endl; - #endif - hdist = bounded_error_Hausdorff_impl( - tm1, tm2, error_bound, vpm1, vpm2, - infinity_value, initial_bound, distance_bound, - tm1_tree, tm2_tree, out); +#endif + sq_hdist = bounded_error_squared_Hausdorff_distance_impl( + tm1, tm2, vpm1, vpm2, tm1_tree, tm2_tree, + sq_error_bound, sq_initial_bound, sq_distance_bound, infinity_value, out); } - #ifdef CGAL_HAUSDORFF_DEBUG +#ifdef CGAL_HAUSDORFF_DEBUG timer.stop(); + std::cout << "* squared distance " << sq_hdist << std::endl; + std::cout << "* distance " << approximate_sqrt(sq_hdist) << std::endl; std::cout << "* computation time (sec.) " << timer.time() << std::endl; - #endif +#endif - CGAL_assertion(hdist >= 0.0); - return hdist; + CGAL_postcondition(sq_hdist >= FT(0)); + + return sq_hdist; } -template< class Concurrency_tag, +template -double bounded_error_symmetric_Hausdorff_impl( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const typename Kernel::FT error_bound, - const typename Kernel::FT distance_bound, - const bool compare_meshes, - const VPM1& vpm1, - const VPM2& vpm2, - const NamedParameters1& np1, - const NamedParameters2& np2, - OutputIterator1& out1, - OutputIterator2& out2) + class OutputIterator2> +typename Kernel::FT +bounded_error_squared_symmetric_Hausdorff_distance_impl(const TriangleMesh1& tm1, + const TriangleMesh2& tm2, + const typename Kernel::FT sq_error_bound, + const typename Kernel::FT sq_distance_bound, + const bool compare_meshes, + const VPM1 vpm1, + const VPM2 vpm2, + const NamedParameters1& np1, + const NamedParameters2& np2, + OutputIterator1& out1, + OutputIterator2& out2) { - #if !defined(CGAL_LINKED_WITH_TBB) || !defined(CGAL_METIS_ENABLED) - CGAL_static_assertion_msg( - !(boost::is_convertible::value), - "Parallel_tag is enabled but at least TBB or METIS is unavailable."); - #endif +#if !defined(CGAL_LINKED_WITH_TBB) || !defined(CGAL_METIS_ENABLED) + CGAL_static_assertion_msg(!(boost::is_convertible::value), + "Parallel_tag is enabled but at least TBB or METIS is unavailable."); +#endif // Optimized version. // -- We compare meshes only if it is required. @@ -2161,44 +2264,48 @@ double bounded_error_symmetric_Hausdorff_impl( std::vector tm1_only; std::vector tm2_only; + FT infinity_value = FT(-1); + // All trees below are built and/or accelerated lazily. TM1_tree tm1_tree; TM2_tree tm2_tree; - FT infinity_value = -FT(1); bool rebuild = false; - std::tie(infinity_value, rebuild) = preprocess_bounded_error_Hausdorff_impl( - tm1, tm2, compare_meshes, vpm1, vpm2, false, np1, np2, + std::tie(infinity_value, rebuild) = preprocess_bounded_error_squared_Hausdorff_distance_impl( + tm1, tm2, compare_meshes, vpm1, vpm2, false /*is_one_sided_distance*/, np1, np2, tm1_tree, tm2_tree, tm1_only, tm2_only); - if (infinity_value < FT(0)) { - #ifdef CGAL_HAUSDORFF_DEBUG + if(is_negative(infinity_value)) + { +#ifdef CGAL_HAUSDORFF_DEBUG std::cout.precision(17); std::cout << "* culling rate: 100%" << std::endl; - #endif +#endif const auto face1 = *(faces(tm1).begin()); const auto face2 = *(faces(tm2).begin()); *out1++ = std::make_pair(face1, face2); *out1++ = std::make_pair(face1, face2); *out2++ = std::make_pair(face2, face1); *out2++ = std::make_pair(face2, face1); - return 0.0; // TM1 and TM2 are equal so the distance is zero + + return 0.; // TM1 and TM2 are equal so the distance is zero } - CGAL_assertion(infinity_value > FT(0)); + CGAL_assertion(is_positive(infinity_value)); // Compute the first one-sided distance. - FT initial_bound = error_bound; - double dista = CGAL::to_double(error_bound); + FT sq_initial_bound = sq_error_bound; + FT sq_dista = sq_error_bound; - if (!compare_meshes || (compare_meshes && tm1_only.size() > 0)) { - dista = bounded_error_Hausdorff_impl( - tm1, tm2, error_bound, vpm1, vpm2, - infinity_value, initial_bound, distance_bound, - tm1_tree, tm2_tree, out1); + if(!compare_meshes || (compare_meshes && tm1_only.size() > 0)) + { + sq_dista = bounded_error_squared_Hausdorff_distance_impl( + tm1, tm2, vpm1, vpm2, tm1_tree, tm2_tree, + sq_error_bound, sq_initial_bound, sq_distance_bound, infinity_value, out1); } // In case this is true, we need to rebuild trees in order to accelerate // computations for the second call. - if (rebuild) { + if(rebuild) + { CGAL_assertion(compare_meshes); tm1_tree.clear(); tm2_tree.clear(); @@ -2209,87 +2316,78 @@ double bounded_error_symmetric_Hausdorff_impl( } // Compute the second one-sided distance. - initial_bound = static_cast(dista); // TODO: we should better test this optimization! - double distb = CGAL::to_double(error_bound); + sq_initial_bound = sq_dista; // @todo we should better test this optimization! + FT sq_distb = sq_error_bound; - if (!compare_meshes || (compare_meshes && tm2_only.size() > 0)) { - distb = bounded_error_Hausdorff_impl( - tm2, tm1, error_bound, vpm2, vpm1, - infinity_value, initial_bound, distance_bound, - tm2_tree, tm1_tree, out2); + if(!compare_meshes || (compare_meshes && tm2_only.size() > 0)) + { + sq_distb = bounded_error_squared_Hausdorff_distance_impl( + tm2, tm1, vpm2, vpm1, tm2_tree, tm1_tree, + sq_error_bound, sq_initial_bound, sq_distance_bound, infinity_value, out2); } - // Return the maximum. - return (CGAL::max)(dista, distb); + return (CGAL::max)(sq_dista, sq_distb); } template -typename Kernel::FT recursive_hausdorff_subdivision( - const typename Kernel::Point_3& v0, - const typename Kernel::Point_3& v1, - const typename Kernel::Point_3& v2, - const TM2_tree& tm2_tree, - const typename Kernel::FT squared_error_bound) +typename Kernel::FT recursive_hausdorff_subdivision(const typename Kernel::Point_3& p0, + const typename Kernel::Point_3& p1, + const typename Kernel::Point_3& p2, + const TM2_tree& tm2_tree, + const typename Kernel::FT sq_error_bound) { - // If all edge lengths of the triangle are below the error_bound, - // return maximum of the distances of the three points to TM2 (via TM2_tree). - const auto max_squared_edge_length = - (CGAL::max)( - (CGAL::max)( - CGAL::squared_distance(v0, v1), - CGAL::squared_distance(v0, v2)), - CGAL::squared_distance(v1, v2)); + using FT = typename Kernel::FT; + using Point_3 = typename Kernel::Point_3; - if (max_squared_edge_length < squared_error_bound) { - return (CGAL::max)( - (CGAL::max)( - CGAL::squared_distance(v0, tm2_tree.closest_point(v0)), - CGAL::squared_distance(v1, tm2_tree.closest_point(v1))), - CGAL::squared_distance(v2, tm2_tree.closest_point(v2))); + // If all edge lengths of the triangle are below the error bound, + // return the maximum of the distances of the three points to TM2 (via TM2_tree). + const FT max_squared_edge_length = (CGAL::max)((CGAL::max)(CGAL::squared_distance(p0, p1), + CGAL::squared_distance(p0, p2)), + CGAL::squared_distance(p1, p2)); + + if(max_squared_edge_length < sq_error_bound) + { + return (CGAL::max)((CGAL::max)(CGAL::squared_distance(p0, tm2_tree.closest_point(p0)), + CGAL::squared_distance(p1, tm2_tree.closest_point(p1))), + CGAL::squared_distance(p2, tm2_tree.closest_point(p2))); } // Else subdivide the triangle and proceed recursively. - const auto v01 = midpoint(v0, v1); - const auto v02 = midpoint(v0, v2); - const auto v12 = midpoint(v1, v2); + const Point_3 p01 = midpoint(p0, p1); + const Point_3 p02 = midpoint(p0, p2); + const Point_3 p12 = midpoint(p1, p2); return (CGAL::max)( - (CGAL::max)( - recursive_hausdorff_subdivision(v0, v01, v02, tm2_tree, squared_error_bound), - recursive_hausdorff_subdivision(v1, v01, v12, tm2_tree, squared_error_bound)), - (CGAL::max)( - recursive_hausdorff_subdivision(v2 , v02, v12, tm2_tree, squared_error_bound), - recursive_hausdorff_subdivision(v01, v02, v12, tm2_tree, squared_error_bound))); + (CGAL::max)(recursive_hausdorff_subdivision( p0, p01, p02, tm2_tree, sq_error_bound), + recursive_hausdorff_subdivision( p1, p01, p12, tm2_tree, sq_error_bound)), + (CGAL::max)(recursive_hausdorff_subdivision( p2, p02, p12, tm2_tree, sq_error_bound), + recursive_hausdorff_subdivision(p01, p02, p12, tm2_tree, sq_error_bound))); } -template< class Concurrency_tag, +template -double bounded_error_Hausdorff_naive_impl( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const typename Kernel::FT error_bound, - const VPM1& vpm1, - const VPM2& vpm2) + class VPM2> +typename Kernel::FT +bounded_error_squared_Hausdorff_distance_naive_impl(const TriangleMesh1& tm1, + const TriangleMesh2& tm2, + const typename Kernel::FT sq_error_bound, + const VPM1 vpm1, + const VPM2 vpm2) { - using FT = typename Kernel::FT; - using Point_3 = typename Kernel::Point_3; + using FT = typename Kernel::FT; + using Point_3 = typename Kernel::Point_3; using Triangle_3 = typename Kernel::Triangle_3; using TM2_primitive = AABB_face_graph_triangle_primitive; - using TM2_traits = AABB_traits; - using TM2_tree = AABB_tree; + using TM2_traits = AABB_traits; + using TM2_tree = AABB_tree; using TM1_face_to_triangle_map = Triangle_from_face_descriptor_map; - // Initially, no lower bound is known. - FT squared_lower_bound = FT(0); - - // Work with squares in the following, only draw sqrt at the very end. - const FT squared_error_bound = error_bound * error_bound; + FT sq_lower_bound = FT(0); // Build an AABB tree on tm2. TM2_tree tm2_tree(faces(tm2).begin(), faces(tm2).end(), tm2, vpm2); @@ -2300,29 +2398,26 @@ double bounded_error_Hausdorff_naive_impl( const TM1_face_to_triangle_map face_to_triangle_map(&tm1, vpm1); // Iterate over the faces of TM1. - for (const auto& face : faces(tm1)) { - + for(const auto& face : faces(tm1)) + { // Get the vertices of the face and pass them on to a recursive method. const Triangle_3 triangle = get(face_to_triangle_map, face); - const Point_3 v0 = triangle.vertex(0); - const Point_3 v1 = triangle.vertex(1); - const Point_3 v2 = triangle.vertex(2); + const Point_3& v0 = triangle.vertex(0); + const Point_3& v1 = triangle.vertex(1); + const Point_3& v2 = triangle.vertex(2); // Recursively process the current triangle to obtain a lower bound on its Hausdorff distance. - const FT triangle_bound = recursive_hausdorff_subdivision( - v0, v1, v2, tm2_tree, squared_error_bound); + const FT sq_triangle_bound = recursive_hausdorff_subdivision(v0, v1, v2, tm2_tree, sq_error_bound); // Store the largest lower bound. - if (triangle_bound > squared_lower_bound) { - squared_lower_bound = triangle_bound; - } + if(sq_triangle_bound > sq_lower_bound) + sq_lower_bound = sq_triangle_bound; } - // Return linear interpolation between found upper and lower bound. - return CGAL::sqrt(CGAL::to_double(squared_lower_bound)); + return to_double(approximate_sqrt(sq_lower_bound)); } -} // end of namespace internal +} // namespace internal /** * \ingroup PMP_distance_grp @@ -2351,91 +2446,62 @@ double bounded_error_Hausdorff_naive_impl( * * \cgalNamedParamsBegin * \cgalParamNBegin{vertex_point_map} - * \cgalParamDescription{a property map associating points to the vertices of `tm1` and `tm2` (`np1` and `np2`, respectively)} + * \cgalParamDescription{a property map associating points to the vertices of `tmX`} * \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` * as key type and `%Point_3` as value type} - * \cgalParamDefault{`boost::get(CGAL::vertex_point, tm)`} + * \cgalParamDefault{`boost::get(CGAL::vertex_point, tmX)`} * \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t` * must be available in `TriangleMeshX`.} * \cgalParamNEnd * \cgalParamNBegin{match_faces} - * \cgalParamDescription{a boolean tag that turns on the preprocessing step that filters out all faces, + * \cgalParamDescription{a boolean tag that turns on the preprocessing step that filters out all faces * which belong to both meshes and hence do not contribute to the final distance} * \cgalParamType{Boolean} * \cgalParamDefault{true} - * \cgalParamExtra{Both `np1` and `np2` must have this tag true in order to activate this preprocessing.} + * \cgalParamExtra{Both `np1` and `np2` must have this tag set to `true` in order to activate this preprocessing.} * \cgalParamNEnd * \cgalNamedParamsEnd * * @return the one-sided Hausdorff distance */ -template< class Concurrency_tag, +template -double bounded_error_Hausdorff_distance( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const double error_bound, - const NamedParameters1& np1, - const NamedParameters2& np2) + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters> +double bounded_error_Hausdorff_distance(const TriangleMesh1& tm1, + const TriangleMesh2& tm2, + const double error_bound = 0.0001, + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values()) { - CGAL_assertion_code( - const bool is_triangle = is_triangle_mesh(tm1) && is_triangle_mesh(tm2)); - CGAL_assertion_msg(is_triangle, - "Both meshes must be triangulated to compute this distance!"); - using Traits = typename GetGeomTraits::type; using FT = typename Traits::FT; - const auto vpm1 = parameters::choose_parameter( - parameters::get_parameter(np1, internal_np::vertex_point), - get_const_property_map(vertex_point, tm1)); - const auto vpm2 = parameters::choose_parameter( - parameters::get_parameter(np2, internal_np::vertex_point), - get_const_property_map(vertex_point, tm2)); + using parameters::choose_parameter; + using parameters::get_parameter; - const bool match_faces1 = parameters::choose_parameter( - parameters::get_parameter(np1, internal_np::match_faces), true); - const bool match_faces2 = parameters::choose_parameter( - parameters::get_parameter(np2, internal_np::match_faces), true); + CGAL_precondition(is_triangle_mesh(tm1) && is_triangle_mesh(tm2)); + + const auto vpm1 = choose_parameter(get_parameter(np1, internal_np::vertex_point), + get_const_property_map(vertex_point, tm1)); + const auto vpm2 = choose_parameter(get_parameter(np2, internal_np::vertex_point), + get_const_property_map(vertex_point, tm2)); + + const bool match_faces1 = choose_parameter(get_parameter(np1, internal_np::match_faces), true); + const bool match_faces2 = choose_parameter(get_parameter(np2, internal_np::match_faces), true); const bool match_faces = match_faces1 && match_faces2; - auto out = parameters::choose_parameter( - parameters::get_parameter(np1, internal_np::output_iterator), - CGAL::Emptyset_iterator()); + auto out = choose_parameter(get_parameter(np1, internal_np::output_iterator), + CGAL::Emptyset_iterator()); - CGAL_precondition(error_bound >= 0.0); - const FT error_threshold = static_cast(error_bound); - return internal::bounded_error_one_sided_Hausdorff_impl( - tm1, tm2, error_threshold, -FT(1), match_faces, vpm1, vpm2, np1, np2, out); -} + CGAL_precondition(error_bound >= 0.); + const FT sq_error_bound = square(FT(error_bound)); -template< class Concurrency_tag, - class TriangleMesh1, - class TriangleMesh2, - class NamedParameters1 > -double bounded_error_Hausdorff_distance( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const double error_bound, - const NamedParameters1& np1) -{ - return bounded_error_Hausdorff_distance( - tm1, tm2, error_bound, np1, parameters::all_default()); -} + const FT sq_hdist = internal::bounded_error_squared_one_sided_Hausdorff_distance_impl( + tm1, tm2, sq_error_bound, FT(-1) /*distance threshold*/, match_faces, vpm1, vpm2, np1, np2, out); -template< class Concurrency_tag, - class TriangleMesh1, - class TriangleMesh2 > -double bounded_error_Hausdorff_distance( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const double error_bound = 0.0001) -{ - return bounded_error_Hausdorff_distance( - tm1, tm2, error_bound, parameters::all_default()); + return to_double(approximate_sqrt(sq_hdist)); } /** @@ -2449,82 +2515,49 @@ double bounded_error_Hausdorff_distance( * @return the symmetric Hausdorff distance * @see `CGAL::Polygon_mesh_processing::bounded_error_Hausdorff_distance()` */ -template< class Concurrency_tag, +template -double bounded_error_symmetric_Hausdorff_distance( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const double error_bound, - const NamedParameters1& np1, - const NamedParameters2& np2) + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters> +double bounded_error_symmetric_Hausdorff_distance(const TriangleMesh1& tm1, + const TriangleMesh2& tm2, + const double error_bound, + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values()) { - CGAL_assertion_code( - const bool is_triangle = is_triangle_mesh(tm1) && is_triangle_mesh(tm2)); - CGAL_assertion_msg(is_triangle, - "Both meshes must be triangulated to compute this distance!"); - using Traits = typename GetGeomTraits::type; using FT = typename Traits::FT; - const auto vpm1 = parameters::choose_parameter( - parameters::get_parameter(np1, internal_np::vertex_point), - get_const_property_map(vertex_point, tm1)); - const auto vpm2 = parameters::choose_parameter( - parameters::get_parameter(np2, internal_np::vertex_point), - get_const_property_map(vertex_point, tm2)); + using parameters::choose_parameter; + using parameters::get_parameter; - const bool match_faces1 = parameters::choose_parameter( - parameters::get_parameter(np1, internal_np::match_faces), true); - const bool match_faces2 = parameters::choose_parameter( - parameters::get_parameter(np2, internal_np::match_faces), true); + CGAL_precondition(is_triangle_mesh(tm1) && is_triangle_mesh(tm2)); + + const auto vpm1 = choose_parameter(get_parameter(np1, internal_np::vertex_point), + get_const_property_map(vertex_point, tm1)); + const auto vpm2 = choose_parameter(get_parameter(np2, internal_np::vertex_point), + get_const_property_map(vertex_point, tm2)); + + const bool match_faces1 = choose_parameter(get_parameter(np1, internal_np::match_faces), true); + const bool match_faces2 = choose_parameter(get_parameter(np2, internal_np::match_faces), true); const bool match_faces = match_faces1 && match_faces2; // TODO: should we return a union of these realizing triangles? - auto out1 = parameters::choose_parameter( - parameters::get_parameter(np1, internal_np::output_iterator), - CGAL::Emptyset_iterator()); - auto out2 = parameters::choose_parameter( - parameters::get_parameter(np2, internal_np::output_iterator), - CGAL::Emptyset_iterator()); + auto out1 = choose_parameter(get_parameter(np1, internal_np::output_iterator), + CGAL::Emptyset_iterator()); + auto out2 = choose_parameter(get_parameter(np2, internal_np::output_iterator), + CGAL::Emptyset_iterator()); - CGAL_precondition(error_bound >= 0.0); - const FT error_threshold = static_cast(error_bound); - return internal::bounded_error_symmetric_Hausdorff_impl( - tm1, tm2, error_threshold, -FT(1), match_faces, vpm1, vpm2, np1, np2, out1, out2); + CGAL_precondition(error_bound >= 0.); + const FT sq_error_bound = square(FT(error_bound)); + + const FT sq_hdist = internal::bounded_error_squared_symmetric_Hausdorff_distance_impl( + tm1, tm2, sq_error_bound, FT(-1) /*distance_threshold*/, match_faces, vpm1, vpm2, np1, np2, out1, out2); + + return to_double(approximate_sqrt(sq_hdist)); } -template< class Concurrency_tag, - class TriangleMesh1, - class TriangleMesh2, - class NamedParameters1 > -double bounded_error_symmetric_Hausdorff_distance( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const double error_bound, - const NamedParameters1& np1) -{ - return bounded_error_symmetric_Hausdorff_distance( - tm1, tm2, error_bound, np1, parameters::all_default()); -} - -template< class Concurrency_tag, - class TriangleMesh1, - class TriangleMesh2> -double bounded_error_symmetric_Hausdorff_distance( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const double error_bound = 0.0001) -{ - return bounded_error_symmetric_Hausdorff_distance( - tm1, tm2, error_bound, parameters::all_default()); -} - -// TODO: Find better name! -// TODO: Should we use one-sided or symmetric distance here? - /** * \ingroup PMP_distance_grp * returns `true` if the Hausdorff distance between two meshes is larger than @@ -2532,7 +2565,7 @@ double bounded_error_symmetric_Hausdorff_distance( * to compute the proximity of the meshes is the bounded-error Hausdorff distance. * * Instead of computing the full distance and checking it against the user-provided - * value, this function early quits in case certain criteria show that the meshes + * value, this function returns early if certain criteria show that the meshes * do not satisfy the provided `distance_bound`. * * \cgalNamedParamsBegin @@ -2545,158 +2578,105 @@ double bounded_error_symmetric_Hausdorff_distance( * \cgalNamedParamsEnd * * @return Boolean `true` or `false` -* @see `CGAL::Polygon_mesh_processing::bounded_error_Hausdorff_distance()` + * + * @see `CGAL::Polygon_mesh_processing::bounded_error_Hausdorff_distance()` */ template< class Concurrency_tag, class TriangleMesh1, class TriangleMesh2, - class NamedParameters1, - class NamedParameters2 > -bool is_Hausdorff_distance_larger( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const double distance_bound, - const double error_bound, - const NamedParameters1& np1, - const NamedParameters2& np2) + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters> +bool is_Hausdorff_distance_larger(const TriangleMesh1& tm1, + const TriangleMesh2& tm2, + const double distance_bound, + const double error_bound, + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values()) { - CGAL_assertion_code( - const bool is_triangle = is_triangle_mesh(tm1) && is_triangle_mesh(tm2)); - CGAL_assertion_msg(is_triangle, - "Both meshes must be triangulated in order to be compared!"); - - using Traits = typename GetGeomTraits::type; - using FT = typename Traits::FT; - - const auto vpm1 = parameters::choose_parameter( - parameters::get_parameter(np1, internal_np::vertex_point), - get_const_property_map(vertex_point, tm1)); - const auto vpm2 = parameters::choose_parameter( - parameters::get_parameter(np2, internal_np::vertex_point), - get_const_property_map(vertex_point, tm2)); - - const bool match_faces1 = parameters::choose_parameter( - parameters::get_parameter(np1, internal_np::match_faces), true); - const bool match_faces2 = parameters::choose_parameter( - parameters::get_parameter(np2, internal_np::match_faces), true); - const bool match_faces = match_faces1 && match_faces2; - - const bool use_one_sided = parameters::choose_parameter( - parameters::get_parameter(np1, internal_np::use_one_sided_hausdorff), true); - CGAL_precondition(error_bound >= 0.0); - const FT error_threshold = static_cast(error_bound); - CGAL_precondition(distance_bound >= 0.0); - const FT distance_threshold = static_cast(distance_bound); - auto stub = CGAL::Emptyset_iterator(); - - double hdist = -1.0; - if (use_one_sided) { - hdist = internal::bounded_error_one_sided_Hausdorff_impl( - tm1, tm2, error_threshold, distance_threshold, match_faces, vpm1, vpm2, np1, np2, stub); - } else { - hdist = internal::bounded_error_symmetric_Hausdorff_impl( - tm1, tm2, error_threshold, distance_threshold, match_faces, vpm1, vpm2, np1, np2, stub, stub); - } - CGAL_assertion(hdist >= 0.0); - - #ifdef CGAL_HAUSDORFF_DEBUG - std::cout.precision(17); - std::cout << "- fin distance: " << hdist << std::endl; - std::cout << "- max distance: " << distance_bound << std::endl; - #endif - return hdist > distance_bound; -} - -template< class Concurrency_tag, - class TriangleMesh1, - class TriangleMesh2, - class NamedParameters1 > -double is_Hausdorff_distance_larger( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const double max_distance, - const double error_bound, - const NamedParameters1& np1) -{ - return is_Hausdorff_distance_larger( - tm1, tm2, max_distance, error_bound, np1, parameters::all_default()); -} - -template< class Concurrency_tag, - class TriangleMesh1, - class TriangleMesh2 > -double is_Hausdorff_distance_larger( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const double max_distance = 1.0, - const double error_bound = 0.0001) -{ - return is_Hausdorff_distance_larger( - tm1, tm2, max_distance, error_bound, parameters::all_default()); -} - -// Implementation of the naive Bounded Error Hausdorff distance. -template< class Concurrency_tag, - class TriangleMesh1, - class TriangleMesh2, - class NamedParameters1, - class NamedParameters2 > -double bounded_error_Hausdorff_distance_naive( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const double error_bound, - const NamedParameters1& np1, - const NamedParameters2& np2) -{ - CGAL_assertion_code( - const bool is_triangle = is_triangle_mesh(tm1) && is_triangle_mesh(tm2)); - CGAL_assertion_msg(is_triangle, - "Both meshes must be triangulated to compute this distance!"); - using Traits = typename GetGeomTraits::type; using FT = typename Traits::FT; using parameters::choose_parameter; using parameters::get_parameter; - const auto vpm1 = choose_parameter(get_parameter(np1, internal_np::vertex_point), - get_const_property_map(vertex_point, tm1)); - const auto vpm2 = choose_parameter(get_parameter(np2, internal_np::vertex_point), - get_const_property_map(vertex_point, tm2)); + CGAL_precondition(is_triangle_mesh(tm1) && is_triangle_mesh(tm2)); - CGAL_precondition(error_bound >= 0.0); - const FT error_threshold = static_cast(error_bound); - return internal::bounded_error_Hausdorff_naive_impl( - tm1, tm2, error_threshold, vpm1, vpm2); + if(distance_bound <= 0.) + return true; + + const auto vpm1 = choose_parameter(get_parameter(np1, internal_np::vertex_point), + get_const_property_map(vertex_point, tm1)); + const auto vpm2 = choose_parameter(get_parameter(np2, internal_np::vertex_point), + get_const_property_map(vertex_point, tm2)); + + const bool match_faces1 = choose_parameter(get_parameter(np1, internal_np::match_faces), true); + const bool match_faces2 = choose_parameter(get_parameter(np2, internal_np::match_faces), true); + const bool match_faces = match_faces1 && match_faces2; + const bool use_one_sided = choose_parameter(get_parameter(np1, internal_np::use_one_sided_hausdorff), true); + + CGAL_precondition(error_bound >= 0.); + const FT sq_error_bound = square(FT(error_bound)); + CGAL_precondition(distance_bound > 0.); + const FT sq_distance_bound = square(FT(distance_bound)); + + auto stub = CGAL::Emptyset_iterator(); + + FT sq_hdist = FT(-1); + if(use_one_sided) + { + sq_hdist = internal::bounded_error_squared_one_sided_Hausdorff_distance_impl( + tm1, tm2, sq_error_bound, sq_distance_bound, match_faces, vpm1, vpm2, np1, np2, stub); + } + else + { + sq_hdist = internal::bounded_error_squared_symmetric_Hausdorff_distance_impl( + tm1, tm2, sq_error_bound, sq_distance_bound, match_faces, vpm1, vpm2, np1, np2, stub, stub); + } + +#ifdef CGAL_HAUSDORFF_DEBUG + std::cout.precision(17); + std::cout << "- fin distance: " << approximate_sqrt(sq_hdist) << std::endl; + std::cout << "- max distance: " << distance_bound << std::endl; +#endif + + return (sq_hdist > sq_distance_bound); } -template< class Concurrency_tag, +// Implementation of the naive Bounded Error Hausdorff distance. +template -double bounded_error_Hausdorff_distance_naive( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const double error_bound, - const NamedParameters1& np1) + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters> +double bounded_error_Hausdorff_distance_naive(const TriangleMesh1& tm1, + const TriangleMesh2& tm2, + const double error_bound, + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values()) { - return bounded_error_Hausdorff_distance_naive( - tm1, tm2, error_bound, np1, parameters::all_default()); + using Traits = typename GetGeomTraits::type; + using FT = typename Traits::FT; + + using parameters::choose_parameter; + using parameters::get_parameter; + + CGAL_precondition(is_triangle_mesh(tm1) && is_triangle_mesh(tm2)); + + const auto vpm1 = choose_parameter(get_parameter(np1, internal_np::vertex_point), + get_const_property_map(vertex_point, tm1)); + const auto vpm2 = choose_parameter(get_parameter(np2, internal_np::vertex_point), + get_const_property_map(vertex_point, tm2)); + + CGAL_precondition(error_bound >= 0.); + const FT sq_error_bound = square(FT(error_bound)); + + const FT sq_hdist = internal::bounded_error_squared_Hausdorff_distance_naive_impl( + tm1, tm2, sq_error_bound, vpm1, vpm2); + + return to_double(approximate_sqrt(sq_hdist)); } -template< class Concurrency_tag, - class TriangleMesh1, - class TriangleMesh2 > -double bounded_error_Hausdorff_distance_naive( - const TriangleMesh1& tm1, - const TriangleMesh2& tm2, - const double error_bound = 0.0001) -{ - return bounded_error_Hausdorff_distance_naive( - tm1, tm2, error_bound, parameters::all_default()); -} - -} } // end of namespace CGAL::Polygon_mesh_processing - +} // namespace Polygon_mesh_processing +} // namespace CGAL #endif //CGAL_POLYGON_MESH_PROCESSING_DISTANCE_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/extrude.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/extrude.h index 0a375b028a9..58152b0fad2 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/extrude.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/extrude.h @@ -19,17 +19,12 @@ #include #include -#include +#include #include #include #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_PMP_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_PMP_NP_CLASS NamedParameters -#endif - namespace CGAL { namespace Polygon_mesh_processing { namespace extrude_impl{ @@ -163,15 +158,15 @@ template void extrude_mesh(const InputMesh& input, OutputMesh& output, const BottomFunctor& bot, const TopFunctor& top, - const NamedParameters1& np_in, - const NamedParameters2& np_out) + const CGAL_NP_CLASS_1& np_in = parameters::default_values(), + const CGAL_NP_CLASS_2& np_out = parameters::default_values()) { typedef typename boost::graph_traits::vertex_descriptor input_vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor input_halfedge_descriptor; @@ -180,8 +175,8 @@ void extrude_mesh(const InputMesh& input, typedef typename boost::graph_traits::halfedge_descriptor output_halfedge_descriptor; CGAL_assertion(!CGAL::is_closed(input)); - typedef typename GetVertexPointMap < OutputMesh, NamedParameters2>::type VPMap; - typedef typename GetVertexPointMap < InputMesh, NamedParameters1>::const_type IVPMap; + typedef typename GetVertexPointMap < OutputMesh, CGAL_NP_CLASS_2>::type VPMap; + typedef typename GetVertexPointMap < InputMesh, CGAL_NP_CLASS_1>::const_type IVPMap; using parameters::get_parameter; using parameters::choose_parameter; @@ -281,68 +276,29 @@ void extrude_mesh(const InputMesh& input, */ template + class CGAL_NP_TEMPLATE_PARAMETERS_1, + class CGAL_NP_TEMPLATE_PARAMETERS_2> void extrude_mesh(const InputMesh& input, OutputMesh& output, #ifdef DOXYGEN_RUNNING Vector_3 v, #else - typename GetGeomTraits::type::Vector_3 v, + typename GetGeomTraits::type::Vector_3 v, #endif - const NamedParameters1& np_in, - const NamedParameters2& np_out) + const CGAL_NP_CLASS_1& np_in = parameters::default_values(), + const CGAL_NP_CLASS_2& np_out = parameters::default_values()) { - typedef typename GetVertexPointMap < OutputMesh, NamedParameters2>::type VPMap; + typedef typename GetVertexPointMap < OutputMesh, CGAL_NP_CLASS_2>::type VPMap; VPMap output_vpm = parameters::choose_parameter(parameters::get_parameter(np_out, internal_np::vertex_point), get_property_map(vertex_point, output)); extrude_impl::Const_dist_translation< - typename GetVertexPointMap::type, - typename GetGeomTraits::type::Vector_3> bot(output_vpm, + typename GetVertexPointMap::type, + typename GetGeomTraits::type::Vector_3> bot(output_vpm, v); extrude_impl::Identity_functor top; extrude_mesh(input, output, bot,top, np_in, np_out); } -//convenience overload -template -void extrude_mesh(const InputMesh& input, - OutputMesh& output, - Vector dir) -{ - extrude_mesh(input, output, dir, - parameters::all_default(), - parameters::all_default()); -} - -template -void extrude_mesh(const InputMesh& input, - OutputMesh& output, - Vector dir, - const CGAL_PMP_NP_CLASS& np) -{ - extrude_mesh(input, output, dir, - np, - parameters::all_default()); -} - -template -void extrude_mesh(const InputMesh& input, - OutputMesh& output, - const BottomFunctor& bot, - const TopFunctor& top) -{ - extrude_mesh(input, output, bot, top, - parameters::all_default(), parameters::all_default()); -} }} //end CGAL::PMP #endif //CGAL_POLYGON_MESH_PROCESSING_EXTRUDE_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/fair.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/fair.h index b6e9d00b9d0..b7255e6c388 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/fair.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/fair.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -124,10 +124,10 @@ namespace internal { */ template + typename NamedParameters = parameters::Default_named_parameters> bool fair(TriangleMesh& tmesh, const VertexRange& vertices, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::get_parameter; using parameters::choose_parameter; @@ -175,13 +175,6 @@ namespace internal { vpmap_); } - template - bool fair(TriangleMesh& tmesh, const VertexRange& vertices) - { - return fair(tmesh, vertices, - CGAL::Polygon_mesh_processing::parameters::all_default()); - } - } //end namespace Polygon_mesh_processing } //end namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h index b08f8269fca..08e0e6e99a9 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h @@ -15,574 +15,669 @@ #include -// STL includes. -#include -#include - -// CGAL includes. #include #include #include +#include + +#include +#include +#include +#include + +#ifdef CGAL_HAUSDORFF_DEBUG_PP + #ifndef CGAL_HAUSDORFF_DEBUG + #define CGAL_HAUSDORFF_DEBUG + #endif +#endif namespace CGAL { +namespace Polygon_mesh_processing { +namespace internal { - // Bounds. - template< class Kernel, - class Face_handle_1, - class Face_handle_2> - struct Bounds { - using FT = typename Kernel::FT; +template +struct Bounds +{ + using FT = typename Kernel::FT; - FT m_infinity_value = -FT(1); - Bounds(const FT infinity_value) : - m_infinity_value(infinity_value) { } + Bounds(const FT infinity_value) : lower(infinity_value), upper(infinity_value) { } + Bounds(const FT lower, const FT upper) : lower(lower), upper(upper) { } - FT lower = m_infinity_value; - FT upper = m_infinity_value; - // TODO: update - Face_handle_2 tm2_lface = Face_handle_2(); - Face_handle_2 tm2_uface = Face_handle_2(); - std::pair lpair = default_face_pair(); - std::pair upair = default_face_pair(); + FT lower; + FT upper; +}; - const std::pair default_face_pair() const { - return std::make_pair(Face_handle_1(), Face_handle_2()); - } - }; +template +struct Local_bounds + : public Bounds +{ + using Base = Bounds; + using FT = typename Kernel::FT; - // Candidate triangle. - template< class Kernel, - class Face_handle_1, - class Face_handle_2> - struct Candidate_triangle { - using FT = typename Kernel::FT; - using Triangle_3 = typename Kernel::Triangle_3; - using Candidate_bounds = Bounds; + Local_bounds(const FT infinity_value) : Base(infinity_value) { } + Local_bounds(const FT lower, const FT upper) : Base(lower, upper) { } - Candidate_triangle( - const Triangle_3& triangle, const Candidate_bounds& bounds, const Face_handle_1& fh) : - triangle(triangle), bounds(bounds), tm1_face(fh) - { } + Face_handle_2 tm2_lface = Face_handle_2(); + Face_handle_2 tm2_uface = Face_handle_2(); +}; - Triangle_3 triangle; - Candidate_bounds bounds; - Face_handle_1 tm1_face; - // TODO: no need to use bounds.lower? - bool operator>(const Candidate_triangle& other) const { - CGAL_assertion(bounds.upper >= FT(0)); - CGAL_assertion(other.bounds.upper >= FT(0)); - return bounds.upper < other.bounds.upper; - } - bool operator<(const Candidate_triangle& other) const { - CGAL_assertion(bounds.upper >= FT(0)); - CGAL_assertion(other.bounds.upper >= FT(0)); - return bounds.upper > other.bounds.upper; - } - }; +template +struct Global_bounds + : public Bounds +{ + using Base = Bounds; + using FT = typename Kernel::FT; - // Hausdorff primitive traits on TM2. - template< class AABBTraits, - class Query, - class Kernel, - class TriangleMesh1, - class TriangleMesh2, - class VPM2> - class Hausdorff_primitive_traits_tm2 + Global_bounds(const FT infinity_value) : Base(infinity_value) { } + Global_bounds(const FT lower, const FT upper) : Base(lower, upper) { } + + std::pair lpair = default_face_pair(); + std::pair upair = default_face_pair(); + + constexpr std::pair default_face_pair() const { - using FT = typename Kernel::FT; - using Point_3 = typename Kernel::Point_3; - using Vector_3 = typename Kernel::Vector_3; - using Triangle_3 = typename Kernel::Triangle_3; + return std::make_pair(Face_handle_1(), Face_handle_2()); + } +}; - using Project_point_3 = typename Kernel::Construct_projected_point_3; - using Face_handle_1 = typename boost::graph_traits::face_descriptor; - using Face_handle_2 = typename boost::graph_traits::face_descriptor; - using Local_bounds = Bounds; +// Candidate triangle. +template +struct Candidate_triangle +{ + using FT = typename Kernel::FT; + using Triangle_3 = typename Kernel::Triangle_3; + using Candidate_bounds = Local_bounds; - using TM2_face_to_triangle_map = Triangle_from_face_descriptor_map; + Candidate_triangle(const Triangle_3& triangle, + const Candidate_bounds& bounds, + const Face_handle_1 fh) + : triangle(triangle), bounds(bounds), tm1_face(fh) + { } - public: - using Priority = FT; - Hausdorff_primitive_traits_tm2( - const AABBTraits& traits, - const TriangleMesh2& tm2, const VPM2& vpm2, - const Local_bounds& local_bounds, - const FT h_v0_lower_init, - const FT h_v1_lower_init, - const FT h_v2_lower_init) : - m_traits(traits), m_tm2(tm2), m_vpm2(vpm2), - m_face_to_triangle_map(&m_tm2, m_vpm2), - h_local_bounds(local_bounds) { + Triangle_3 triangle; + Candidate_bounds bounds; + Face_handle_1 tm1_face; - // Initialize the global and local bounds with the given values. - h_v0_lower = h_v0_lower_init; - h_v1_lower = h_v1_lower_init; - h_v2_lower = h_v2_lower_init; - } - - // Explore the whole tree, i.e. always enter children if the method - // do_intersect() below determines that it is worthwhile. - bool go_further() const { return true; } - - // Compute the explicit Hausdorff distance to the given primitive. - template - void intersection(const Query& query, const Primitive& primitive) { - - /* Have reached a single triangle, process it. - / Determine the distance according to - / min_{b \in primitive} ( max_{vertex in query} ( d(vertex, b) ) ) - / - / Here, we only have one triangle in B, i.e. tm2. Thus, it suffices to - / compute the distance of the vertices of the query triangles to the - / primitive triangle and use the maximum of the obtained distances. - */ - - // The query object is a triangle from TM1, get its vertices. - const Point_3 v0 = query.vertex(0); - const Point_3 v1 = query.vertex(1); - const Point_3 v2 = query.vertex(2); - - CGAL_assertion(primitive.id() != Face_handle_2()); - const Triangle_3 triangle = get(m_face_to_triangle_map, primitive.id()); - - // Compute distances of the vertices to the primitive triangle in TM2. - const FT v0_dist = CGAL::approximate_sqrt(CGAL::squared_distance(m_project_point(triangle, v0), v0)); - if (v0_dist < h_v0_lower) h_v0_lower = v0_dist; // it is () part of (11) in the paper - - const FT v1_dist = CGAL::approximate_sqrt(CGAL::squared_distance(m_project_point(triangle, v1), v1)); - if (v1_dist < h_v1_lower) h_v1_lower = v1_dist; // it is () part of (11) in the paper - - const FT v2_dist = CGAL::approximate_sqrt(CGAL::squared_distance(m_project_point(triangle, v2), v2)); - if (v2_dist < h_v2_lower) h_v2_lower = v2_dist; // it is () part of (11) in the paper - - // Get the distance as maximizers over all vertices. - const FT distance_lower = (CGAL::max)((CGAL::max)(h_v0_lower, h_v1_lower), h_v2_lower); // it is (11) in the paper - const FT distance_upper = (CGAL::max)((CGAL::max)(v0_dist, v1_dist), v2_dist); // it is () part of (10) in the paper - - CGAL_assertion(distance_lower >= FT(0)); - CGAL_assertion(distance_upper >= FT(0)); - CGAL_assertion(distance_upper >= distance_lower); - - // Since we are at the level of a single triangle in TM2, distance_upper is - // actually the correct Hausdorff distance from the query triangle in - // TM1 to the primitive triangle in TM2. - CGAL_assertion(h_local_bounds.lower >= FT(0)); - if (distance_lower < h_local_bounds.lower) { - h_local_bounds.lower = distance_lower; - h_local_bounds.tm2_lface = primitive.id(); - } - CGAL_assertion(h_local_bounds.upper >= FT(0)); - if (distance_upper < h_local_bounds.upper) { // it is (10) in the paper - h_local_bounds.upper = distance_upper; - h_local_bounds.tm2_uface = primitive.id(); - } - CGAL_assertion(h_local_bounds.upper >= h_local_bounds.lower); - } - - // Determine whether child nodes will still contribute to a smaller - // Hausdorff distance and thus have to be entered. - template - std::pair - do_intersect_with_priority(const Query& query, const Node& node) const { - - // Get the bounding box of the nodes. - const auto bbox = node.bbox(); - - // Get the vertices of the query triangle. - const Point_3 v0 = query.vertex(0); - const Point_3 v1 = query.vertex(1); - const Point_3 v2 = query.vertex(2); - - // Find the axis aligned bbox of the triangle. - const Point_3 tri_min = Point_3( - (CGAL::min)((CGAL::min)(v0.x(), v1.x()), v2.x()), - (CGAL::min)((CGAL::min)(v0.y(), v1.y()), v2.y()), - (CGAL::min)((CGAL::min)(v0.z(), v1.z()), v2.z())); - - const Point_3 tri_max = Point_3( - (CGAL::max)((CGAL::max)(v0.x(), v1.x()), v2.x()), - (CGAL::max)((CGAL::max)(v0.y(), v1.y()), v2.y()), - (CGAL::max)((CGAL::max)(v0.z(), v1.z()), v2.z())); - - // Compute distance of the bounding boxes. - // Distance along the x-axis. - FT dist_x = FT(0); - if (tri_max.x() < (bbox.min)(0)) { - dist_x = (bbox.min)(0) - tri_max.x(); - } else if ((bbox.max)(0) < tri_min.x()) { - dist_x = tri_min.x() - (bbox.max)(0); - } - - // Distance along the y-axis. - FT dist_y = FT(0); - if (tri_max.y() < (bbox.min)(1)) { - dist_y = (bbox.min)(1) - tri_max.y(); - } else if ((bbox.max)(1) < tri_min.y()) { - dist_y = tri_min.y() - (bbox.max)(1); - } - - // Distance along the z-axis. - FT dist_z = FT(0); - if (tri_max.z() < (bbox.min)(2)) { - dist_z = (bbox.min)(2) - tri_max.z(); - } else if ((bbox.max)(2) < tri_min.z()) { - dist_z = tri_min.z() - (bbox.max)(2); - } - - // Lower bound on the distance between the two bounding boxes is given - // as the length of the diagonal of the bounding box between them. - const FT dist = CGAL::approximate_sqrt(Vector_3(dist_x, dist_y, dist_z).squared_length()); - - // See Algorithm 2. - // Check whether investigating the bbox can still lower the Hausdorff - // distance and improve the current global bound. If so, enter the box. - CGAL_assertion(h_local_bounds.lower >= FT(0)); - if (dist <= h_local_bounds.lower) { - return std::make_pair(true , -dist); - } else { - return std::make_pair(false, FT(0)); - } - } - - template - bool do_intersect(const Query& query, const Node& node) const { - return this->do_intersect_with_priority(query, node).first; - } - - // Return the local Hausdorff bounds computed for the passed query triangle. - Local_bounds get_local_bounds() const { - return h_local_bounds; - } - - template - void traverse_group(const Query& query, PrimitiveConstIterator group_begin, PrimitiveConstIterator group_end) { - for (PrimitiveConstIterator it = group_begin; it != group_end; ++it) { - this->intersection(query, *it); - } - } - - private: - // Input data. - const AABBTraits& m_traits; - const TriangleMesh2& m_tm2; - const VPM2& m_vpm2; - const TM2_face_to_triangle_map m_face_to_triangle_map; - - // Local Hausdorff bounds for the query triangle. - Local_bounds h_local_bounds; - FT h_v0_lower, h_v1_lower, h_v2_lower; - Project_point_3 m_project_point; - }; - - // Hausdorff primitive traits on TM1. - template< class AABBTraits, - class Query, - class Kernel, - class TriangleMesh1, - class TriangleMesh2, - class VPM1, - class VPM2> - class Hausdorff_primitive_traits_tm1 + // Comparator for the priority queue. + // Provide std::less for Candidate_triangle to have the largest 'upper' value at the top of the PQ + bool operator<(const Candidate_triangle& other) const { - using FT = typename Kernel::FT; - using Point_3 = typename Kernel::Point_3; - using Vector_3 = typename Kernel::Vector_3; - using Triangle_3 = typename Kernel::Triangle_3; + CGAL_precondition(bounds.upper >= FT(0)); + CGAL_precondition(other.bounds.upper >= FT(0)); - using TM2_primitive = AABB_face_graph_triangle_primitive; - using TM2_traits = AABB_traits; - using TM2_tree = AABB_tree; - using TM2_hd_traits = Hausdorff_primitive_traits_tm2; + return bounds.upper < other.bounds.upper; + } +}; - using TM1_face_to_triangle_map = Triangle_from_face_descriptor_map; +// Hausdorff primitive traits on TM2. +template +class Hausdorff_primitive_traits_tm2 +{ + using FT = typename Kernel::FT; + using Point_3 = typename Kernel::Point_3; + using Vector_3 = typename Kernel::Vector_3; + using Triangle_3 = typename Kernel::Triangle_3; - using Face_handle_1 = typename boost::graph_traits::face_descriptor; - using Face_handle_2 = typename boost::graph_traits::face_descriptor; + using Project_point_3 = typename Kernel::Construct_projected_point_3; + using Face_handle_1 = typename boost::graph_traits::face_descriptor; + using Face_handle_2 = typename boost::graph_traits::face_descriptor; - using Global_bounds = Bounds; - using Candidate = Candidate_triangle; - using Heap_type = std::priority_queue; + using Local_bounds = internal::Local_bounds; + using Global_bounds = internal::Global_bounds; - public: - using Priority = FT; - Hausdorff_primitive_traits_tm1( - const AABBTraits& traits, const TM2_tree& tree, - const TriangleMesh1& tm1, const TriangleMesh2& tm2, - const VPM1& vpm1, const VPM2& vpm2, - const FT error_bound, - const FT infinity_value, - const FT initial_bound, - const FT distance_bound) : - m_traits(traits), - m_tm1(tm1), m_tm2(tm2), - m_vpm1(vpm1), m_vpm2(vpm2), - m_tm2_tree(tree), - m_face_to_triangle_map(&m_tm1, m_vpm1), - m_error_bound(error_bound), - m_infinity_value(infinity_value), - m_initial_bound(initial_bound), - m_distance_bound(distance_bound), - h_global_bounds(m_infinity_value), - m_early_quit(false) { + using TM2_face_to_triangle_map = Triangle_from_face_descriptor_map; - CGAL_precondition(m_error_bound >= FT(0)); - CGAL_precondition(m_infinity_value >= FT(0)); - CGAL_precondition(m_initial_bound >= m_error_bound); +public: + using Priority = FT; - // Initialize the global bounds with 0, they will only grow. - // If we leave zero here, then we are very slow even for big input error bounds! - // Instead, we can use m_error_bound as our initial guess to filter out all pairs, - // which are already within this bound. It makes the code faster for close meshes. - // We also use initial_lower_bound here to accelerate the symmetric distance computation. - h_global_bounds.lower = m_initial_bound; // = FT(0); - h_global_bounds.upper = m_initial_bound; // = FT(0); +private: + const Bbox_3& m_t1_bbox; + const TriangleMesh2& m_tm2; + const VPM2 m_vpm2; + const TM2_face_to_triangle_map m_face_to_triangle_map; + + Local_bounds m_local_bounds; // local Hausdorff bounds for the query triangle + const Global_bounds& m_global_bounds; + FT m_v0_lower, m_v1_lower, m_v2_lower; + + bool m_early_exit; + +public: + Hausdorff_primitive_traits_tm2(const Bbox_3& t1_bbox, + const TriangleMesh2& tm2, const VPM2 vpm2, + const Local_bounds& initial_bounds, + const Global_bounds& global_bounds, + const FT infinity_value) + : m_t1_bbox(t1_bbox), + m_tm2(tm2), m_vpm2(vpm2), + m_face_to_triangle_map(&m_tm2, m_vpm2), + m_local_bounds(initial_bounds), + m_global_bounds(global_bounds), + m_v0_lower(infinity_value), + m_v1_lower(infinity_value), + m_v2_lower(infinity_value), + m_early_exit(false) + { } + + // Return the local Hausdorff bounds computed for the passed query triangle. + Local_bounds& get_local_bounds() { return m_local_bounds; } + const Local_bounds& get_local_bounds() const { return m_local_bounds; } + + // Because + // h(TM1, TM2) := max_{query in TM1} h(query, TM2), + // it is pointless to continue trying to find a smaller bound if the value is already known + // to be below the current max computed through another TM1 face + bool go_further() const { return !m_early_exit; } + + // Compute the explicit Hausdorff distance to the given primitive. + template + void intersection(const Query& query, const Primitive& primitive) + { + if(m_early_exit) + return; + +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Intersection with TM2's " << primitive.id() << std::endl; + std::cout << "Initial local bounds " << m_local_bounds.lower << " " << m_local_bounds.upper << std::endl; +#endif + + /* Have reached a single triangle, process it. + / Determine the upper distance according to + / min_{b \in primitive} ( max_{vertex in query} ( d(vertex, b) ) ) + / + / Here, we only have one triangle in B, i.e. tm2. Thus, it suffices to + / compute the distance of the vertices of the query triangle to the + / primitive triangle and use the maximum of the obtained distances. + */ + + // The query object is a triangle from TM1, get its vertices. + const Point_3& v0 = query.vertex(0); + const Point_3& v1 = query.vertex(1); + const Point_3& v2 = query.vertex(2); + + CGAL_assertion(primitive.id() != Face_handle_2()); + const Triangle_3 triangle = get(m_face_to_triangle_map, primitive.id()); + +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Geometry: " << triangle << std::endl; +#endif + + // Compute distances of the vertices to the primitive triangle in TM2. + const FT v0_dist = CGAL::squared_distance(v0, triangle); + if(v0_dist < m_v0_lower) + m_v0_lower = v0_dist; + + const FT v1_dist = CGAL::squared_distance(v1, triangle); + if(v1_dist < m_v1_lower) + m_v1_lower = v1_dist; + + const FT v2_dist = CGAL::squared_distance(v2, triangle); + if(v2_dist < m_v2_lower) + m_v2_lower = v2_dist; + + // Get the distance as maximizers over all vertices. + // + // Since we are at the level of a single triangle in TM2, distance_upper is actually + // the Hausdorff distance from the query triangle in TM1 to the primitive triangle in TM2. + + // max_{v in query} (v, primitive), used in h_upper_i(query, TM2) + const FT distance_upper = (CGAL::max)((CGAL::max)(v0_dist, v1_dist), v2_dist); + + // h_lower_i(query, TM2) := max_{v in query} min_{1<=j<=i} d(v, primitive_j) + const FT distance_lower = (CGAL::max)((CGAL::max)(m_v0_lower, m_v1_lower), m_v2_lower); + +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Distance from vertices of t1 to t2: " << v0_dist << " " << v1_dist << " " << v2_dist << std::endl; +#endif + + CGAL_assertion(distance_lower >= FT(0)); + CGAL_assertion(distance_upper >= distance_lower); + + // With each new TM2 face, the min value m_v{k}_lower can become smaller, + // and thus also the value max_{v in query} min_{1<=j<=i} d(v, primitive_j) + CGAL_assertion(m_local_bounds.lower >= FT(0)); + if(distance_lower < m_local_bounds.lower) + { +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "new best lower (" << distance_lower << ") with TM2 face: " << triangle << std::endl; +#endif + m_local_bounds.lower = distance_lower; + m_local_bounds.tm2_lface = primitive.id(); } - // Explore the whole tree, i.e. always enter children if the methods - // do_intersect() below determine that it is worthwhile. - bool go_further() const { - return !m_early_quit; + // This is the 'min_{1<=j<=i}' part in: + // h_upper_i(query, TM2) = min_{1<=j<=i} max_{v in query} (v, primitive_j), Equation (10) + CGAL_assertion(m_local_bounds.upper >= FT(0)); + if(distance_upper < m_local_bounds.upper) + { +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "new best upper (" << distance_upper << ") with TM2 face: " << triangle << std::endl; +#endif + m_local_bounds.upper = distance_upper; + m_local_bounds.tm2_uface = primitive.id(); } - // Compute the explicit Hausdorff distance to the given primitive. - template - void intersection(const Query&, const Primitive& primitive) { +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Distance from vertices of t1 to t2: " << v0_dist << " " << v1_dist << " " << v2_dist << std::endl; + std::cout << "Current local bounds " << m_local_bounds.lower << " " << m_local_bounds.upper << std::endl; +#endif + CGAL_assertion(m_local_bounds.lower <= m_local_bounds.upper); - if (m_early_quit) return; +// #define CGAL_PMP_HDIST_NO_CULLING_DURING_TRAVERSAL +#ifndef CGAL_PMP_HDIST_NO_CULLING_DURING_TRAVERSAL + // the lhs can only go down with every additional TM2 face, + // whereas the rhs can only go up with every additional TM1 face + if(m_local_bounds.upper < m_global_bounds.lower) // Section 4.1, first § + { +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Quitting early (TM2 traversal): " << m_global_bounds.lower << std::endl; +#endif + m_early_exit = true; + } +#endif + } - // Set initial tight bounds. - CGAL_assertion(primitive.id() != Face_handle_1()); - std::pair fpair; - const FT max_dist = get_maximum_distance(primitive.id(), fpair); - CGAL_assertion(max_dist >= FT(0)); - CGAL_assertion(fpair.first == primitive.id()); + // Determine whether child nodes will still contribute to a smaller + // Hausdorff distance and thus have to be entered. + template + std::pair + do_intersect_with_priority(const Query&, const Node& node) const + { + if(m_early_exit) + return std::make_pair(false, FT(0)); - Bounds initial_bounds(m_infinity_value); - initial_bounds.lower = max_dist + m_error_bound; - initial_bounds.upper = max_dist + m_error_bound; - initial_bounds.tm2_lface = fpair.second; - initial_bounds.tm2_uface = fpair.second; +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Do_intersect TM2 node with bbox: " << node.bbox() << std::endl; +#endif - // Call Culling on B with the single triangle found. - TM2_hd_traits traversal_traits_tm2( - m_tm2_tree.traits(), m_tm2, m_vpm2, - initial_bounds, // tighter bounds, in the paper, they start from infinity, see below - // Bounds(m_infinity_value), // starting from infinity - m_infinity_value, - m_infinity_value, - m_infinity_value); + // Compute a lower bound between the query (face of TM1) and a group of TM2 faces. + const Bbox_3 node_bbox = node.bbox(); - const Triangle_3 triangle = get(m_face_to_triangle_map, fpair.first); - m_tm2_tree.traversal_with_priority(triangle, traversal_traits_tm2); + // Distance along the x-axis. + double dist_x = 0.; + if(m_t1_bbox.xmax() < node_bbox.xmin()) + dist_x = node_bbox.xmin() - m_t1_bbox.xmax(); + else if(node_bbox.xmax() < m_t1_bbox.xmin()) + dist_x = m_t1_bbox.xmin() - node_bbox.xmax(); - // Update global Hausdorff bounds according to the obtained local bounds. - const auto local_bounds = traversal_traits_tm2.get_local_bounds(); + // Distance along the y-axis. + double dist_y = 0.; + if(m_t1_bbox.ymax() < node_bbox.ymin()) + dist_y = node_bbox.ymin() - m_t1_bbox.ymax(); + else if(node_bbox.ymax() < m_t1_bbox.ymin()) + dist_y = m_t1_bbox.ymin() - node_bbox.ymax(); - CGAL_assertion(local_bounds.lower >= FT(0)); - CGAL_assertion(local_bounds.upper >= FT(0)); - CGAL_assertion(local_bounds.upper >= local_bounds.lower); - CGAL_assertion(local_bounds.lpair == initial_bounds.default_face_pair()); - CGAL_assertion(local_bounds.upair == initial_bounds.default_face_pair()); + // Distance along the z-axis. + double dist_z = 0.; + if(m_t1_bbox.zmax() < node_bbox.zmin()) + dist_z = node_bbox.zmin() - m_t1_bbox.zmax(); + else if(node_bbox.zmax() < m_t1_bbox.zmin()) + dist_z = m_t1_bbox.zmin() - node_bbox.zmax(); - CGAL_assertion(h_global_bounds.lower >= FT(0)); - if (local_bounds.lower > h_global_bounds.lower) { // it is (6) in the paper, see also Algorithm 1 - h_global_bounds.lower = local_bounds.lower; - h_global_bounds.lpair.first = fpair.first; - h_global_bounds.lpair.second = local_bounds.tm2_lface; - } - CGAL_assertion(h_global_bounds.upper >= FT(0)); - if (local_bounds.upper > h_global_bounds.upper) { // it is (6) in the paper, see also Algorithm 1 - h_global_bounds.upper = local_bounds.upper; - h_global_bounds.upair.first = fpair.first; - h_global_bounds.upair.second = local_bounds.tm2_uface; - } - CGAL_assertion(h_global_bounds.upper >= h_global_bounds.lower); + const FT sq_dist = square(dist_x) + square(dist_y) + square(dist_z); - // Store the triangle given as primitive here as candidate triangle - // together with the local bounds it obtained to send it to subdivision later. - m_candidiate_triangles.push(Candidate(triangle, local_bounds, fpair.first)); + // Culling on TM2: + // The value 'dist' is the distance between bboxes and thus a lower bound on the distance + // between the query and the TM2 primitives that are children of this node. + // If this lower bound is greater than the current upper bound for this query, + // then none of these primitives will reduce the Hausdorff distance between the query and TM2. +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Culling TM1? dist vs local bound upper " << sq_dist << " " << m_local_bounds.upper << std::endl; +#endif + CGAL_assertion(m_local_bounds.upper >= FT(0)); + if(sq_dist > m_local_bounds.upper) + return std::make_pair(false, FT(0)); + else + return std::make_pair(true , -sq_dist); + } + + template + bool do_intersect(const Query& query, const Node& node) const + { + if(m_early_exit) + return false; + +#ifdef CGAL_PMP_HDIST_NO_CULLING_DURING_TRAVERSAL + CGAL_USE(query); CGAL_USE(node); + return true; +#else + return this->do_intersect_with_priority(query, node).first; +#endif + } + + template + void traverse_group(const Query& query, + PrimitiveConstIterator group_begin, + PrimitiveConstIterator group_end) + { + for(PrimitiveConstIterator it = group_begin; it != group_end; ++it) + this->intersection(query, *it); + } +}; + +// Hausdorff primitive traits on TM1. +template +class Hausdorff_primitive_traits_tm1 +{ + using FT = typename Kernel::FT; + using Point_3 = typename Kernel::Point_3; + using Vector_3 = typename Kernel::Vector_3; + using Triangle_3 = typename Kernel::Triangle_3; + + using TM2_primitive = AABB_face_graph_triangle_primitive; + using TM2_traits = AABB_traits; + using TM2_tree = AABB_tree; + using TM2_hd_traits = Hausdorff_primitive_traits_tm2; + + using TM1_face_to_triangle_map = Triangle_from_face_descriptor_map; + + using Face_handle_1 = typename boost::graph_traits::face_descriptor; + using Face_handle_2 = typename boost::graph_traits::face_descriptor; + + using Global_bounds = internal::Global_bounds; + using Candidate = Candidate_triangle; + using Heap_type = std::priority_queue; + +public: + using Priority = FT; + +private: + // Input data. + const TriangleMesh1& m_tm1; + const TriangleMesh2& m_tm2; + const VPM1 m_vpm1; + const VPM2 m_vpm2; + const TM2_tree& m_tm2_tree; + const TM1_face_to_triangle_map m_face_to_triangle_map; + + // Internal bounds and values. + const FT m_sq_error_bound; + const FT m_sq_initial_bound; + const FT m_sq_distance_bound; + const FT m_infinity_value; + Global_bounds m_global_bounds; + bool m_early_exit; + + // All candidate triangles. + Heap_type m_candidate_triangles; + +public: + Hausdorff_primitive_traits_tm1(const TM2_tree& tree, + const TriangleMesh1& tm1, + const TriangleMesh2& tm2, + const VPM1 vpm1, + const VPM2 vpm2, + const FT sq_error_bound, + const FT infinity_value, + const FT sq_initial_bound, + const FT sq_distance_bound) + : m_tm1(tm1), m_tm2(tm2), + m_vpm1(vpm1), m_vpm2(vpm2), + m_tm2_tree(tree), + m_face_to_triangle_map(&m_tm1, m_vpm1), + m_sq_error_bound(sq_error_bound), + m_sq_initial_bound(sq_initial_bound), + m_sq_distance_bound(sq_distance_bound), + m_infinity_value(infinity_value), + m_global_bounds(m_infinity_value), + m_early_exit(false) + { + CGAL_precondition(m_sq_error_bound >= FT(0)); + CGAL_precondition(m_infinity_value >= FT(0)); + CGAL_precondition(m_sq_initial_bound >= m_sq_error_bound); + + // Bounds grow with every face of TM1 (Equation (6)). + // If we initialize to zero here, then we are very slow even for big input error bounds! + // Instead, we can use m_sq_error_bound as our initial guess to filter out all pairs + // which are already within this bound. It makes the code faster for close meshes. + m_global_bounds.lower = m_sq_initial_bound; + m_global_bounds.upper = m_sq_initial_bound; + } + + // Return those triangles from TM1, which are candidates for including a + // point realizing the Hausdorff distance. + Heap_type& get_candidate_triangles() { return m_candidate_triangles; } + + // Return the global Hausdorff bounds computed for the passed query triangle. + Global_bounds get_global_bounds() + { + CGAL_assertion(m_global_bounds.lower >= FT(0)); + CGAL_assertion(m_global_bounds.upper >= m_global_bounds.lower); + + update_global_bounds(); + return m_global_bounds; + } + + // The maximum distance from one of the face corners to the second mesh, and the face realizing this max + std::pair get_maximum_distance(const Face_handle_1 tm1_face) const + { + const Triangle_3 triangle = get(m_face_to_triangle_map, tm1_face); + const Point_3& v0 = triangle.vertex(0); + const Point_3& v1 = triangle.vertex(1); + const Point_3& v2 = triangle.vertex(2); + + const auto pair0 = m_tm2_tree.closest_point_and_primitive(v0); + const auto pair1 = m_tm2_tree.closest_point_and_primitive(v1); + const auto pair2 = m_tm2_tree.closest_point_and_primitive(v2); + + const FT sq_dist0 = CGAL::squared_distance(v0, pair0.first); + const FT sq_dist1 = CGAL::squared_distance(v1, pair1.first); + const FT sq_dist2 = CGAL::squared_distance(v2, pair2.first); + + if(sq_dist0 > sq_dist1) + { + if(sq_dist0 > sq_dist2) + return std::make_pair(sq_dist0, pair0.second); + else + return std::make_pair(sq_dist2, pair2.second); + } + else + { + if(sq_dist1 > sq_dist2) + return std::make_pair(sq_dist1, pair1.second); + else + return std::make_pair(sq_dist2, pair2.second); + } + } + + // In case, we did not enter any loop, we set the realizing triangles here. + void update_global_bounds() + { + if(m_candidate_triangles.size() > 0) + { + const Candidate& top = m_candidate_triangles.top(); + + if(m_global_bounds.lpair.first == Face_handle_1()) + m_global_bounds.lpair.first = top.tm1_face; + if(m_global_bounds.lpair.second == Face_handle_2()) + m_global_bounds.lpair.second = top.bounds.tm2_lface; + + if(m_global_bounds.upair.first == Face_handle_1()) + m_global_bounds.upair.first = top.tm1_face; + if(m_global_bounds.upair.second == Face_handle_2()) + m_global_bounds.upair.second = top.bounds.tm2_uface; + } + else + { + Face_handle_1 tm1_f = *(faces(m_tm1).begin()); + const std::pair max_dist = get_maximum_distance(tm1_f); + + if(m_global_bounds.lpair.first == Face_handle_1()) + m_global_bounds.lpair.first = tm1_f; + if(m_global_bounds.lpair.second == Face_handle_2()) + m_global_bounds.lpair.second = max_dist.second; + + if(m_global_bounds.upair.first == Face_handle_1()) + m_global_bounds.upair.first = tm1_f; + if(m_global_bounds.upair.second == Face_handle_2()) + m_global_bounds.upair.second = max_dist.second; + } + } + + // Traversal-related + bool early_exit() const { return m_early_exit; } + + // If the distance is already larger than the user-defined bound, traversal can stop + bool go_further() const { return !m_early_exit; } + + // Compute Hausdorff distance bounds between a TM1 face and TM2 + template + void intersection(const Query&, const Primitive& primitive) + { + if(m_early_exit) + return; + +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Intersection with TM1's " << primitive.id() << std::endl; + std::cout << "Initial global bounds " << m_global_bounds.lower << " " << m_global_bounds.upper << std::endl; +#endif + + // Set initial tight bounds. + CGAL_assertion(primitive.id() != Face_handle_1()); + const Face_handle_1 tm1_face = primitive.id(); + const Triangle_3 triangle = get(m_face_to_triangle_map, tm1_face); + +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Geometry: " << triangle << std::endl; +#endif + + // Call culling on TM2 with the TM1 triangle. + const Bbox_3 t1_bbox = triangle.bbox(); + Local_bounds initial_bounds(m_infinity_value); + TM2_hd_traits traversal_traits_tm2(t1_bbox, m_tm2, m_vpm2, initial_bounds, m_global_bounds, m_infinity_value); + m_tm2_tree.traversal_with_priority(triangle, traversal_traits_tm2); + + // Post traversal, we have computed h_lower(query, TM2) and h_upper(query, TM2) + const auto& local_bounds = traversal_traits_tm2.get_local_bounds(); +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Bounds for TM1 primitive: " << local_bounds.lower << " " << local_bounds.upper << std::endl; +#endif + + CGAL_assertion(local_bounds.lower >= FT(0)); + CGAL_assertion(local_bounds.upper >= local_bounds.lower); + + // Update global Hausdorff bounds according to the obtained local bounds. + // h_lower(TM1, TM2) = max_{query in TM1} h_lower(query, TM2) + CGAL_assertion(m_global_bounds.lower >= FT(0)); + if(local_bounds.lower > m_global_bounds.lower) // Equation (6) in the paper, see also Algorithm 1, L.5 + { + m_global_bounds.lower = local_bounds.lower; + m_global_bounds.lpair.first = tm1_face; + m_global_bounds.lpair.second = local_bounds.tm2_lface; } - // Determine whether child nodes will still contribute to a larger - // Hausdorff distance and thus have to be entered. - template - std::pair - do_intersect_with_priority(const Query&, const Node& node) { - - // Check if we can stop already here. Since our bounds only grow, in case, we are - // above the user-defined max distance bound, we return. This way, the user can - // early detect that he is behind his thresholds. - if (m_distance_bound >= FT(0) && !m_early_quit) { - - CGAL_assertion(h_global_bounds.lower >= FT(0)); - CGAL_assertion(h_global_bounds.upper >= FT(0)); - CGAL_assertion(h_global_bounds.upper >= h_global_bounds.lower); - - const FT hdist = (h_global_bounds.lower + h_global_bounds.upper) / FT(2); - m_early_quit = (hdist >= m_distance_bound); - // std::cout << "- hdist: " << hdist << std::endl; - // std::cout << "- early quit: " << m_early_quit << std::endl; - } - if (m_early_quit) return std::make_pair(false, FT(0)); - - // Have reached a node, determine whether or not to enter it. - // Get the bounding box of the nodes. - const auto bbox = node.bbox(); - - // Compute its center. - const Point_3 center = Point_3( - (bbox.min(0) + bbox.max(0)) / FT(2), - (bbox.min(1) + bbox.max(1)) / FT(2), - (bbox.min(2) + bbox.max(2)) / FT(2)); - - // Find the point from TM2 closest to the center. - const Point_3 closest = m_tm2_tree.closest_point(center); - - // Compute the difference vector between the bbox center and the closest point in tm2. - Vector_3 difference = Vector_3(closest, center); - - // Shift the vector to be the difference between the farthest corner - // of the bounding box away from the closest point on TM2. - FT diff_x = ((bbox.max)(0) - (bbox.min)(0)) / FT(2); - if (difference.x() < 0) diff_x = diff_x * -FT(1); - FT diff_y = ((bbox.max)(1) - (bbox.min)(1)) / FT(2); - if (difference.y() < 0) diff_y = diff_y * -FT(1); - FT diff_z = ((bbox.max)(2) - (bbox.min)(2)) / FT(2); - if (difference.z() < 0) diff_z = diff_z * -FT(1); - difference = difference + Vector_3(diff_x, diff_y, diff_z); // it is (9) in the paper - - // Compute distance from the farthest corner of the bbox to the closest point in TM2. - const FT dist = CGAL::approximate_sqrt(difference.squared_length()); - - // See Algorithm 1 here. - // If the distance is larger than the global lower bound, enter the node, i.e. return true. - CGAL_assertion(h_global_bounds.lower >= FT(0)); - if (dist > h_global_bounds.lower) { - return std::make_pair(true , +dist); - } else { - return std::make_pair(false, FT(0)); - } + // h_upper(TM1, TM2) = max_{query in TM1} h_upper(query, TM2) + CGAL_assertion(m_global_bounds.upper >= FT(0)); + if(local_bounds.upper > m_global_bounds.upper) // Equation (6) in the paper, see also Algorithm 1, L.8 + { + m_global_bounds.upper = local_bounds.upper; + m_global_bounds.upair.first = tm1_face; + m_global_bounds.upair.second = local_bounds.tm2_uface; } - template - bool do_intersect(const Query& query, const Node& node) { - return this->do_intersect_with_priority(query, node).first; + CGAL_postcondition(m_global_bounds.upper >= m_global_bounds.lower); + + // Bounds only grow with each additional face of TM1 considered (Eq. (6)), + // if the lower bound is already larger than the user-defined upper bound, we can stop + if(is_positive(m_sq_distance_bound) && + m_sq_distance_bound <= m_global_bounds.lower) + { + m_early_exit = true; + return; } - template - void traverse_group(const Query& query, PrimitiveConstIterator group_begin, PrimitiveConstIterator group_end) { - CGAL_assertion_msg(false, "ERROR: we should not call the group traversal on TM1!"); - for (PrimitiveConstIterator it = group_begin; it != group_end; ++it) { - this->intersection(query, *it); - } - } + // Store the TM1 triangle given as primitive in this function as a candidate triangle, + // together with the local bounds it obtained to send it to subdivision later. + m_candidate_triangles.emplace(triangle, local_bounds, tm1_face); + } - bool early_quit() const { - return m_early_quit; - } + // Determine whether child nodes will still contribute to a larger + // Hausdorff distance and thus have to be entered. + template + std::pair + do_intersect_with_priority(const Query&, const Node& node) + { + if(m_early_exit) + return std::make_pair(false, FT(0)); - // Return those triangles from TM1, which are candidates for including a - // point realizing the Hausdorff distance. - Heap_type& get_candidate_triangles() { - return m_candidiate_triangles; - } +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Do_intersect TM1 node with bbox " << node.bbox() << std::endl; +#endif - // Return the global Hausdorff bounds computed for the passed query triangle. - Global_bounds get_global_bounds() { + // Compute an upper bound on the distance between the closest point in TM2 and + // the corner of the bbox farthest from the closest point. This is an upper bound + // on the Hausdorff distance between any children primitive of the node and TM2. + // + // @todo could find the bbox vertex that is closest to 'closest' to reduce a bit the bound + const Bbox_3 bbox = node.bbox(); + const Point_3 bp(bbox.xmin(), bbox.ymin(), bbox.zmin()); + const Point_3 closest = m_tm2_tree.closest_point(bp); + const Vector_3 difference(bp, closest); + const Vector_3 diag(bbox.x_span(), bbox.y_span(), bbox.z_span()); - CGAL_assertion(h_global_bounds.lower >= FT(0)); - CGAL_assertion(h_global_bounds.upper >= FT(0)); - CGAL_assertion(h_global_bounds.upper >= h_global_bounds.lower); + // @todo something better to avoid the sqrt + const FT sq_dist = square(CGAL::approximate_sqrt(difference.squared_length()) + + CGAL::approximate_sqrt(diag.squared_length())); - update_global_bounds(); - return h_global_bounds; - } + // The Hausdorff distance grows with every TM1 face. + // If the upper bound is smaller than the current global lower bound, + // it is pointless to visit this node (and its children) because a larger distance + // has been found somewhere else. +#ifdef CGAL_HAUSDORFF_DEBUG_PP + std::cout << "Culling TM1? dist & global lower bound: " << sq_dist << " " << m_global_bounds.lower << std::endl; +#endif + CGAL_assertion(m_global_bounds.lower >= FT(0)); + if(sq_dist < m_global_bounds.lower) + return std::make_pair(false, FT(0)); + else + return std::make_pair(true , +sq_dist); + } - // Here, we return the maximum distance from one of the face corners - // to the second mesh. We also return a pair of realizing this distance faces. - FT get_maximum_distance( - const Face_handle_1 tm1_lface, - std::pair& fpair) const { + template + bool do_intersect(const Query& query, const Node& node) + { + if(m_early_exit) + return false; - const auto triangle = get(m_face_to_triangle_map, tm1_lface); - const Point_3 v0 = triangle.vertex(0); - const Point_3 v1 = triangle.vertex(1); - const Point_3 v2 = triangle.vertex(2); +#ifdef CGAL_PMP_HDIST_NO_CULLING_DURING_TRAVERSAL + CGAL_USE(query); CGAL_USE(node); + return true; +#else + return this->do_intersect_with_priority(query, node).first; +#endif + } - const auto pair0 = m_tm2_tree.closest_point_and_primitive(v0); - const auto pair1 = m_tm2_tree.closest_point_and_primitive(v1); - const auto pair2 = m_tm2_tree.closest_point_and_primitive(v2); + template + void traverse_group(const Query& query, + PrimitiveConstIterator group_begin, + PrimitiveConstIterator group_end) + { + CGAL_assertion_msg(false, "ERROR: we should not call the group traversal on TM1!"); - const auto sq_dist0 = std::make_pair( - CGAL::squared_distance(v0, pair0.first), pair0.second); - const auto sq_dist1 = std::make_pair( - CGAL::squared_distance(v1, pair1.first), pair1.second); - const auto sq_dist2 = std::make_pair( - CGAL::squared_distance(v2, pair2.first), pair2.second); + for(PrimitiveConstIterator it = group_begin; it != group_end; ++it) + this->intersection(query, *it); + } +}; - const auto mdist1 = (sq_dist0.first > sq_dist1.first) ? sq_dist0 : sq_dist1; - const auto mdist2 = (mdist1.first > sq_dist2.first) ? mdist1 : sq_dist2; - - Face_handle_2 tm2_uface = mdist2.second; - fpair = std::make_pair(tm1_lface, tm2_uface); - return CGAL::approximate_sqrt(mdist2.first); - } - - private: - // Input data. - const AABBTraits& m_traits; - const TriangleMesh1& m_tm1; - const TriangleMesh2& m_tm2; - const VPM1& m_vpm1; - const VPM2& m_vpm2; - const TM2_tree& m_tm2_tree; - const TM1_face_to_triangle_map m_face_to_triangle_map; - - // Internal bounds and values. - const FT m_error_bound; - const FT m_infinity_value; - const FT m_initial_bound; - const FT m_distance_bound; - Global_bounds h_global_bounds; - bool m_early_quit; - - // All candidate triangles. - Heap_type m_candidiate_triangles; - - // In case, we did not enter any loop, we set the realizing triangles here. - void update_global_bounds() { - - if (m_candidiate_triangles.size() > 0) { - const auto top = m_candidiate_triangles.top(); - - if (h_global_bounds.lpair.first == Face_handle_1()) - h_global_bounds.lpair.first = top.tm1_face; - if (h_global_bounds.lpair.second == Face_handle_2()) - h_global_bounds.lpair.second = top.bounds.tm2_lface; - - if (h_global_bounds.upair.first == Face_handle_1()) - h_global_bounds.upair.first = top.tm1_face; - if (h_global_bounds.upair.second == Face_handle_2()) - h_global_bounds.upair.second = top.bounds.tm2_uface; - - } else { - - std::pair fpair; - get_maximum_distance(*(faces(m_tm1).begin()), fpair); - CGAL_assertion(fpair.first == *(faces(m_tm1).begin())); - - if (h_global_bounds.lpair.first == Face_handle_1()) - h_global_bounds.lpair.first = fpair.first; - if (h_global_bounds.lpair.second == Face_handle_2()) - h_global_bounds.lpair.second = fpair.second; - - if (h_global_bounds.upair.first == Face_handle_1()) - h_global_bounds.upair.first = fpair.first; - if (h_global_bounds.upair.second == Face_handle_2()) - h_global_bounds.upair.second = fpair.second; - } - } - }; -} +} // namespace internal +} // namespace Polygon_mesh_processing +} // namespace CGAL #endif // CGAL_PMP_INTERNAL_AABB_TRAVERSAL_TRAITS_WITH_HAUSDORFF_DISTANCE 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 07268ec93ed..08a1d0e29e5 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 @@ -55,9 +55,6 @@ namespace Corefinement { enum Boolean_operation_type {UNION = 0, INTERSECTION, TM1_MINUS_TM2, TM2_MINUS_TM1, NONE }; -namespace PMP=Polygon_mesh_processing; -namespace params=PMP::parameters; - // extra functions for handling non-documented functions for user visitors // with no extra functions BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_extra_functions, @@ -158,7 +155,7 @@ class Face_graph_output_builder // Internal typedefs typedef std::size_t Node_id; typedef std::pair Node_id_pair; - typedef boost::unordered_set Intersection_edge_map; + typedef std::unordered_set Intersection_edge_map; // to maintain a halfedge on each polyline per TriangleMesh + pair // with first = "is the key (pair) was reversed?" and // second is the number of edges -1 in the polyline @@ -168,9 +165,9 @@ class Face_graph_output_builder std::pair > > An_edge_per_polyline_map; - typedef boost::unordered_map Node_id_map; - typedef boost::unordered_map Edge_map; + typedef std::unordered_map Node_id_map; + typedef std::unordered_map Edge_map; //Data members TriangleMesh &tm1, &tm2; // property maps of input meshes @@ -428,8 +425,8 @@ public: , requested_output(requested_output) , is_tm1_closed( is_closed(tm1)) , is_tm2_closed( is_closed(tm2)) - , is_tm1_inside_out( is_tm1_closed && !PMP::is_outward_oriented(tm1, parameters::vertex_point_map(vpm1)) ) - , is_tm2_inside_out( is_tm2_closed && !PMP::is_outward_oriented(tm2, parameters::vertex_point_map(vpm2)) ) + , is_tm1_inside_out( is_tm1_closed && !is_outward_oriented(tm1, parameters::vertex_point_map(vpm1)) ) + , is_tm2_inside_out( is_tm2_closed && !is_outward_oriented(tm2, parameters::vertex_point_map(vpm2)) ) , NID((std::numeric_limits::max)()) , mesh_to_intersection_edges(tm1, tm2) , used_to_clip_a_surface(false) @@ -557,8 +554,8 @@ public: typename An_edge_per_polyline_map::iterator epp_it=input_have_coplanar_faces ? an_edge_per_polyline.begin() : epp_it_end; - boost::unordered_set inter_edges_to_remove1, - inter_edges_to_remove2; + std::unordered_set inter_edges_to_remove1, + inter_edges_to_remove2; // Each vector contains a subset of coplanar faces. More particularly only // the coplanar faces incident to an intersection edge. Note @@ -707,10 +704,10 @@ public: std::vector tm1_patch_ids( num_faces(tm1),NID ); Border_edge_map is_marked_1(intersection_edges1, tm1); std::size_t nb_patches_tm1 = - PMP::connected_components(tm1, - bind_property_maps(fids1,make_property_map(&tm1_patch_ids[0])), - params::edge_is_constrained_map(is_marked_1) - .face_index_map(fids1)); + connected_components(tm1, + bind_property_maps(fids1,make_property_map(&tm1_patch_ids[0])), + parameters::edge_is_constrained_map(is_marked_1) + .face_index_map(fids1)); std::vector tm1_patch_sizes(nb_patches_tm1, 0); for(std::size_t i : tm1_patch_ids) @@ -720,10 +717,10 @@ public: std::vector tm2_patch_ids( num_faces(tm2),NID ); Border_edge_map is_marked_2(intersection_edges2, tm2); std::size_t nb_patches_tm2 = - PMP::connected_components(tm2, - bind_property_maps(fids2,make_property_map(&tm2_patch_ids[0])), - params::edge_is_constrained_map(is_marked_2) - .face_index_map(fids2)); + connected_components(tm2, + bind_property_maps(fids2,make_property_map(&tm2_patch_ids[0])), + parameters::edge_is_constrained_map(is_marked_2) + .face_index_map(fids2)); std::vector tm2_patch_sizes(nb_patches_tm2, 0); for(Node_id i : tm2_patch_ids) @@ -1577,7 +1574,7 @@ public: typedef Patch_container Patches1; typedef Patch_container Patches2; - boost::unordered_set border_nm_vertices; // only used if used_to_clip_a_surface == true + std::unordered_set border_nm_vertices; // only used if used_to_clip_a_surface == true if (used_to_clip_a_surface) { if (!is_tm1_closed) @@ -1961,7 +1958,7 @@ public: for(vertex_descriptor vd : border_nm_vertices) { // first check if at least one incident patch will be kept - boost::unordered_set id_p_rm; + std::unordered_set id_p_rm; bool all_removed=true; for(halfedge_descriptor h : halfedges_around_target(vd, tm1)) { diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Generic_clip_output_builder.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Generic_clip_output_builder.h index d84788ff868..7ee732f4e83 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Generic_clip_output_builder.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Generic_clip_output_builder.h @@ -28,15 +28,10 @@ #include - namespace CGAL { namespace Polygon_mesh_processing { namespace Corefinement { - -namespace PMP=Polygon_mesh_processing; -namespace params=PMP::parameters; - template > > An_edge_per_polyline_map; - typedef boost::unordered_map Node_id_map; - typedef boost::unordered_map Edge_map; + typedef std::unordered_map Node_id_map; + typedef std::unordered_map Edge_map; //Data members TriangleMesh &tm1, &tm2; // property maps of input meshes @@ -116,7 +111,7 @@ public: , ecm1(ecm1) , fids1(fids1) , use_compact_clipper(use_compact_clipper) - , is_tm2_inside_out( !PMP::is_outward_oriented(tm2, parameters::vertex_point_map(vpm2)) ) + , is_tm2_inside_out( !is_outward_oriented(tm2, parameters::vertex_point_map(vpm2)) ) , NID((std::numeric_limits::max)()) {} @@ -152,10 +147,10 @@ public: std::vector tm1_patch_ids( num_faces(tm1),NID ); std::size_t nb_patches_tm1 = - PMP::connected_components(tm1, - bind_property_maps(fids1,make_property_map(&tm1_patch_ids[0])), - params::edge_is_constrained_map(ecm1) - .face_index_map(fids1)); + connected_components(tm1, + bind_property_maps(fids1,make_property_map(&tm1_patch_ids[0])), + parameters::edge_is_constrained_map(ecm1) + .face_index_map(fids1)); std::vector tm1_patch_sizes(nb_patches_tm1, 0); for(std::size_t i : tm1_patch_ids) @@ -233,7 +228,7 @@ public: } } - PMP::keep_connected_components(tm1, cc_to_keep, bind_property_maps(fids1,make_property_map(&tm1_patch_ids[0]))); + keep_connected_components(tm1, cc_to_keep, bind_property_maps(fids1,make_property_map(&tm1_patch_ids[0]))); } }; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h index 6e5b3a73705..5db5f0911ec 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h @@ -34,9 +34,6 @@ namespace CGAL { namespace Polygon_mesh_processing { namespace Corefinement { -namespace PMP=Polygon_mesh_processing; -namespace params=PMP::parameters; - template An_edge_per_polyline_map; - typedef boost::unordered_map Node_id_map; - // typedef boost::unordered_map Edge_map; - typedef boost::unordered_map All_intersection_edges_map; + typedef std::unordered_map Node_id_map; + // typedef std::unordered_map Edge_map; + typedef std::unordered_map> All_intersection_edges_map; //Data members TriangleMesh &tm; // property maps of input mesh @@ -161,7 +158,7 @@ public: , fids(fids) , ecm(ecm) , is_tm_closed( is_closed(tm)) - , is_tm_inside_out( is_tm_closed && !PMP::is_outward_oriented(tm) ) + , is_tm_inside_out( is_tm_closed && !is_outward_oriented(tm) ) , NID((std::numeric_limits::max)()) , all_fixed(true) {} @@ -216,7 +213,7 @@ public: { // first build an unordered_map mapping a vertex to its node id + a set // of all intersection edges - typedef boost::unordered_set Intersection_edge_map; + typedef std::unordered_set Intersection_edge_map; Intersection_edge_map intersection_edges; typedef std::pair Pair_type; @@ -257,7 +254,7 @@ public: typename An_edge_per_polyline_map::iterator epp_it=input_have_coplanar_faces ? an_edge_per_polyline.begin() : epp_it_end; - boost::unordered_set inter_edges_to_remove; + std::unordered_set inter_edges_to_remove; for (;epp_it!=epp_it_end;) { halfedge_descriptor h1 = epp_it->second.h1; @@ -348,14 +345,13 @@ public: // component limited by intersection edges of the surface they are. // ... for tm std::vector patch_ids( num_faces(tm),NID ); - Boolean_property_map< boost::unordered_set > + Boolean_property_map< std::unordered_set > is_intersection(intersection_edges); std::size_t nb_patches = - PMP::connected_components(tm, - bind_property_maps(fids,make_property_map(patch_ids)), - params::edge_is_constrained_map( - is_intersection) - .face_index_map(fids)); + connected_components(tm, + bind_property_maps(fids,make_property_map(patch_ids)), + parameters::edge_is_constrained_map(is_intersection) + .face_index_map(fids)); // (2-a) Use the orientation around an edge to classify a patch boost::dynamic_bitset<> patches_to_keep(nb_patches); @@ -735,6 +731,14 @@ public: std::size_t patch_id_q1=patch_ids[ get(fids, face(opposite(h2,tm),tm)) ]; std::size_t patch_id_q2=patch_ids[ get(fids, face(h2,tm)) ]; + if (patch_id_p1==patch_id_p2 || patch_id_q1==patch_id_q2) + { + // polyline in the middle of a patch is always impossible to fix but + // removing the whole all the patch + all_fixed = false; + continue; + } + //indicates that patch status will be updated patch_status_not_set.reset(patch_id_p1); patch_status_not_set.reset(patch_id_p2); @@ -1181,12 +1185,13 @@ public: //remove the extra patch remove_patches(tm, ~patches_to_keep,patches, ecm); - PMP::stitch_borders(tm, hedge_pairs_to_stitch, params::vertex_point_map(vpm)); + stitch_borders(tm, hedge_pairs_to_stitch, parameters::vertex_point_map(vpm)); } }; - -} } } // CGAL::Corefinement +} // namespace Corefinement +} // namespace Polygon_mesh_processing +} // namespace CGAL #include diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h index 7e7bfd600a1..a0e269d4232 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h @@ -341,6 +341,96 @@ public: } }; +namespace internal{ +//version for corefinement, only one vertex per node_id +template +struct Node_id_to_vertex +{ + typedef boost::graph_traits Graph_traits; + typedef typename Graph_traits::vertex_descriptor vertex_descriptor; + std::vector data; + + vertex_descriptor get_vertex(std::size_t i) const + { + return data[i]; + } + void register_vertex(std::size_t i, vertex_descriptor v) + { + data[i] = v; + } + void set_vertex_for_retriangulation(std::size_t i, vertex_descriptor v) + { + data[i] = v; + } + void set_temporary_vertex_for_retriangulation(std::size_t i, vertex_descriptor v) + { + data[i] = v; + } + void resize(std::size_t n) + { + data.resize(n,Graph_traits::null_vertex()); + } + std::size_t size() const + { + return data.size(); + } + template + void update_vertex_point(std::size_t i, const Point_3& p, const VPM& vpm) const + { + if (data[i]!=Graph_traits::null_vertex()) + put(vpm, data[i], p); + } +}; + +//version for autorefinement and non-manifold corefinement, several vertices per node_id +template +struct Node_id_to_vertex +{ + typedef boost::graph_traits Graph_traits; + typedef typename Graph_traits::vertex_descriptor vertex_descriptor; + std::vector< std::vector > data; + + vertex_descriptor get_vertex(std::size_t i) const + { + if (data[i].empty()) + return Graph_traits::null_vertex(); + return data[i].back(); + } + void register_vertex(std::size_t i, vertex_descriptor v) + { + data[i].push_back(v); + } + void set_temporary_vertex_for_retriangulation(std::size_t i, vertex_descriptor v) + { + data[i].assign(1,v); + } + // warning: data[i] might then contains several times the same vertex + // but it is probably still a better option than look for the + // vertex and remove it + void set_vertex_for_retriangulation(std::size_t i, vertex_descriptor v) + { + assert(!data[i].empty()); + if (data[i].back()!=v) + data[i].push_back(v); + } + void resize(std::size_t n) + { + data.resize(n); + } + std::size_t size() const + { + return data.size(); + } + template + void update_vertex_point(std::size_t i, const Point_3& p, const VPM& vpm) const + { + for (vertex_descriptor v : data[i]) + put(vpm, v, p); + } +}; +} + + // A visitor for Intersection_of_triangle_meshes that can be used to corefine // two meshes template< class TriangleMesh, @@ -373,16 +463,19 @@ private: typedef typename Graph_traits::vertex_descriptor vertex_descriptor; typedef typename Graph_traits::halfedge_descriptor halfedge_descriptor; typedef std::vector Node_ids; - typedef boost::unordered_map On_face_map; - typedef boost::unordered_map On_edge_map; + typedef std::unordered_map On_face_map; + typedef std::unordered_map On_edge_map; //to keep the correspondance between node_id and vertex_handle in each mesh - typedef std::vector Node_id_to_vertex; - typedef std::map Mesh_to_map_node; + typedef internal::Node_id_to_vertex + Node_id_to_vertex; + typedef std::map Mesh_to_map_node; //to handle coplanar halfedge of polyhedra that are full in the intersection - typedef std::multimap Node_to_target_of_hedge_map; + typedef std::multimap Node_to_target_of_hedge_map; typedef std::map Mesh_to_vertices_on_intersection_map; - typedef boost::unordered_map Vertex_to_node_id; + typedef std::unordered_map Vertex_to_node_id; typedef std::map Mesh_to_vertex_to_node_id; typedef Non_manifold_feature_map NM_features_map; // typedef for the CDT @@ -667,8 +760,8 @@ public: mesh_to_vertices_on_inter[tm2_ptr].insert(std::make_pair(node_id,h_2)); Node_id_to_vertex& node_id_to_vertex=mesh_to_node_id_to_vertex[tm2_ptr]; if (node_id_to_vertex.size()<=node_id) - node_id_to_vertex.resize(node_id+1,Graph_traits::null_vertex()); - node_id_to_vertex[node_id]=target(h_2,tm2); + node_id_to_vertex.resize(node_id+1); + node_id_to_vertex.register_vertex(node_id, target(h_2,tm2)); all_incident_faces_got_a_node_as_vertex(h_2,node_id,*tm2_ptr); check_node_on_boundary_vertex_case(node_id,h_2,tm2); output_builder.set_vertex_id(target(h_2, tm2), node_id, tm2); @@ -690,8 +783,8 @@ public: mesh_to_vertices_on_inter[tm1_ptr].insert(std::make_pair(node_id,h_1)); Node_id_to_vertex& node_id_to_vertex=mesh_to_node_id_to_vertex[tm1_ptr]; if (node_id_to_vertex.size()<=node_id) - node_id_to_vertex.resize(node_id+1,Graph_traits::null_vertex()); - node_id_to_vertex[node_id]=target(h_1,tm1); + node_id_to_vertex.resize(node_id+1); + node_id_to_vertex.register_vertex(node_id, target(h_1,tm1)); all_incident_faces_got_a_node_as_vertex(h_1,node_id, *tm1_ptr); // register the vertex in the output builder output_builder.set_vertex_id(target(h_1, tm1), node_id, tm1); @@ -704,8 +797,8 @@ public: mesh_to_vertices_on_inter[tm1_ptr].insert(std::make_pair(node_id,h_1_opp)); Node_id_to_vertex& node_id_to_vertex=mesh_to_node_id_to_vertex[tm1_ptr]; if(node_id_to_vertex.size()<=node_id) - node_id_to_vertex.resize(node_id+1,Graph_traits::null_vertex()); - node_id_to_vertex[node_id]=source(h_1,tm1); + node_id_to_vertex.resize(node_id+1); + node_id_to_vertex.register_vertex(node_id, source(h_1,tm1)); all_incident_faces_got_a_node_as_vertex(h_1_opp,node_id, *tm1_ptr); // register the vertex in the output builder output_builder.set_vertex_id(source(h_1, tm1), node_id, tm1); @@ -819,7 +912,8 @@ public: h = next(h, tm); for(std::size_t id : node_ids_array[i]) { - node_id_to_vertex[id] = target(h, tm); + // needed when we triangulate a face --> need to pick the right vertex + node_id_to_vertex.set_vertex_for_retriangulation(id, target(h, tm)); h = next(h, tm); } CGAL_assertion(h == halfedges[i]); @@ -828,7 +922,7 @@ public: }; - typedef boost::unordered_map Face_boundaries; + typedef std::unordered_map Face_boundaries; //update the id of input mesh vertex that are also a node void update_face_indices( @@ -837,7 +931,7 @@ public: Vertex_to_node_id& vertex_to_node_id) { for (int k=0;k<3;++k){ - typename boost::unordered_map::iterator it = + typename std::unordered_map::iterator it = vertex_to_node_id.find(f_vertices[k]); if (it!=vertex_to_node_id.end()) f_indices[k]=it->second; @@ -1000,7 +1094,7 @@ public: nodes.call_put(vpm, vnew, node_id, tm); // register the new vertex in the output builder output_builder.set_vertex_id(vnew, node_id, tm); - node_id_to_vertex[node_id]=vnew; + node_id_to_vertex.register_vertex(node_id, vnew); if (first){ first=false; hedge_incident_to_src=next(opposite(hedge,tm),tm); @@ -1088,7 +1182,7 @@ public: typename EK::Point_3 p = nodes.to_exact(get(vpm,f_vertices[0])), q = nodes.to_exact(get(vpm,f_vertices[1])), r = nodes.to_exact(get(vpm,f_vertices[2])); -///TODO use a positive normal and remove all work around to guarantee that triangulation of coplanar patches are compatible +///TODO use a positive normal and remove all workaround to guarantee that triangulation of coplanar patches are compatible CDT_traits traits(typename EK::Construct_normal_3()(p,q,r)); CDT cdt(traits); @@ -1100,14 +1194,13 @@ public: triangle_vertices[2]=cdt.tds().insert_dim_up(cdt.infinite_vertex(), false); triangle_vertices[2]->set_point(r); - triangle_vertices[0]->info()=f_indices[0]; triangle_vertices[1]->info()=f_indices[1]; triangle_vertices[2]->info()=f_indices[2]; - node_id_to_vertex[nb_nodes ]=f_vertices[0]; - node_id_to_vertex[nb_nodes+1]=f_vertices[1]; - node_id_to_vertex[nb_nodes+2]=f_vertices[2]; + node_id_to_vertex.set_temporary_vertex_for_retriangulation(nb_nodes, f_vertices[0]); + node_id_to_vertex.set_temporary_vertex_for_retriangulation(nb_nodes+1, f_vertices[1]); + node_id_to_vertex.set_temporary_vertex_for_retriangulation(nb_nodes+2, f_vertices[2]); //if one of the triangle input vertex is also a node for (int ik=0;ik<3;++ik){ @@ -1118,7 +1211,10 @@ public: if (doing_autorefinement || handle_non_manifold_features) // update the current vertex in node_id_to_vertex // to match the one of the face - node_id_to_vertex[f_indices[ik]]=f_vertices[ik]; + node_id_to_vertex.set_temporary_vertex_for_retriangulation(f_indices[ik], f_vertices[ik]); + // Note on set_temporary_vertex instead of set_vertex: here since the point is an input point + // it is OK not to store all vertices corresponding to this id as the approximate version + // is already tight and the call in Intersection_nodes::finalize() will not fix anything } } //insert points on edges @@ -1297,12 +1393,11 @@ public: TriangleMesh* tm1_ptr = const_cast(&tm1); TriangleMesh* tm2_ptr = const_cast(&tm2); - vertex_descriptor null_vertex = Graph_traits::null_vertex(); const Node_id nb_nodes = nodes.size(); // we reserve nb_nodes+3 because we use the last three entries for the // face triangulation - mesh_to_node_id_to_vertex[tm1_ptr].resize(nb_nodes+3, null_vertex); - mesh_to_node_id_to_vertex[tm2_ptr].resize(nb_nodes+3, null_vertex); + mesh_to_node_id_to_vertex[tm1_ptr].resize(nb_nodes+3); + mesh_to_node_id_to_vertex[tm2_ptr].resize(nb_nodes+3); //store for each triangle face which boundary is intersected by the other surface, //original vertices (and halfedges in the refined mesh pointing on these vertices) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h index 05c0dc0f373..a3e0cd9d514 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h @@ -477,6 +477,7 @@ template < class TriangleMesh, class VertexPointMap, class Node_id, class Node_vector, + class Node_id_to_vertex, class CDT, class OutputBuilder, class UserVisitor> @@ -486,8 +487,7 @@ triangulate_a_face( TriangleMesh& tm, Node_vector& nodes, const std::vector& node_ids, - typename std::vector - ::vertex_descriptor>& node_id_to_vertex, + Node_id_to_vertex& node_id_to_vertex, std::map, typename boost::graph_traits ::halfedge_descriptor>& edge_to_hedge, @@ -513,7 +513,7 @@ triangulate_a_face( user_visitor.new_vertex_added(node_id, v, tm); CGAL_assertion(node_id_to_vertex.size()>node_id); - node_id_to_vertex[node_id]=v; + node_id_to_vertex.register_vertex(node_id, v); } //insert the new halfedge and set their incident vertex @@ -535,10 +535,10 @@ triangulate_a_face( halfedge_descriptor h=halfedge(e,tm), h_opp=opposite(h,tm); Node_id i0=cdt_v0->info(), i1=cdt_v1->info(); - CGAL_assertion( node_id_to_vertex[i0]!=GT::null_vertex()); - CGAL_assertion( node_id_to_vertex[i1]!=GT::null_vertex()); + CGAL_assertion( node_id_to_vertex.get_vertex(i0)!=GT::null_vertex()); + CGAL_assertion( node_id_to_vertex.get_vertex(i1)!=GT::null_vertex()); - vertex_descriptor v0=node_id_to_vertex[i0], v1=node_id_to_vertex[i1]; + vertex_descriptor v0=node_id_to_vertex.get_vertex(i0), v1=node_id_to_vertex.get_vertex(i1); set_target(h,v0,tm); set_target(h_opp,v1,tm); @@ -569,9 +569,9 @@ triangulate_a_face( halfedge_descriptor h12=edge_to_hedge[std::make_pair(i1,i2)]; halfedge_descriptor h20=edge_to_hedge[std::make_pair(i2,i0)]; - CGAL_assertion(target(h01,tm)==node_id_to_vertex[i1]); - CGAL_assertion(target(h12,tm)==node_id_to_vertex[i2]); - CGAL_assertion(target(h20,tm)==node_id_to_vertex[i0]); + CGAL_assertion(target(h01,tm)==node_id_to_vertex.get_vertex(i1)); + CGAL_assertion(target(h12,tm)==node_id_to_vertex.get_vertex(i2)); + CGAL_assertion(target(h20,tm)==node_id_to_vertex.get_vertex(i0)); set_next(h01,h12,tm); set_next(h12,h20,tm); @@ -602,7 +602,7 @@ class Border_edge_map { typedef boost::graph_traits GT; typedef typename GT::halfedge_descriptor halfedge_descriptor; typedef typename GT::edge_descriptor edge_descriptor; - typedef boost::unordered_set Intersection_edge_map; + typedef std::unordered_set Intersection_edge_map; const Intersection_edge_map* intersection_edges; const PolygonMesh* tm; public: @@ -979,7 +979,7 @@ struct Triangle_mesh_extension_helper typedef typename GT::edge_descriptor edge_descriptor; typedef typename GT::face_descriptor face_descriptor; - typedef boost::unordered_map< edge_descriptor, edge_descriptor> Edge_map; + typedef std::unordered_map< edge_descriptor, edge_descriptor> Edge_map; Edge_map& tm_to_output_edges; const TriangleMesh& tm; TriangleMesh& output; @@ -1020,7 +1020,7 @@ struct Triangle_mesh_extension_helper typedef typename GT::edge_descriptor edge_descriptor; typedef typename GT::face_descriptor face_descriptor; - typedef boost::unordered_map< edge_descriptor, edge_descriptor> Edge_map; + typedef std::unordered_map< edge_descriptor, edge_descriptor> Edge_map; Edge_map& tm_to_output_edges; const TriangleMesh& tm; TriangleMesh& output; @@ -1070,7 +1070,7 @@ void append_patches_to_triangle_mesh( const VertexPointMap& vpm_tm, EdgeMarkMapOut& edge_mark_map_out, const EdgeMarkMapIn& edge_mark_map_in, - boost::unordered_map< + std::unordered_map< typename boost::graph_traits::edge_descriptor, typename boost::graph_traits::edge_descriptor >& tm_to_output_edges, @@ -1086,9 +1086,17 @@ void append_patches_to_triangle_mesh( Triangle_mesh_extension_helper helper(tm_to_output_edges, tm, output); + std::vector ids_of_patches_to_append; + ids_of_patches_to_append.reserve(patches_to_append.count()); for (std::size_t i=patches_to_append.find_first(); i < patches_to_append.npos; i = patches_to_append.find_next(i)) + { + ids_of_patches_to_append.push_back(i); + } + + std::vector interior_vertex_halfedges; + for (std::size_t i : ids_of_patches_to_append) { #ifdef CGAL_COREFINEMENT_POLYHEDRA_DEBUG #warning the size of tm_to_output_edges will increase at each step \ @@ -1099,8 +1107,6 @@ void append_patches_to_triangle_mesh( Patch_description& patch = patches[i]; - std::vector interior_vertex_halfedges; - //insert interior halfedges and create interior vertices for(halfedge_descriptor h : patch.interior_edges) { @@ -1146,6 +1152,11 @@ void append_patches_to_triangle_mesh( interior_vertex_halfedges.push_back( new_h_opp ); } } + } + + for (std::size_t i : ids_of_patches_to_append) + { + Patch_description& patch = patches[i]; //create faces and connect halfedges for(face_descriptor f : patch.faces) @@ -1164,20 +1175,24 @@ void append_patches_to_triangle_mesh( set_face(hedges[i], new_f, output); } } + } - // handle interior edges that are on the border of the mesh: - // they do not have a prev/next pointer set since only the pointers - // of patch interior halfedges part a face have been. In the following - // (i) we set the next/prev pointer around interior vertices on the mesh - // boundary and (ii) we collect interior mesh border halfedges incident to - // a patch border vertex and set their next/prev pointer (possibly of - // another patch) + // handle interior edges that are on the border of the mesh: + // they do not have a prev/next pointer set since only the pointers + // of patch interior halfedges part a face have been. In the following + // (i) we set the next/prev pointer around interior vertices on the mesh + // boundary and (ii) we collect interior mesh border halfedges incident to + // a patch border vertex and set their next/prev pointer (possibly of + // another patch) - // Containers used for step (ii) for collecting mesh border halfedges - // with source/target on an intersection polyline that needs it prev/next - // pointer to be set - std::vector border_halfedges_source_to_link; - std::vector border_halfedges_target_to_link; + // Containers used for step (ii) for collecting mesh border halfedges + // with source/target on an intersection polyline that needs it prev/next + // pointer to be set + std::vector border_halfedges_source_to_link; + std::vector border_halfedges_target_to_link; + for (std::size_t i : ids_of_patches_to_append) + { + Patch_description& patch = patches[i]; for(halfedge_descriptor h : patch.interior_edges) if (is_border_edge(h,tm)) { @@ -1204,41 +1219,46 @@ void append_patches_to_triangle_mesh( CGAL_assertion(is_border(h_out,output) && is_border(h_out_next,output)); set_next(h_out, h_out_next, output); } - // now the step (ii) we look for the candidate halfedge by turning around - // the vertex in the direction of the interior of the patch - for(halfedge_descriptor h_out : border_halfedges_target_to_link) - { - halfedge_descriptor candidate = - opposite(prev(opposite(h_out, output), output), output); - CGAL_assertion_code(halfedge_descriptor start=candidate); - while (!is_border(candidate, output)){ - candidate=opposite(prev(candidate, output), output); - CGAL_assertion(candidate!=start); - } - set_next(h_out, candidate, output); - } - for(halfedge_descriptor h_out : border_halfedges_source_to_link) - { - halfedge_descriptor candidate = - opposite(next(opposite(h_out, output), output), output); - while (!is_border(candidate, output)) - candidate = opposite(next(candidate, output), output); - set_next(candidate, h_out, output); - } + } - // For all interior vertices, update the vertex pointer - // of all but the vertex halfedge - for(halfedge_descriptor h_out : interior_vertex_halfedges) - { - vertex_descriptor v = target(h_out, output); - halfedge_descriptor next_around_vertex=h_out; - do{ - CGAL_assertion(next(next_around_vertex, output) != GT::null_halfedge()); - next_around_vertex=opposite(next(next_around_vertex, output), output); - set_target(next_around_vertex, v, output); - }while(h_out != next_around_vertex); + // now the step (ii) we look for the candidate halfedge by turning around + // the vertex in the direction of the interior of the patch + for(halfedge_descriptor h_out : border_halfedges_target_to_link) + { + halfedge_descriptor candidate = + opposite(prev(opposite(h_out, output), output), output); + CGAL_assertion_code(halfedge_descriptor start=candidate); + while (!is_border(candidate, output)){ + candidate=opposite(prev(candidate, output), output); + CGAL_assertion(candidate!=start); } + set_next(h_out, candidate, output); + } + for(halfedge_descriptor h_out : border_halfedges_source_to_link) + { + halfedge_descriptor candidate = + opposite(next(opposite(h_out, output), output), output); + while (!is_border(candidate, output)) + candidate = opposite(next(candidate, output), output); + set_next(candidate, h_out, output); + } + // For all interior vertices, update the vertex pointer + // of all but the vertex halfedge + for(halfedge_descriptor h_out : interior_vertex_halfedges) + { + vertex_descriptor v = target(h_out, output); + halfedge_descriptor next_around_vertex=h_out; + do{ + CGAL_assertion(next(next_around_vertex, output) != GT::null_halfedge()); + next_around_vertex=opposite(next(next_around_vertex, output), output); + set_target(next_around_vertex, v, output); + }while(h_out != next_around_vertex); + } + + for (std::size_t i : ids_of_patches_to_append) + { + Patch_description& patch = patches[i]; // For all patch boundary vertices, update the vertex pointer // of all but the vertex halfedge for(halfedge_descriptor h : patch.shared_edges) @@ -1313,8 +1333,8 @@ void fill_new_triangle_mesh( //add a polyline inside O for each intersection polyline std::size_t nb_polylines = polylines.lengths.size(); - boost::unordered_map tm1_to_output_vertices; - boost::unordered_map tm1_to_output_edges, + std::unordered_map tm1_to_output_vertices; + std::unordered_map tm1_to_output_edges, tm2_to_output_edges; for (std::size_t i=0; i < nb_polylines; ++i) @@ -1403,7 +1423,7 @@ void disconnect_patches( // start the duplicate step std::size_t nb_shared_edges = patch.shared_edges.size(); new_patch_border.reserve( nb_shared_edges ); - boost::unordered_map old_to_new; + std::unordered_map old_to_new; // save faces inside the patch and set the halfedge // to be duplicated on the boundary @@ -1560,7 +1580,7 @@ void compute_inplace_operation_delay_removal_and_insideout( typedef boost::graph_traits GT; typedef typename GT::edge_descriptor edge_descriptor; typedef typename GT::halfedge_descriptor halfedge_descriptor; - typedef boost::unordered_map Edge_map; + typedef std::unordered_map Edge_map; Edge_map tm2_edge_to_tm1_edge, tm1_edge_to_tm2_edge; //maps intersection edges from tm2 to tm1 @@ -1714,13 +1734,13 @@ void compute_inplace_operation( EdgeMarkMapIn1& edge_mark_map_in1, const EdgeMarkMapIn2& edge_mark_map_in2, EdgeMarkMapOut1& edge_mark_map_out1, - boost::unordered_map< + std::unordered_map< typename boost::graph_traits::edge_descriptor, typename boost::graph_traits::edge_descriptor >& tm2_edge_to_tm1_edge, UserVisitor& user_visitor) { - typedef boost::unordered_map< + typedef std::unordered_map< typename boost::graph_traits::edge_descriptor, typename boost::graph_traits::edge_descriptor> EdgeMap; //clean up patches not kept @@ -1828,7 +1848,7 @@ void compute_inplace_operation( typedef boost::graph_traits GT; typedef typename GT::edge_descriptor edge_descriptor; - boost::unordered_map tm2_edge_to_tm1_edge; + std::unordered_map tm2_edge_to_tm1_edge; //maps intersection edges from tm2 to the equivalent in tm1 compute_border_edge_map(tm1, tm2, diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_callbacks.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_callbacks.h index 3c33b980cbc..52a037f7543 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_callbacks.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_callbacks.h @@ -353,12 +353,12 @@ public: Polygon_mesh_processing::does_self_intersect( *tmf_collected_faces_ptr, this->tm_faces, - Polygon_mesh_processing::parameters::vertex_point_map(this->vpmap_tmf)) + CGAL::parameters::vertex_point_map(this->vpmap_tmf)) || Polygon_mesh_processing::does_self_intersect( *tme_collected_faces_ptr, this->tm_edges, - Polygon_mesh_processing::parameters::vertex_point_map(this->vpmap_tme)); + CGAL::parameters::vertex_point_map(this->vpmap_tme)); } }; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_impl.h index 1c7f56491bf..c4312cdfd5e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_impl.h @@ -26,12 +26,13 @@ #include #include -#include -#include #include #include +#include #include +#include +#include namespace CGAL{ namespace Polygon_mesh_processing { @@ -194,8 +195,8 @@ class Intersection_of_triangle_meshes typedef CGAL::Box_intersection_d::ID_FROM_BOX_ADDRESS Box_policy; typedef CGAL::Box_intersection_d::Box_with_info_d Box; - typedef boost::unordered_set Face_set; - typedef boost::unordered_map Edge_to_faces; + typedef std::unordered_set Face_set; + typedef std::unordered_map Edge_to_faces; static const bool Predicates_on_constructions_needed = Node_visitor::Predicates_on_constructions_needed; @@ -208,7 +209,7 @@ class Intersection_of_triangle_meshes // we use Face_pair_and_int and not Face_pair to handle coplanar case. // Indeed the boundary of the intersection of two coplanar triangles // may contain several segments. - typedef boost::unordered_map< Face_pair, Node_id_set > Faces_to_nodes_map; + typedef std::unordered_map< Face_pair, Node_id_set, boost::hash > Faces_to_nodes_map; typedef Intersection_nodes Node_vector; @@ -1114,8 +1115,8 @@ class Intersection_of_triangle_meshes const VPM& vpm, Node_id& current_node) { - boost::unordered_map > face_intersections; + std::unordered_map > face_intersections; for (typename Faces_to_nodes_map::iterator it=f_to_node.begin(); it!=f_to_node.end(); ++it) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_nodes.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_nodes.h index e262e64ea25..95652746b6e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_nodes.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_nodes.h @@ -296,10 +296,8 @@ public: for (std::size_t i=0, e=enodes.size(); i!=e; ++i) { Point_3 pt = exact_to_double(enodes[i]); - if ( tm1_vertices[i] != GT::null_vertex() ) - put(vpm1, tm1_vertices[i], pt); - if ( tm2_vertices[i] != GT::null_vertex() ) - put(vpm2, tm2_vertices[i], pt); + tm1_vertices.update_vertex_point(i, pt, vpm1); + tm2_vertices.update_vertex_point(i, pt, vpm2); } } else{ @@ -307,8 +305,7 @@ public: for (std::size_t i=0, e=enodes.size(); i!=e; ++i) { Point_3 pt = exact_to_double(enodes[i]); - if ( tm1_vertices[i] != GT::null_vertex() ) - put(vpm1, tm1_vertices[i], pt); + tm1_vertices.update_vertex_point(i, pt, vpm1); } } } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polygon_mesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polygon_mesh.h index f4eb6980549..8b930f64255 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polygon_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polygon_mesh.h @@ -46,16 +46,21 @@ struct Tracer_polyhedron int i, int k, bool last = true) { - if(i + 1 == k) { return P[i+1]; } + if(i + 1 == k) + return P[i+1]; halfedge_descriptor h, g; - if(i+2 == k){ + if(i+2 == k) + { if(last) - { - h = P[i+1]; - Euler::fill_hole(h,pmesh); } + { + h = P[i + 1]; + Euler::fill_hole(h, pmesh); + } else - { h = Euler::add_face_to_border(prev(P[i+1],pmesh), P[i+2/*k*/], pmesh); } + { + h = Euler::add_face_to_border(prev(P[i + 1], pmesh), P[i + 2 /*k*/], pmesh); + } CGAL_assertion(face(h,pmesh) != boost::graph_traits::null_face()); *out++ = face(h,pmesh); @@ -68,12 +73,14 @@ struct Tracer_polyhedron g = operator()(lambda, la, k, false); if(last) - { - h = g; - Euler::fill_hole(g,pmesh); - } + { + h = g; + Euler::fill_hole(g, pmesh); + } else - { h = Euler::add_face_to_border(prev(h,pmesh), g, pmesh); } + { + h = Euler::add_face_to_border(prev(h, pmesh), g, pmesh); + } CGAL_assertion(face(h,pmesh) != boost::graph_traits::null_face()); *out++ = face(h,pmesh); @@ -96,6 +103,7 @@ triangulate_hole_polygon_mesh(PolygonMesh& pmesh, bool use_delaunay_triangulation, const Kernel& k, const bool use_cdt, + const bool skip_cubic_algorithm, const typename Kernel::FT max_squared_distance) { typedef Halfedge_around_face_circulator Hedge_around_face_circulator; @@ -106,28 +114,29 @@ triangulate_hole_polygon_mesh(PolygonMesh& pmesh, typedef std::map Vertex_map; typedef typename Vertex_map::iterator Vertex_map_it; - #ifdef CGAL_PMP_HOLE_FILLING_DEBUG +#ifdef CGAL_PMP_HOLE_FILLING_DEBUG CGAL::Timer timer; timer.start(); - #endif +#endif - std::vector P, Q; + std::vector P, Q; std::vector P_edges; Vertex_map vertex_map; int id = 0; Hedge_around_face_circulator circ(border_halfedge,pmesh), done(circ); - do{ + do + { P.push_back(get(vpmap, target(*circ, pmesh))); Q.push_back(get(vpmap, target(next(opposite(next(*circ,pmesh),pmesh),pmesh),pmesh))); P_edges.push_back(*circ); - if(!vertex_map.insert(std::make_pair(target(*circ,pmesh), id++)).second) { - #ifndef CGAL_TEST_SUITE + if(!vertex_map.insert(std::make_pair(target(*circ,pmesh), id++)).second) + { +#ifndef CGAL_TEST_SUITE CGAL_warning_msg(false, "Returning no output. Non-manifold vertex is found on boundary!"); - #else +#else std::cerr << "W: Returning no output. Non-manifold vertex is found on boundary!\n"; - #endif - return std::make_pair(out, - CGAL::internal::Weight_min_max_dihedral_and_area::NOT_VALID()); +#endif + return std::make_pair(out, CGAL::internal::Weight_min_max_dihedral_and_area::NOT_VALID()); } } while (++circ != done); @@ -151,52 +160,52 @@ triangulate_hole_polygon_mesh(PolygonMesh& pmesh, if(v_it_neigh_it != vertex_map.end()) //other endpoint found in the map { int v_it_neigh_id = v_it_neigh_it->second; - if( v_it_neigh_id != v_it_prev && v_it_neigh_id != v_it_next ) - { //there is an edge incident to v_it, which is not next or previous + if(v_it_neigh_id != v_it_prev && v_it_neigh_id != v_it_next) + { + //there is an edge incident to v_it, which is not next or previous //from vertex_map (checked by comparing IDs) if(v_it_id < v_it_neigh_id) // to include each edge only once - { existing_edges.push_back(std::make_pair(v_it_id, v_it_neigh_id)); } + existing_edges.push_back(std::make_pair(v_it_id, v_it_neigh_id)); } } } while(++circ_vertex != done_vertex); } - //#define CGAL_USE_WEIGHT_INCOMPLETE - #ifdef CGAL_USE_WEIGHT_INCOMPLETE +//#define CGAL_USE_WEIGHT_INCOMPLETE +#ifdef CGAL_USE_WEIGHT_INCOMPLETE typedef CGAL::internal::Weight_calculator, CGAL::internal::Is_valid_existing_edges_and_degenerate_triangle> WC; - #else +#else typedef CGAL::internal::Weight_calculator WC; - #endif +#endif CGAL::internal::Is_valid_existing_edges_and_degenerate_triangle is_valid(existing_edges); // fill hole using polyline function, with custom tracer for PolygonMesh - Tracer_polyhedron - tracer(out, pmesh, P_edges); + Tracer_polyhedron tracer(out, pmesh, P_edges); #ifndef CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 - if(use_cdt && triangulate_hole_polyline_with_cdt(P, tracer, is_valid, k, max_squared_distance)) - { - return std::make_pair(tracer.out, CGAL::internal::Weight_min_max_dihedral_and_area(0,0)); - } + if(use_cdt && triangulate_hole_polyline_with_cdt(P, tracer, is_valid, k, max_squared_distance)) + return std::make_pair(tracer.out, CGAL::internal::Weight_min_max_dihedral_and_area(0,0)); #endif CGAL::internal::Weight_min_max_dihedral_and_area weight = - triangulate_hole_polyline(P, Q, tracer, WC(is_valid), - use_delaunay_triangulation, k) -#ifdef CGAL_USE_WEIGHT_INCOMPLETE - .weight // get actual weight in Weight_incomplete +#ifndef CGAL_USE_WEIGHT_INCOMPLETE + triangulate_hole_polyline(P, Q, tracer, WC(is_valid), use_delaunay_triangulation, skip_cubic_algorithm, k); +#else + // get actual weight in Weight_incomplete + triangulate_hole_polyline(P, Q, tracer, WC(is_valid), use_delaunay_triangulation, k).weight; #endif - ; - #ifdef CGAL_PMP_HOLE_FILLING_DEBUG +#ifdef CGAL_PMP_HOLE_FILLING_DEBUG std::cerr << "Hole filling: " << timer.time() << " sc." << std::endl; timer.reset(); - #endif +#endif + return std::make_pair(tracer.out, weight); } -}// namespace internal -}// namespace Polygon_mesh_processing -}// namespace CGAL +} // namespace internal +} // namespace Polygon_mesh_processing +} // namespace CGAL + #endif //CGAL_HOLE_FILLING_TRIANGULATE_HOLE_POLYHEDRON_3_H 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 5eab37058cd..52352f96a9b 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 @@ -42,11 +42,9 @@ #include #include #include +#include #include -#include -#include -#include namespace CGAL { namespace internal { @@ -651,7 +649,7 @@ struct Edge_graph } }; - typedef boost::unordered_set Vertex_container; + typedef std::unordered_set Vertex_container; // contains edges as key, and each edge contains set of third vertices which denote neighbor facets to that edge typedef std::map, Vertex_container, Edge_comp> Graph; @@ -791,8 +789,8 @@ public: Triangulation tr; std::vector edge_exist; std::pair range(0, n-1); - boost::tuple, bool, bool> res = construct_3D_triangulation(P, range, tr, edge_exist); - if(!res.template get<2>()) { + std::tuple, bool, bool> res = construct_3D_triangulation(P, range, tr, edge_exist); + if(!std::get<2>(res)) { #ifdef CGAL_HOLE_FILLING_VERBOSE #ifndef CGAL_TEST_SUITE CGAL_warning_msg(false, "Returning no output. Dimension of 3D Triangulation is below 2!"); @@ -804,12 +802,12 @@ public: } // all border edges inside 3D Triangulation - if(boost::get<1>(res)) { + if(std::get<1>(res)) { LookupTable W(n, Weight::DEFAULT()); // do not forget that these default values are not changed for [i, i+1] LookupTable lambda(n,-1); typename Incident_facet_circulator_base::Edge_wrapper - e_start(*boost::get<0>(res)); + e_start(*std::get<0>(res)); if(tr.dimension() == 3) { triangulate_DT(P, Q, W, lambda, e_start, tr, WC, false); } @@ -839,7 +837,7 @@ public: #else // This approach produce better patches when used with Weight_incomplete // (which should be arranged in internal::triangulate_hole_Polyhedron, triangulate_polyline) - return fill_by_incomplete_patches(tr, res.get<0>(), edge_exist, P, Q, tracer, WC); + return fill_by_incomplete_patches(tr, std::get<0>(res), edge_exist, P, Q, tracer, WC); #endif } @@ -928,7 +926,7 @@ private: } // returns [h.first-h.second edge, true if all edges inside 3D triangulation, true if tr.dimension() >= 2] - boost::tuple, bool, bool> + std::tuple, bool, bool> construct_3D_triangulation(const Polyline_3& P, std::pair h, Triangulation& tr, @@ -937,11 +935,11 @@ private: // construct 3D tr with P[h.first], P[h.second] also assign ids from h.first to h.second boost::optional e; int n_border = h.second - h.first + 1; - tr.insert(boost::make_transform_iterator(boost::next(P.begin(), h.first), Auto_count(h.first)), - boost::make_transform_iterator(boost::next(P.begin(), h.second +1), Auto_count(h.first))); + tr.insert(boost::make_transform_iterator(std::next(P.begin(), h.first), Auto_count(h.first)), + boost::make_transform_iterator(std::next(P.begin(), h.second +1), Auto_count(h.first))); tr.infinite_vertex()->info() = -1; - if(tr.dimension() < 2) { return boost::make_tuple(e, false, false); } + if(tr.dimension() < 2) { return std::make_tuple(e, false, false); } // check whether all edges are included in DT, and get v0-vn-1 edge edge_exist.assign(n_border, false); @@ -972,7 +970,7 @@ private: bool is_3D_T_complete = (nb_exists == n_border); if(edge_exist[n_border-1]) { e = *v_first_v_second_edge; } - return boost::make_tuple(e, is_3D_T_complete, true); + return std::make_tuple(e, is_3D_T_complete, true); } /************************************************************************ @@ -992,7 +990,7 @@ private: { typedef std::pair Range; typedef std::back_insert_iterator > Output_hole_iterator; - typedef Tracer_polyline_incomplete, Emptyset_iterator, Output_hole_iterator> Remaining_holes_tracer; + typedef Tracer_polyline_incomplete, Emptyset_iterator, Output_hole_iterator> Remaining_holes_tracer; std::vector remaining_holes; @@ -1055,14 +1053,14 @@ private: // construct tr for next coming hole h = remaining_holes.back(); tr.clear(); - boost::tuple, bool, bool> res = construct_3D_triangulation(P, h, tr, edge_exist); - if(!boost::get<0>(res)) { + std::tuple, bool, bool> res = construct_3D_triangulation(P, h, tr, edge_exist); + if(!std::get<0>(res)) { #ifdef CGAL_HOLE_FILLING_VERBOSE CGAL_warning_msg(false, "Returning no output. Filling hole with incomplete patches is not successful!"); #endif return Weight::NOT_VALID(); } - start_edge = *boost::get<0>(res); + start_edge = *std::get<0>(res); // clear related regions in W, lambda for next coming hole W.set_range_to_default(h.first, h.second); lambda.set_range_to_default(h.first, h.second); @@ -1244,7 +1242,7 @@ bool is_planar_2( const Squared_distance_3 squared_distance_3 = traits.compute_squared_distance_3_object(); - const std::size_t n = points.size() - 1; // the first equals to the last + const double n = static_cast(points.size() - 1); // the first equals to the last if (n < 3) { return false; // cant be a plane! } @@ -1256,8 +1254,8 @@ bool is_planar_2( // Compute covariance matrix. FT xx = FT(0), yy = FT(0), zz = FT(0); FT xy = FT(0), xz = FT(0), yz = FT(0); - for (std::size_t i = 0; i < n; ++i) { - const Point_3& p = points[i]; + for (const Point_3& p : points) + { const FT dx = p.x() - centroid.x(); const FT dy = p.y() - centroid.y(); const FT dz = p.z() - centroid.z(); @@ -1278,15 +1276,14 @@ bool is_planar_2( } // Here, avg_squared_distance is a little bit more tolerant than avg_distance^2. - CGAL_assertion(avg_normal != typename Traits::Vector_3()); const Plane_3 plane = Plane_3(centroid, avg_normal); FT avg_squared_distance = FT(0); - for (std::size_t i = 0; i < n; ++i) { - const Point_3& p = points[i]; + for (const Point_3& p : points) + { const Point_3 q = projection_3(plane, p); avg_squared_distance += CGAL::abs(squared_distance_3(p, q)); } - avg_squared_distance /= static_cast(n); + avg_squared_distance /= FT(n); // std::cout << "avg squared distance: " << avg_squared_distance << std::endl; CGAL_assertion(max_squared_distance >= FT(0)); @@ -1327,7 +1324,7 @@ triangulate_hole_polyline_with_cdt(const PointRange& points, } FT x = FT(0), y = FT(0), z = FT(0); - std::size_t num_normals = 0; + int num_normals = 0; const Point_3& ref_point = P[0]; const std::size_t size = P.size() - 1; for (std::size_t i = 1; i < size - 1; ++i) { @@ -1362,12 +1359,15 @@ triangulate_hole_polyline_with_cdt(const PointRange& points, } // Setting the final normal. - x /= static_cast(num_normals); - y /= static_cast(num_normals); - z /= static_cast(num_normals); + FT ft_nn(num_normals); + x /= ft_nn; + y /= ft_nn; + z /= ft_nn; const Vector_3 avg_normal = Vector_3(x, y, z); // std::cout << "avg normal: " << avg_normal << std::endl; + if (avg_normal==NULL_VECTOR) return false; + // Checking the hole planarity. if (!is_planar_2(P, avg_normal, max_squared_distance, traits)) { // std::cerr << "WARNING: planarity, cdt 2 falls back to the original solution!" << std::endl; @@ -1486,17 +1486,20 @@ triangulate_hole_polyline(const PointRange1& points, Tracer& tracer, const WeightCalculator& WC, bool use_delaunay_triangulation, + bool skip_cubic_algorithm, const Kernel&) { CGAL_assertion(!points.empty()); + if (!use_delaunay_triangulation && skip_cubic_algorithm) + return WeightCalculator::Weight::NOT_VALID(); typedef Kernel K; typedef typename K::Point_3 Point_3; - #ifndef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 +#ifndef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 typedef CGAL::internal::Triangulate_hole_polyline_DT Fill_DT; - #else +#else CGAL_USE(use_delaunay_triangulation); - #endif +#endif typedef CGAL::internal::Triangulate_hole_polyline Fill; std::vector P(boost::begin(points), boost::end(points)); @@ -1510,20 +1513,23 @@ triangulate_hole_polyline(const PointRange1& points, } typename WeightCalculator::Weight w = - #ifndef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 +#ifndef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 use_delaunay_triangulation ? Fill_DT().operator()(P,Q,tracer,WC) : - #endif +#endif Fill().operator()(P,Q,tracer,WC); #ifndef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 - if (use_delaunay_triangulation - && w == WeightCalculator::Weight::NOT_VALID()) + if(use_delaunay_triangulation && + w == WeightCalculator::Weight::NOT_VALID() + &&!skip_cubic_algorithm) + { w = Fill().operator()(P, Q, tracer, WC); + } #endif - #ifdef CGAL_PMP_HOLE_FILLING_DEBUG +#ifdef CGAL_PMP_HOLE_FILLING_DEBUG std::cerr << w << std::endl; - #endif +#endif return w; } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/experimental/experimental_code.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/experimental/experimental_code.h index db45e2a4cbb..a33bd8964be 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/experimental/experimental_code.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/experimental/experimental_code.h @@ -121,7 +121,7 @@ triangulate_hole_polyline_incomplete(InputIterator pbegin, InputIterator pend, typedef Weight_incomplete Weight; typedef Weight_calculator WC; - typedef std::vector > Facet_vector; /* deliberately not OutputIteratorValueType*/ + typedef std::vector > Facet_vector; /* deliberately not OutputIteratorValueType*/ typedef std::back_insert_iterator OutIt; typedef Tracer_polyline_incomplete Tracer; typedef std::pair Range; 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 1fa79af240f..8c5cb13c0ae 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 @@ -40,8 +40,6 @@ #include #include #include -#include -#include #include #include #include @@ -52,6 +50,8 @@ #include #include #include +#include +#include #ifdef CGAL_PMP_REMESHING_DEBUG #include @@ -68,11 +68,7 @@ #define CGAL_PMP_REMESHING_VERBOSE #endif - namespace CGAL { - -namespace PMP = Polygon_mesh_processing; - namespace Polygon_mesh_processing { namespace internal { @@ -114,8 +110,7 @@ namespace internal { , pmesh_ptr_(&pmesh) { std::vector border; - PMP::border_halfedges(faces, *pmesh_ptr_, std::back_inserter(border) - , PMP::parameters::face_index_map(fimap)); + border_halfedges(faces, *pmesh_ptr_, std::back_inserter(border), parameters::face_index_map(fimap)); for(halfedge_descriptor h : border) border_edges_ptr->insert(edge(h, *pmesh_ptr_)); @@ -193,22 +188,19 @@ namespace internal { if ( same_range(face_range, (faces(pmesh))) ) { // applied on the whole mesh - nb_cc - = PMP::connected_components(pmesh, - patch_ids_map, - PMP::parameters::edge_is_constrained_map(ecmap) - .face_index_map(fimap)); + nb_cc = connected_components(pmesh, patch_ids_map, + parameters::edge_is_constrained_map(ecmap) + .face_index_map(fimap)); } else { // applied on a subset of the mesh - nb_cc - = PMP::connected_components(pmesh, - patch_ids_map, - PMP::parameters::edge_is_constrained_map( - make_OR_property_map(ecmap - , internal::Border_constraint_pmap(pmesh, face_range, fimap) ) ) - .face_index_map(fimap)); + nb_cc = connected_components( + pmesh, patch_ids_map, + parameters::edge_is_constrained_map( + make_OR_property_map(ecmap, + internal::Border_constraint_pmap(pmesh, face_range, fimap))) + .face_index_map(fimap)); } } else @@ -812,9 +804,7 @@ namespace internal { #ifdef CGAL_PMP_REMESHING_DEBUG debug_status_map(); debug_self_intersections(); - CGAL_assertion(PMP::remove_degenerate_faces(mesh_, - parameters::vertex_point_map(vpmap_) - .geom_traits(gt_))); + CGAL_assertion(remove_degenerate_faces(mesh_, parameters::vertex_point_map(vpmap_).geom_traits(gt_))); #endif } @@ -850,18 +840,19 @@ namespace internal { if (!is_flip_allowed(e)) continue; //add geometric test to avoid axe cuts - if (!PMP::internal::should_flip(e, mesh_, vpmap_, gt_)) + if (!internal::should_flip(e, mesh_, vpmap_, gt_)) continue; halfedge_descriptor he = halfedge(e, mesh_); - std::array r1 = PMP::internal::is_badly_shaped( + std::array r1 = internal::is_badly_shaped( face(he, mesh_), mesh_, vpmap_, vcmap_, ecmap_, gt_, cap_threshold, // bound on the angle: above 160 deg => cap 4, // bound on shortest/longest edge above 4 => needle 0);// collapse length threshold : not needed here - std::array r2 = PMP::internal::is_badly_shaped( + + std::array r2 = internal::is_badly_shaped( face(opposite(he, mesh_), mesh_), mesh_, vpmap_, vcmap_, ecmap_, gt_, cap_threshold, 4, 0); @@ -976,9 +967,7 @@ namespace internal { #ifdef CGAL_PMP_REMESHING_DEBUG debug_status_map(); - CGAL_assertion(PMP::remove_degenerate_faces(mesh_, - PMP::parameters::vertex_point_map(vpmap_) - .geom_traits(gt_))); + CGAL_assertion(remove_degenerate_faces(mesh_, parameters::vertex_point_map(vpmap_).geom_traits(gt_))); debug_self_intersections(); #endif @@ -1016,9 +1005,7 @@ namespace internal { else if (is_on_patch(v)) { - Vector_3 vn = PMP::compute_vertex_normal(v, mesh_, - parameters::vertex_point_map(vpmap_) - .geom_traits(gt_)); + Vector_3 vn = compute_vertex_normal(v, mesh_, parameters::vertex_point_map(vpmap_).geom_traits(gt_)); Vector_3 move = CGAL::NULL_VECTOR; unsigned int star_size = 0; for(halfedge_descriptor h : halfedges_around_target(v, mesh_)) @@ -1547,8 +1534,7 @@ private: if (f == boost::graph_traits::null_face()) return CGAL::NULL_VECTOR; - return PMP::compute_face_normal(f, mesh_, parameters::vertex_point_map(vpmap_) - .geom_traits(gt_)); + return compute_face_normal(f, mesh_, parameters::vertex_point_map(vpmap_).geom_traits(gt_)); } template @@ -1698,7 +1684,7 @@ private: { CGAL_assertion_code(std::size_t nb_done = 0); - boost::unordered_set degenerate_faces; + std::unordered_set degenerate_faces; for(halfedge_descriptor h : halfedges_around_target(halfedge(v, mesh_), mesh_)) { @@ -1959,10 +1945,8 @@ private: { std::cout << "Test self intersections..."; std::vector > facets; - PMP::self_intersections(mesh_, - std::back_inserter(facets), - PMP::parameters::vertex_point_map(vpmap_) - .geom_traits(gt_)); + self_intersections(mesh_, std::back_inserter(facets), + parameters::vertex_point_map(vpmap_).geom_traits(gt_)); //CGAL_assertion(facets.empty()); std::cout << "done ("<< facets.size() <<" facets)." << std::endl; } @@ -1971,11 +1955,8 @@ private: { std::cout << "Test self intersections..."; std::vector > facets; - PMP::self_intersections(faces_around_target(halfedge(v, mesh_), mesh_), - mesh_, - std::back_inserter(facets), - PMP::parameters::vertex_point_map(vpmap_) - .geom_traits(gt_)); + self_intersections(faces_around_target(halfedge(v, mesh_), mesh_), mesh_, std::back_inserter(facets), + parameters::vertex_point_map(vpmap_).geom_traits(gt_)); //CGAL_assertion(facets.empty()); std::cout << "done ("<< facets.size() <<" facets)." << std::endl; } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/curvature_flow_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/curvature_flow_impl.h index fa600557af3..66ecda4314e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/curvature_flow_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/curvature_flow_impl.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/helper.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/helper.h index 0c3fc465392..ce67cc83a84 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/helper.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/helper.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include namespace CGAL { @@ -42,12 +42,12 @@ void vertices_as_halfedges(const VertexRange& vertex_range, template + typename NamedParameters = parameters::Default_named_parameters> void assign_tolerance_with_local_edge_length_bound(const HalfedgeRange& halfedge_range, ToleranceMap& tolerance_map, const typename GetGeomTraits::type::FT tolerance, PolygonMesh& mesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -92,17 +92,6 @@ void assign_tolerance_with_local_edge_length_bound(const HalfedgeRange& halfedge } } -template -void assign_tolerance_with_local_edge_length_bound(const HalfedgeRange& halfedge_range, - ToleranceMap& tolerance_map, - const typename GetGeomTraits::type::FT tolerance, - PolygonMesh& mesh) -{ - return assign_tolerance_with_local_edge_length_bound(halfedge_range, tolerance_map, tolerance, mesh, CGAL::parameters::all_default()); -} - template bool is_collinear_with_tolerance(const typename GeomTraits::Point_3& p, // va == vb const typename GeomTraits::Point_3& pa, @@ -233,6 +222,10 @@ struct Snapping_default_visitor template void after_vertex_edge_snap(const Vertex /*new_vertex*/, const Mesh&) { } + // Called after CGAL::Euler::split_face(h1, h2, tm) + template + void after_split_face(const Halfedge_descriptor /*h1*/, const Halfedge_descriptor /*h2*/, const Mesh& /*tm*/) { } + // ------------------------------- Two passes (segmentation or not) ------------------------------ // Called at the start of the snapping pass that is restricted to compatible patch (first pass). diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h index 490cc457b13..45fa0ac7a92 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include @@ -178,7 +178,7 @@ void simplify_range(HalfedgeRange& halfedge_range, halfedge_range = HalfedgeRange(new_range.begin(), new_range.end()); - CGAL_postcondition(halfedge_range.size() == initial_n - collapsed_n); + CGAL_postcondition(halfedge_range.size() <= initial_n - collapsed_n); } // Adapted from @@ -764,15 +764,19 @@ std::size_t split_edges(EdgesToSplitContainer& edges_to_split, if(is_visible) { + halfedge_descriptor h2 = prev(prev(h_to_split_opp, tm_T), tm_T); halfedge_descriptor new_hd = CGAL::Euler::split_face(h_to_split_opp, - prev(prev(h_to_split_opp, tm_T), tm_T), tm_T); + h2, tm_T); h_to_split = opposite(prev(new_hd, tm_T), tm_T); + visitor.after_split_face(h_to_split_opp, h2, tm_T); } else { + halfedge_descriptor h2 = prev(h_to_split_opp, tm_T); halfedge_descriptor new_hd = CGAL::Euler::split_face(opposite(res, tm_T), - prev(h_to_split_opp, tm_T), tm_T); + h2, tm_T); h_to_split = opposite(next(new_hd, tm_T), tm_T); + visitor.after_split_face(opposite(res, tm_T), h2, tm_T); } } } @@ -1094,7 +1098,6 @@ std::size_t snap_non_conformal(HalfedgeRange& halfedge_range_A, >::reference Visitor; using CGAL::parameters::choose_parameter; - using CGAL::parameters::is_default_parameter; using CGAL::parameters::get_parameter; using CGAL::parameters::get_parameter_reference; @@ -1291,13 +1294,16 @@ namespace experimental { template + typename NamedParameters_A = parameters::Default_named_parameters, + typename NamedParameters_B = parameters::Default_named_parameters> std::size_t snap_borders(TriangleMesh& tm_A, ToleranceMap_A tolerance_map_A, TriangleMesh& tm_B, ToleranceMap_B tolerance_map_B, - const NamedParameters_A& np_A, - const NamedParameters_B& np_B) + const NamedParameters_A& np_A = parameters::default_values(), + const NamedParameters_B& np_B = parameters::default_values(), + const typename std::enable_if_t::value>* = 0 // Added to please MSVC 2015 + ) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -1313,11 +1319,12 @@ std::size_t snap_borders(TriangleMesh& tm_A, template + typename NamedParameters_A = parameters::Default_named_parameters, + typename NamedParameters_B = parameters::Default_named_parameters> std::size_t snap_borders(TriangleMesh& tm_A, TriangleMesh& tm_B, - const NamedParameters_A& np_A, - const NamedParameters_B& np_B) + const NamedParameters_A& np_A = parameters::default_values(), + const NamedParameters_B& np_B = parameters::default_values()) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -1342,27 +1349,6 @@ std::size_t snap_borders(TriangleMesh& tm_A, border_vertices_B, tm_B, tolerance_map_B, false /*no self snapping*/, np_A, np_B); } - -template -std::size_t snap_borders(TriangleMesh& tm_A, - ToleranceMap_A tolerance_map_A, - TriangleMesh& tm_B, - ToleranceMap_B tolerance_map_B) -{ - return snap_borders(tm_A, tolerance_map_A, tm_B, tolerance_map_B, - CGAL::parameters::all_default(), CGAL::parameters::all_default()); -} - -template -std::size_t snap_borders(TriangleMesh& tm_A, - TriangleMesh& tm_B) -{ - return snap_borders(tm_A, tm_B, CGAL::parameters::all_default(), CGAL::parameters::all_default()); -} - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1371,10 +1357,12 @@ std::size_t snap_borders(TriangleMesh& tm_A, template + typename CGAL_NP_TEMPLATE_PARAMETERS> std::size_t snap_borders(TriangleMesh& tm, ToleranceMap tolerance_map, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values(), + const typename std::enable_if_t::value>* = 0 // Added to please MSVC 2015 +) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -1388,18 +1376,9 @@ std::size_t snap_borders(TriangleMesh& tm, template + typename CGAL_NP_TEMPLATE_PARAMETERS> std::size_t snap_borders(TriangleMesh& tm, - ToleranceMap tolerance_map) -{ - return snap_borders(tm, tolerance_map, CGAL::parameters::all_default()); -} - -template -std::size_t snap_borders(TriangleMesh& tm, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -1421,13 +1400,6 @@ std::size_t snap_borders(TriangleMesh& tm, true /*self snapping*/, np, np); } -template -std::size_t snap_borders(TriangleMesh& tm) -{ - return snap_borders(tm, CGAL::parameters::all_default()); -} - } // end namespace experimental } // end namespace Polygon_mesh_processing } // end namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap_vertices.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap_vertices.h index 98aa23f2862..2c445fdc14d 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap_vertices.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap_vertices.h @@ -22,7 +22,7 @@ #endif #include -#include +#include #include #include @@ -1196,15 +1196,16 @@ namespace experimental { template + typename NamedParameters_A = parameters::Default_named_parameters, + typename NamedParameters_B = parameters::Default_named_parameters> std::size_t snap_vertices(const HalfedgeRange_A& halfedge_range_A, PolygonMesh& tm_A, ToleranceMap_A tolerance_map_A, const HalfedgeRange_B& halfedge_range_B, PolygonMesh& tm_B, ToleranceMap_B tolerance_map_B, - const NamedParameters_A& np_A, - const NamedParameters_B& np_B) + const NamedParameters_A& np_A = parameters::default_values(), + const NamedParameters_B& np_B = parameters::default_values()) { CGAL::Emptyset_iterator unused_output_iterator; @@ -1214,34 +1215,19 @@ std::size_t snap_vertices(const HalfedgeRange_A& halfedge_range_A, unused_output_iterator, np_A, np_B); } -template -std::size_t snap_vertices(const HalfedgeRange_A& halfedge_range_A, - PolygonMesh& tm_A, - ToleranceMap_A tolerance_map_A, - const HalfedgeRange_B& halfedge_range_B, - PolygonMesh& tm_B, - ToleranceMap_B tolerance_map_B) -{ - return snap_vertices(halfedge_range_A, tm_A, tolerance_map_A, - halfedge_range_B, tm_B, tolerance_map_B, - CGAL::parameters::all_default(), CGAL::parameters::all_default()); -} template + typename CGAL_NP_TEMPLATE_PARAMETERS_1, + typename CGAL_NP_TEMPLATE_PARAMETERS_2> std::size_t snap_vertices(const HalfedgeRange_A& halfedge_range_A, PolygonMesh& tm_A, const HalfedgeRange_B& halfedge_range_B, PolygonMesh& tm_B, - const CGAL::Named_function_parameters& np_A, - const CGAL::Named_function_parameters& np_B) + const CGAL_NP_CLASS_1& np_A=parameters::default_values(), + const CGAL_NP_CLASS_2& np_B=parameters::default_values()) { - typedef CGAL::Named_function_parameters NamedParameters_A; - typedef typename GetGeomTraits::type GT; + typedef typename GetGeomTraits::type GT; typedef typename GT::FT FT; typedef CGAL::dynamic_vertex_property_t Vertex_property_tag; typedef typename boost::property_map::type Tolerance_map; @@ -1256,17 +1242,6 @@ std::size_t snap_vertices(const HalfedgeRange_A& halfedge_range_A, return snap_vertices(halfedge_range_A, tm_A, tolerance_map_A, halfedge_range_B, tm_B, tolerance_map_B, np_A, np_B); } -template -std::size_t snap_vertices(const HalfedgeRange_A& halfedge_range_A, - PolygonMesh& tm_A, - const HalfedgeRange_B& halfedge_range_B, - PolygonMesh& tm_B) -{ - return snap_vertices(halfedge_range_A, tm_A, halfedge_range_B, tm_B, - parameters::all_default(), parameters::all_default()); -} - /////////////////////////////////////////////////////////////////////////////////////////////////// /// Border convenience overloads /////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/named_function_params.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/named_function_params.h deleted file mode 100644 index 52b528a889f..00000000000 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/named_function_params.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2015 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) : Jane Tournois - -#ifndef CGAL_PMP_BGL_NAMED_FUNCTION_PARAMS_H -#define CGAL_PMP_BGL_NAMED_FUNCTION_PARAMS_H - -#include - - -#include - -#define CGAL_PMP_NP_TEMPLATE_PARAMETERS CGAL_BGL_NP_TEMPLATE_PARAMETERS -#define CGAL_PMP_NP_CLASS CGAL_BGL_NP_CLASS - -namespace CGAL { namespace Polygon_mesh_processing { namespace parameters = CGAL::parameters; } } - -#endif //CGAL_PMP_BGL_NAMED_FUNCTION_PARAMS_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/repair_extra.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/repair_extra.h index f18ef7186be..af22ed1df25 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/repair_extra.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/repair_extra.h @@ -16,11 +16,17 @@ #include -#include +#include #include +#include +#include #include -#include +#include + +#include +#include +#include #ifndef DOXYGEN_RUNNING @@ -32,11 +38,14 @@ namespace internal { template -struct Edges_proximity_report{ +struct Edges_proximity_report +{ typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef std::vector< std::pair > Halfedge_pairs; - double m_epsilon; + typedef typename GetGeomTraits::type::FT FT; + + FT m_sq_epsilon; Vpm m_vpm; PM& m_pm; Halfedge_multiplicity& m_multiplicity; @@ -46,7 +55,7 @@ struct Edges_proximity_report{ Edges_proximity_report(double epsilon, Vpm vpm, PM& pm, Halfedge_multiplicity& multiplicity, Halfedge_pairs& matching_hedges) - : m_epsilon( epsilon ) + : m_sq_epsilon(square(epsilon)) , m_vpm(vpm) , m_pm(pm) , m_multiplicity(multiplicity) @@ -72,12 +81,12 @@ struct Edges_proximity_report{ Point_ref src2 = get(m_vpm, source(h2, m_pm)); Point_ref tgt2 = get(m_vpm, target(h2, m_pm)); - if ( squared_distance(src1,tgt2) < m_epsilon * m_epsilon && - squared_distance(tgt1,src2) < m_epsilon * m_epsilon && + if ( compare_squared_distance(src1, tgt2, m_sq_epsilon) == SMALLER && + compare_squared_distance(tgt1, src2, m_sq_epsilon) == SMALLER && angle(src1, tgt1, tgt2, src2) == ACUTE ) { // candidate for stitching - m_matching_hedges.push_back( std::make_pair(h1,h2) ); + m_matching_hedges.emplace_back(h1,h2); ++(m_multiplicity.insert(std::make_pair(h1,0)).first->second); ++(m_multiplicity.insert(std::make_pair(h2,0)).first->second); } @@ -107,7 +116,7 @@ void collect_close_stitchable_boundary_edges(PM& pm, typedef typename boost::graph_traits::edge_descriptor edge_descriptor; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef boost::unordered_map Halfedge_multiplicity; + typedef std::unordered_map Halfedge_multiplicity; typedef std::vector > Halfedge_pairs; typedef CGAL::Box_intersection_d::ID_FROM_BOX_ADDRESS Box_policy; @@ -118,6 +127,8 @@ void collect_close_stitchable_boundary_edges(PM& pm, typedef typename boost::property_traits::reference Point_ref; + const double half_eps = 0.5 * epsilon; + std::vector boxes; for(edge_descriptor ed : edges(pm)) { @@ -126,14 +137,18 @@ void collect_close_stitchable_boundary_edges(PM& pm, Point_ref src = get(vpm, source(ed, pm)); Point_ref tgt = get(vpm, target(ed, pm)); - boxes.push_back( Box( - Bbox_3( src.x()-epsilon/2, src.y()-epsilon/2, src.z()-epsilon/2, - src.x()+epsilon/2, src.y()+epsilon/2, src.z()+epsilon/2 ) - + - Bbox_3( tgt.x()-epsilon/2, tgt.y()-epsilon/2, tgt.z()-epsilon/2, - tgt.x()+epsilon/2, tgt.y()+epsilon/2, tgt.z()+epsilon/2 ), - ed ) - ); + const double sx = to_double(src.x()); + const double sy = to_double(src.y()); + const double sz = to_double(src.z()); + const double tx = to_double(tgt.x()); + const double ty = to_double(tgt.y()); + const double tz = to_double(tgt.z()); + + boxes.emplace_back(Bbox_3(sx - half_eps, sy - half_eps, sz - half_eps, + sx + half_eps, sy + half_eps, sz + half_eps) + + Bbox_3(tx - half_eps, ty - half_eps, tz - half_eps, + tx + half_eps, ty + half_eps, tz + half_eps), + ed); } } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/simplify_polyline.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/simplify_polyline.h index 68a7333fabd..016dedea22d 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/simplify_polyline.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/simplify_polyline.h @@ -15,7 +15,7 @@ #include -#include +#include #include #include @@ -28,12 +28,13 @@ namespace experimental { enum Polyline_simplification_algorithms { DOUGLAS_PEUCKER, ITERATIVE }; template + typename NamedParametersIn = parameters::Default_named_parameters, + typename NamedParametersOut = parameters::Default_named_parameters> void simplify_polyline(const PointRangeIn& input, PointRangeOut& output, const double max_squared_frechet_distance, - const NamedParametersIn& np_in, - const NamedParametersOut& np_out) + const NamedParametersIn& np_in = parameters::default_values(), + const NamedParametersOut& np_out = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -44,7 +45,7 @@ void simplify_polyline(const PointRangeIn& input, typedef typename GetPointMap::type Point_map_in; typedef typename GetPointMap::type Point_map_out; - typedef typename Point_set_processing_3::GetK::Kernel Kernel; + typedef typename Point_set_processing_3_np_helper::Geom_traits Kernel; Point_map_in in_pm = choose_parameter(get_parameter(np_in, internal_np::point_map)); Point_map_out out_pm = choose_parameter(get_parameter(np_out, internal_np::point_map)); @@ -182,25 +183,6 @@ void simplify_polyline(const PointRangeIn& input, } } - -template -void simplify_polyline(const PointRangeIn& input, - PointRangeOut& output, - const double max_squared_frechet_distance) -{ - simplify_polyline(input, output, max_squared_frechet_distance, - parameters::all_default(), parameters::all_default()); -} - -template -void simplify_polyline(const PointRangeIn& input, - PointRangeOut& output, - const double max_squared_frechet_distance, - const NamedParametersIn& np_in) -{ - simplify_polyline(input, output, max_squared_frechet_distance, np_in, parameters::all_default()); -} - } } } // end of CGAL::Polygon_mesh_processing::experimental namespace diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/intersection.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/intersection.h index 169e6a66219..fb65a38fedb 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/intersection.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/intersection.h @@ -1045,19 +1045,19 @@ void get_one_point_per_cc(TriangleMesh& tm, std::vector& points_of_interest) { typedef typename boost::graph_traits::face_descriptor face_descriptor; - boost::unordered_map fid_map; + std::unordered_map fid_map; int id = 0; for(face_descriptor fd : faces(tm)) { fid_map.insert(std::make_pair(fd,id++)); } - boost::associative_property_map< boost::unordered_map > + boost::associative_property_map< std::unordered_map > fid_pmap(fid_map); - boost::unordered_map fcc_map; + std::unordered_map fcc_map; int nb_cc = Polygon_mesh_processing::connected_components(tm, boost::make_assoc_property_map(fcc_map), - Polygon_mesh_processing::parameters::face_index_map(fid_pmap)); + parameters::face_index_map(fid_pmap)); std::vector is_cc_treated(nb_cc, false); points_of_interest.resize(nb_cc); int cc_treated = 0; @@ -1251,12 +1251,18 @@ bool do_intersect(const Polyline& polyline1, * */ template + class CGAL_NP_TEMPLATE_PARAMETERS_1, + class CGAL_NP_TEMPLATE_PARAMETERS_2> bool do_intersect(const TriangleMesh& tm1, const TriangleMesh& tm2, - const NamedParameters1& np1, - const NamedParameters2& np2) + const CGAL_NP_CLASS_1& np1 = parameters::default_values(), + const CGAL_NP_CLASS_2& np2 = parameters::default_values() +#ifndef DOXYGEN_RUNNING + , const typename boost::disable_if< + typename boost::has_range_const_iterator::type + >::type* = 0 +#endif + ) { using parameters::choose_parameter; using parameters::get_parameter; @@ -1279,13 +1285,13 @@ bool do_intersect(const TriangleMesh& tm1, if (test_overlap) { - typedef typename GetVertexPointMap::const_type VertexPointMap1; - typedef typename GetVertexPointMap::const_type VertexPointMap2; + typedef typename GetVertexPointMap::const_type VertexPointMap1; + typedef typename GetVertexPointMap::const_type VertexPointMap2; VertexPointMap1 vpm1 = choose_parameter(get_parameter(np1, internal_np::vertex_point), get_const_property_map(boost::vertex_point, tm1)); VertexPointMap2 vpm2 = choose_parameter(get_parameter(np2, internal_np::vertex_point), get_const_property_map(boost::vertex_point, tm2)); - typedef typename GetGeomTraits::type GeomTraits; + typedef typename GetGeomTraits::type GeomTraits; GeomTraits gt = choose_parameter(get_parameter(np1, internal_np::geom_traits)); return internal::is_mesh2_in_mesh1(tm1, tm2, vpm1, vpm2, gt) || @@ -1294,19 +1300,6 @@ bool do_intersect(const TriangleMesh& tm1, return false; } -//convenient overload -template -bool do_intersect(const TriangleMesh& tm1, - const TriangleMesh& tm2, - const typename boost::disable_if< - typename boost::has_range_const_iterator::type - >::type* = 0) -{ - CGAL_precondition(CGAL::is_triangle_mesh(tm1)); - CGAL_precondition(CGAL::is_triangle_mesh(tm2)); - return CGAL::Polygon_mesh_processing::do_intersect(tm1, tm2, parameters::all_default(), parameters::all_default()); -} - /** * \ingroup PMP_predicates_grp * returns `true` if there exists a face of `tm` and a segment of a polyline of `polylines` which intersect, @@ -1344,10 +1337,10 @@ bool do_intersect(const TriangleMesh& tm1, */ template + class NamedParameters = parameters::Default_named_parameters> bool do_intersect(const TriangleMesh& tm, const PolylineRange& polylines, - const NamedParameters& np + const NamedParameters& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , const typename boost::enable_if< typename boost::has_range_iterator< @@ -1409,18 +1402,22 @@ bool do_intersect(const TriangleMesh& tm, */ template + class CGAL_NP_TEMPLATE_PARAMETERS> bool do_intersect(const TriangleMesh& tm, const Polyline& polyline, - const NamedParameters& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , const typename boost::disable_if< - typename boost::has_range_iterator< - typename boost::mpl::eval_if< - boost::has_range_iterator, - boost::range_value, - boost::false_type - >::type + typename boost::mpl::or_< + typename boost::is_same::type, // Added to please MSVC 2015 + typename boost::mpl::not_::type>::type, // not a range + typename boost::has_range_iterator< + typename boost::mpl::eval_if< + boost::has_range_iterator, + boost::range_value, + boost::false_type + >::type + >::type // not a range of a range >::type >::type* = 0 #endif @@ -1438,46 +1435,6 @@ bool do_intersect(const TriangleMesh& tm, return false; } -template -bool do_intersect(const TriangleMesh& tm, - const PolylineRange& polylines, - const typename boost::enable_if< - typename boost::has_range_iterator< - typename boost::mpl::eval_if< - boost::has_range_iterator, - boost::range_value, - boost::false_type - >::type - >::type - >::type* = 0) -{ - CGAL_precondition(CGAL::is_triangle_mesh(tm)); - return CGAL::Polygon_mesh_processing::do_intersect(tm, polylines, parameters::all_default()); -} - - -template -bool do_intersect(const TriangleMesh& tm, - const Polyline& polyline, - const typename boost::disable_if< - typename boost::has_range_const_iterator::type - >::type* = 0, - const typename boost::disable_if< - typename boost::has_range_iterator< - typename boost::mpl::eval_if< - boost::has_range_iterator, - boost::range_value, - boost::false_type - >::type - >::type - >::type* = 0) -{ - CGAL_precondition(CGAL::is_triangle_mesh(tm)); - return CGAL::Polygon_mesh_processing::do_intersect(tm, polyline, parameters::all_default()); -} - namespace internal{ templateinfo(), *b2->info(), - Polygon_mesh_processing::parameters::vertex_point_map(vpm1) + parameters::vertex_point_map(vpm1) .geom_traits(gt), - Polygon_mesh_processing::parameters::vertex_point_map(vpm2) + parameters::vertex_point_map(vpm2) .geom_traits(gt))) { *m_iterator++ = std::make_pair(mesh_id_1, mesh_id_2); @@ -1688,8 +1645,8 @@ OutputIterator intersecting_meshes(const TriangleMeshRange& range, OutputIterator out, const NamedParameters& np) { - std::vector >nps( - std::distance(range.begin(), range.end()), parameters::all_default()); + std::vector nps( + std::distance(range.begin(), range.end()), parameters::default_values()); return intersecting_meshes(range, out, np, nps); } @@ -1697,7 +1654,7 @@ template OutputIterator intersecting_meshes(const TriangleMeshRange& range, OutputIterator out) { - return intersecting_meshes(range, out, parameters::all_default()); + return intersecting_meshes(range, out, parameters::default_values()); } /** @@ -1746,14 +1703,14 @@ OutputIterator intersecting_meshes(const TriangleMeshRange& range, */ template + class NamedParameters1 = parameters::Default_named_parameters, + class NamedParameters2 = parameters::Default_named_parameters > OutputIterator surface_intersection(const TriangleMesh& tm1, const TriangleMesh& tm2, OutputIterator polyline_output, - const NamedParameters1& np1, - const NamedParameters2& np2) + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values()) { const bool throw_on_self_intersection = parameters::choose_parameter(parameters::get_parameter(np1, internal_np::throw_on_self_intersection), false); @@ -1809,11 +1766,11 @@ namespace experimental { */ template + class NamedParameters = parameters::Default_named_parameters > OutputIterator surface_self_intersection(const TriangleMesh& tm, OutputIterator polyline_output, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { // Vertex point maps typedef typename GetVertexPointMap::const_type VPM; @@ -1829,77 +1786,6 @@ surface_self_intersection(const TriangleMesh& tm, return polyline_output; } -} //end of namespace experimental - - -template -OutputIterator -surface_intersection(const TriangleMesh& tm1, - const TriangleMesh& tm2, - OutputIterator polyline_output) -{ - return surface_intersection(tm1, tm2, polyline_output, - CGAL::Polygon_mesh_processing::parameters::all_default(), - CGAL::Polygon_mesh_processing::parameters::all_default()); -} - -template -OutputIterator -surface_intersection(const TriangleMesh& tm1, - const TriangleMesh& tm2, - OutputIterator polyline_output, - const NamedParameters1& np) -{ - return surface_intersection(tm1, tm2, polyline_output, np, - CGAL::Polygon_mesh_processing::parameters::all_default()); -} - -#ifndef CGAL_NO_DEPRECATED_CODE -template -OutputIterator -surface_intersection(const TriangleMesh& tm1, - const TriangleMesh& tm2, - OutputIterator polyline_output, - const NamedParameters1& np1, - const NamedParameters2& np2, - const bool throw_on_self_intersection) -{ - return surface_intersection(tm1, tm2, polyline_output, - np1.throw_on_self_intersection(throw_on_self_intersection), np2); -} - -template -OutputIterator -surface_intersection(const TriangleMesh& tm1, - const TriangleMesh& tm2, - OutputIterator polyline_output, - const bool throw_on_self_intersection) -{ - return surface_intersection(tm1, tm2, polyline_output, - CGAL::Polygon_mesh_processing::parameters::throw_on_self_intersection(throw_on_self_intersection), - CGAL::Polygon_mesh_processing::parameters::all_default()); -} -#endif - -namespace experimental { -template -OutputIterator -surface_self_intersection(const TriangleMesh& tm, - OutputIterator polyline_output) -{ - return surface_self_intersection(tm, polyline_output, - CGAL::Polygon_mesh_processing::parameters::all_default() - ); -} - } //end of namespace experimental } //end of namespace Polygon_mesh_processing } //end of namespace CGAL 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 fa51dc44d3a..1d1033a41b2 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/locate.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/locate.h @@ -73,7 +73,7 @@ struct Ray_type_selector // Just for convenience template > + typename NamedParameters = parameters::Default_named_parameters> struct Location_traits { typedef typename GetVertexPointMap::const_type VertexPointMap; @@ -586,7 +586,7 @@ get_descriptor_from_location(const std::pair +template #ifdef DOXYGEN_RUNNING Point construct_point(const Face_location& loc, @@ -596,7 +596,7 @@ construct_point(const std::pair::face std::array >& loc, #endif const TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename GetGeomTraits::type Geom_traits; @@ -623,19 +623,6 @@ construct_point(const std::pair::face return bp_constructor(p0, loc.second[0], p1, loc.second[1], p2, loc.second[2], gt); } -template -typename property_map_value::type -#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()); -} - /// \name Location Predicates /// @{ @@ -1110,7 +1097,7 @@ locate_on_halfedge(const typename boost::graph_traits::halfedge_de /// 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 +template #ifdef DOXYGEN_RUNNING Face_location locate_in_face(const Point& query, @@ -1120,7 +1107,7 @@ locate_in_face(const typename internal::Location_traits::face_descriptor fd, const TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; @@ -1165,16 +1152,6 @@ locate_in_face(const typename internal::Location_traits -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) -{ - return locate_in_face(query, f, tm, parameters::all_default()); -} -#endif /// \ingroup PMP_locate_grp /// @@ -1589,7 +1566,7 @@ void build_AABB_tree(const TriangleMesh& tm, /// \cgalParamNEnd /// \cgalNamedParamsEnd /// -template +template void build_AABB_tree(const TriangleMesh& tm, AABB_tree< @@ -1600,7 +1577,7 @@ build_AABB_tree(const TriangleMesh& tm, typename GetGeomTraits::type, #endif CGAL::AABB_face_graph_triangle_primitive > >& outTree, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename GetVertexPointMap::const_type VertexPointMap; @@ -1613,14 +1590,6 @@ build_AABB_tree(const TriangleMesh& tm, return internal::build_AABB_tree(tm, outTree, vpm); } -#ifndef DOXYGEN_RUNNING -template -void build_AABB_tree(const TriangleMesh& tm, AABB_tree& outTree) -{ - return build_AABB_tree(tm, outTree, parameters::all_default()); -} -#endif - /// \ingroup PMP_locate_grp /// /// \brief returns the face location nearest to the given point, as a location. @@ -1671,7 +1640,7 @@ void build_AABB_tree(const TriangleMesh& tm, AABB_tree& outTree) /// 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 +template #ifdef DOXYGEN_RUNNING Face_location locate_with_AABB_tree(const Point& p, @@ -1685,7 +1654,7 @@ locate_with_AABB_tree(const typename internal::Location_traits > >& tree, #endif const TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename internal::Location_traits::Point Point; typedef internal::Point_to_Point_3 P_to_P3; @@ -1718,17 +1687,6 @@ locate_with_AABB_tree(const typename internal::Location_traits -typename internal::Location_traits::Face_location -locate_with_AABB_tree(const typename internal::Location_traits::Point& p, - const AABB_tree& tree, - const TriangleMesh& tm) -{ - return locate_with_AABB_tree(p, tree, tm, parameters::all_default()); -} -#endif - /// \ingroup PMP_locate_grp /// /// \brief returns the nearest face location to the given point. @@ -1771,7 +1729,7 @@ locate_with_AABB_tree(const typename internal::Location_traits::Po /// \cgalParamNEnd /// \cgalNamedParamsEnd /// -template +template #ifdef DOXYGEN_RUNNING Face_location locate(const Point& p, @@ -1780,7 +1738,7 @@ typename internal::Location_traits::Face_location locate(const typename internal::Location_traits::Point& p, #endif const TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { // Wrap the input VPM with a one converting to 3D (costs nothing if the input VPM // already has value type Kernel::Point_3) @@ -1812,16 +1770,6 @@ locate(const typename internal::Location_traits:: return locate_with_AABB_tree(p3, tree, tm, parameters::vertex_point_map(wrapped_vpm)); } -#ifndef DOXYGEN_RUNNING -template -typename internal::Location_traits::Face_location -locate(const typename property_map_value::type& p, - const TriangleMesh& tm) -{ - return locate(p, tm, parameters::all_default()); -} -#endif - /// \ingroup PMP_locate_grp /// /// \brief returns the face location along `ray` nearest to its source point. @@ -1868,7 +1816,7 @@ locate(const typename property_map_value::t /// /// \pre `ray` is an object with the same ambient dimension as the point type (the value type of the vertex point map). /// -template +template #ifdef DOXYGEN_RUNNING Face_location locate_with_AABB_tree(const Ray& ray, @@ -1883,7 +1831,7 @@ locate_with_AABB_tree(const typename internal::Location_traits >& tree, #endif const TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename GetGeomTraits::type Geom_traits; @@ -1952,17 +1900,6 @@ locate_with_AABB_tree(const typename internal::Location_traits -typename internal::Location_traits::Face_location -locate_with_AABB_tree(const typename internal::Location_traits::Ray& ray, - const AABB_tree& tree, - const TriangleMesh& tm) -{ - return locate_with_AABB_tree(ray, tree, tm, parameters::all_default()); -} -#endif - /// \ingroup PMP_locate_grp /// /// \brief returns the face location along `ray` nearest to its source point. @@ -2010,7 +1947,7 @@ locate_with_AABB_tree(const typename internal::Location_traits::Ra /// /// \pre `ray` is an object with the same ambient dimension as the point type (the value type of the vertex point map). /// -template +template #ifdef DOXYGEN_RUNNING Face_location locate(const Ray& ray, @@ -2019,7 +1956,7 @@ typename internal::Location_traits::Face_location locate(const typename internal::Location_traits::Ray& ray, #endif const TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename GetVertexPointMap::const_type VertexPointMap; @@ -2044,17 +1981,6 @@ locate(const typename internal::Location_traits:: return locate_with_AABB_tree(ray, tree, tm, np); } -#ifndef DOXYGEN_RUNNING -template -typename internal::Location_traits::Face_location -locate(const typename internal::Ray_type_selector< - typename internal::Location_traits::Point>::type& ray, - const TriangleMesh& tm) -{ - return locate(ray, tm, parameters::all_default()); -} -#endif - /// @} } // namespace Polygon_mesh_processing diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/manifoldness.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/manifoldness.h index 351019d5b11..0dd4050e057 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/manifoldness.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/manifoldness.h @@ -15,7 +15,7 @@ #include -#include +#include #include #include @@ -427,9 +427,9 @@ OutputIterator non_manifold_vertices(const PolygonMesh& pm, /// \cgalNamedParamsEnd /// /// \return the number of vertices created. -template +template std::size_t duplicate_non_manifold_vertices(PolygonMesh& pm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::get_parameter; using parameters::choose_parameter; @@ -460,12 +460,6 @@ std::size_t duplicate_non_manifold_vertices(PolygonMesh& pm, return nb_new_vertices; } -template -std::size_t duplicate_non_manifold_vertices(PolygonMesh& pm) -{ - return duplicate_non_manifold_vertices(pm, parameters::all_default()); -} - } // namespace Polygon_mesh_processing } // namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h index 2078575a982..733b0d75ddf 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h @@ -21,30 +21,25 @@ #include #include #include -#include +#include #include #include // needed for CGAL::exact(FT)/CGAL::exact(Lazy_exact_nt) #include -#include #include #include #include #include - -#ifdef DOXYGEN_RUNNING -#define CGAL_PMP_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_PMP_NP_CLASS NamedParameters -#endif +#include namespace CGAL { // workaround for area(face_range, tm) overload -template -class GetGeomTraits +template +class GetGeomTraits { public: struct type{}; @@ -102,7 +97,7 @@ inline void rearrange_face_ids(boost::container::small_vector& i * @sa `face_border_length()` */ template + typename NamedParameters = parameters::Default_named_parameters> #ifdef DOXYGEN_RUNNING FT #else @@ -110,7 +105,7 @@ typename GetGeomTraits::type::FT #endif edge_length(typename boost::graph_traits::halfedge_descriptor h, const PolygonMesh& pmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename GetGeomTraits::type Geom_traits; @@ -129,34 +124,17 @@ edge_length(typename boost::graph_traits::halfedge_descriptor h, get(vpm, target(h, pmesh)))); } -template -typename CGAL::Kernel_traits::type>::Kernel::FT -edge_length(typename boost::graph_traits::halfedge_descriptor h, - const PolygonMesh& pmesh) -{ - return edge_length(h, pmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); -} // edge overloads template + typename NamedParameters = parameters::Default_named_parameters> typename GetGeomTraits::type::FT edge_length(typename boost::graph_traits::edge_descriptor e, const PolygonMesh& pmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { return edge_length(halfedge(e, pmesh), pmesh, np); } -template -typename CGAL::Kernel_traits::type>::Kernel::FT -edge_length(typename boost::graph_traits::edge_descriptor e, - const PolygonMesh& pmesh) -{ - return edge_length(halfedge(e, pmesh), pmesh); -} - /** * \ingroup measure_grp * computes the squared length of an edge of a given polygon mesh. @@ -194,7 +172,7 @@ edge_length(typename boost::graph_traits::edge_descriptor e, * @sa `face_border_length()` */ template + typename NamedParameters = parameters::Default_named_parameters> #ifdef DOXYGEN_RUNNING FT #else @@ -202,7 +180,7 @@ typename GetGeomTraits::type::FT #endif squared_edge_length(typename boost::graph_traits::halfedge_descriptor h, const PolygonMesh& pmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename GetGeomTraits::type Geom_traits; @@ -221,35 +199,18 @@ squared_edge_length(typename boost::graph_traits::halfedge_descript get(vpm, target(h, pmesh))); } -template -typename CGAL::Kernel_traits::type>::Kernel::FT -squared_edge_length(typename boost::graph_traits::halfedge_descriptor h, - const PolygonMesh& pmesh) -{ - return squared_edge_length(h, pmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); -} + // edge overloads template + typename NamedParameters = parameters::Default_named_parameters> typename GetGeomTraits::type::FT squared_edge_length(typename boost::graph_traits::edge_descriptor e, const PolygonMesh& pmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { return squared_edge_length(halfedge(e, pmesh), pmesh, np); } -template -typename CGAL::Kernel_traits::type>::Kernel::FT -squared_edge_length(typename boost::graph_traits::edge_descriptor e, - const PolygonMesh& pmesh) -{ - return squared_edge_length(halfedge(e, pmesh), pmesh); -} - - /** * \ingroup measure_grp * computes the length of the border polyline @@ -291,7 +252,7 @@ squared_edge_length(typename boost::graph_traits::edge_descriptor e * @sa `edge_length()` */ template + typename NamedParameters = parameters::Default_named_parameters> #ifdef DOXYGEN_RUNNING FT #else @@ -299,7 +260,7 @@ typename GetGeomTraits::type::FT #endif face_border_length(typename boost::graph_traits::halfedge_descriptor h, const PolygonMesh& pmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typename GetGeomTraits::type::FT result = 0; @@ -312,15 +273,6 @@ face_border_length(typename boost::graph_traits::halfedge_descripto return result; } -template -typename CGAL::Kernel_traits::type>::Kernel::FT -face_border_length(typename boost::graph_traits::halfedge_descriptor h, - const PolygonMesh& pmesh) -{ - return face_border_length(h, pmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); -} - /** * \ingroup measure_grp * finds the longest border of a given triangulated surface and returns @@ -360,7 +312,7 @@ face_border_length(typename boost::graph_traits::halfedge_descripto * */ template + typename NamedParameters = parameters::Default_named_parameters> #ifdef DOXYGEN_RUNNING std::pair #else @@ -368,13 +320,13 @@ std::pair::halfedge_descriptor, typename GetGeomTraits::type::FT> #endif longest_border(const PolygonMesh& pmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename CGAL::Kernel_traits< typename property_map_value::type>::Kernel::FT FT; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - boost::unordered_set visited; + std::unordered_set visited; halfedge_descriptor result_halfedge = boost::graph_traits::null_halfedge(); FT result_len = 0; for(halfedge_descriptor h : halfedges(pmesh)) @@ -401,15 +353,6 @@ longest_border(const PolygonMesh& pmesh, return std::make_pair(result_halfedge, result_len); } -template -std::pair::halfedge_descriptor, -typename CGAL::Kernel_traits::type>::Kernel::FT> -longest_border(const PolygonMesh& pmesh) -{ - return longest_border(pmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); -} - /** * \ingroup measure_grp * computes the area of a face of a given @@ -454,15 +397,15 @@ longest_border(const PolygonMesh& pmesh) * @sa `area()` */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> #ifdef DOXYGEN_RUNNING FT #else -typename GetGeomTraits::type::FT +typename GetGeomTraits::type::FT #endif face_area(typename boost::graph_traits::face_descriptor f, const TriangleMesh& tmesh, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -471,14 +414,14 @@ face_area(typename boost::graph_traits::face_descriptor f, CGAL_precondition(boost::graph_traits::null_face() != f); - typename GetVertexPointMap::const_type + typename GetVertexPointMap::const_type vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(CGAL::vertex_point, tmesh)); halfedge_descriptor hd = halfedge(f, tmesh); halfedge_descriptor nhd = next(hd, tmesh); - typedef typename GetGeomTraits::type GT; + typedef typename GetGeomTraits::type GT; GT traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); return approximate_sqrt(traits.compute_squared_area_3_object()(get(vpm, source(hd, tmesh)), @@ -486,14 +429,6 @@ face_area(typename boost::graph_traits::face_descriptor f, get(vpm, target(nhd, tmesh)))); } -template -typename CGAL::Kernel_traits::type>::Kernel::FT -face_area(typename boost::graph_traits::face_descriptor f, - const TriangleMesh& tmesh) -{ - return face_area(f, tmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); -} /** * \ingroup measure_grp @@ -534,15 +469,15 @@ face_area(typename boost::graph_traits::face_descriptor f, * @sa `face_area()` */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> #ifdef DOXYGEN_RUNNING FT #else -typename GetGeomTraits::type::FT +typename GetGeomTraits::type::FT #endif squared_face_area(typename boost::graph_traits::face_descriptor f, const TriangleMesh& tmesh, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -551,14 +486,14 @@ squared_face_area(typename boost::graph_traits::face_descriptor f, CGAL_precondition(boost::graph_traits::null_face() != f); - typename GetVertexPointMap::const_type + typename GetVertexPointMap::const_type vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(CGAL::vertex_point, tmesh)); halfedge_descriptor hd = halfedge(f, tmesh); halfedge_descriptor nhd = next(hd, tmesh); - typedef typename GetGeomTraits::type GT; + typedef typename GetGeomTraits::type GT; GT traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); return traits.compute_squared_area_3_object()(get(vpm, source(hd, tmesh)), @@ -566,16 +501,6 @@ squared_face_area(typename boost::graph_traits::face_descriptor f, get(vpm, target(nhd, tmesh))); } -template -typename CGAL::Kernel_traits::type>::Kernel::FT -squared_face_area(typename boost::graph_traits::face_descriptor f, - const TriangleMesh& tmesh) -{ - return squared_face_area(f, tmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); -} - - /** * \ingroup measure_grp * computes the area of a range of faces of a given @@ -621,19 +546,19 @@ squared_face_area(typename boost::graph_traits::face_descriptor f, */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> #ifdef DOXYGEN_RUNNING FT #else -typename GetGeomTraits::type::FT +typename GetGeomTraits::type::FT #endif area(FaceRange face_range, const TriangleMesh& tmesh, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { typedef typename boost::graph_traits::face_descriptor face_descriptor; - typename GetGeomTraits::type::FT result = 0; + typename GetGeomTraits::type::FT result = 0; for(face_descriptor f : face_range) { result += face_area(f, tmesh, np); @@ -643,13 +568,6 @@ area(FaceRange face_range, return result; } -template -typename GetGeomTraits::type::FT -area(FaceRange face_range, const TriangleMesh& tmesh) -{ - return area(face_range, tmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); -} - /** * \ingroup measure_grp * computes the surface area of a triangulated surface mesh. @@ -689,25 +607,17 @@ area(FaceRange face_range, const TriangleMesh& tmesh) * @sa `face_area()` */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> #ifdef DOXYGEN_RUNNING FT #else -typename GetGeomTraits::type::FT +typename GetGeomTraits::type::FT #endif -area(const TriangleMesh& tmesh, const CGAL_PMP_NP_CLASS& np) +area(const TriangleMesh& tmesh, const CGAL_NP_CLASS& np = parameters::default_values()) { return area(faces(tmesh), tmesh, np); } -template -typename CGAL::Kernel_traits::type>::Kernel::FT -area(const TriangleMesh& tmesh) -{ - return area(faces(tmesh), tmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); -} - /** * \ingroup measure_grp * computes the volume of the domain bounded by @@ -744,14 +654,14 @@ area(const TriangleMesh& tmesh) * of `tmesh`. */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> #ifdef DOXYGEN_RUNNING FT #else -typename GetGeomTraits::type::FT +typename GetGeomTraits::type::FT #endif volume(const TriangleMesh& tmesh, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { CGAL_assertion(is_triangle_mesh(tmesh)); CGAL_assertion(is_closed(tmesh)); @@ -759,14 +669,14 @@ volume(const TriangleMesh& tmesh, using parameters::choose_parameter; using parameters::get_parameter; - typename GetVertexPointMap::const_type + typename GetVertexPointMap::const_type vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(CGAL::vertex_point, tmesh)); - typename GetGeomTraits::type::Point_3 origin(0, 0, 0); + typename GetGeomTraits::type::Point_3 origin(0, 0, 0); typedef typename boost::graph_traits::face_descriptor face_descriptor; - typename GetGeomTraits::type::FT volume = 0; + typename GetGeomTraits::type::FT volume = 0; typename CGAL::Kernel_traits::type>::Kernel::Compute_volume_3 cv3; @@ -782,14 +692,6 @@ volume(const TriangleMesh& tmesh, return volume; } -template -typename CGAL::Kernel_traits::type>::Kernel::FT -volume(const TriangleMesh& tmesh) -{ - return volume(tmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); -} - /** * \ingroup measure_grp * computes the aspect ratio of a face of a given triangulated surface mesh. @@ -825,28 +727,28 @@ volume(const TriangleMesh& tmesh) * */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> #ifdef DOXYGEN_RUNNING FT #else -typename GetGeomTraits::type::FT +typename GetGeomTraits::type::FT #endif face_aspect_ratio(typename boost::graph_traits::face_descriptor f, const TriangleMesh& tmesh, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { CGAL_precondition(f != boost::graph_traits::null_face()); CGAL_precondition(is_triangle(halfedge(f, tmesh), tmesh)); typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef typename GetGeomTraits::type Geom_traits; + typedef typename GetGeomTraits::type Geom_traits; typedef typename Geom_traits::FT FT; using parameters::choose_parameter; using parameters::get_parameter; - typename GetVertexPointMap::const_type + typename GetVertexPointMap::const_type vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(CGAL::vertex_point, tmesh)); @@ -901,15 +803,6 @@ face_aspect_ratio(typename boost::graph_traits::face_descriptor f, return aspect_ratio; } -template -typename CGAL::Kernel_traits::type>::Kernel::FT -face_aspect_ratio(typename boost::graph_traits::face_descriptor f, - const TriangleMesh& tmesh) -{ - return face_aspect_ratio(f, tmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); -} - /** * \ingroup measure_grp * computes the centroid of a volume bounded by @@ -941,13 +834,13 @@ face_aspect_ratio(typename boost::graph_traits::face_descriptor f, * * @return the centroid of the domain bounded by `tmesh`. */ -template +template #ifdef DOXYGEN_RUNNING Point_3 #else -typename GetGeomTraits::type::Point_3 +typename GetGeomTraits::type::Point_3 #endif -centroid(const TriangleMesh& tmesh, const CGAL_PMP_NP_CLASS& np) +centroid(const TriangleMesh& tmesh, const CGAL_NP_CLASS& np = parameters::default_values()) { // See: http://www2.imperial.ac.uk/~rn/centroid.pdf @@ -957,11 +850,11 @@ centroid(const TriangleMesh& tmesh, const CGAL_PMP_NP_CLASS& np) using parameters::choose_parameter; using parameters::get_parameter; - typedef typename GetVertexPointMap::const_type Vpm; + typedef typename GetVertexPointMap::const_type Vpm; Vpm vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(CGAL::vertex_point, tmesh)); - typedef typename GetGeomTraits::type Kernel; + typedef typename GetGeomTraits::type Kernel; typedef typename Kernel::Point_3 Point_3; typedef typename Kernel::Vector_3 Vector_3; typedef typename Kernel::Construct_translated_point_3 Construct_translated_point_3; @@ -1010,15 +903,6 @@ centroid(const TriangleMesh& tmesh, const CGAL_PMP_NP_CLASS& np) return point(ORIGIN, centroid); } -template -typename CGAL::Kernel_traits::type>::Kernel::Point_3 -centroid(const TriangleMesh& tmesh) -{ - return centroid(tmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); -} - - /** * \ingroup measure_grp * identifies faces only present in `m1` and `m2` as well as the faces present @@ -1073,11 +957,12 @@ template< typename PolygonMesh1, typename FacePairOutputIterator, typename FaceOutputIterator1, typename FaceOutputIterator2, - typename NamedParameters1, - typename NamedParameters2 > + typename NamedParameters1 = parameters::Default_named_parameters, + typename NamedParameters2 = parameters::Default_named_parameters > void match_faces(const PolygonMesh1& m1, const PolygonMesh2& m2, FacePairOutputIterator common, FaceOutputIterator1 m1_only, FaceOutputIterator2 m2_only, - const NamedParameters1& np1, const NamedParameters2& np2) + const NamedParameters1& np1 = parameters::default_values(), + const NamedParameters2& np2 = parameters::default_values()) { typedef typename GetVertexPointMap::const_type VPMap1; typedef typename GetVertexPointMap::const_type VPMap2; @@ -1189,21 +1074,6 @@ void match_faces(const PolygonMesh1& m1, const PolygonMesh2& m2, } } -template -void match_faces(const PolygonMesh1& m1, const PolygonMesh2& m2, - FacePairOutputIterator common, FaceOutputIterator1 m1_only, FaceOutputIterator2 m2_only, - const NamedParameters& np) -{ - match_faces(m1, m2, common, m1_only, m2_only, np, parameters::all_default()); -} - -template -void match_faces(const PolygonMesh1& m1, const PolygonMesh2& m2, - FacePairOutputIterator common, FaceOutputIterator1 m1_only, FaceOutputIterator2 m2_only) -{ - match_faces(m1, m2, common, m1_only, m2_only, parameters::all_default(), parameters::all_default()); -} - } // namespace Polygon_mesh_processing } // namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/merge_border_vertices.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/merge_border_vertices.h index 812373cb7c8..d188195b104 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/merge_border_vertices.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/merge_border_vertices.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -277,11 +277,11 @@ void merge_vertices_in_range(const HalfedgeRange& sorted_hedges, /// \cgalParamNEnd /// \cgalNamedParamsEnd /// -template +template void merge_duplicated_vertices_in_boundary_cycle( typename boost::graph_traits::halfedge_descriptor h, PolygonMesh& pm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename GetVertexPointMap::const_type Vpm; @@ -333,9 +333,9 @@ void merge_duplicated_vertices_in_boundary_cycle( /// \cgalNamedParamsEnd /// /// \sa `merge_duplicated_vertices_in_boundary_cycle()` -template +template void merge_duplicated_vertices_in_boundary_cycles( PolygonMesh& pm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -346,20 +346,6 @@ void merge_duplicated_vertices_in_boundary_cycles( PolygonMesh& pm, merge_duplicated_vertices_in_boundary_cycle(h, pm, np); } -template -void merge_duplicated_vertices_in_boundary_cycles(PolygonMesh& pm) -{ - merge_duplicated_vertices_in_boundary_cycles(pm, parameters::all_default()); -} - -template -void merge_duplicated_vertices_in_boundary_cycle( - typename boost::graph_traits::halfedge_descriptor h, - PolygonMesh& pm) -{ - merge_duplicated_vertices_in_boundary_cycle(h, pm, parameters::all_default()); -} - } } // end of CGAL::Polygon_mesh_processing #endif //CGAL_POLYGON_MESH_PROCESSING_MERGE_BORDER_VERTICES_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h index 6769b9e49a1..4621879ee1d 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -522,10 +522,10 @@ struct Polygon_soup_orienter * @return `false` if some points were duplicated, thus producing a self-intersecting polyhedron. * */ -template +template bool orient_polygon_soup(PointRange& points, PolygonRange& polygons, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -546,14 +546,6 @@ bool orient_polygon_soup(PointRange& points, return inital_nb_pts==points.size(); } - -template -bool orient_polygon_soup(PointRange& points, - PolygonRange& polygons) -{ - return orient_polygon_soup(points, polygons, parameters::all_default()); -} - } }//end namespace CGAL::Polygon_mesh_processing #include diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup_extension.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup_extension.h index 2a9b8e05099..98e3e45af81 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup_extension.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup_extension.h @@ -118,13 +118,13 @@ duplicate_non_manifold_edges_in_polygon_soup(PointRange& points, */ template + class TriangleMesh, class NamedParameters = parameters::Default_named_parameters> void orient_triangle_soup_with_reference_triangle_mesh( const TriangleMesh& tm_ref, PointRange& points, TriangleRange& triangles, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { namespace PMP = CGAL::Polygon_mesh_processing; @@ -187,17 +187,5 @@ orient_triangle_soup_with_reference_triangle_mesh( process_facet); } - -template -void -orient_triangle_soup_with_reference_triangle_mesh( - const TriangleMesh& tm_ref, - PointRange& points, - TriangleRange& triangles) -{ - orient_triangle_soup_with_reference_triangle_mesh(tm_ref, points, triangles, CGAL::parameters::all_default()); -} - }}//end namespace CGAL::Polygon_mesh_processing #endif // CGAL_ORIENT_POLYGON_SOUP_EXTENSION_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h index 768019c0718..f209ddefb13 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -30,10 +30,10 @@ #include #include -#include #include #include +#include #include namespace CGAL { @@ -181,9 +181,9 @@ namespace internal{ * * \sa `CGAL::Polygon_mesh_processing::reverse_face_orientations()` */ -template +template bool is_outward_oriented(const TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { CGAL_warning(CGAL::is_closed(tm)); CGAL_warning(CGAL::is_triangle_mesh(tm)); @@ -230,17 +230,6 @@ bool is_outward_oriented(const TriangleMesh& tm, return internal::is_outward_oriented(v_max, tm, np); } -///\cond SKIP_IN_MANUAL - -template -bool is_outward_oriented(const TriangleMesh& tm) -{ - return is_outward_oriented(tm, - CGAL::Polygon_mesh_processing::parameters::all_default()); -} - -/// \endcond - template void reverse_orientation(typename boost::graph_traits::halfedge_descriptor first, PolygonMesh& pmesh) { @@ -311,7 +300,7 @@ void reverse_face_orientations_of_mesh_with_polylines(PolygonMesh& pmesh) reverse_orientation(halfedge(fd,pmesh),pmesh); //extract all border cycles - boost::unordered_set already_seen; + std::unordered_set already_seen; std::vector border_cycles; for(halfedge_descriptor h : halfedges(pmesh)) if ( is_border(h,pmesh) && already_seen.insert(h).second ) @@ -405,9 +394,9 @@ void reverse_face_orientations(const FaceRange& face_range, PolygonMesh& pmesh) * \cgalParamNEnd * \cgalNamedParamsEnd */ -template +template void orient(TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef boost::graph_traits Graph_traits; typedef typename Graph_traits::vertex_descriptor vertex_descriptor; @@ -472,12 +461,6 @@ void orient(TriangleMesh& tm, } } -template -void orient(TriangleMesh& tm) -{ - orient(tm, parameters::all_default()); -} - /*! * \ingroup PMP_orientation_grp * Enumeration type used to indicate the status of a set of faces @@ -811,11 +794,11 @@ void set_cc_intersecting_pairs( * * \return the number of volume components defined by `tm` */ -template +template std::size_t volume_connected_components(const TriangleMesh& tm, VolumeFaceIndexMap volume_id_map, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { CGAL_precondition(is_triangle_mesh(tm)); CGAL_precondition(is_closed(tm)); @@ -1269,8 +1252,8 @@ volume_connected_components(const TriangleMesh& tm, * * \see `CGAL::Polygon_mesh_processing::orient_to_bound_a_volume()` */ -template -bool does_bound_a_volume(const TriangleMesh& tm, const NamedParameters& np) +template +bool does_bound_a_volume(const TriangleMesh& tm, const NamedParameters& np = parameters::default_values()) { typedef boost::graph_traits GT; typedef typename GT::face_descriptor face_descriptor; @@ -1287,21 +1270,6 @@ bool does_bound_a_volume(const TriangleMesh& tm, const NamedParameters& np) return res!=0; } -/// \cond SKIP_IN_MANUAL -template -bool does_bound_a_volume(const TriangleMesh& tm) -{ - return does_bound_a_volume(tm, parameters::all_default()); -} - -template -std::size_t volume_connected_components(const TriangleMesh& tm, VolumeFaceIndexMap volume_id_map) -{ - return volume_connected_components(tm, volume_id_map, parameters::all_default()); -} -/// \endcond - - /** \ingroup PMP_orientation_grp * * orients the connected components of `tm` to make it bound a volume. @@ -1349,9 +1317,9 @@ std::size_t volume_connected_components(const TriangleMesh& tm, VolumeFaceIndexM * * \see `CGAL::Polygon_mesh_processing::does_bound_a_volume()` */ -template +template void orient_to_bound_a_volume(TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef boost::graph_traits Graph_traits; typedef typename Graph_traits::face_descriptor face_descriptor; @@ -1415,12 +1383,6 @@ void orient_to_bound_a_volume(TriangleMesh& tm, reverse_face_orientations(faces_to_reverse, tm); } -template -void orient_to_bound_a_volume(TriangleMesh& tm) -{ - orient_to_bound_a_volume(tm, parameters::all_default()); -} - /*! * \ingroup PMP_orientation_grp * reverses the connected components of `tm` having compatible boundary cycles @@ -1460,9 +1422,9 @@ void orient_to_bound_a_volume(TriangleMesh& tm) * \cgalParamNEnd * \cgalNamedParamsEnd */ -template +template void merge_reversible_connected_components(PolygonMesh& pm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef boost::graph_traits GrT; typedef typename GrT::face_descriptor face_descriptor; @@ -1627,11 +1589,6 @@ void merge_reversible_connected_components(PolygonMesh& pm, } } -template -void merge_reversible_connected_components(PolygonMesh& pm) -{ - merge_reversible_connected_components(pm, parameters::all_default()); -} } // namespace Polygon_mesh_processing } // namespace CGAL #endif // CGAL_ORIENT_POLYGON_MESH_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h index e9c0f6ce302..5766b85593f 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h @@ -16,8 +16,9 @@ #include #include +#include #include -#include +#include #include #include #include @@ -26,8 +27,33 @@ #include #include +#include +#include + namespace CGAL { namespace Polygon_mesh_processing { +namespace internal { + +template +struct PM_to_PS_point_converter +{ + PS_Point operator()(const PM_Point& p) const + { + CGAL_static_assertion((std::is_convertible::value)); + return PS_Point(p); + } +}; + +template +struct PM_to_PS_point_converter > +{ + std::array operator()(const PM_Point& p) const + { + return { p[0], p[1], p[2] }; + } +}; + +} // namespace internal /// \ingroup PMP_repairing_grp /// @@ -68,11 +94,11 @@ namespace Polygon_mesh_processing { /// template + typename NamedParameters = parameters::Default_named_parameters> void polygon_mesh_to_polygon_soup(const PolygonMesh& mesh, PointRange& points, PolygonRange& polygons, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -84,20 +110,24 @@ void polygon_mesh_to_polygon_soup(const PolygonMesh& mesh, typedef typename GetVertexPointMap::const_type VPM; VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(vertex_point, mesh)); + typedef typename boost::property_traits::value_type PM_Point; typedef CGAL::dynamic_vertex_property_t Vertex_index; typedef typename boost::property_map::const_type VIM; VIM vim = get(Vertex_index(), mesh); + typedef typename boost::range_value::type PS_Point; typedef typename boost::range_value::type Polygon; + internal::PM_to_PS_point_converter converter; + std::size_t index = points.size(); // so that multiple meshes can be put into the same soup CGAL::internal::reserve(points, points.size() + vertices(mesh).size()); CGAL::internal::reserve(polygons, polygons.size() + faces(mesh).size()); for(const vertex_descriptor v : vertices(mesh)) { - points.emplace_back(get(vpm, v)); + points.push_back(converter(get(vpm, v))); put(vim, v, index++); } @@ -117,18 +147,6 @@ void polygon_mesh_to_polygon_soup(const PolygonMesh& mesh, } } -/// \cond SKIP_IN_MANUAL - -template -void polygon_mesh_to_polygon_soup(const PolygonMesh& mesh, - PointRange& points, - PolygonRange& polygons) -{ - return polygon_mesh_to_polygon_soup(mesh, points, polygons, CGAL::parameters::all_default()); -} - -/// \endcond - } // namespace Polygon_mesh_processing } // namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h index 9e704870c18..8aea03c4e96 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h @@ -269,12 +269,12 @@ bool is_polygon_soup_a_polygon_mesh(const PolygonRange& polygons) */ template + typename NamedParameters_PS = parameters::Default_named_parameters, typename NamedParameters_PM = parameters::Default_named_parameters> void polygon_soup_to_polygon_mesh(const PointRange& points, const PolygonRange& polygons, PolygonMesh& out, - const NamedParameters_PS& np_ps, - const NamedParameters_PM& np_pm) + const NamedParameters_PS& np_ps = parameters::default_values(), + const NamedParameters_PM& np_pm = parameters::default_values()) { CGAL_precondition_msg(is_polygon_soup_a_polygon_mesh(polygons), "Input soup needs to define a valid polygon mesh! See is_polygon_soup_a_polygon_mesh() for further information."); @@ -293,29 +293,6 @@ void polygon_soup_to_polygon_mesh(const PointRange& points, converter(out, vpm); } -/// \cond SKIP_IN_MANUAL - -template -void polygon_soup_to_polygon_mesh(const PointRange& points, - const PolygonRange& polygons, - PolygonMesh& out, - const NamedParameters_PS& np_ps) -{ - return polygon_soup_to_polygon_mesh(points, polygons, out, np_ps, parameters::all_default()); -} - -template -void polygon_soup_to_polygon_mesh(const PointRange& points, - const PolygonRange& polygons, - PolygonMesh& out) -{ - return polygon_soup_to_polygon_mesh(points, polygons, out, parameters::all_default(), parameters::all_default()); -} - -/// \endcond - } // namespace Polygon_mesh_processing } // namespace CGAL 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 556998e2f9a..4e78ce22c26 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 @@ -19,7 +19,7 @@ #include -#include +#include #include #include @@ -152,11 +152,11 @@ namespace internal { * \cgalNamedParamsEnd * */ -template +template void random_perturbation(VertexRange vertices , TriangleMesh& tmesh , const double& perturbation_max_size - , const NamedParameters& np) + , const NamedParameters& np = parameters::default_values()) { typedef TriangleMesh PM; using parameters::get_parameter; @@ -212,32 +212,13 @@ void random_perturbation(VertexRange vertices * \ingroup PMP_meshing_grp * @brief same as above, but all non-border vertices of `tmesh` are perturbed. */ -template +template void random_perturbation(TriangleMesh& tmesh , const double& perturbation_max_size - , const NamedParameters& np) + , const NamedParameters& np = parameters::default_values()) { random_perturbation(vertices(tmesh), tmesh, perturbation_max_size, np); } - -template -void random_perturbation(VertexRange vertices - , TriangleMesh& tmesh - , const double& perturbation_max_size) -{ - random_perturbation(vertices, tmesh, perturbation_max_size, - parameters::all_default()); -} - -template -void random_perturbation(TriangleMesh& tmesh - , const double& perturbation_max_size) -{ - random_perturbation(tmesh, - perturbation_max_size, - parameters::all_default()); -} - } //end namespace Polygon_mesh_processing } //end namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/refine.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/refine.h index 5c4742f6b60..effb3fb7d3f 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/refine.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/refine.h @@ -16,7 +16,7 @@ #include -#include +#include #include #include @@ -27,7 +27,7 @@ namespace Polygon_mesh_processing { /*! \ingroup PMP_meshing_grp - @brief refines a region of a triangle mesh + @brief refines a region of a triangle mesh. @tparam TriangleMesh model of `MutableFaceGraph` @tparam FaceRange range of face descriptors, model of `Range`. @@ -72,13 +72,13 @@ namespace Polygon_mesh_processing { typename FaceRange, typename FaceOutputIterator, typename VertexOutputIterator, - typename NamedParameters> + typename NamedParameters = parameters::Default_named_parameters> std::pair refine(TriangleMesh& tmesh, const FaceRange& faces, FaceOutputIterator faces_out, VertexOutputIterator vertices_out, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -97,22 +97,6 @@ namespace Polygon_mesh_processing { return std::make_pair(faces_out, vertices_out); } -///\cond SKIP_IN_MANUAL - template - - std::pair - refine(TriangleMesh& tmesh, - const FaceRange& faces, - FaceOutputIterator faces_out, - VertexOutputIterator vertices_out) - { - return refine(tmesh, faces, faces_out, vertices_out, - CGAL::Polygon_mesh_processing::parameters::all_default()); - } -///\endcond }//end namespace Polygon_mesh_processing }//end namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h index b011b2d61b6..030864e6bbe 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h @@ -19,7 +19,7 @@ #include -#include +#include #include #ifdef CGAL_PMP_REMESHING_VERBOSE @@ -105,7 +105,7 @@ namespace Polygon_mesh_processing { * * \cgalParamNBegin{protect_constraints} * \cgalParamDescription{If `true`, the edges set as constrained in `edge_is_constrained_map` -* (or by default the boundary edges) are not split nor collapsed during remeshing.} +* (or by default the boundary edges) are neither split nor collapsed during remeshing.} * \cgalParamType{Boolean} * \cgalParamDefault{`false`} * \cgalParamExtra{Note that around constrained edges that have their length higher than @@ -192,11 +192,11 @@ namespace Polygon_mesh_processing { */ template + , typename NamedParameters = parameters::Default_named_parameters> void isotropic_remeshing(const FaceRange& faces , const double& target_edge_length , PolygonMesh& pmesh - , const NamedParameters& np) + , const NamedParameters& np = parameters::default_values()) { if (boost::begin(faces)==boost::end(faces)) return; @@ -217,7 +217,7 @@ void isotropic_remeshing(const FaceRange& faces #endif static const bool need_aabb_tree = - parameters::is_default_parameter(get_parameter(np, internal_np::projection_functor)); + parameters::is_default_parameter(); typedef typename GetGeomTraits::type GT; GT gt = choose_parameter(get_parameter(np, internal_np::geom_traits)); @@ -254,7 +254,7 @@ void isotropic_remeshing(const FaceRange& faces FPMap fpmap = choose_parameter( get_parameter(np, internal_np::face_patch), internal::Connected_components_pmap(faces, pmesh, ecmap, fimap, - parameters::is_default_parameter(get_parameter(np, internal_np::face_patch)) && (need_aabb_tree + parameters::is_default_parameter() && (need_aabb_tree #if !defined(CGAL_NO_PRECONDITIONS) || protect // face patch map is used to identify patch border edges to check protected edges are short enough #endif @@ -337,20 +337,6 @@ void isotropic_remeshing(const FaceRange& faces #endif } -template -void isotropic_remeshing( - const FaceRange& faces - , const double& target_edge_length - , PolygonMesh& pmesh) -{ - isotropic_remeshing( - faces, - target_edge_length, - pmesh, - parameters::all_default()); -} - /*! * \ingroup PMP_meshing_grp * @brief splits the edges listed in `edges` into sub-edges @@ -404,11 +390,11 @@ void isotropic_remeshing( */ template + , typename NamedParameters = parameters::Default_named_parameters> void split_long_edges(const EdgeRange& edges , const double& max_length , PolygonMesh& pmesh - , const NamedParameters& np) + , const NamedParameters& np = parameters::default_values()) { typedef PolygonMesh PM; typedef typename boost::graph_traits::edge_descriptor edge_descriptor; @@ -448,17 +434,6 @@ void split_long_edges(const EdgeRange& edges remesher.split_long_edges(edges, max_length); } -template -void split_long_edges(const EdgeRange& edges - , const double& max_length - , PolygonMesh& pmesh) -{ - split_long_edges(edges, - max_length, - pmesh, - parameters::all_default()); -} - } //end namespace Polygon_mesh_processing } //end namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h index 46b3dbe9ae8..2c60db87688 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h @@ -148,9 +148,9 @@ std::size_t remove_isolated_vertices(PolygonMesh& pmesh) /// \return the number of connected components removed (ignoring isolated vertices). /// template + typename NamedParameters = parameters::Default_named_parameters> std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::is_default_parameter; @@ -175,8 +175,8 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh, FT volume_threshold = choose_parameter(get_parameter(np, internal_np::volume_threshold), FT(-1)); // If no threshold is provided, compute it as a % of the bbox - const bool is_default_area_threshold = is_default_parameter(get_parameter(np, internal_np::area_threshold)); - const bool is_default_volume_threshold = is_default_parameter(get_parameter(np, internal_np::volume_threshold)); + const bool is_default_area_threshold = is_default_parameter(); + const bool is_default_volume_threshold = is_default_parameter(); const bool dry_run = choose_parameter(get_parameter(np, internal_np::dry_run), false); @@ -339,12 +339,6 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh, return res; } -template -std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh) -{ - return remove_connected_components_of_negligible_size(tmesh, parameters::all_default()); -} - } // namespace Polygon_mesh_processing } // namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h index ccad1bf4d50..b5eaa33b734 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include @@ -187,6 +187,7 @@ bool is_collapse_geometrically_valid(typename boost::graph_traits: } */ +// @todo handle boundary edges template boost::optional get_collapse_volume(typename boost::graph_traits::halfedge_descriptor h, @@ -202,10 +203,10 @@ get_collapse_volume(typename boost::graph_traits::halfedge_descrip 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 + typename Traits::Compute_volume_3 volume = gt.compute_volume_3_object(); + // source is kept, target is removed Point_ref kept = get(vpm, source(h, tmesh)); Point_ref removed= get(vpm, target(h, tmesh)); @@ -529,13 +530,13 @@ struct Filter_wrapper_for_cap_needle_removal +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) + const NamedParameters& np = parameters::default_values()) { using CGAL::parameters::choose_parameter; using CGAL::parameters::get_parameter; @@ -908,40 +909,17 @@ bool remove_almost_degenerate_faces(const FaceRange& face_range, 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 +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) + const CGAL_NP_CLASS& np = parameters::default_values()) { 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 //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1225,11 +1203,11 @@ remove_a_border_edge(typename boost::graph_traits::edge_descriptor return remove_a_border_edge(ed, tm, input_range, edge_set, face_set); } -template +template bool remove_degenerate_edges(const EdgeRange& edge_range, TriangleMesh& tmesh, FaceSet& face_set, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { CGAL_assertion(CGAL::is_triangle_mesh(tmesh)); CGAL_assertion(CGAL::is_valid_polygon_mesh(tmesh)); @@ -1265,7 +1243,7 @@ bool remove_degenerate_edges(const EdgeRange& edge_range, all_removed = true; std::set degenerate_edges_to_remove; degenerate_edges(local_edge_range, tmesh, std::inserter(degenerate_edges_to_remove, - degenerate_edges_to_remove.end())); + degenerate_edges_to_remove.end()), np); #ifdef CGAL_PMP_REMOVE_DEGENERATE_FACES_DEBUG std::cout << "Found " << degenerate_edges_to_remove.size() << " null edges.\n"; @@ -1728,38 +1706,23 @@ bool remove_degenerate_edges(const EdgeRange& edge_range, return all_removed; } -template +template bool remove_degenerate_edges(const EdgeRange& edge_range, TriangleMesh& tmesh, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { std::set::face_descriptor> face_set; return remove_degenerate_edges(edge_range, tmesh, face_set, np); } -template +template bool remove_degenerate_edges(TriangleMesh& tmesh, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { std::set::face_descriptor> face_set; return remove_degenerate_edges(edges(tmesh), tmesh, face_set, np); } -template -bool remove_degenerate_edges(const EdgeRange& edge_range, - TriangleMesh& tmesh) -{ - std::set::face_descriptor> face_set; - return remove_degenerate_edges(edge_range, tmesh, face_set, parameters::all_default()); -} - -template -bool remove_degenerate_edges(TriangleMesh& tmesh) -{ - std::set::face_descriptor> face_set; - return remove_degenerate_edges(edges(tmesh), tmesh, face_set, parameters::all_default()); -} - // \ingroup PMP_repairing_grp // removes the degenerate faces from a triangulated surface mesh. // A face is considered degenerate if two of its vertices share the same location, @@ -1801,10 +1764,10 @@ bool remove_degenerate_edges(TriangleMesh& tmesh) // We should probably do something with the return type. // // \return `true` if all degenerate faces were successfully removed, and `false` otherwise. -template +template bool remove_degenerate_faces(const FaceRange& face_range, TriangleMesh& tmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { CGAL_assertion(CGAL::is_triangle_mesh(tmesh)); CGAL_assertion(CGAL::is_valid_polygon_mesh(tmesh)); @@ -2617,26 +2580,13 @@ bool remove_degenerate_faces(const FaceRange& face_range, return all_removed; } -template -bool remove_degenerate_faces(const FaceRange& face_range, - TriangleMesh& tmesh) -{ - return remove_degenerate_faces(face_range, tmesh, CGAL::parameters::all_default()); -} - -template +template bool remove_degenerate_faces(TriangleMesh& tmesh, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { return remove_degenerate_faces(faces(tmesh), tmesh, np); } -template -bool remove_degenerate_faces(TriangleMesh& tmesh) -{ - return remove_degenerate_faces(tmesh, CGAL::parameters::all_default()); -} - } // namespace Polygon_mesh_processing } // namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h index 6af8c8cbdbc..54a7a171aa5 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h @@ -14,8 +14,7 @@ #include -#include -#include +#include #include #include @@ -475,10 +474,10 @@ std::size_t remove_isolated_points_in_polygon_soup(PointRange& points, /// /// \returns the number of removed points /// -template +template std::size_t merge_duplicate_points_in_polygon_soup(PointRange& points, PolygonRange& polygons, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename internal::Polygon_types::P_ID P_ID; typedef typename internal::Polygon_types::Point_3 Point_3; @@ -549,13 +548,6 @@ std::size_t merge_duplicate_points_in_polygon_soup(PointRange& points, return removed_points_n; } -template -std::size_t merge_duplicate_points_in_polygon_soup(PointRange& points, - PolygonRange& polygons) -{ - return merge_duplicate_points_in_polygon_soup(points, polygons, CGAL::parameters::all_default()); -} - namespace internal { // Find the position of the (arbitrarily chose) first point of the canonical point @@ -881,10 +873,10 @@ DuplicateOutputIterator collect_duplicate_polygons(const PointRange& points, /// /// \returns the number of removed polygons /// -template +template std::size_t merge_duplicate_polygons_in_polygon_soup(const PointRange& points, PolygonRange& polygons, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::get_parameter; using parameters::choose_parameter; @@ -980,13 +972,6 @@ std::size_t merge_duplicate_polygons_in_polygon_soup(const PointRange& points, return removed_polygons_n; } -template -std::size_t merge_duplicate_polygons_in_polygon_soup(PointRange& points, - PolygonRange& polygons) -{ - return merge_duplicate_polygons_in_polygon_soup(points, polygons, CGAL::parameters::all_default()); -} - /// \ingroup PMP_repairing_grp /// /// cleans a given polygon soup through various repairing operations. More precisely, this function @@ -1003,7 +988,7 @@ std::size_t merge_duplicate_polygons_in_polygon_soup(PointRange& points, /// using the function `CGAL::Polygon_mesh_processing::remove_isolated_points_in_polygon_soup()`. /// /// Note that the point and polygon containers will be modified by the repairing operations, -/// and thus the indexation of the polygons will also be changed. +/// and thus the indexing of the polygons will also be changed. /// /// \tparam PointRange a model of the concepts `SequenceContainer` and `Swappable` /// and whose value type is the point type. @@ -1044,10 +1029,10 @@ std::size_t merge_duplicate_polygons_in_polygon_soup(PointRange& points, /// \cgalParamNEnd /// \cgalNamedParamsEnd /// -template +template void repair_polygon_soup(PointRange& points, PolygonRange& polygons, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::get_parameter; using parameters::choose_parameter; @@ -1067,13 +1052,6 @@ void repair_polygon_soup(PointRange& points, remove_isolated_points_in_polygon_soup(points, polygons); } -template -void repair_polygon_soup(PointRange& points, - PolygonRange& polygons) -{ - return repair_polygon_soup(points, polygons, CGAL::parameters::all_default()); -} - } // end namespace Polygon_mesh_processing } // end namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_self_intersections.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_self_intersections.h index e6ad38f591f..87c3bc18fd3 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_self_intersections.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_self_intersections.h @@ -15,10 +15,12 @@ #include +#include #include #include #include #include +#include #include #include #include @@ -26,21 +28,27 @@ #include #endif +#include +#include +#include #include #include #include -#include +#include #include #include #include +#ifdef CGAL_PMP_REPAIR_SI_USE_OBB_IN_COMPACTIFICATION +#include +#endif #include - #include #include #include #include #include #include +#include #include #include #include @@ -75,44 +83,45 @@ static int self_intersections_solved_by_unconstrained_hole_filling = 0; // -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- -// @todo these could be extracted to somewhere else, it's useful in itself -template -FaceOutputIterator replace_faces_with_patch(const std::vector::vertex_descriptor>& border_vertices, - const std::set::vertex_descriptor>& interior_vertices, - const std::vector::halfedge_descriptor>& border_hedges, - const std::set::edge_descriptor>& interior_edges, - const std::set::face_descriptor>& faces, - const std::vector >& patch, - PolygonMesh& pmesh, - VPM& vpm, - FaceOutputIterator out) +template +FaceOutputIterator replace_faces_with_patch_without_reuse(const std::vector::vertex_descriptor>& border_vertices, + const std::set::face_descriptor>& faces, + const std::vector >& patch, + PolygonMesh& pmesh, + VertexPointMap vpm, + FaceOutputIterator out) { - CGAL_static_assertion((std::is_same::value_type, Point>::value)); - 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 std::vector Point_face; typedef std::vector Vertex_face; - CGAL_precondition(is_valid_polygon_mesh(pmesh)); + std::map point_to_vd; - // To be used to create new elements - std::vector vertex_stack(interior_vertices.begin(), interior_vertices.end()); - std::vector edge_stack(interior_edges.begin(), interior_edges.end()); - std::vector face_stack(faces.begin(), faces.end()); - - // Introduce new vertices, convert the patch in vertex patches - std::vector patch_with_vertices; - patch_with_vertices.reserve(patch.size()); - - std::map point_to_vs; - - // first, add those for which the vertex will not change + // First, add those for which the vertex will not change for(const vertex_descriptor v : border_vertices) - point_to_vs[get(vpm, v)] = v; + { + // In this version, remove_face() will get rid of isolated vertices so only vertices incident + // to at least one face that is not going to be removed will be kept + bool kept_vertex = false; + for(face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) + { + if(f != boost::graph_traits::null_face() && faces.count(f) == 0) + { + kept_vertex = true; + break; + } + } + + if(kept_vertex) + point_to_vd[get(vpm, v)] = v; + } + + for(face_descriptor f : faces) + Euler::remove_face(halfedge(f, pmesh), pmesh); + + CGAL_assertion(is_valid_polygon_mesh(pmesh)); // now build a correspondence map and the faces with vertices const vertex_descriptor null_v = boost::graph_traits::null_vertex(); @@ -125,10 +134,97 @@ FaceOutputIterator replace_faces_with_patch(const std::vector::iterator it; - std::tie(it, success) = point_to_vs.insert(std::make_pair(p, null_v)); + std::tie(it, success) = point_to_vd.emplace(p, null_v); vertex_descriptor& v = it->second; - if(success) // first time we meet that point, means it`s an interior point and we need to make a new vertex + if(success) + { + // first time we meet that point, means it's an interior point and we need to make a new vertex + v = add_vertex(pmesh); + put(vpm, v, p); + } + + vface.push_back(v); + } + + face_descriptor new_f = boost::graph_traits::null_face(); + if(Euler::can_add_face(vface, pmesh)) + new_f = Euler::add_face(vface, pmesh); + + if(new_f == boost::graph_traits::null_face()) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cerr << "Error: failed to insert patch face??" << std::endl; +#endif + return out; + } + + out++ = new_f; + } + + return out; +} + + +// @todo these could be extracted to somewhere else, it's useful in itself +template +FaceOutputIterator replace_faces_with_patch(const std::vector::vertex_descriptor>& border_vertices, + const std::set::vertex_descriptor>& interior_vertices, + const std::vector::halfedge_descriptor>& border_hedges, + const std::set::edge_descriptor>& interior_edges, + const std::set::face_descriptor>& faces, + const std::vector >& patch, + PolygonMesh& pmesh, + VertexPointMap vpm, + FaceOutputIterator out) +{ + CGAL_static_assertion((std::is_same::value_type, Point>::value)); + + 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 std::vector Point_face; + typedef std::vector Vertex_face; + + CGAL_precondition(is_valid_polygon_mesh(pmesh)); + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Replacing range with patch: "; + std::cout << faces.size() << " triangles removed, " << patch.size() << " created\n"; +#endif + + // To be used to create new elements + std::vector vertex_stack(interior_vertices.begin(), interior_vertices.end()); + std::vector edge_stack(interior_edges.begin(), interior_edges.end()); + std::vector face_stack(faces.begin(), faces.end()); + + // Introduce new vertices, convert the patch in vertex patches + std::vector patch_with_vertices; + patch_with_vertices.reserve(patch.size()); + + std::map point_to_vd; + + // first, add those for which the vertex will not change + for(const vertex_descriptor v : border_vertices) + point_to_vd[get(vpm, v)] = v; + + // now build a correspondence map and the faces with vertices + const vertex_descriptor null_v = boost::graph_traits::null_vertex(); + for(const Point_face& face : patch) + { + Vertex_face vface; + vface.reserve(face.size()); + + for(const Point& p : face) + { + bool success; + typename std::map::iterator it; + std::tie(it, success) = point_to_vd.emplace(p, null_v); + vertex_descriptor& v = it->second; + + if(success) // first time we meet that point, means it's an interior point and we need to make a new vertex { if(vertex_stack.empty()) { @@ -160,16 +256,13 @@ FaceOutputIterator replace_faces_with_patch(const std::vector::null_face(); -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::vector new_faces; -#endif for(const Vertex_face& vface : patch_with_vertices) { @@ -183,10 +276,8 @@ FaceOutputIterator replace_faces_with_patch(const std::vector::null_face()); *out++ = f; -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - new_faces.push_back(f); -#endif std::vector hedges; hedges.reserve(vface.size()); @@ -199,8 +290,8 @@ FaceOutputIterator replace_faces_with_patch(const std::vector::null_halfedge())); + std::tie(it, success) = halfedge_map.emplace(std::make_pair(vi, vj), + boost::graph_traits::null_halfedge()); halfedge_descriptor& h = it->second; if(success) // this halfedge is an interior halfedge @@ -244,29 +335,20 @@ FaceOutputIterator replace_faces_with_patch(const std::vector +template FaceOutputIterator replace_faces_with_patch(const std::set::face_descriptor>& face_range, const std::vector >& patch, PolygonMesh& pmesh, - VPM& vpm, + VertexPointMap vpm, FaceOutputIterator out) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; @@ -317,11 +399,11 @@ FaceOutputIterator replace_faces_with_patch(const std::set +template void replace_faces_with_patch(const std::set::face_descriptor>& faces, const std::vector >& patch, PolygonMesh& pmesh, - VPM& vpm) + VertexPointMap vpm) { CGAL::Emptyset_iterator out; replace_faces_with_patch(faces, patch, pmesh, vpm, out); @@ -329,39 +411,17 @@ void replace_faces_with_patch(const std::set -void back_up_face_range_as_point_patch(std::vector >& point_patch, - const FaceRange& face_range, - const PolygonMesh& tmesh, - const VertexPointMap vpm) -{ - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - - point_patch.reserve(face_range.size()); - - for(const face_descriptor f : face_range) - { - std::vector face_points; - for(const halfedge_descriptor h : CGAL::halfedges_around_face(halfedge(f, tmesh), tmesh)) - face_points.push_back(get(vpm, target(h, tmesh))); - - point_patch.push_back(face_points); - } -} - -// -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- - template -void constrain_sharp_and_border_edges(const FaceRange& faces, - TriangleMesh& tmesh, - EdgeConstrainMap& eif, - const bool constrain_sharp_edges, - const double dihedral_angle, - const double /*weak_DA*/, - VertexPointMap vpm, - const GeomTraits& gt) +void constrain_edges(const FaceRange& faces, + TriangleMesh& tmesh, + const bool constrain_border_edges, + const bool constrain_sharp_edges, + const double dihedral_angle, + const double /*weak_DA*/, + EdgeConstrainMap& eif, + VertexPointMap vpm, + const GeomTraits& gt) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::edge_descriptor edge_descriptor; @@ -370,16 +430,18 @@ void constrain_sharp_and_border_edges(const FaceRange& faces, typedef typename GeomTraits::FT FT; typedef typename GeomTraits::Vector_3 Vector; - std::map is_border_of_selection; + std::unordered_map is_border_of_selection; for(face_descriptor f : faces) { - // @fixme what about nm vertices for(halfedge_descriptor h : CGAL::halfedges_around_face(halfedge(f, tmesh), tmesh)) { // Default initialization is guaranteed to be `false`. Thus, meet it once will switch // the value to `true` and meeting it twice will switch back to `false`. const edge_descriptor e = edge(h, tmesh); - is_border_of_selection[e] = !(is_border_of_selection[e]); + if(constrain_sharp_edges) + is_border_of_selection[e] = !(is_border_of_selection[e]); + else + is_border_of_selection[e] = false; } } @@ -387,10 +449,7 @@ void constrain_sharp_and_border_edges(const FaceRange& faces, CGAL::Polygon_mesh_processing::experimental::detect_sharp_edges_pp(faces, tmesh, dihedral_angle, eif, parameters::weak_dihedral_angle(weak_DA)); - // borders are also constrained - for(const auto& ep : is_border_of_selection) - if(ep.second) - put(eif, ep.first, true); + // ... #else // this is basically the code that is in detect_features (at the very bottom) // but we do not want a folding to be marked as a sharp feature so the dihedral angle is also @@ -401,6 +460,9 @@ void constrain_sharp_and_border_edges(const FaceRange& faces, for(const auto& ep : is_border_of_selection) { bool flag = ep.second; + if(!constrain_border_edges) + flag = false; + if(constrain_sharp_edges && !flag) { const halfedge_descriptor h = halfedge(ep.first, tmesh); @@ -409,15 +471,18 @@ void constrain_sharp_and_border_edges(const FaceRange& faces, const face_descriptor f1 = face(h, tmesh); const face_descriptor f2 = face(opposite(h, tmesh), tmesh); - // @todo cache normals + // @speed cache normals const Vector n1 = compute_face_normal(f1, tmesh, parameters::vertex_point_map(vpm).geom_traits(gt)); const Vector n2 = compute_face_normal(f2, tmesh, parameters::vertex_point_map(vpm).geom_traits(gt)); - const FT c = gt.compute_scalar_product_3_object()(n1, n2); + if(n1 != CGAL::NULL_VECTOR && n2 != CGAL::NULL_VECTOR) + { + const FT c = gt.compute_scalar_product_3_object()(n1, n2); - // Do not mark as sharp edges with a dihedral angle that is almost `pi` because this is likely - // due to a foldness on the mesh rather than a sharp edge that we wish to preserve - // (Ideally this would be pre-treated as part of the flatness treatment) - flag = (c <= cos_angle && c >= -cos_angle); + // Do not mark as sharp edges with a dihedral angle that is almost `pi` because this is likely + // due to a fold on the mesh rather than a sharp edge that we would like to preserve + // (Ideally this would be pre-treated as part of the flatness treatment) + flag = (c <= cos_angle && c >= -cos_angle); + } } is_border_of_selection[ep.first] = flag; // Only needed for output, really @@ -477,8 +542,8 @@ bool remove_self_intersections_with_smoothing(std::set > patch; for(const face_descriptor f : faces(local_mesh)) { @@ -515,7 +581,6 @@ bool remove_self_intersections_with_smoothing(std::set new_faces; replace_faces_with_patch(face_range, patch, tmesh, vpm, std::inserter(new_faces, new_faces.end())); - CGAL_assertion(!does_self_intersect(new_faces, tmesh, parameters::vertex_point_map(vpm))); #ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG if(constrain_sharp_edges) @@ -558,712 +623,6 @@ bool order_border_halfedge_range(std::vector -void dump_cc(const FaceContainer& cc_faces, - const TriangleMesh& mesh, - const std::string filename) -{ - typedef typename boost::graph_traits::face_descriptor face_descriptor; - - typedef typename GetVertexPointMap::const_type VertexPointMap; - VertexPointMap vpm =get_const_property_map(vertex_point, mesh); - - std::ofstream out(filename); - out.precision(17); - - out << "OFF\n"; - out << 3*cc_faces.size() << " " << cc_faces.size() << " 0\n"; - - for(const face_descriptor f : cc_faces) - { - out << get(vpm, source(halfedge(f, mesh), mesh)) << "\n"; - out << get(vpm, target(halfedge(f, mesh), mesh)) << "\n"; - out << get(vpm, target(next(halfedge(f, mesh), mesh), mesh)) << "\n"; - } - - int id = 0; - for(const face_descriptor f : cc_faces) - { - CGAL_USE(f); - out << "3 " << id << " " << id+1 << " " << id+2 << "\n"; - id += 3; - } - - out.close(); -} - -template -void dump_tentative_hole(std::vector >& point_patch, - const std::string filename) -{ - std::ofstream out(filename); - out << std::setprecision(17); - - std::map unique_points_with_id; - for(const std::vector& face : point_patch) - for(const Point& p : face) - unique_points_with_id.insert(std::make_pair(p, 0)); - - out << "OFF\n"; - out << unique_points_with_id.size() << " " << point_patch.size() << " 0\n"; - - int unique_id = 0; - for(auto& pp : unique_points_with_id) - { - out << pp.first << "\n"; - pp.second = unique_id++; - } - - for(const std::vector& face : point_patch) - { - out << face.size(); - for(const Point& p : face) - out << " " << unique_points_with_id.at(p); - out << "\n"; - } - - out << std::endl; - out.close(); -} - -#endif // CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT - -// -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- - -// Hole filling can be influenced by setting a third point associated to an edge on the border of the hole. -// This third point is supposed to represent how the mesh continues on the other side of the hole. -// If that edge is a border edge, there is no third point (since the opposite face is the null face). -// Similarly if the edge is an internal sharp edge, we don't really want to use the opposite face because -// there is by definition a strong discontinuity and it might thus mislead the hole filling algorithm. -// -// Rather, we construct an artifical third point that is in the same plane as the face incident to `h`, -// defined as the third point of the imaginary equilateral triangle incident to opp(h, tmesh) -template -typename boost::property_traits::value_type -construct_artificial_third_point(const typename boost::graph_traits::halfedge_descriptor h, - const TriangleMesh& tmesh, - const VertexPointMap vpm, - const GeomTraits& gt) -{ - typedef typename GeomTraits::FT FT; - typedef typename boost::property_traits::value_type Point; - typedef typename boost::property_traits::reference Point_ref; - typedef typename GeomTraits::Vector_3 Vector; - - const Point_ref p1 = get(vpm, source(h, tmesh)); - const Point_ref p2 = get(vpm, target(h, tmesh)); - const Point_ref opp_p = get(vpm, target(next(h, tmesh), tmesh)); - - // sqrt(3)/2 to have an equilateral triangle with p1, p2, and third_point - const FT dist = 0.5 * CGAL::sqrt(3.) * CGAL::approximate_sqrt(gt.compute_squared_distance_3_object()(p1, p2)); - - const Vector ve1 = gt.construct_vector_3_object()(p1, p2); - const Vector ve2 = gt.construct_vector_3_object()(p1, opp_p); - - // gram schmidt - const FT e1e2_sp = gt.compute_scalar_product_3_object()(ve1, ve2); - Vector orthogonalized_ve2 = gt.construct_sum_of_vectors_3_object()( - ve2, gt.construct_scaled_vector_3_object()(ve1, - e1e2_sp)); - Polygon_mesh_processing::internal::normalize(orthogonalized_ve2, gt); - - const Point mid_p1p2 = gt.construct_midpoint_3_object()(p1, p2); - const Point third_p = gt.construct_translated_point_3_object()( - mid_p1p2, gt.construct_scaled_vector_3_object()(orthogonalized_ve2, -dist)); - - return third_p; -} - -template -bool construct_tentative_hole_patch(std::vector::vertex_descriptor>& cc_border_vertices, - std::set::vertex_descriptor>& cc_interior_vertices, - std::set::edge_descriptor>& cc_interior_edges, - const std::vector& hole_points, - const std::vector& third_points, - const std::vector::halfedge_descriptor>& cc_border_hedges, - const std::set::face_descriptor>& cc_faces, - std::vector >& point_patch, - const TriangleMesh& tmesh, - VertexPointMap /*vpm*/, - const GeomTraits& /*gt*/) -{ - CGAL_static_assertion((std::is_same::value_type, Point>::value)); - - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - - typedef CGAL::Triple Face_indices; - - CGAL_assertion(cc_border_hedges.size() == cc_border_hedges.size()); - CGAL_assertion(hole_points.size() == third_points.size()); - - // Collect vertices and edges inside the current selection cc: first collect all vertices and - // edges incident to the faces to remove... - for(const face_descriptor f : cc_faces) - { - for(halfedge_descriptor h : halfedges_around_face(halfedge(f, tmesh), tmesh)) - { - if(halfedge(target(h, tmesh), tmesh) == h) // limit the number of insertions - cc_interior_vertices.insert(target(h, tmesh)); - - cc_interior_edges.insert(edge(h, tmesh)); - } - } - - // ... and then remove those on the boundary - for(halfedge_descriptor h : cc_border_hedges) - { - cc_interior_vertices.erase(target(h, tmesh)); - cc_interior_edges.erase(edge(h, tmesh)); - } - - // try to triangulate the hole using default parameters - // (using Delaunay search space if CGAL_HOLE_FILLING_DO_NOT_USE_DT3 is not defined) - std::vector hole_faces; - if(hole_points.size() > 3) - triangulate_hole_polyline(hole_points, third_points, std::back_inserter(hole_faces)); - else - hole_faces.emplace_back(0, 1, 2); // trivial hole filling - - if(hole_faces.empty()) - { -#ifndef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 - #ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: Failed to fill a hole using Delaunay search space.\n"; - #endif - - triangulate_hole_polyline(hole_points, third_points, std::back_inserter(hole_faces), - parameters::use_delaunay_triangulation(false)); -#endif - if(hole_faces.empty()) - { -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: Failed to fill a hole using the whole search space.\n"; -#endif - return false; - } - } - -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT - std::cout << " DEBUG: " << hole_faces.size() << " faces in the patch" << std::endl; - std::vector > to_dump; - for(const Face_indices& face : hole_faces) - { - to_dump.emplace_back(std::initializer_list{hole_points[face.first], - hole_points[face.second], - hole_points[face.third]}); - } - - CGAL_assertion(to_dump.size() == hole_faces.size()); - - static int hole_id = 0; - std::stringstream oss; - oss << "results/tentative_hole_" << hole_id++ << ".off" << std::ends; - const std::string filename = oss.str().c_str(); - - dump_tentative_hole(to_dump, filename); -#endif - - // make sure that the hole filling is valid, we check that no - // edge already in the mesh is present in hole_faces. - bool non_manifold_edge_found = false; - for(const Face_indices& triangle : hole_faces) - { - std::array edges = make_array(triangle.first, triangle.second, - triangle.second, triangle.third, - triangle.third, triangle.first); - for(int k=0; k<3; ++k) - { - const int vi = edges[2*k], vj = edges[2*k+1]; - - // ignore boundary edges - if(vi+1 == vj || (vj == 0 && static_cast(vi) == cc_border_vertices.size()-1)) - continue; - - halfedge_descriptor h = halfedge(cc_border_vertices[vi], cc_border_vertices[vj], tmesh).first; - if(h != boost::graph_traits::null_halfedge() && - cc_interior_edges.count(edge(h, tmesh)) == 0) - { - non_manifold_edge_found = true; - break; - } - } - - if(non_manifold_edge_found) - break; - } - - if(non_manifold_edge_found) - { -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: Triangulation produced is non-manifold when plugged into the mesh.\n"; -#endif - - return false; - } - - point_patch.reserve(point_patch.size() + hole_faces.size()); - for(const Face_indices& face : hole_faces) - { - point_patch.emplace_back(std::initializer_list{hole_points[face.first], - hole_points[face.second], - hole_points[face.third]}); - } - -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: Found acceptable hole-filling patch.\n"; -#endif - - return true; -} - -// This function constructs the ranges `hole_points` and `third_points`. Note that for a sub-hole, -// these two ranges are constructed in another function because we don't want to set 'third_points' -// for edges that are on the border of the sub-hole but not on the border of the (full) hole. -template -bool construct_tentative_hole_patch(std::vector::vertex_descriptor>& cc_border_vertices, - std::set::vertex_descriptor>& cc_interior_vertices, - std::set::edge_descriptor>& cc_interior_edges, - const std::vector::halfedge_descriptor>& cc_border_hedges, - const std::set::face_descriptor>& cc_faces, - std::vector::value_type> >& patch, - const TriangleMesh& tmesh, - VertexPointMap vpm, - const GeomTraits& gt) -{ - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - - typedef typename boost::property_traits::value_type Point; - - std::vector hole_points, third_points; - hole_points.reserve(cc_border_hedges.size()); - third_points.reserve(cc_border_hedges.size()); - - for(const halfedge_descriptor h : cc_border_hedges) - { - const vertex_descriptor v = source(h, tmesh); - hole_points.push_back(get(vpm, v)); - cc_border_vertices.push_back(v); - - CGAL_assertion(!is_border(h, tmesh)); - - if(is_border_edge(h, tmesh)) - third_points.push_back(construct_artificial_third_point(h, tmesh, vpm, gt)); - else - third_points.push_back(get(vpm, target(next(opposite(h, tmesh), tmesh), tmesh))); - } - - CGAL_postcondition(hole_points.size() >= 3); - - return construct_tentative_hole_patch(cc_border_vertices, cc_interior_vertices, cc_interior_edges, - hole_points, third_points, cc_border_hedges, cc_faces, - patch, tmesh, vpm, gt); -} - -// In that overload, we don't know the border of the patch because the face range is a sub-region -// of the hole. We also construct `hole_points` and `third_points`, but with no third point for internal -// sharp edges because a local self-intersection is usually caused by folding and thus we do not want -// a third point resulting from folding to constrain the way we fill the hole in the wrong way. -template -bool construct_tentative_sub_hole_patch(std::vector::value_type> >& patch, - const std::set::face_descriptor>& sub_cc_faces, - const std::set::face_descriptor>& cc_faces, - TriangleMesh& tmesh, - VertexPointMap vpm, - const GeomTraits& gt) -{ - 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 typename boost::property_traits::value_type Point; - - // Collect halfedges on the boundary of the region to be selected - // (pointing inside the domain to be remeshed) - std::set internal_hedges; - std::vector cc_border_hedges; - for(const face_descriptor fd : sub_cc_faces) - { - halfedge_descriptor h = halfedge(fd, tmesh); - for(int i=0; i<3;++i) - { - if(is_border(opposite(h, tmesh), tmesh)) - { - cc_border_hedges.push_back(h); - } - else - { - const face_descriptor opp_f = face(opposite(h, tmesh), tmesh); - if(sub_cc_faces.count(opp_f) == 0) - { - cc_border_hedges.push_back(h); - if(cc_faces.count(opp_f) != 0) - internal_hedges.insert(h); - } - } - - h = next(h, tmesh); - } - } - - // Sort halfedges so that they describe the sequence of halfedges of the hole to be made - if(!order_border_halfedge_range(cc_border_hedges, tmesh)) - { -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: More than one border in sub-hole. Not currently handled." << std::endl; -#endif - - return false; - } - - // @todo we don't care about those sets, so instead there could be a system of output iterators - // in construct_tentative_hole_patch() instead (and here would be emptyset iterators). - std::set cc_interior_vertices; - std::set cc_interior_edges; - - std::vector cc_border_vertices; - cc_border_vertices.reserve(cc_border_hedges.size()); - - std::vector hole_points, third_points; - hole_points.reserve(cc_border_hedges.size()); - third_points.reserve(cc_border_hedges.size()); - - for(const halfedge_descriptor h : cc_border_hedges) - { - const vertex_descriptor v = source(h, tmesh); - hole_points.push_back(get(vpm, v)); - cc_border_vertices.push_back(v); - - CGAL_assertion(!is_border(h, tmesh)); - - if(internal_hedges.count(h) == 0 && // `h` is on the border of the full CC - !is_border_edge(h, tmesh)) - { - third_points.push_back(get(vpm, target(next(opposite(h, tmesh), tmesh), tmesh))); - } - else // `h` is on the border of the sub CC but not on the border of the full CC - { - const Point tp = construct_artificial_third_point(h, tmesh, vpm, gt); - third_points.push_back(tp); - } - } - - return construct_tentative_hole_patch(cc_border_vertices, cc_interior_vertices, cc_interior_edges, - hole_points, third_points, cc_border_hedges, sub_cc_faces, - patch, tmesh, vpm, gt); -} - -// -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- - -// Patch is not valid if: -// - we insert the same face more than once -// - insert (geometric) non-manifold edges -template -bool check_patch_sanity(const std::vector >& patch) -{ - std::set > unique_faces; - std::map, int> unique_edges; - - for(const std::vector& face : patch) - { - if(!unique_faces.emplace(face.begin(), face.end()).second) // this face had already been found - return false; - - int i = (unique_edges.insert(std::make_pair(std::set { face[0], face[1] }, 0)).first->second)++; - if(i == 2) // non-manifold edge - return false; - - i = (unique_edges.insert(std::make_pair(std::set { face[1], face[2] }, 0)).first->second)++; - if(i == 2) // non-manifold edge - return false; - - i = (unique_edges.insert(std::make_pair(std::set { face[2], face[0] }, 0)).first->second)++; - if(i == 2) // non-manifold edge - return false; - } - - // Check for self-intersections - // Don't know anything better than just making a mesh out of the soup for now... - std::vector points; - std::vector > faces; - std::map ids; - - std::size_t c = 0; - for(const std::vector& face : patch) - { - std::vector ps_f; - for(const Point& pt : face) - { - std::size_t id = c; - std::pair::iterator, bool> is_insert_successful = - ids.insert(std::make_pair(pt, c)); - if(is_insert_successful.second) // first time we've seen that point - { - ++c; - points.push_back(pt); - } - else // already seen that point - { - id = is_insert_successful.first->second; - } - - CGAL_assertion(id < points.size()); - ps_f.push_back(id); - } - - faces.push_back(ps_f); - } - - TriangleMesh patch_mesh; - if(is_polygon_soup_a_polygon_mesh(faces)) - polygon_soup_to_polygon_mesh(points, faces, patch_mesh); - else - return false; - - if(does_self_intersect(patch_mesh)) - { -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: Tentative patch has self-intersections." << std::endl; -#endif - - return false; - } - - return true; -} - -// This function is only called when the hole is NOT subdivided into smaller holes -template -bool fill_hole(std::vector::halfedge_descriptor>& cc_border_hedges, - std::set::face_descriptor>& cc_faces, - std::set::face_descriptor>& working_face_range, - TriangleMesh& tmesh, - const PolyhedralEnvelope& cc_envelope, - VertexPointMap vpm, - const GeomTraits& gt) -{ - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef typename boost::graph_traits::edge_descriptor edge_descriptor; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - - typedef typename boost::property_traits::value_type Point; - -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: Attempting hole-filling (no constraints), " << cc_faces.size() << " faces\n"; -#endif - - if(!order_border_halfedge_range(cc_border_hedges, tmesh)) - { - CGAL_assertion(false); // we shouldn't fail to orient the boundary cycle of the complete hole - return false; - } - - std::set cc_interior_vertices; - std::set cc_interior_edges; - - std::vector cc_border_vertices; - cc_border_vertices.reserve(cc_border_hedges.size()); - - std::vector > patch; - if(!construct_tentative_hole_patch(cc_border_vertices, cc_interior_vertices, cc_interior_edges, - cc_border_hedges, cc_faces, patch, tmesh, vpm, gt) || - !check_patch_sanity(patch)) - { -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: Failed to find acceptable hole patch\n"; -#endif - - return false; - } - - if (!cc_envelope.is_empty() && !cc_envelope(patch)) - { -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: Patch is not inside the input polyhedral envelope\n"; -#endif - return false; - } - - // Could renew the range directly within the patch replacement function - // to avoid erasing and re-adding the same face - for(const face_descriptor f : cc_faces) - working_face_range.erase(f); - - // Plug the new triangles in the mesh, reusing previous edges and faces - replace_faces_with_patch(cc_border_vertices, cc_interior_vertices, - cc_border_hedges, cc_interior_edges, - cc_faces, patch, tmesh, vpm, - std::inserter(working_face_range, working_face_range.end())); - -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT - static int filed_hole_id = 0; - std::stringstream oss; - oss << "results/filled_basic_" << filed_hole_id++ << ".off" << std::ends; - std::ofstream(oss.str().c_str()) << std::setprecision(17) << tmesh; -#endif - - CGAL_postcondition(is_valid_polygon_mesh(tmesh)); - - return true; -} - -// Same function as above but border of the hole is not known -template -bool fill_hole(std::set::face_descriptor>& cc_faces, - std::set::face_descriptor>& working_face_range, - TriangleMesh& tmesh, - const PolyhedralEnvelope& cc_envelope, - VertexPointMap vpm, - const GeomTraits& gt) -{ - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - - std::vector cc_border_hedges; - for(face_descriptor fd : cc_faces) - { - halfedge_descriptor h = halfedge(fd, tmesh); - for(int i=0; i<3; ++i) - { - if(is_border(opposite(h, tmesh), tmesh) || cc_faces.count(face(opposite(h, tmesh), tmesh)) == 0) - cc_border_hedges.push_back(h); - - h = next(h, tmesh); - } - } - - if(order_border_halfedge_range(cc_border_hedges, tmesh)) - return fill_hole(cc_border_hedges, cc_faces, working_face_range, tmesh, - cc_envelope,vpm, gt); - else - return false; -} - -template -bool fill_hole_with_constraints(std::vector::halfedge_descriptor>& cc_border_hedges, - std::set::face_descriptor>& cc_faces, - std::set::face_descriptor>& working_face_range, - TriangleMesh& tmesh, - const double dihedral_angle, - const double weak_DA, - const PolyhedralEnvelope& cc_envelope, - VertexPointMap vpm, - const GeomTraits& gt) -{ - typedef typename boost::graph_traits::face_descriptor face_descriptor; - - typedef typename boost::property_traits::value_type Point; - -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: Attempting local hole-filling with constrained sharp edges..." << std::endl; -#endif - - // If we are treating self intersections locally, first try to constrain sharp edges in the hole - typedef CGAL::dynamic_edge_property_t Edge_property_tag; - typedef typename boost::property_map::type EIFMap; - EIFMap eif = get(Edge_property_tag(), tmesh); - - constrain_sharp_and_border_edges(cc_faces, tmesh, eif, true /*constrain_sharp_edges*/, dihedral_angle, weak_DA, vpm, gt); - - // Partition the hole using these constrained edges - std::set visited_faces; - std::vector > patch; - - int cc_counter = 0; - for(face_descriptor f : cc_faces) - { - if(!visited_faces.insert(f).second) // already visited that face - continue; - - // gather the faces of the sub-hole - std::set sub_cc; - Polygon_mesh_processing::connected_component(f, tmesh, std::inserter(sub_cc, sub_cc.end()), - CGAL::parameters::edge_is_constrained_map(eif)); - - visited_faces.insert(sub_cc.begin(), sub_cc.end()); -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << "CC of size " << sub_cc.size() << " (total: " << cc_faces.size() << ")" << std::endl; -#endif - ++cc_counter; - -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT - dump_cc(sub_cc, tmesh, "results/current_cc.off"); -#endif - - // The mesh is not modified, but 'patch' gets filled - if(!construct_tentative_sub_hole_patch(patch, sub_cc, cc_faces, tmesh, vpm, gt)) - { - // Something went wrong while finding a potential cover for the a sub-hole --> use basic hole-filling - return fill_hole(cc_border_hedges, cc_faces, working_face_range, tmesh, - cc_envelope,vpm, gt); - } - } -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << cc_counter << " independent sub holes" << std::endl; -#endif -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT - std::ofstream out("results/hole_fillers.off"); - out.precision(17); - - out << "OFF\n"; - out << 3*patch.size() << " " << patch.size() << " 0\n"; - - for(const auto& f : patch) - { - for(const auto& pt : f) - out << pt << "\n"; - } - - int id = 0; - for(std::size_t i=0; i(patch)) - { -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << "Unhealthy patch, use base fill_hole" << std::endl; -#endif - return fill_hole(cc_border_hedges, cc_faces, working_face_range, tmesh, - cc_envelope, vpm, gt); - } - - // check if the patch is inside the input polyhedral envelope - if(!cc_envelope.is_empty() && !cc_envelope(patch)) - { -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << "Patch is not entirely inside the input polyhedral envelope, use base fill_hole" << std::endl; -#endif - return fill_hole(cc_border_hedges, cc_faces, working_face_range, tmesh, - cc_envelope, vpm, gt); - } - - // Plug the hole-filling patch in the mesh - std::set new_faces; - replace_faces_with_patch(cc_faces, patch, tmesh, vpm, std::inserter(new_faces, new_faces.end())); - - // Otherwise it should have failed the sanity check - CGAL_assertion(!does_self_intersect(new_faces, tmesh, parameters::vertex_point_map(vpm))); - - // Update working range with the new faces - for(const face_descriptor f : cc_faces) - working_face_range.erase(f); - - working_face_range.insert(new_faces.begin(), new_faces.end()); - - return true; -} - template struct Strict_intersect_edges // "strict" as in "not sharing a vertex" { @@ -1352,15 +711,937 @@ bool is_simple_3(const std::vector::h return true; } -template +// -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT +template +void dump_patch(const std::string filename, + std::vector >& point_patch) +{ + std::ofstream out(filename); + out << std::setprecision(17); + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Writing " << point_patch.size() << " face(s) into " << filename << std::endl; +#endif + + std::vector points; + std::vector > faces; + + std::map unique_points_with_id; + for(const std::vector& face : point_patch) + for(const Point& p : face) + unique_points_with_id.emplace(p, 0); + + out << "OFF\n"; + out << unique_points_with_id.size() << " " << point_patch.size() << " 0\n"; + + int unique_id = 0; + for(auto& e : unique_points_with_id) + { + e.second = unique_id++; + out << e.first << "\n"; + } + + for(const std::vector& face : point_patch) + { + out << face.size(); + for(const Point& p : face) + out << " " << unique_points_with_id.at(p); + out << "\n"; + } + + out << std::endl; + out.close(); +} + +template +void dump_cc(const std::string filename, + const FaceContainer& cc_faces, + const PolygonMesh& pmesh, + const VertexPointMap vpm) +{ + typedef typename boost::property_traits::value_type Point; + + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::face_descriptor face_descriptor; + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Writing " << cc_faces.size() << " face(s) into " << filename << std::endl; +#endif + + std::unordered_map vertex_ids; + std::stringstream vss, fss; + std::size_t id = 0; + for(face_descriptor f : cc_faces) + { + fss << degree(f, pmesh); + for(vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) + { + auto res = vertex_ids.emplace(v, id); + if(res.second) // insert was successful (first time seeing this vertex) + { + ++id; + vss << get(vpm, v) << "\n"; + } + + fss << " " << res.first->second /*id*/; + } + fss << "\n"; + } + + std::ofstream out(filename); + out << std::setprecision(17); + + out << "OFF\n"; + out << id << " " << cc_faces.size() << " 0\n"; + out << vss.str() << "\n" << fss.str() << std::endl; +} +#endif // CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT + +// -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- + +// Hole filling can be influenced by setting a third point associated to an edge on the border of the hole. +// This third point is supposed to represent how the mesh continues on the other side of the hole. +// If that edge is a border edge, there is no third point (since the opposite face is the null face). +// Similarly if the edge is an internal sharp edge, we don't really want to use the opposite face because +// there is by definition a strong discontinuity and it might thus mislead the hole filling algorithm. +// +// Rather, we construct an artifical third point that is in the same plane as the face incident to `h`, +// defined as the third point of the imaginary equilateral triangle incident to opp(h, tmesh) +template +typename boost::property_traits::value_type +construct_artificial_third_point(const typename boost::graph_traits::halfedge_descriptor h, + const TriangleMesh& tmesh, + const VertexPointMap vpm, + const GeomTraits& gt) +{ + typedef typename GeomTraits::FT FT; + typedef typename boost::property_traits::value_type Point; + typedef typename boost::property_traits::reference Point_ref; + typedef typename GeomTraits::Vector_3 Vector; + + const Point_ref p1 = get(vpm, source(h, tmesh)); + const Point_ref p2 = get(vpm, target(h, tmesh)); + const Point_ref opp_p = get(vpm, target(next(h, tmesh), tmesh)); + + // sqrt(3)/2 to have an equilateral triangle with p1, p2, and third_point + const FT dist = 0.5 * CGAL::sqrt(3.) * CGAL::approximate_sqrt(gt.compute_squared_distance_3_object()(p1, p2)); + + const Vector ve1 = gt.construct_vector_3_object()(p1, p2); + const Vector ve2 = gt.construct_vector_3_object()(p1, opp_p); + + // gram schmidt + const FT e1e2_sp = gt.compute_scalar_product_3_object()(ve1, ve2); + Vector orthogonalized_ve2 = gt.construct_sum_of_vectors_3_object()( + ve2, gt.construct_scaled_vector_3_object()(ve1, - e1e2_sp)); + Polygon_mesh_processing::internal::normalize(orthogonalized_ve2, gt); + + const Point mid_p1p2 = gt.construct_midpoint_3_object()(p1, p2); + const Point third_p = gt.construct_translated_point_3_object()( + mid_p1p2, gt.construct_scaled_vector_3_object()(orthogonalized_ve2, -dist)); + + return third_p; +} + +template +bool check_patch_compatibility(const std::vector >& patch, + const std::vector::vertex_descriptor>& border_vertices, + const std::vector::halfedge_descriptor>& border_hedges, + const std::set::edge_descriptor>& interior_edges, + const TriangleMesh& tmesh, + const VertexPointMap vpm) +{ + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + + if(patch.empty()) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Empty patch" << std::endl; +#endif + return false; + } + + std::map point_to_vd; + for(vertex_descriptor v : border_vertices) + point_to_vd[get(vpm, v)] = v; + + // make sure that the hole filling is valid: check that no edge + // already in the mesh is present in hole_faces. + bool non_manifold_edge_found = false; + for(const std::vector& f : patch) + { + for(int i=0; i<3; ++i) + { + const Point& p0 = f[i]; + const Point& p1 = f[(i+1)%3]; + + auto p0_it = point_to_vd.find(p0); + auto p1_it = point_to_vd.find(p1); + + // @fixme + // If any of the vertices is an inner point created through refine(), we don't have an easy way + //to know the possible correspondency with an existing vertex of the mesh: it might be a vertex + // part of a completely different CC. Unfortunately, a nm edge could be created with this vertex, + // but the complexity to check all vertices of the mesh is horrible (even spatially filtered, + // this needs to be updated, ...) + if(p0_it == point_to_vd.end() || p1_it == point_to_vd.end()) + continue; + + const vertex_descriptor v0 = p0_it->second; + const vertex_descriptor v1 = p1_it->second; + + halfedge_descriptor h = halfedge(v0, v1, tmesh).first; // null halfedge if not found + if(h != boost::graph_traits::null_halfedge()) + { + if(std::find(border_hedges.begin(), border_hedges.end(), h) == border_hedges.end() && + interior_edges.count(edge(h, tmesh)) == 0) + { + non_manifold_edge_found = true; + break; + } + } + } + + if(non_manifold_edge_found) + break; + } + + if(non_manifold_edge_found) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Triangulation produced is non-manifold when plugged into the mesh.\n"; +#endif + + return false; + } + + return true; +} + +// Patch is not valid if: +// - we insert the same face more than once +// - insert (geometric) non-manifold edges +template +bool check_patch_sanity(const std::vector >& patch) +{ + std::set > unique_faces; + std::map, int> unique_edges; + + for(const std::vector& face : patch) + { + if(!unique_faces.emplace(face.begin(), face.end()).second) // this face had already been found + return false; + + int i = (unique_edges.insert(std::make_pair(std::set { face[0], face[1] }, 0)).first->second)++; + if(i == 2) // non-manifold edge + return false; + + i = (unique_edges.insert(std::make_pair(std::set { face[1], face[2] }, 0)).first->second)++; + if(i == 2) // non-manifold edge + return false; + + i = (unique_edges.insert(std::make_pair(std::set { face[2], face[0] }, 0)).first->second)++; + if(i == 2) // non-manifold edge + return false; + } + + // Check for self-intersections within the patch + // @todo something better than just making a mesh out of the soup? + std::vector points; + std::vector > faces; + std::map ids; + + std::size_t c = 0; + for(const std::vector& face : patch) + { + std::vector ps_f; + for(const Point& pt : face) + { + std::size_t id = c; + auto is_insert_successful = ids.emplace(pt, c); + if(is_insert_successful.second) // first time we've seen that point + { + ++c; + points.push_back(pt); + } + else // already seen that point + { + id = is_insert_successful.first->second; + } + + CGAL_assertion(id < points.size()); + ps_f.push_back(id); + } + + faces.push_back(ps_f); + } + + TriangleMesh patch_mesh; + if(is_polygon_soup_a_polygon_mesh(faces)) + polygon_soup_to_polygon_mesh(points, faces, patch_mesh); + else + return false; + + if(does_self_intersect(patch_mesh)) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Tentative patch has self-intersections." << std::endl; +#endif + + return false; + } + + return true; +} + +template +bool construct_hole_patch(std::vector >& hole_faces, + const std::vector& hole_points, + const std::vector& third_points, + const GeomTraits& gt) +{ + if(hole_points.size() > 3) + { + triangulate_hole_polyline(hole_points, third_points, std::back_inserter(hole_faces), + parameters::geom_traits(gt)); + } + else + { + hole_faces.emplace_back(0, 1, 2); // trivial hole filling + } + + if(hole_faces.empty()) + { +#ifndef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 + #ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Failed to fill a hole using Delaunay search space.\n"; + #endif + + triangulate_hole_polyline(hole_points, third_points, std::back_inserter(hole_faces), + parameters::use_delaunay_triangulation(false).geom_traits(gt)); +#endif + if(hole_faces.empty()) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Failed to fill a hole using the whole search space.\n"; +#endif + return false; + } + } + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT + std::cout << " DEBUG: " << hole_faces.size() << " faces in the patch" << std::endl; + std::vector > to_dump; + for(const auto& face : hole_faces) + { + to_dump.emplace_back(std::initializer_list{ hole_points[face.first], + hole_points[face.second], + hole_points[face.third] }); + } + + CGAL_assertion(to_dump.size() == hole_faces.size()); + + static int patch_id = 0; + std::stringstream oss; + oss << "results/raw_patch_" << patch_id++ << ".off" << std::ends; + const std::string filename = oss.str().c_str(); + + dump_patch(filename, to_dump); +#endif + + return true; +} + +template +struct Mesh_projection_functor +{ + typedef typename GeomTraits::Point_3 Point_3; + typedef typename GeomTraits::Triangle_3 Triangle_3; + + typedef std::vector Triangle_container; + typedef CGAL::AABB_triangle_primitive Primitive; + typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_tree Tree; + + template + Mesh_projection_functor(const TriangleMesh& mesh, + const VPM vpm) + { + triangles.reserve(num_faces(mesh)); + for(auto f : faces(mesh)) + triangles.emplace_back(get(vpm, target(halfedge(f, mesh), mesh)), + get(vpm, target(next(halfedge(f, mesh), mesh), mesh)), + get(vpm, source(halfedge(f, mesh), mesh))); + + tree.insert(std::cbegin(triangles), std::cend(triangles)); + } + + Point_3 operator()(const Point_3& p) const { return tree.closest_point(p); } + +private: + Triangle_container triangles; + Tree tree; +}; + +template +bool adapt_patch(std::vector >& point_patch, + const Projector& projector, + const TriangleMesh&, + const GeomTraits&) +{ + 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; + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT + dump_patch("results/pre-adapt.off", point_patch); +#endif + + CGAL_precondition(!point_patch.empty()); + + std::vector soup_points; + std::vector > soup_faces; + + std::size_t pid = 0; + std::map point_ids; + for(const auto& fp : point_patch) + { + CGAL_assertion(fp.size() == 3); + std::array f; + for(std::size_t i=0; i<3; ++i) + { + auto res = point_ids.emplace(fp[i], pid); + if(res.second) + { + soup_points.push_back(fp[i]); + ++pid; + } + f[i] = res.first->second; + } + soup_faces.push_back(f); + } + + CGAL_assertion(is_polygon_soup_a_polygon_mesh(soup_faces)); + + TriangleMesh local_mesh; + auto local_vpm = get(vertex_point, local_mesh); + + polygon_soup_to_polygon_mesh(soup_points, soup_faces, local_mesh); + bool has_SI = does_self_intersect(local_mesh); + + std::vector border_hedges; + border_halfedges(faces(local_mesh), local_mesh, std::back_inserter(border_hedges)); + + std::vector new_vertices; + refine(local_mesh, faces(local_mesh), CGAL::Emptyset_iterator(), std::back_inserter(new_vertices)); + + for(vertex_descriptor v : new_vertices) + put(local_vpm, v, projector(get(local_vpm, v))); + + // The projector can create degenerate faces + if(!remove_degenerate_faces(local_mesh)) + return !has_SI; + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT + static int adapted_patch_id = 0; + std::stringstream oss; + oss << "results/adapted_patch_" << adapted_patch_id++ << ".off" << std::ends; + const std::string filename = oss.str().c_str(); + std::cout << " DEBUG: Writing " << point_patch.size() << " faces into " << filename << std::endl; + IO::write_polygon_mesh(filename, local_mesh); +#endif + + // If the adapted tentative patch has SI, revert back to the base patch + if(does_self_intersect(local_mesh)) + return !has_SI; // if the base patch also has self-intersections, we are done + + // Replace the tentative patch with the new, self-intersection-less, adapted patch + point_patch.clear(); + point_patch.reserve(num_faces(local_mesh)); + + for(face_descriptor f : faces(local_mesh)) + { + std::vector fp { get(local_vpm, target(halfedge(f, local_mesh), local_mesh)), + get(local_vpm, target(next(halfedge(f, local_mesh), local_mesh), local_mesh)), + get(local_vpm, source(halfedge(f, local_mesh), local_mesh)) }; + point_patch.push_back(fp); + } + + return true; +} + +// This overload uses hole filling to construct a patch and tests the manifoldness of the patch +template +bool construct_manifold_hole_patch(std::vector >& point_patch, + const std::vector& hole_points, + const std::vector& third_points, + const std::vector::vertex_descriptor>& cc_border_vertices, + const std::vector::halfedge_descriptor>& cc_border_hedges, + const std::set::edge_descriptor>& cc_interior_edges, + const Projector& projector, + const TriangleMesh& tmesh, + const VertexPointMap vpm, + const GeomTraits& gt) +{ + typedef CGAL::Triple Face_indices; + + // Try to triangulate the hole using default parameters + // (using Delaunay search space if CGAL_HOLE_FILLING_DO_NOT_USE_DT3 is not defined) + std::vector hole_faces; + construct_hole_patch(hole_faces, hole_points, third_points, gt); + + std::vector > local_point_patch; + local_point_patch.reserve(hole_faces.size()); + for(const Face_indices& face : hole_faces) + { + local_point_patch.emplace_back(std::initializer_list{hole_points[face.first], + hole_points[face.second], + hole_points[face.third]}); + } + + if(!adapt_patch(local_point_patch, projector, tmesh, gt)) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Failed to adapt the patch..." << std::endl; +#endif + return false; + } + + // Check manifoldness compatibility with the rest of the mesh + if(!check_patch_compatibility(local_point_patch, cc_border_vertices, cc_border_hedges, cc_interior_edges, tmesh, vpm)) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Incompatible patch" << std::endl; +#endif + return false; + } + + point_patch.reserve(point_patch.size() + local_point_patch.size()); + std::move(std::begin(local_point_patch), std::end(local_point_patch), std::back_inserter(point_patch)); + + bool is_sane = check_patch_sanity(point_patch); +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + if(is_sane) + std::cout << " DEBUG: Found sane hole-filling patch (" << point_patch.size() << " faces)\n"; + else + std::cout << " DEBUG: Insane hole-filling patch\n"; +#endif + + return is_sane; +} + +// This overloads fill the containers `cc_interior_vertices` and `cc_interior_edges` +template +bool construct_tentative_hole_patch_with_border(std::vector >& point_patch, + const std::vector& hole_points, + const std::vector& third_points, + const std::vector::vertex_descriptor>& cc_border_vertices, + const std::vector::halfedge_descriptor>& cc_border_hedges, + std::set::vertex_descriptor>& cc_interior_vertices, + std::set::edge_descriptor>& cc_interior_edges, + const std::set::face_descriptor>& cc_faces, + const Projector& projector, + const TriangleMesh& tmesh, + const VertexPointMap vpm, + const GeomTraits& gt) +{ + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + typedef typename boost::graph_traits::face_descriptor face_descriptor; + + CGAL_assertion(hole_points.size() == third_points.size()); + + // Collect vertices and edges inside the current selection cc: first collect all vertices and + // edges incident to the faces to remove... + for(const face_descriptor f : cc_faces) + { + for(halfedge_descriptor h : halfedges_around_face(halfedge(f, tmesh), tmesh)) + { + if(halfedge(target(h, tmesh), tmesh) == h) // to limit the number of insertions + cc_interior_vertices.insert(target(h, tmesh)); + + cc_interior_edges.insert(edge(h, tmesh)); + } + } + + // ... and then remove those on the boundary + for(halfedge_descriptor h : cc_border_hedges) + { + cc_interior_vertices.erase(target(h, tmesh)); + cc_interior_edges.erase(edge(h, tmesh)); + } + + return construct_manifold_hole_patch(point_patch, hole_points, third_points, + cc_border_vertices, cc_border_hedges, cc_interior_edges, + projector, tmesh, vpm, gt); +} + +// This function constructs the ranges `hole_points` and `third_points`. Note that for a sub-hole, +// these two ranges are constructed in another function because we don't want to set 'third_points' +// for edges that are on the border of the sub-hole but not on the border of the (full) hole. +template +bool construct_tentative_hole_patch(std::vector::value_type> >& patch, + std::vector::vertex_descriptor>& cc_border_vertices, + std::set::vertex_descriptor>& cc_interior_vertices, + std::set::edge_descriptor>& cc_interior_edges, + const std::vector::halfedge_descriptor>& cc_border_hedges, + const std::set::face_descriptor>& cc_faces, + const Projector& projector, + const TriangleMesh& tmesh, + const VertexPointMap vpm, + const GeomTraits& gt) +{ + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + + typedef typename boost::property_traits::value_type Point; + + cc_border_vertices.reserve(cc_border_hedges.size()); + + std::vector hole_points, third_points; + hole_points.reserve(cc_border_hedges.size()); + third_points.reserve(cc_border_hedges.size()); + + for(const halfedge_descriptor h : cc_border_hedges) + { + const vertex_descriptor v = source(h, tmesh); + hole_points.push_back(get(vpm, v)); + cc_border_vertices.push_back(v); + + CGAL_assertion(!is_border(h, tmesh)); + + if(is_border_edge(h, tmesh)) + third_points.push_back(construct_artificial_third_point(h, tmesh, vpm, gt)); + else + third_points.push_back(get(vpm, target(next(opposite(h, tmesh), tmesh), tmesh))); + } + + CGAL_postcondition(hole_points.size() >= 3); + + return construct_tentative_hole_patch_with_border(patch, hole_points, third_points, + cc_border_vertices, cc_border_hedges, + cc_interior_vertices, cc_interior_edges, + cc_faces, projector, tmesh, vpm, gt); +} + +// In this overload, we don't know the border of the patch because the face range is a sub-region +// of the hole. We also construct `hole_points` and `third_points`, but with no third point for internal +// sharp edges because a local self-intersection is usually caused by folding and thus we do not want +// a third point resulting from folding to wrongly influence the hole filling process. +template +bool construct_tentative_sub_hole_patch(std::vector::value_type> >& patch, + const std::set::face_descriptor>& sub_cc_faces, + const std::set::face_descriptor>& cc_faces, + const Projector& projector, + TriangleMesh& tmesh, + VertexPointMap vpm, + const GeomTraits& gt) +{ + 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 typename boost::property_traits::value_type Point; + + // Collect halfedges on the boundary of the region to be selected + // (pointing inside the domain to be remeshed) + std::set internal_hedges; + std::vector cc_border_hedges; + for(const face_descriptor fd : sub_cc_faces) + { + halfedge_descriptor h = halfedge(fd, tmesh); + for(int i=0; i<3;++i) + { + if(is_border(opposite(h, tmesh), tmesh)) + { + cc_border_hedges.push_back(h); + } + else + { + const face_descriptor opp_f = face(opposite(h, tmesh), tmesh); + if(sub_cc_faces.count(opp_f) == 0) + { + cc_border_hedges.push_back(h); + if(cc_faces.count(opp_f) != 0) + internal_hedges.insert(h); + } + } + + h = next(h, tmesh); + } + } + + // Sort halfedges so that they describe the sequence of halfedges of the hole to be made + if(!order_border_halfedge_range(cc_border_hedges, tmesh)) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: More than one border in sub-hole. Not currently handled." << std::endl; +#endif + + return false; + } + + if(!is_simple_3(cc_border_hedges, tmesh, vpm, gt)) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << "Hole filling cannot handle non-simple sub border" << std::endl; +#endif + return false; + } + + // @todo we don't care about these sets, so instead there could be a system of output iterators + // in construct_tentative_hole_patch instead (and here would be emptyset iterators). + std::set cc_interior_vertices; + std::set cc_interior_edges; + + std::vector cc_border_vertices; + cc_border_vertices.reserve(cc_border_hedges.size()); + + std::vector hole_points, third_points; + hole_points.reserve(cc_border_hedges.size()); + third_points.reserve(cc_border_hedges.size()); + + for(const halfedge_descriptor h : cc_border_hedges) + { + const vertex_descriptor v = source(h, tmesh); + hole_points.push_back(get(vpm, v)); + cc_border_vertices.push_back(v); + + CGAL_assertion(!is_border(h, tmesh)); + + if(internal_hedges.count(h) == 0 && // `h` is on the border of the full CC + !is_border_edge(h, tmesh)) + { + third_points.push_back(get(vpm, target(next(opposite(h, tmesh), tmesh), tmesh))); + } + else // `h` is on the border of the sub CC but not on the border of the full CC + { + const Point tp = construct_artificial_third_point(h, tmesh, vpm, gt); + third_points.push_back(tp); + } + } + + return construct_tentative_hole_patch_with_border(patch, hole_points, third_points, + cc_border_vertices, cc_border_hedges, + cc_interior_vertices, cc_interior_edges, + sub_cc_faces, projector, tmesh, vpm, gt); +} + +// -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- + +// This function is only called when the hole is NOT subdivided into smaller holes +template +bool fill_hole(std::vector::halfedge_descriptor>& cc_border_hedges, + const std::set::face_descriptor>& cc_faces, + std::set::face_descriptor>& working_face_range, + const PolyhedralEnvelope& cc_envelope, + const Projector& projector, + TriangleMesh& tmesh, + VertexPointMap vpm, + const GeomTraits& gt, + bool reuse_faces = true) +{ + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::edge_descriptor edge_descriptor; + typedef typename boost::graph_traits::face_descriptor face_descriptor; + + typedef typename boost::property_traits::value_type Point; + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Attempting hole-filling (no constraints), " << cc_faces.size() << " faces\n"; +#endif + + std::set cc_interior_vertices; + std::set cc_interior_edges; + + std::vector cc_border_vertices; + cc_border_vertices.reserve(cc_border_hedges.size()); + + std::vector > patch; + if(!construct_tentative_hole_patch(patch, cc_border_vertices, cc_interior_vertices, cc_interior_edges, + cc_border_hedges, cc_faces, projector, tmesh, vpm, gt)) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Failed to find acceptable hole patch\n"; +#endif + + return false; + } + + if(!cc_envelope.is_empty() && !cc_envelope(patch)) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Patch is not inside the input polyhedral envelope\n"; +#endif + return false; + } + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Found acceptable hole-filling patch (" << patch.size() << " faces)\n"; +#endif + + for(const face_descriptor f : cc_faces) + working_face_range.erase(f); + + // Plug the new triangles in the mesh, reusing previous edges and faces + if(reuse_faces) + { + replace_faces_with_patch(cc_border_vertices, cc_interior_vertices, + cc_border_hedges, cc_interior_edges, + cc_faces, patch, tmesh, vpm, + std::inserter(working_face_range, working_face_range.end())); + } + else + { + replace_faces_with_patch_without_reuse(cc_border_vertices, cc_faces, patch, tmesh, vpm, + std::inserter(working_face_range, working_face_range.end())); + } + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT_INTERMEDIATE_FULL_MESH + static int filed_hole_id = 0; + std::stringstream oss; + oss << "results/filled_basic_" << filed_hole_id++ << ".off" << std::ends; + CGAL::IO::write_polygon_mesh(oss.str().c_str(), tmesh, CGAL::parameters::stream_precision(17)); +#endif + + CGAL_postcondition(is_valid_polygon_mesh(tmesh)); + + return true; +} + +// Same function as above but border of the hole is not known +template +bool fill_hole(const std::set::face_descriptor>& cc_faces, + std::set::face_descriptor>& working_face_range, + const PolyhedralEnvelope& cc_envelope, + const Projector& projector, + TriangleMesh& tmesh, + VertexPointMap vpm, + const GeomTraits& gt) +{ + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + typedef typename boost::graph_traits::face_descriptor face_descriptor; + + std::vector cc_border_hedges; + for(face_descriptor fd : cc_faces) + { + halfedge_descriptor h = halfedge(fd, tmesh); + for(int i=0; i<3; ++i) + { + if(is_border(opposite(h, tmesh), tmesh) || cc_faces.count(face(opposite(h, tmesh), tmesh)) == 0) + cc_border_hedges.push_back(h); + + h = next(h, tmesh); + } + } + + if(order_border_halfedge_range(cc_border_hedges, tmesh)) + return fill_hole(cc_border_hedges, cc_faces, working_face_range, cc_envelope, projector, tmesh, vpm, gt); + else + return false; +} + +template +bool fill_hole_with_constraints(std::vector::halfedge_descriptor>& cc_border_hedges, + const std::set::face_descriptor>& cc_faces, + std::set::face_descriptor>& working_face_range, + TriangleMesh& tmesh, + const double dihedral_angle, + const double weak_DA, + const PolyhedralEnvelope& cc_envelope, + const Projector& projector, + VertexPointMap vpm, + const GeomTraits& gt) +{ + typedef typename boost::graph_traits::face_descriptor face_descriptor; + + typedef typename boost::property_traits::value_type Point; + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Attempting local hole-filling with constrained sharp edges..." << std::endl; +#endif + + // If we are treating self intersections locally, first try to constrain sharp edges in the hole + typedef CGAL::dynamic_edge_property_t Edge_property_tag; + typedef typename boost::property_map::type EIFMap; + EIFMap eif = get(Edge_property_tag(), tmesh); + + constrain_edges(cc_faces, tmesh, true /*constrain_border_edges*/, true /*constrain_sharp_edges*/, + dihedral_angle, weak_DA, eif, vpm, gt); + + // Partition the hole using these constrained edges + std::set visited_faces; + std::vector > patch; + + int cc_counter = 0; + for(face_descriptor f : cc_faces) + { + if(!visited_faces.insert(f).second) // already visited that face + continue; + + // gather the faces making a sub-hole + std::set sub_cc; + Polygon_mesh_processing::connected_component(f, tmesh, std::inserter(sub_cc, sub_cc.end()), + CGAL::parameters::edge_is_constrained_map(eif)); + + visited_faces.insert(sub_cc.begin(), sub_cc.end()); + ++cc_counter; + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT + dump_cc("results/current_cc.off", sub_cc, tmesh, vpm); +#endif + + // The mesh is not modified, but 'patch' gets filled + if(!construct_tentative_sub_hole_patch(patch, sub_cc, cc_faces, projector, tmesh, vpm, gt)) + { + // Something went wrong while finding a potential cover for the a sub-hole --> use basic hole-filling + return fill_hole(cc_border_hedges, cc_faces, working_face_range, cc_envelope, projector, tmesh, vpm, gt); + } + } + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT + dump_patch("results/hole_fillers.off", patch); +#endif + + // We're assembling multiple patches so we could have the same face appearing multiple times... + if(!check_patch_sanity(patch)) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Unhealthy patch, defaulting to basic fill_hole" << std::endl; +#endif + return fill_hole(cc_border_hedges, cc_faces, working_face_range, cc_envelope, projector, tmesh, vpm, gt); + } + + // check if the patch is inside the input polyhedral envelope + if(!cc_envelope.is_empty() && !cc_envelope(patch)) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Patch is not entirely inside the input polyhedral envelope, defaulting to basic fill_hole" << std::endl; +#endif + return fill_hole(cc_border_hedges, cc_faces, working_face_range, cc_envelope, projector, tmesh, vpm, gt); + } + + for(const face_descriptor f : cc_faces) + working_face_range.erase(f); + + // Plug the hole-filling patch in the mesh + replace_faces_with_patch(cc_faces, patch, tmesh, vpm, + std::inserter(working_face_range, working_face_range.end())); + + return true; +} + +template bool remove_self_intersections_with_hole_filling(std::vector::halfedge_descriptor>& cc_border_hedges, - std::set::face_descriptor>& cc_faces, + const std::set::face_descriptor>& cc_faces, std::set::face_descriptor>& working_face_range, TriangleMesh& tmesh, - bool local_self_intersection_removal, const double strong_dihedral_angle, const double weak_dihedral_angle, const PolyhedralEnvelope& cc_envelope, + const Projector& projector, VertexPointMap vpm, const GeomTraits& gt) { @@ -1372,6 +1653,16 @@ bool remove_self_intersections_with_hole_filling(std::vector +template +bool handle_CC_with_complex_topology(std::vector::halfedge_descriptor>& cc_border_hedges, + const std::set::face_descriptor>& cc_faces, + std::set::face_descriptor>& working_face_range, + TriangleMesh& tmesh, + const double strong_dihedral_angle, + const double weak_dihedral_angle, + const bool preserve_genus, + const PolyhedralEnvelope& cc_envelope, + const Projector& projector, + VertexPointMap vpm, + const GeomTraits& gt) +{ + 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 typename GeomTraits::FT FT; + typedef typename boost::property_traits::value_type Point; + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: CC with Euler_chi != 1" << std::endl; +#endif + + if(preserve_genus) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: CC not handled, selection is not a topological disk (preserve_genus=true)\n"; +#endif + return false; + } + + const CGAL::Face_filtered_graph ccmesh(tmesh, cc_faces); + if(!ccmesh.is_selection_valid()) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: invalid FFG selection\n"; +#endif + return false; + } + + std::vector boundary_reps; + extract_boundary_cycles(ccmesh, std::back_inserter(boundary_reps)); + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: " << boundary_reps.size() << " borders in the CC\n"; +#endif + + if(boundary_reps.size() == 1) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Complex topology but single border --> standard hole filling\n"; +#endif + + // If there is a single border, fill the hole as if it were a topological disk. + // This will lose some information since chi != -1, but preserve_genus = false here + return remove_self_intersections_with_hole_filling(cc_border_hedges, cc_faces, working_face_range, + tmesh, strong_dihedral_angle, weak_dihedral_angle, + cc_envelope, projector, vpm, gt); + } + + // From there on, there is more than one border + + std::vector is_hole_incident_to_patch(boundary_reps.size()); + std::vector hole_lengths(boundary_reps.size()); + + int holes_incident_to_patches_n = 0; + for(std::size_t hole_id = 0; hole_id longest_border_hedges; + halfedge_descriptor bh = boundary_reps[longest_border_id], end = bh; + do + { + longest_border_hedges.push_back(opposite(bh, tmesh)); + bh = prev(bh, ccmesh); // prev because we insert the opposite + } + while(bh != end); + + // 'false' because we can't do on-the-fly patching due to multiple boundary cycles + // @todo this currently doesn't attempt to constrain sharp edges + return fill_hole(longest_border_hedges, cc_faces, working_face_range, cc_envelope, projector, + tmesh, vpm, gt, false /*reuse*/); + } + + // If there exists some boundary cycles with "fake" border halfedges, hole-fill those +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Complex topology, some fake borders (" << holes_incident_to_patches_n << ")\n"; +#endif + + // This is needed for the patch insertion process at the end + std::vector all_border_vertices; // border vertices for all the borders to be filled + + // The patch is built iteratively and made of as many CCs as there are holes being filled + std::vector > patch; + + for(std::size_t hole_id=0; hole_id border_hedges; + halfedge_descriptor bh = boundary_reps[hole_id], end = bh; + do + { + border_hedges.push_back(opposite(bh, tmesh)); + bh = prev(bh, ccmesh); // prev because we insert the opposite + } + while(bh != end); + + std::vector border_vertices; + border_vertices.reserve(border_hedges.size()); + all_border_vertices.reserve(all_border_vertices.size() + border_hedges.size()); + + std::vector hole_points, third_points; + hole_points.reserve(border_hedges.size()); + third_points.reserve(border_hedges.size()); + + for(const halfedge_descriptor h : border_hedges) + { + CGAL_assertion(!is_border(h, tmesh)); + + const vertex_descriptor v = source(h, tmesh); + hole_points.push_back(get(vpm, v)); + + border_vertices.push_back(v); + all_border_vertices.push_back(v); + + if(is_border_edge(h, tmesh)) // h is incident to a real face + third_points.push_back(construct_artificial_third_point(h, tmesh, vpm, gt)); + else + third_points.push_back(get(vpm, target(next(opposite(h, tmesh), tmesh), tmesh))); + } + + std::set interior_vertices; + std::set interior_edges; + + if(!construct_tentative_hole_patch_with_border(patch, hole_points, third_points, + border_vertices, border_hedges, + interior_vertices, interior_edges, + cc_faces, projector, tmesh, vpm, gt)) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Failed to fill hole #" << hole_id << "\n"; +#endif + + return false; + } + } + + // Built the patch from all the boundary cycles, put it in +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT + dump_patch("results/multiple_real_borders.off", patch); +#endif + + // We're assembling multiple patches so we could have the same face appearing multiple times... + if(!check_patch_sanity(patch)) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Unhealthy patch(s), defaulting to basic fill_hole" << std::endl; +#endif + return false; + } + + // check if the patch is inside the input polyhedral envelope + if(!cc_envelope.is_empty() && !cc_envelope(patch)) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Patch is not entirely inside the input polyhedral envelope, defaulting to basic fill_hole" << std::endl; +#endif + return false; + } + + for(const face_descriptor f : cc_faces) + working_face_range.erase(f); + + // Plug the hole-filling patch in the mesh + replace_faces_with_patch_without_reuse(all_border_vertices, cc_faces, patch, tmesh, vpm, + std::inserter(working_face_range, working_face_range.end())); + + return true; +} + +// the parameter `step` controls how many extra layers of faces we take around the range `faces_to_treat` +template std::pair -remove_self_intersections_one_step(std::set::face_descriptor>& faces_to_remove, +remove_self_intersections_one_step(std::set::face_descriptor>& faces_to_treat, std::set::face_descriptor>& working_face_range, TriangleMesh& tmesh, const int step, const bool preserve_genus, - const bool only_treat_self_intersections_locally, + const bool treat_all_CCs, const double strong_dihedral_angle, const double weak_dihedral_angle, const double containment_epsilon, + const Projector& projector, VertexPointMap vpm, const GeomTraits& gt, Visitor& visitor) { - typedef boost::graph_traits graph_traits; - typedef typename graph_traits::vertex_descriptor vertex_descriptor; - typedef typename graph_traits::halfedge_descriptor halfedge_descriptor; - typedef typename graph_traits::face_descriptor face_descriptor; + typedef boost::graph_traits graph_traits; + typedef typename graph_traits::halfedge_descriptor halfedge_descriptor; + typedef typename graph_traits::face_descriptor face_descriptor; - std::set faces_to_remove_copy = faces_to_remove; - -#if defined(CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG) || defined(CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT) - static int call_id = -1; - ++call_id; +#ifdef CGAL_PMP_REPAIR_SI_USE_OBB_IN_COMPACTIFICATION + typedef typename graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::property_traits::value_type Point; #endif -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << "##### running remove_self_intersections_one_step (#" << call_id << "), step " << step - << " with " << faces_to_remove.size() << " intersecting faces\n"; -#endif + std::set faces_to_treat_copy = faces_to_treat; bool something_was_done = false; // indicates if a region was successfully remeshed bool all_fixed = true; // indicates if all removal went well @@ -1451,34 +1958,41 @@ remove_self_intersections_one_step(std::set cc_faces; - std::vector queue(1, *faces_to_remove.begin()); // temporary queue + std::vector queue(1, *faces_to_treat.begin()); // temporary queue cc_faces.insert(queue.back()); while(!queue.empty()) { @@ -1488,9 +2002,9 @@ remove_self_intersections_one_step(std::set::null_face()) + if(adjacent_face != boost::graph_traits::null_face()) { - if(faces_to_remove.count(adjacent_face) != 0 && cc_faces.insert(adjacent_face).second) + if(faces_to_treat.count(adjacent_face) != 0 && cc_faces.insert(adjacent_face).second) queue.push_back(adjacent_face); } @@ -1499,21 +2013,17 @@ remove_self_intersections_one_step(std::set stack_for_expension; + +#ifdef CGAL_PMP_REPAIR_SI_USE_OBB_IN_COMPACTIFICATION + std::set cc_points; + for(face_descriptor f : cc_faces) + for(vertex_descriptor v : vertices_around_face(halfedge(f, tmesh), tmesh)) + cc_points.insert(get(vpm, v)); + + typedef typename GeomTraits::Aff_transformation_3 Aff_transformation; + Aff_transformation tr{CGAL::Identity_transformation()}; + + if(cc_points.size() > 3) + CGAL::oriented_bounding_box(cc_points, tr, CGAL::parameters::random_seed(0)); + + // Construct the rotated OBB Bbox_3 bb; + for(const Point& p : cc_points) + bb += (tr.transform(p)).bbox(); + +#else + Bbox_3 bb; +#endif + for(face_descriptor fd : cc_faces) { for(halfedge_descriptor h : halfedges_around_face(halfedge(fd, tmesh), tmesh)) { +#ifndef CGAL_PMP_REPAIR_SI_USE_OBB_IN_COMPACTIFICATION bb += get(vpm, target(h, tmesh)).bbox(); +#endif face_descriptor nf = face(opposite(h, tmesh), tmesh); if(nf != boost::graph_traits::null_face() && cc_faces.count(nf) == 0) - { stack_for_expension.push_back(opposite(h, tmesh)); - } } } @@ -1554,7 +2087,11 @@ remove_self_intersections_one_step(std::set > is_selected(cc_faces); + expand_face_selection_for_removal(cc_faces, tmesh, is_selected); #ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG std::cout << " DEBUG: " << cc_faces.size() << " faces in expanded and compactified CC\n"; #endif - // remove faces from the set to process - for(const face_descriptor f : cc_faces) - faces_to_remove.erase(f); - #ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT - fname="results/expanded_compactified_r_"+std::to_string(call_id)+"_cc_"+std::to_string(cc_id)+"_s_"+std::to_string(step)+".off"; - std::cout << " DEBUG: Writing expanded and compactified CC #" << cc_id << " in " << fname << std::endl; - dump_cc(cc_faces, tmesh, fname); + fname = "results/expanded_compactified_step_"+std::to_string(step)+"_CC_"+std::to_string(cc_id)+".off"; + dump_cc(fname, cc_faces, tmesh, vpm); #endif - //Check for non-manifold vertices in the selection and remove them by selecting all incident faces: - // extract the set of halfedges that is on the boundary of the holes to be - // made. In addition, we make sure no hole to be created contains a vertex - // visited more than once along a hole border (pinched surface) - // We save the size of boundary_hedges to make sur halfedges added - // from non_filled_hole are not removed. - bool non_manifold_vertex_remaining_in_selection = false; - do - { - bool non_manifold_vertex_removed = false; //here non-manifold is for the 1D polyline - std::vector boundary_hedges; - for(face_descriptor fh : cc_faces) - { - halfedge_descriptor h = halfedge(fh, tmesh); - for(int i=0; i<3; ++i) - { - if(is_border(opposite(h, tmesh), tmesh) || cc_faces.count(face(opposite(h, tmesh), tmesh)) == 0) - boundary_hedges.push_back(h); + // Now, we have a proper selection to work on. - h = next(h, tmesh); - } - } + for(const face_descriptor f : cc_faces) + faces_to_treat.erase(f); - // detect vertices visited more than once along - // a hole border. We then remove all faces incident - // to such a vertex to force the removal of the vertex. - // Actually even if two holes are sharing a vertex, this - // vertex will be removed. It is not needed but since - // we do not yet have one halfedge per hole it is simpler - // and does not harm - std::set border_vertices; - for(halfedge_descriptor h : boundary_hedges) - { - if(!border_vertices.insert(target(h, tmesh)).second) - { - bool any_face_added = false; - for(halfedge_descriptor hh : halfedges_around_target(h, tmesh)) - { - if(!is_border(hh, tmesh)) - { - // add the face to the current selection - any_face_added |= cc_faces.insert(face(hh, tmesh)).second; - faces_to_remove.erase(face(hh, tmesh)); - } - } - - if(any_face_added) - non_manifold_vertex_removed = true; - else - non_manifold_vertex_remaining_in_selection = true; - } - } - - if(!non_manifold_vertex_removed) - break; - } - while(true); - - if(preserve_genus && non_manifold_vertex_remaining_in_selection) - { - topology_issue = true; -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: CC not handled due to the presence at least one non-manifold vertex\n"; - - ++unsolved_self_intersections; -#endif - - visitor.end_component_handling(); - continue; // cannot replace a patch containing a nm vertex by a disk - } - - // before running this function if preserve_genus=false, we duplicated - // all of them - CGAL_assertion(!non_manifold_vertex_remaining_in_selection); - - // Collect halfedges on the boundary of the region to be selected - // (pointing inside the domain to be remeshed) - std::vector cc_border_hedges; - for(face_descriptor fd : cc_faces) - { - halfedge_descriptor h = halfedge(fd, tmesh); - for(int i=0; i<3; ++i) - { - if(is_border(opposite(h, tmesh), tmesh) || cc_faces.count(face(opposite(h, tmesh), tmesh)) == 0) - cc_border_hedges.push_back(h); - - h = next(h, tmesh); - } - } - - if(cc_faces.size() == 1) // it is a triangle nothing better can be done + if(cc_faces.size() == 1) { #ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - ++unsolved_self_intersections; + std::cout << " DEBUG: Compactified CC of size 1, moving on\n"; #endif visitor.end_component_handling(); continue; } - working_face_range.insert(cc_faces.begin(), cc_faces.end()); + bool self_intersects = does_self_intersect(cc_faces, tmesh, parameters::vertex_point_map(vpm).geom_traits(gt)); +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + if(!self_intersects) + std::cout << " DEBUG: No self-intersection within the CC\n"; +#endif - // Now, we have a proper selection that we can work on. + if(!treat_all_CCs && !self_intersects) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + ++unsolved_self_intersections; +#endif + + all_fixed = false; + visitor.end_component_handling(); + continue; + } #ifndef CGAL_PMP_REMOVE_SELF_INTERSECTION_NO_POLYHEDRAL_ENVELOPE_CHECK Polyhedral_envelope cc_envelope; - if (containment_epsilon!=0) + if(containment_epsilon != 0) cc_envelope = Polyhedral_envelope(cc_faces, tmesh, containment_epsilon); #else - struct Return_true { + struct Return_true + { bool is_empty() const { return true; } bool operator()(const std::vector >&) const { return true; } bool operator()(const TriangleMesh&) const { return true; } @@ -1718,188 +2167,120 @@ remove_self_intersections_one_step(std::set mesh_non_border_hedges; - std::set mesh_border_hedge; - - for(halfedge_descriptor h : cc_border_hedges) - { - if(!is_border(opposite(h, tmesh), tmesh)) - mesh_non_border_hedges.push_back(h); - else - mesh_border_hedge.insert(opposite(h, tmesh)); - } - - if (mesh_border_hedge.empty()) - { -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: CC not handled, selection is not a topological disk (preserve_genus=false)\n"; - ++unsolved_self_intersections; -#endif - topology_issue = true; - continue; - } - - // we look for cycles of border halfedges and update selection_chi - while(!mesh_border_hedge.empty()) - { - // we must count the number of cycle of boundary edges - halfedge_descriptor h_b = *mesh_border_hedge.begin(), h=h_b; - mesh_border_hedge.erase(mesh_border_hedge.begin()); - do - { - h = next(h, tmesh); - if(h == h_b) - { - // found a cycle - selection_chi += 1; - break; - } - else - { - typename std::set::iterator it = mesh_border_hedge.find(h); - if(it == mesh_border_hedge.end()) - break; // not a cycle does not count - - mesh_border_hedge.erase(it); - } - } - while(true); - } - - if(selection_chi!=1) - { -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: CC not handled, selection is not a topological disk even if" - << " boundary cycles are removed: chi=" << selection_chi << "\n"; - ++unsolved_self_intersections; -#endif - topology_issue = true; + something_was_done = true; visitor.end_component_handling(); continue; } + #ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG else { - cc_border_hedges.swap(mesh_non_border_hedges); + std::cout << " DEBUG: Could not be solved via smoothing\n"; + } + #endif + } - // count the number of cycles of halfedges of the boundary - std::map bhs; - for(halfedge_descriptor h : cc_border_hedges) - bhs[source(h, tmesh)] = target(h, tmesh); +#endif // ndef CGAL_PMP_REMOVE_SELF_INTERSECTIONS_NO_SMOOTHING - int nbc=0; - while(!bhs.empty()) - { - ++nbc; - std::pair top=*bhs.begin(); - bhs.erase(bhs.begin()); - - do - { - typename std::map::iterator it_find = bhs.find(top.second); - if(it_find == bhs.end()) - break; - - top = *it_find; - bhs.erase(it_find); - } - while(true); - } - - if(nbc != 1) - { #ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: CC not handled because it is not a topological disk(" - << nbc << " boundary cycles)\n"; - ++unsolved_self_intersections; + std::cout << " DEBUG: Trying hole-filling based approach...\n"; #endif - all_fixed = false; - visitor.end_component_handling(); - continue; - } - else - { -#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << " DEBUG: CC that is not a topological disk but has only one boundary cycle(preserve_genus=false)\n"; -#endif - } + // Collect halfedges on the boundary of the region to be selected + // (incident to faces that are part of the CC) + std::vector cc_border_hedges; + for(face_descriptor fd : cc_faces) + { + for(halfedge_descriptor h : halfedges_around_face(halfedge(fd, tmesh), tmesh)) + { + if(is_border(opposite(h, tmesh), tmesh) || cc_faces.count(face(opposite(h, tmesh), tmesh)) == 0) + cc_border_hedges.push_back(h); } } + // Whichever step we are at, no border means no expansion will change this selection + // This CC was not fixed by smoothing, and there is nothing hole filling can do + // @todo just remove the CC? + if(cc_border_hedges.empty()) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: CC is closed!\n"; // @todo wrap? + ++unsolved_self_intersections; +#endif + + all_fixed = false; + visitor.end_component_handling(); + continue; + } + + int selection_chi = euler_characteristic_of_selection(cc_faces, tmesh); + if(selection_chi != 1) // not a topological disk + { + if(!handle_CC_with_complex_topology(cc_border_hedges, cc_faces, working_face_range, + tmesh, strong_dihedral_angle, weak_dihedral_angle, + preserve_genus, cc_envelope, projector, vpm, gt)) + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: Failed to handle complex CC\n"; + ++unsolved_self_intersections; +#endif + topology_issue = true; + all_fixed = false; + } + else + { +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + ++self_intersections_solved_by_unconstrained_hole_filling; +#endif + + something_was_done = true; + } + + visitor.end_component_handling(); + continue; + } + + // From here on, the CC is a topological disk + if(!remove_self_intersections_with_hole_filling(cc_border_hedges, cc_faces, working_face_range, - tmesh, only_treat_self_intersections_locally, - strong_dihedral_angle, weak_dihedral_angle, - cc_envelope, - vpm, gt)) + tmesh, strong_dihedral_angle, weak_dihedral_angle, + cc_envelope, projector, vpm, gt)) { #ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG std::cout << " DEBUG: Failed to fill hole\n"; @@ -1912,21 +2293,26 @@ remove_self_intersections_one_step(std::set +template bool remove_self_intersections(const FaceRange& face_range, TriangleMesh& tmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -1967,6 +2353,10 @@ bool remove_self_intersections(const FaceRange& face_range, typedef boost::graph_traits graph_traits; typedef typename graph_traits::face_descriptor face_descriptor; +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT + IO::write_polygon_mesh("results/input.off", tmesh, parameters::stream_precision(17)); +#endif + // named parameter extraction typedef typename GetVertexPointMap::type VertexPointMap; VertexPointMap vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), @@ -1976,12 +2366,15 @@ bool remove_self_intersections(const FaceRange& face_range, GeomTraits gt = choose_parameter(get_parameter(np, internal_np::geom_traits)); bool preserve_genus = choose_parameter(get_parameter(np, internal_np::preserve_genus), true); - const bool only_treat_self_intersections_locally = choose_parameter(get_parameter(np, internal_np::apply_per_connected_component), false); + + // @tmp Squatting that named parameter to signify that treatment should be applied within the CC + // even if there are no self-intersections. For example, two spheres intersecting each other. + const bool treat_all_CCs = choose_parameter(get_parameter(np, internal_np::apply_per_connected_component), true); // When treating intersections locally, we don't want to grow the working range too much as // either the solution is found fast, or it's too difficult and neither local smoothing or local // hole filling are going to provide nice results. - const int default_max_step = only_treat_self_intersections_locally ? 2 : 7; + const int default_max_step = 7; const int max_steps = choose_parameter(get_parameter(np, internal_np::number_of_iterations), default_max_step); // @fixme give it its own named parameter rather than abusing 'with_dihedral_angle'? @@ -1990,7 +2383,8 @@ bool remove_self_intersections(const FaceRange& face_range, // detect_feature_pp NP (unused for now) const double weak_dihedral_angle = 0.; // choose_parameter(get_parameter(np, internal_np::weak_dihedral_angle), 20.); - struct Return_false { + struct Return_false + { bool operator()(std::pair) const { return false; } }; @@ -2005,10 +2399,12 @@ bool remove_self_intersections(const FaceRange& face_range, // use containment check const double containment_epsilon = choose_parameter(get_parameter(np, internal_np::polyhedral_envelope_epsilon), 0.); + internal::Mesh_projection_functor projector(tmesh, vpm); + #ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG std::cout << "DEBUG: Starting remove_self_intersections, is_valid(tmesh)? " << is_valid_polygon_mesh(tmesh) << "\n"; std::cout << "\tpreserve_genus: " << preserve_genus << std::endl; - std::cout << "\tonly_treat_self_intersections_locally: " << only_treat_self_intersections_locally << std::endl; + std::cout << "\ttreat_all_CCs: " << treat_all_CCs << std::endl; std::cout << "\tmax_steps: " << max_steps << std::endl; std::cout << "\tstrong_dihedral_angle: " << strong_dihedral_angle << std::endl; std::cout << "\tweak_dihedral_angle: " << weak_dihedral_angle << std::endl; @@ -2023,7 +2419,7 @@ bool remove_self_intersections(const FaceRange& face_range, Visitor visitor = choose_parameter(get_parameter(np, internal_np::visitor)); visitor.parameters_used(preserve_genus, - only_treat_self_intersections_locally, + treat_all_CCs, max_steps, strong_dihedral_angle, weak_dihedral_angle, @@ -2036,16 +2432,22 @@ bool remove_self_intersections(const FaceRange& face_range, int step = -1; bool all_fixed = true; // indicates if the filling of all created holes went fine bool topology_issue = false; // indicates if some boundary cycles of edges are blocking the fixing - std::set faces_to_remove; + std::set faces_to_treat; std::set working_face_range(face_range.begin(), face_range.end()); visitor.start_main_loop(); while(++step < max_steps) { - if (visitor.stop()) break; +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + std::cout << " DEBUG: ========== STEP " << step << " / " << max_steps - 1 << " ==========" << std::endl; +#endif + + if(visitor.stop()) + break; + visitor.start_iteration(); - if(faces_to_remove.empty()) // the previous round might have been blocked due to topological constraints + if(faces_to_treat.empty()) // the previous round might have been blocked due to topological constraints { typedef std::pair Face_pair; std::vector self_inter; @@ -2053,32 +2455,33 @@ bool remove_self_intersections(const FaceRange& face_range, // TODO : possible optimization to reduce the range to check with the bbox // of the previous patches or something. self_intersections(working_face_range, tmesh, - CGAL::filter_output_iterator(std::back_inserter(self_inter), out_it_predicates)); + filter_output_iterator(std::back_inserter(self_inter), out_it_predicates), + parameters::vertex_point_map(vpm).geom_traits(gt)); #ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG std::cout << " DEBUG: " << self_inter.size() << " intersecting pairs" << std::endl; #endif for(const Face_pair& fp : self_inter) { - faces_to_remove.insert(fp.first); - faces_to_remove.insert(fp.second); + faces_to_treat.insert(fp.first); + faces_to_treat.insert(fp.second); } } - if(faces_to_remove.empty() && all_fixed) + if(faces_to_treat.empty()) { #ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG - std::cout << "DEBUG: There are no more faces to remove." << std::endl; + std::cout << "DEBUG: There are no more faces to treat." << std::endl; #endif break; } - visitor.status_update(faces_to_remove); + visitor.status_update(faces_to_treat); std::tie(all_fixed, topology_issue) = internal::remove_self_intersections_one_step( - faces_to_remove, working_face_range, tmesh, - step, preserve_genus, only_treat_self_intersections_locally, - strong_dihedral_angle, weak_dihedral_angle, containment_epsilon, vpm, gt, visitor); + faces_to_treat, working_face_range, tmesh, step, + preserve_genus, treat_all_CCs, strong_dihedral_angle, weak_dihedral_angle, + containment_epsilon, projector, vpm, gt, visitor); #ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG if(all_fixed && topology_issue) @@ -2094,34 +2497,29 @@ bool remove_self_intersections(const FaceRange& face_range, std::cout << "solved by unconstrained smoothing: " << internal::self_intersections_solved_by_unconstrained_smoothing << std::endl; std::cout << "solved by constrained hole-filling: " << internal::self_intersections_solved_by_constrained_hole_filling << std::endl; std::cout << "solved by unconstrained hole-filling: " << internal::self_intersections_solved_by_unconstrained_hole_filling << std::endl; - std::cout << "unsolved: " << internal::unsolved_self_intersections << std::endl; + std::cout << "issues during CC treatment: " << internal::unsolved_self_intersections << std::endl; #endif #ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT std::ofstream("results/final.off") << std::setprecision(17) << tmesh; #endif - return step < max_steps; + bool self_intersects = does_self_intersect(working_face_range, tmesh, parameters::vertex_point_map(vpm).geom_traits(gt)); + +#ifdef CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG + if(self_intersects) + std::cout << "DEBUG: Failed to solve all self-intersections.\n"; +#endif + + return !self_intersects; } -template -bool remove_self_intersections(const FaceRange& face_range, TriangleMesh& tmesh) -{ - return remove_self_intersections(face_range, tmesh, parameters::all_default()); -} - -template -bool remove_self_intersections(TriangleMesh& tmesh, const CGAL_PMP_NP_CLASS& np) +template +bool remove_self_intersections(TriangleMesh& tmesh, const CGAL_NP_CLASS& np = parameters::default_values()) { return remove_self_intersections(faces(tmesh), tmesh, np); } -template -bool remove_self_intersections(TriangleMesh& tmesh) -{ - return remove_self_intersections(tmesh, parameters::all_default()); -} - } // namespace experimental } // namespace Polygon_mesh_processing } // namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h index 606e13e9750..1f7ccc69ffa 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h @@ -21,7 +21,7 @@ #include -#include +#include #include #include @@ -50,11 +50,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_PMP_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_PMP_NP_CLASS NamedParameters -#endif - namespace CGAL { namespace Polygon_mesh_processing { namespace internal { @@ -187,7 +182,7 @@ bool do_faces_intersect(typename boost::graph_traits::halfedge_descriptor h, return true; return false; -}; +} template @@ -238,7 +233,7 @@ self_intersections_impl(const FaceRange& face_range, using CGAL::parameters::choose_parameter; using CGAL::parameters::get_parameter; - using parameters::is_default_parameter; + using CGAL::parameters::is_default_parameter; typedef TriangleMesh TM; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -254,7 +249,7 @@ self_intersections_impl(const FaceRange& face_range, VPM vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(boost::vertex_point, tmesh)); - const bool do_limit = !(is_default_parameter(get_parameter(np, internal_np::maximum_number))); + const bool do_limit = !(is_default_parameter()); const unsigned int maximum_number = choose_parameter(get_parameter(np, internal_np::maximum_number), 0); if(do_limit && maximum_number == 0) { @@ -461,30 +456,16 @@ template < class ConcurrencyTag = Sequential_tag, class TriangleMesh, class FaceRange, class FacePairOutputIterator, - class NamedParameters> + class NamedParameters = parameters::Default_named_parameters> FacePairOutputIterator self_intersections(const FaceRange& face_range, const TriangleMesh& tmesh, FacePairOutputIterator out, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { return internal::self_intersections_impl(face_range, tmesh, out, false /*don't throw*/, np); } -/// \cond SKIP_IN_MANUAL -template -FacePairOutputIterator -self_intersections(const FaceRange& face_range, - const TriangleMesh& tmesh, - FacePairOutputIterator out) -{ - return self_intersections(face_range, tmesh, out, CGAL::parameters::all_default()); -} -/// \endcond - /** * \ingroup PMP_intersection_grp * collects intersections between all the faces of a triangulated surface mesh. @@ -539,24 +520,15 @@ self_intersections(const FaceRange& face_range, template + class CGAL_NP_TEMPLATE_PARAMETERS> FacePairOutputIterator self_intersections(const TriangleMesh& tmesh, FacePairOutputIterator out, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { return self_intersections(faces(tmesh), tmesh, out, np); } -/// \cond SKIP_IN_MANUAL -template -FacePairOutputIterator -self_intersections(const TriangleMesh& tmesh, FacePairOutputIterator out) -{ - return self_intersections(faces(tmesh), tmesh, out, parameters::all_default()); -} -/// \endcond - /** * \ingroup PMP_intersection_grp * tests if a set of faces of a triangulated surface mesh self-intersects. @@ -595,10 +567,10 @@ self_intersections(const TriangleMesh& tmesh, FacePairOutputIterator out) template + class NamedParameters = parameters::Default_named_parameters> bool does_self_intersect(const FaceRange& face_range, const TriangleMesh& tmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { CGAL_precondition(CGAL::is_triangle_mesh(tmesh)); @@ -660,28 +632,13 @@ bool does_self_intersect(const FaceRange& face_range, */ template + class CGAL_NP_TEMPLATE_PARAMETERS> bool does_self_intersect(const TriangleMesh& tmesh, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { return does_self_intersect(faces(tmesh), tmesh, np); } -/// \cond SKIP_IN_MANUAL -template -bool does_self_intersect(const TriangleMesh& tmesh) -{ - return does_self_intersect(faces(tmesh), tmesh, CGAL::parameters::all_default()); -} - -template -bool does_self_intersect(const FaceRange& face_range, - const TriangleMesh& tmesh) -{ - return does_self_intersect(face_range, tmesh, CGAL::parameters::all_default()); -} -/// \endcond - }// namespace Polygon_mesh_processing }// namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/shape_predicates.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/shape_predicates.h index fb05b41b819..a811060949c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/shape_predicates.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/shape_predicates.h @@ -16,7 +16,7 @@ #include -#include +#include #include #include @@ -66,10 +66,10 @@ namespace Polygon_mesh_processing { /// \sa `degenerate_edges()` /// /// \return `true` if the edge `e` is degenerate, `false` otherwise. -template +template bool is_degenerate_edge(typename boost::graph_traits::edge_descriptor e, const PolygonMesh& pm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::get_parameter; using parameters::choose_parameter; @@ -84,13 +84,6 @@ bool is_degenerate_edge(typename boost::graph_traits::edge_descript return traits.equal_3_object()(get(vpmap, source(e, pm)), get(vpmap, target(e, pm))); } -template -bool is_degenerate_edge(typename boost::graph_traits::edge_descriptor e, - const PolygonMesh& pm) -{ - return is_degenerate_edge(e, pm, parameters::all_default()); -} - /// \ingroup PMP_repairing_grp /// collects the degenerate edges within a given range of edges. /// @@ -121,11 +114,11 @@ bool is_degenerate_edge(typename boost::graph_traits::edge_descript /// \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} /// \cgalParamNEnd /// \cgalNamedParamsEnd -template +template OutputIterator degenerate_edges(const EdgeRange& edges, const TriangleMesh& tm, OutputIterator out, - const NamedParameters& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { typedef typename boost::graph_traits::edge_descriptor edge_descriptor; @@ -136,43 +129,20 @@ OutputIterator degenerate_edges(const EdgeRange& edges, return out; } -template -OutputIterator degenerate_edges(const EdgeRange& edges, - const TriangleMesh& tm, - OutputIterator out, - typename boost::enable_if< - typename boost::has_range_iterator - >::type* = 0) -{ - return degenerate_edges(edges, tm, out, CGAL::parameters::all_default()); -} - /// \ingroup PMP_repairing_grp /// calls the function `degenerate_edges()` with the range: `edges(tm)`. /// /// See above for the comprehensive description of the parameters. /// -template +template OutputIterator degenerate_edges(const TriangleMesh& tm, OutputIterator out, - const NamedParameters& np -#ifndef DOXYGEN_RUNNING - , - typename boost::disable_if< - boost::has_range_iterator - >::type* = 0 -#endif + const CGAL_NP_CLASS& np = parameters::default_values() ) { return degenerate_edges(edges(tm), tm, out, np); } -template -OutputIterator degenerate_edges(const TriangleMesh& tm, OutputIterator out) -{ - return degenerate_edges(edges(tm), tm, out, CGAL::parameters::all_default()); -} - /// \ingroup PMP_repairing_grp /// checks whether a triangle face is degenerate. /// A triangle face is considered degenerate if the geometric positions of its vertices are collinear. @@ -204,10 +174,10 @@ OutputIterator degenerate_edges(const TriangleMesh& tm, OutputIterator out) /// \sa `degenerate_faces()` /// /// \return `true` if the face `f` is degenerate, `false` otherwise. -template +template bool is_degenerate_triangle_face(typename boost::graph_traits::face_descriptor f, const TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { CGAL_precondition(CGAL::is_triangle(halfedge(f, tm), tm)); @@ -228,13 +198,6 @@ bool is_degenerate_triangle_face(typename boost::graph_traits::fac get(vpmap, target(next(h, tm), tm))); } -template -bool is_degenerate_triangle_face(typename boost::graph_traits::face_descriptor f, - const TriangleMesh& tm) -{ - return CGAL::Polygon_mesh_processing::is_degenerate_triangle_face(f, tm, parameters::all_default()); -} - /// \ingroup PMP_repairing_grp /// collects the degenerate faces within a given range of faces. /// @@ -266,11 +229,11 @@ bool is_degenerate_triangle_face(typename boost::graph_traits::fac /// \cgalParamNEnd /// \cgalNamedParamsEnd /// -template +template OutputIterator degenerate_faces(const FaceRange& faces, const TriangleMesh& tm, OutputIterator out, - const NamedParameters& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { typedef typename boost::graph_traits::face_descriptor face_descriptor; @@ -282,43 +245,20 @@ OutputIterator degenerate_faces(const FaceRange& faces, return out; } -template -OutputIterator degenerate_faces(const FaceRange& faces, - const TriangleMesh& tm, - OutputIterator out, - typename boost::enable_if< - boost::has_range_iterator - >::type* = 0) -{ - return degenerate_faces(faces, tm, out, CGAL::parameters::all_default()); -} - /// \ingroup PMP_repairing_grp /// calls the function `degenerate_faces()` with the range: `faces(tm)`. /// /// See above for the comprehensive description of the parameters. /// -template +template OutputIterator degenerate_faces(const TriangleMesh& tm, OutputIterator out, - const NamedParameters& np -#ifndef DOXYGEN_RUNNING - , - typename boost::disable_if< - boost::has_range_iterator - >::type* = 0 -#endif + const CGAL_NP_CLASS& np = parameters::default_values() ) { return degenerate_faces(faces(tm), tm, out, np); } -template -OutputIterator degenerate_faces(const TriangleMesh& tm, OutputIterator out) -{ - return degenerate_faces(faces(tm), tm, out, CGAL::parameters::all_default()); -} - /// \ingroup PMP_repairing_grp /// checks whether a triangle face is needle. /// A triangle is said to be a needle if its longest edge is much longer than its shortest edge. @@ -350,12 +290,12 @@ OutputIterator degenerate_faces(const TriangleMesh& tm, OutputIterator out) /// /// \return the shortest halfedge if the triangle face is a needle, and a null halfedge otherwise. /// If the face contains degenerate edges, a halfedge corresponding to one of these edges is returned. -template +template typename boost::graph_traits::halfedge_descriptor is_needle_triangle_face(typename boost::graph_traits::face_descriptor f, const TriangleMesh& tm, const double threshold, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { CGAL_precondition(threshold >= 1.); CGAL_precondition(f != boost::graph_traits::null_face()); @@ -415,15 +355,6 @@ is_needle_triangle_face(typename boost::graph_traits::face_descrip return boost::graph_traits::null_halfedge(); } -template -typename boost::graph_traits::halfedge_descriptor -is_needle_triangle_face(typename boost::graph_traits::face_descriptor f, - const TriangleMesh& tm, - const double threshold) -{ - return is_needle_triangle_face(f, tm, threshold, parameters::all_default()); -} - /// \ingroup PMP_repairing_grp /// checks whether a triangle face is a cap. /// A triangle is said to be a cap if one of the its angles is close to `180` degrees. @@ -457,12 +388,12 @@ is_needle_triangle_face(typename boost::graph_traits::face_descrip /// \cgalNamedParamsEnd /// /// \return the halfedge opposite of the largest angle if the face is a cap, and a null halfedge otherwise. -template +template typename boost::graph_traits::halfedge_descriptor is_cap_triangle_face(typename boost::graph_traits::face_descriptor f, const TriangleMesh& tm, const double threshold, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { CGAL_precondition(f != boost::graph_traits::null_face()); CGAL_precondition(CGAL::is_triangle(halfedge(f, tm), tm)); @@ -524,15 +455,6 @@ is_cap_triangle_face(typename boost::graph_traits::face_descriptor return boost::graph_traits::null_halfedge(); } -template -typename boost::graph_traits::halfedge_descriptor -is_cap_triangle_face(typename boost::graph_traits::face_descriptor f, - const TriangleMesh& tm, - const double threshold) -{ - return is_cap_triangle_face(f, tm, threshold, parameters::all_default()); -} - } } // end namespaces CGAL and PMP #endif // CGAL_POLYGON_MESH_PROCESSING_SHAPE_PREDICATES_H 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 c054e7feda8..630bb83b09a 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 @@ -20,16 +20,11 @@ #include #include -#include +#include #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_PMP_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_PMP_NP_CLASS NamedParameters -#endif - namespace CGAL { namespace Polygon_mesh_processing { @@ -134,10 +129,10 @@ namespace Polygon_mesh_processing { * * @pre `tmesh` does not contain any degenerate faces */ -template +template void smooth_mesh(const FaceRange& faces, TriangleMesh& tmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -194,13 +189,17 @@ void smooth_mesh(const FaceRange& faces, bool use_area_smoothing = choose_parameter(get_parameter(np, internal_np::use_area_smoothing), true); #ifndef CGAL_PMP_USE_CERES_SOLVER - std::cerr << "Area-based smoothing requires the Ceres Library, which is not available." << std::endl; - std::cerr << "No such smoothing will be performed!" << std::endl; +#ifdef CGAL_PMP_SMOOTHING_DEBUG + if(use_area_smoothing) + std::cerr << "Requested area-based smoothing requires the Ceres Library, which is not available." << std::endl; +#endif use_area_smoothing = false; #endif +#ifdef CGAL_PMP_SMOOTHING_DEBUG if(!use_angle_smoothing && !use_area_smoothing) std::cerr << "Called PMP::smooth_mesh() without any smoothing method selected or available" << std::endl; +#endif unsigned int nb_iterations = choose_parameter(get_parameter(np, internal_np::number_of_iterations), 1); const bool do_project = choose_parameter(get_parameter(np, internal_np::do_project), true); @@ -329,24 +328,12 @@ void smooth_mesh(const FaceRange& faces, } ///\cond SKIP_IN_MANUAL -template -void smooth_mesh(const FaceRange& face_range, TriangleMesh& tmesh) -{ - smooth_mesh(face_range, tmesh, parameters::all_default()); -} - -template -void smooth_mesh(TriangleMesh& tmesh, const CGAL_PMP_NP_CLASS& np) +template +void smooth_mesh(TriangleMesh& tmesh, const CGAL_NP_CLASS& np = parameters::default_values()) { smooth_mesh(faces(tmesh), tmesh, np); } -template -void smooth_mesh(TriangleMesh& tmesh) -{ - smooth_mesh(faces(tmesh), tmesh, parameters::all_default()); -} - template void angles_evaluation(TriangleMesh& tmesh, GeomTraits traits, Stream& output) { diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_shape.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_shape.h index 9f0bb5771a8..a8ff2ce530c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_shape.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_shape.h @@ -30,11 +30,6 @@ #include #endif -#ifdef DOXYGEN_RUNNING -#define CGAL_PMP_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_PMP_NP_CLASS NamedParameters -#endif - namespace CGAL { namespace Polygon_mesh_processing { @@ -100,11 +95,11 @@ namespace Polygon_mesh_processing { * * @warning This function involves linear algebra, that is computed using a non-exact floating-point arithmetic. */ -template +template void smooth_shape(const FaceRange& faces, TriangleMesh& tmesh, const double time, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { if(std::begin(faces) == std::end(faces)) return; @@ -202,28 +197,13 @@ void smooth_shape(const FaceRange& faces, } /// \cond SKIP_IN_MANUAL -template -void smooth_shape(const FaceRange& faces, - TriangleMesh& tmesh, - const double time) -{ - smooth_shape(faces, tmesh, time, parameters::all_default()); -} - -template +template void smooth_shape(TriangleMesh& tmesh, const double time, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { smooth_shape(faces(tmesh), tmesh, time, np); } - -template -void smooth_shape(TriangleMesh& tmesh, - const double time) -{ - smooth_shape(faces(tmesh), tmesh, time, parameters::all_default()); -} /// \endcond } // Polygon_mesh_processing 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 e936df1bff9..f2b20bf7c5b 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 @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -44,11 +45,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_PMP_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_PMP_NP_CLASS NamedParameters -#endif - #ifdef CGAL_PMP_STITCHING_DEBUG_PP # ifndef CGAL_PMP_STITCHING_DEBUG # define CGAL_PMP_STITCHING_DEBUG @@ -366,20 +362,20 @@ template + typename CGAL_NP_TEMPLATE_PARAMETERS> OutputIterator collect_duplicated_stitchable_boundary_edges(const HalfedgeRange& halfedge_range, PolygonMesh& pmesh, const HalfedgeKeeper& hd_kpr, const bool per_cc, OutputIterator out, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np) { using parameters::choose_parameter; using parameters::get_parameter; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef typename GetVertexPointMap::const_type VPM; + typedef typename GetVertexPointMap::const_type VPM; VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(vertex_point, pmesh)); @@ -695,8 +691,10 @@ filter_stitchable_pairs(PolygonMesh& pmesh, // We look for vertex to be stitched and collect all incident edges with another endpoint // to be stitched (that is not an edge scheduled for stitching). That way we can detect // if more that one edge will share the same two "master" endpoints. - typedef boost::unordered_map, - std::vector > Halfedges_after_stitching; + typedef std::pair Vertex_pair; + typedef std::unordered_map, + boost::hash> Halfedges_after_stitching; Halfedges_after_stitching halfedges_after_stitching; typedef std::pair Pair_type; @@ -1026,11 +1024,11 @@ std::size_t zip_boundary_cycle(typename boost::graph_traits::halfed /// High-level functions -template +template std::size_t stitch_boundary_cycle(const typename boost::graph_traits::halfedge_descriptor h, PolygonMesh& pmesh, CycleRepMaintainer& cycle_reps_maintainer, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename std::pair halfedges_pair; @@ -1042,12 +1040,12 @@ std::size_t stitch_boundary_cycle(const typename boost::graph_traits::const_type VPM; + typedef typename GetVertexPointMap::const_type VPM; VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(vertex_point, pmesh)); typedef typename internal_np::Lookup_named_param_def >::type Halfedge_keeper; const Halfedge_keeper hd_kpr = choose_parameter(get_parameter(np, internal_np::halfedges_keeper), Default_halfedges_keeper()); @@ -1119,30 +1117,23 @@ std::size_t stitch_boundary_cycle(const typename boost::graph_traits +template std::size_t stitch_boundary_cycle(const typename boost::graph_traits::halfedge_descriptor h, PolygonMesh& pmesh, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { internal::Dummy_cycle_rep_maintainer dummy_maintainer(pmesh); return internal::stitch_boundary_cycle(h, pmesh, dummy_maintainer, np); } -template -std::size_t stitch_boundary_cycle(const typename boost::graph_traits::halfedge_descriptor h, - PolygonMesh& pmesh) -{ - return stitch_boundary_cycle(h, pmesh, parameters::all_default()); -} - namespace internal { template + typename CycleRepMaintainer, typename CGAL_NP_TEMPLATE_PARAMETERS> std::size_t stitch_boundary_cycles(const BorderHalfedgeRange& boundary_cycle_representatives, PolygonMesh& pmesh, CycleRepMaintainer& cycle_reps_maintainer, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -1187,10 +1178,10 @@ std::size_t stitch_boundary_cycles(const BorderHalfedgeRange& boundary_cycle_rep /// \sa `stitch_boundary_cycle()` /// \sa `stitch_borders()` /// -template +template std::size_t stitch_boundary_cycles(const BorderHalfedgeRange& boundary_cycle_representatives, PolygonMesh& pmesh, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { // If this API is called, we are not from stitch_borders() (otherwise there would be a maintainer) // so there is only one pass and we don't carea bout maintaining the cycle subset @@ -1201,9 +1192,9 @@ std::size_t stitch_boundary_cycles(const BorderHalfedgeRange& boundary_cycle_rep ///\cond SKIP_IN_MANUAL // convenience overloads -template +template std::size_t stitch_boundary_cycles(PolygonMesh& pmesh, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -1213,44 +1204,11 @@ std::size_t stitch_boundary_cycles(PolygonMesh& pmesh, return stitch_boundary_cycles(boundary_cycle_representatives, pmesh, np); } -template -std::size_t stitch_boundary_cycles(const BorderHalfedgeRange& boundary_cycle_representatives, - PolygonMesh& pmesh) -{ - return stitch_boundary_cycles(boundary_cycle_representatives, pmesh, parameters::all_default()); -} +/// \endcond -template -std::size_t stitch_boundary_cycles(PolygonMesh& pmesh) -{ - return stitch_boundary_cycles(pmesh, parameters::all_default()); -} // 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 -std::size_t stitch_borders(PolygonMesh& pmesh, - const HalfedgePairsRange& hedge_pairs_to_stitch, - const CGAL_PMP_NP_CLASS& np, - typename boost::enable_if< - typename boost::has_range_iterator - >::type* = 0) -{ - using parameters::choose_parameter; - using parameters::get_parameter; - - typedef typename GetVertexPointMap::const_type VPM; - VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), - get_const_property_map(vertex_point, pmesh)); - - return internal::stitch_halfedge_range_dispatcher(hedge_pairs_to_stitch, pmesh, vpm); -} - -///\endcond - /*! * \ingroup PMP_repairing_grp * @@ -1269,33 +1227,51 @@ std::size_t 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 +* \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below +* +* \cgalNamedParamsBegin +* \cgalParamNBegin{vertex_point_map} +* \cgalParamDescription{a property map associating points to the vertices of `pm`} +* \cgalParamType{a class model of `ReadWritePropertyMap` with `boost::graph_traits::%vertex_descriptor` +* as key type and `%Point_3` as value type} +* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} +* \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t` +* must be available in `PolygonMesh`.} +* \cgalParamNEnd +* \cgalNamedParamsEnd * * \return the number of pairs of halfedges that were stitched. * */ template + typename HalfedgePairsRange, + typename CGAL_NP_TEMPLATE_PARAMETERS> std::size_t stitch_borders(PolygonMesh& pmesh, - const HalfedgePairsRange& hedge_pairs_to_stitch -#ifndef DOXYGEN_RUNNING - , typename boost::enable_if< - typename boost::has_range_iterator - >::type* = 0 -#endif - ) + const HalfedgePairsRange& hedge_pairs_to_stitch, + const CGAL_NP_CLASS& np = parameters::default_values(), + typename boost::enable_if< + typename boost::has_range_iterator + >::type* = 0) { - return stitch_borders(pmesh, hedge_pairs_to_stitch, parameters::all_default()); + using parameters::choose_parameter; + using parameters::get_parameter; + + typedef typename GetVertexPointMap::const_type VPM; + VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), + get_const_property_map(vertex_point, pmesh)); + + return internal::stitch_halfedge_range_dispatcher(hedge_pairs_to_stitch, pmesh, vpm); } namespace internal { template + typename CGAL_NP_TEMPLATE_PARAMETERS> std::size_t stitch_borders(const BorderHalfedgeRange& boundary_cycle_representatives, PolygonMesh& pmesh, CycleRepMaintainer& cycle_maintainer, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np) { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -1305,12 +1281,12 @@ std::size_t stitch_borders(const BorderHalfedgeRange& boundary_cycle_representat if(boundary_cycle_representatives.size() == 0) return 0; - typedef typename GetVertexPointMap::const_type VPM; + typedef typename GetVertexPointMap::const_type VPM; VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(vertex_point, pmesh)); typedef typename internal_np::Lookup_named_param_def >::type Halfedge_keeper; const Halfedge_keeper hd_kpr = choose_parameter(get_parameter(np, internal_np::halfedges_keeper), Default_halfedges_keeper()); @@ -1369,6 +1345,65 @@ std::size_t stitch_borders(const BorderHalfedgeRange& boundary_cycle_representat /// \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` /// \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" /// +/// \param pmesh the polygon mesh to be modified by the stitching procedure +/// \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below +/// +/// \cgalNamedParamsBegin +/// \cgalParamNBegin{vertex_point_map} +/// \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +/// \cgalParamType{a class model of `ReadWritePropertyMap` with `boost::graph_traits::%vertex_descriptor` +/// as key type and `%Point_3` as value type} +/// \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} +/// \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t` +/// must be available in `PolygonMesh`.} +/// \cgalParamNEnd +/// +/// \cgalParamNBegin{apply_per_connected_component} +/// \cgalParamDescription{specifies if the borders should only be stitched only within their own connected component.} +/// \cgalParamType{Boolean} +/// \cgalParamDefault{`false`} +/// \cgalParamNEnd +/// +/// \cgalParamNBegin{face_index_map} +/// \cgalParamDescription{a property map associating to each face of `pmesh` a unique index between `0` and `num_faces(pmesh) - 1`} +/// \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits::%face_descriptor` +/// as key type and `std::size_t` as value type} +/// \cgalParamDefault{an automatically indexed internal map} +/// \cgalParamNEnd +/// \cgalNamedParamsEnd +/// +/// \return the number of pairs of halfedges that were stitched. +/// +/// \sa `stitch_boundary_cycle()` +/// \sa `stitch_boundary_cycles()` +/// +template +std::size_t stitch_borders(PolygonMesh& pmesh, + const CGAL_NP_CLASS& np = parameters::default_values()) +{ + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + + std::vector boundary_cycle_representatives; + extract_boundary_cycles(pmesh, std::back_inserter(boundary_cycle_representatives)); + + // We are working on all boundary cycles, so there is no need to keep track of any subset + internal::Dummy_cycle_rep_maintainer dummy_maintainer(pmesh); + return stitch_borders(boundary_cycle_representatives, pmesh, dummy_maintainer, np); +} + +/// \ingroup PMP_repairing_grp +/// +/// \brief Same as the other overload, but the pairs of halfedges to be stitched +/// are automatically found amongst halfedges in cycles described by `boundary_cycle_representatives`. +/// +/// Two border halfedges `h1` and `h2` are set to be stitched +/// if the points associated to the source and target vertices of `h1` are +/// the same as those of the target and source vertices of `h2`, respectively. +/// +/// \tparam BorderHalfedgeRange a model of `Range` with value type `boost::graph_traits::%halfedge_descriptor` +/// \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` +/// \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" +/// /// \param boundary_cycle_representatives a range of border halfedges, each describing a boundary cycle whose halfedges /// will be considered for stitching /// \param pmesh the polygon mesh to be modified by the stitching procedure @@ -1403,10 +1438,10 @@ std::size_t stitch_borders(const BorderHalfedgeRange& boundary_cycle_representat /// \sa `stitch_boundary_cycle()` /// \sa `stitch_boundary_cycles()` /// -template +template std::size_t stitch_borders(const BorderHalfedgeRange& boundary_cycle_representatives, PolygonMesh& pmesh, - const CGAL_PMP_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if< typename boost::has_range_iterator @@ -1419,41 +1454,6 @@ std::size_t stitch_borders(const BorderHalfedgeRange& boundary_cycle_representat return stitch_borders(boundary_cycle_representatives, pmesh, cycle_reps_maintainer, np); } -/// \cond SKIP_IN_MANUAL - -template -std::size_t stitch_borders(const BorderHalfedgeRange& boundary_cycle_representatives, - PolygonMesh& pmesh, - typename boost::enable_if< - typename boost::has_range_iterator - >::type* = 0) -{ - // Need to keep track of the cycles since we are working on a subset of all the boundary cycles - internal::Boundary_cycle_rep_maintainer cycle_reps_maintainer(pmesh); - return stitch_borders(boundary_cycle_representatives, pmesh, cycle_reps_maintainer, parameters::all_default()); -} - -template -std::size_t stitch_borders(PolygonMesh& pmesh, - const CGAL_PMP_NP_CLASS& np) -{ - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - - std::vector boundary_cycle_representatives; - extract_boundary_cycles(pmesh, std::back_inserter(boundary_cycle_representatives)); - - // We are working on all boundary cycles, so there is no need to keep track of any subset - internal::Dummy_cycle_rep_maintainer dummy_maintainer(pmesh); - return stitch_borders(boundary_cycle_representatives, pmesh, dummy_maintainer, np); -} - -template -std::size_t stitch_borders(PolygonMesh& pmesh) -{ - return stitch_borders(pmesh, parameters::all_default()); -} - -/// \endcond } // namespace Polygon_mesh_processing } // namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/transform.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/transform.h index 01cf935b924..606db68b196 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/transform.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/transform.h @@ -13,7 +13,7 @@ #define CGAL_POLYGON_MESH_PROCESSING_TRANSFORM_H #include -#include +#include #include namespace CGAL{ @@ -44,10 +44,10 @@ namespace Polygon_mesh_processing{ * \cgalNamedParamsEnd * */ -template +template void transform(const Transformation& transformation, PolygonMesh& mesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename GetVertexPointMap::type VPMap; VPMap vpm = parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_point), @@ -59,14 +59,6 @@ void transform(const Transformation& transformation, } } -/// \cond SKIP_IN_MANUAL -template -void transform(const Transformation& transformation, - PolygonMesh& mesh) -{ - transform(transformation, mesh, parameters::all_default()); -} -/// \endcond } } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index a2cc56ae520..f34f5d52049 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include @@ -107,8 +107,8 @@ public: typename Traits::Vector_3 normal = Polygon_mesh_processing::compute_face_normal( - f, pmesh, CGAL::Polygon_mesh_processing::parameters::geom_traits(_traits) - .vertex_point_map(_vpmap)); + f, pmesh, CGAL::parameters::geom_traits(_traits) + .vertex_point_map(_vpmap)); if(normal == typename Traits::Vector_3(0,0,0)) return false; @@ -317,7 +317,7 @@ public: typedef CGAL::Triple Face_indices; std::vector patch; PMP::triangulate_hole_polyline(hole_points, std::back_inserter(patch), - PMP::parameters::geom_traits(_traits)); + parameters::geom_traits(_traits)); if(patch.empty()) return false; @@ -462,10 +462,10 @@ public: * * @return `true` if the face has been triangulated. */ -template +template bool triangulate_face(typename boost::graph_traits::face_descriptor f, PolygonMesh& pmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -495,13 +495,6 @@ bool triangulate_face(typename boost::graph_traits::face_descriptor return modifier.triangulate_face(f, pmesh, use_cdt, visitor); } -template -bool triangulate_face(typename boost::graph_traits::face_descriptor f, - PolygonMesh& pmesh) -{ - return triangulate_face(f, pmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); -} - /** * \ingroup PMP_meshing_grp * triangulates given faces of a polygon mesh. This function depends on the package \ref PkgTriangulation2 @@ -546,10 +539,10 @@ bool triangulate_face(typename boost::graph_traits::face_descriptor * * @see triangulate_face() */ -template +template bool triangulate_faces(FaceRange face_range, PolygonMesh& pmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -579,12 +572,6 @@ bool triangulate_faces(FaceRange face_range, return modifier(face_range, pmesh, use_cdt, visitor); } -template -bool triangulate_faces(FaceRange face_range, PolygonMesh& pmesh) -{ - return triangulate_faces(face_range, pmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); -} - /** * \ingroup PMP_meshing_grp * triangulates all faces of a polygon mesh. This function depends on the package \ref PkgTriangulation2 @@ -624,19 +611,13 @@ bool triangulate_faces(FaceRange face_range, PolygonMesh& pmesh) * * @see triangulate_face() */ -template +template bool triangulate_faces(PolygonMesh& pmesh, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { return triangulate_faces(faces(pmesh), pmesh, np); } -template -bool triangulate_faces(PolygonMesh& pmesh) -{ - return triangulate_faces(faces(pmesh), pmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); -} - } // end namespace Polygon_mesh_processing } // end namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_hole.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_hole.h index de4525c3890..dcef88592af 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_hole.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_hole.h @@ -22,20 +22,15 @@ #include #include -#include +#include #include #include -#include +#include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_PMP_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_PMP_NP_CLASS NamedParameters -#endif - namespace CGAL { namespace Polygon_mesh_processing { @@ -106,6 +101,16 @@ namespace Polygon_mesh_processing { \cgalParamExtra{This parameter is used only in conjunction with the parameter `use_2d_constrained_delaunay_triangulation`.} \cgalParamNEnd + + \cgalParamNBegin{do_not_use_cubic_algorithm} + \cgalParamDescription{Set this parameter to `true` if you only want to use the Delaunay based versions of the algorithm, + skipping the cubic search space one in case of failure.} + \cgalParamType{Boolean} + \cgalParamDefault{`false`} + \cgalParamExtra{If `true`, `use_2d_constrained_delaunay_triangulation` or `use_delaunay_triangulation` must be set to `true` + otherwise nothing will be done.} + \cgalParamNEnd + \cgalNamedParamsEnd @return `out` @@ -120,12 +125,12 @@ namespace Polygon_mesh_processing { */ template + typename NamedParameters = parameters::Default_named_parameters> OutputIterator triangulate_hole(PolygonMesh& pmesh, typename boost::graph_traits::halfedge_descriptor border_halfedge, OutputIterator out, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -141,7 +146,7 @@ namespace Polygon_mesh_processing { CGAL_precondition(face(border_halfedge, pmesh) == boost::graph_traits::null_face()); bool use_cdt = - #ifdef CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 +#ifdef CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 false; #else choose_parameter(get_parameter(np, internal_np::use_2d_constrained_delaunay_triangulation), false); @@ -178,35 +183,10 @@ namespace Polygon_mesh_processing { use_dt3, choose_parameter(get_parameter(np, internal_np::geom_traits)), use_cdt, + choose_parameter(get_parameter(np, internal_np::do_not_use_cubic_algorithm), false), max_squared_distance).first; } - template - OutputIterator - triangulate_hole(PolygonMesh& pmesh, - typename boost::graph_traits::halfedge_descriptor border_halfedge, - OutputIterator out) - { - return triangulate_hole(pmesh, border_halfedge, out, - CGAL::Polygon_mesh_processing::parameters::all_default()); - } - - template - void test_in_edges(const PM& pmesh, const VertexRange& patch) - { - for(typename boost::graph_traits::vertex_descriptor v0 : patch) - { - typename boost::graph_traits::in_edge_iterator e, e_end; - for (boost::tie(e, e_end) = in_edges(v0, pmesh); e != e_end; e++) - { - typename boost::graph_traits::halfedge_descriptor he = halfedge(*e, pmesh); - if (is_border(he, pmesh)) { continue; } - - CGAL_assertion(v0 == target(he, pmesh) || v0 == source(he, pmesh)); - } - } - } - /*! \ingroup hole_filling_grp @brief triangulates and refines a hole in a polygon mesh. @@ -270,6 +250,15 @@ namespace Polygon_mesh_processing { the parameter `use_2d_constrained_delaunay_triangulation`.} \cgalParamNEnd + \cgalParamNBegin{do_not_use_cubic_algorithm} + \cgalParamDescription{Set this parameter to `true` if you only want to use the Delaunay based versions of the algorithm, + skipping the cubic search space one in case of failure.} + \cgalParamType{Boolean} + \cgalParamDefault{`false`} + \cgalParamExtra{If `true`, `use_2d_constrained_delaunay_triangulation` or `use_delaunay_triangulation` must be set to `true` + otherwise nothing will be done.} + \cgalParamNEnd + \cgalParamNBegin{density_control_factor} \cgalParamDescription{factor to control density of the ouput mesh, where larger values cause denser refinements, as in `refine()`} @@ -288,37 +277,21 @@ namespace Polygon_mesh_processing { template + typename NamedParameters = parameters::Default_named_parameters> std::pair triangulate_and_refine_hole(PolygonMesh& pmesh, typename boost::graph_traits::halfedge_descriptor border_halfedge, FaceOutputIterator face_out, VertexOutputIterator vertex_out, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { std::vector::face_descriptor> patch; triangulate_hole(pmesh, border_halfedge, std::back_inserter(patch), np); face_out = std::copy(patch.begin(), patch.end(), face_out); - test_in_edges(pmesh, vertices(pmesh)); - return refine(pmesh, patch, face_out, vertex_out, np); } - template - std::pair - triangulate_and_refine_hole(PolygonMesh& pmesh, - typename boost::graph_traits::halfedge_descriptor border_halfedge, - FaceOutputIterator face_out, - VertexOutputIterator vertex_out) - { - return triangulate_and_refine_hole(pmesh, border_halfedge, - face_out, vertex_out, - CGAL::Polygon_mesh_processing::parameters::all_default()); - } - /*! \ingroup hole_filling_grp @brief triangulates, refines and fairs a hole in a polygon mesh. @@ -422,24 +395,21 @@ namespace Polygon_mesh_processing { template + typename NamedParameters = parameters::Default_named_parameters> std::tuple triangulate_refine_and_fair_hole(PolygonMesh& pmesh, typename boost::graph_traits::halfedge_descriptor border_halfedge, FaceOutputIterator face_out, VertexOutputIterator vertex_out, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { + CGAL_precondition(CGAL::is_triangle_mesh(pmesh)); + std::vector::vertex_descriptor> patch; - - CGAL_assertion(CGAL::is_triangle_mesh(pmesh)); - face_out = triangulate_and_refine_hole (pmesh, border_halfedge, face_out, std::back_inserter(patch), np).first; - CGAL_assertion(CGAL::is_triangle_mesh(pmesh)); - - test_in_edges(pmesh, patch); + CGAL_postcondition(CGAL::is_triangle_mesh(pmesh)); bool fair_success = fair(pmesh, patch, np); @@ -447,20 +417,6 @@ namespace Polygon_mesh_processing { return std::make_tuple(fair_success, face_out, vertex_out); } - template - std::tuple - triangulate_refine_and_fair_hole(PolygonMesh& pmesh, - typename boost::graph_traits::halfedge_descriptor border_halfedge, - FaceOutputIterator face_out, - VertexOutputIterator vertex_out) - { - return triangulate_refine_and_fair_hole(pmesh, border_halfedge, - face_out, vertex_out, - CGAL::Polygon_mesh_processing::parameters::all_default()); - } - /*! \ingroup hole_filling_grp creates triangles to fill the hole defined by points in the range `points`. @@ -536,12 +492,12 @@ namespace Polygon_mesh_processing { template + typename NamedParameters = parameters::Default_named_parameters> OutputIterator triangulate_hole_polyline(const PointRange1& points, const PointRange2& third_points, OutputIterator out, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { if (points.empty()) return out; @@ -552,7 +508,7 @@ namespace Polygon_mesh_processing { #ifdef CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 false; #else - choose_parameter(get_parameter(np, internal_np::use_2d_constrained_delaunay_triangulation), true); + choose_parameter(get_parameter(np, internal_np::use_2d_constrained_delaunay_triangulation), false); #endif bool use_dt3 = #ifdef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 @@ -577,51 +533,46 @@ bool use_dt3 = typedef typename std::iterator_traits::value_type Point; typedef typename CGAL::Kernel_traits::Kernel Kernel; #ifndef CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 - struct Always_valid{ - bool operator()(const std::vector&, int,int,int)const - {return true;} - }; - Always_valid is_valid; + if (use_cdt) + { + struct Always_valid + { + bool operator()(const std::vector&, int,int,int) const { return true; } + }; + Always_valid is_valid; - const typename Kernel::Iso_cuboid_3 bbox = CGAL::bounding_box(points.begin(), points.end()); - typename Kernel::FT default_squared_distance = CGAL::abs(CGAL::squared_distance(bbox.vertex(0), bbox.vertex(5))); - default_squared_distance /= typename Kernel::FT(16); // one quarter of the bbox height + const typename Kernel::Iso_cuboid_3 bbox = CGAL::bounding_box(points.begin(), points.end()); + typename Kernel::FT default_squared_distance = CGAL::abs(CGAL::squared_distance(bbox.vertex(0), bbox.vertex(5))); + default_squared_distance /= typename Kernel::FT(16); // one quarter of the bbox height - const typename Kernel::FT threshold_distance = choose_parameter( - get_parameter(np, internal_np::threshold_distance), typename Kernel::FT(-1)); - typename Kernel::FT max_squared_distance = default_squared_distance; - if (threshold_distance >= typename Kernel::FT(0)) - max_squared_distance = threshold_distance * threshold_distance; - CGAL_assertion(max_squared_distance >= typename Kernel::FT(0)); + const typename Kernel::FT threshold_distance = choose_parameter( + get_parameter(np, internal_np::threshold_distance), typename Kernel::FT(-1)); + typename Kernel::FT max_squared_distance = default_squared_distance; + if(threshold_distance >= typename Kernel::FT(0)) + max_squared_distance = threshold_distance * threshold_distance; - if(!use_cdt || - !triangulate_hole_polyline_with_cdt( - points, - tracer, - is_valid, - choose_parameter(get_parameter(np, internal_np::geom_traits)), - max_squared_distance)) + CGAL_assertion(max_squared_distance >= typename Kernel::FT(0)); + if (triangulate_hole_polyline_with_cdt( + points, + tracer, + is_valid, + choose_parameter(get_parameter(np, internal_np::geom_traits)), + max_squared_distance)) + { + CGAL_assertion(holes.empty()); + return tracer.out; + } + } #endif triangulate_hole_polyline(points, third_points, tracer, WC(), use_dt3, + choose_parameter(get_parameter(np, internal_np::do_not_use_cubic_algorithm), false), choose_parameter(get_parameter(np, internal_np::geom_traits))); CGAL_assertion(holes.empty()); return tracer.out; } - template - OutputIterator - triangulate_hole_polyline(const PointRange1& points, - const PointRange2& third_points, - OutputIterator out) - { - return triangulate_hole_polyline(points, third_points, out, - CGAL::Polygon_mesh_processing::parameters::all_default()); - } - /*! \ingroup hole_filling_grp Same as above but the range of third points is omitted. They are not @@ -629,11 +580,11 @@ bool use_dt3 = */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> OutputIterator triangulate_hole_polyline(const PointRange& points, OutputIterator out, - const CGAL_PMP_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { typedef typename std::iterator_traits< typename PointRange::iterator>::value_type Point; @@ -641,16 +592,6 @@ bool use_dt3 = return triangulate_hole_polyline(points, third_points, out, np); } - template - OutputIterator - triangulate_hole_polyline(const PointRange& points, - OutputIterator out) - { - return triangulate_hole_polyline(points, out, - CGAL::Polygon_mesh_processing::parameters::all_default()); - } - } //end namespace Polygon_mesh_processing } //end namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h b/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h index c8d8b784513..147f7e90b26 100644 --- a/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h +++ b/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h @@ -69,6 +69,7 @@ #include #include +#include #ifdef CGAL_ENVELOPE_DEBUG // This is for computing the surface mesh of a prism @@ -88,11 +89,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_PMP_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_PMP_NP_CLASS NamedParameters -#endif - namespace CGAL { /** @@ -364,10 +360,10 @@ public: * \note The triangle mesh gets copied internally, that is it can be modifed after having passed as argument, * while the queries are performed */ - template + template Polyhedral_envelope(const TriangleMesh& tmesh, double epsilon, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -407,7 +403,7 @@ public: else deg_faces.insert(f); } - if (is_default_parameter(get_parameter(np, internal_np::face_epsilon_map))) + if (is_default_parameter()) init(epsilon); else { @@ -464,11 +460,11 @@ public: * \note The triangle mesh gets copied internally, that is it can be modifed after having passed as argument, * while the queries are performed */ - template + template Polyhedral_envelope(const FaceRange& face_range, const TriangleMesh& tmesh, double epsilon, - const NamedParameters& np + const NamedParameters& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename std::enable_if::value>::type* = 0 #endif @@ -516,7 +512,7 @@ public: deg_faces.insert(f); } - if (is_default_parameter(get_parameter(np, internal_np::face_epsilon_map))) + if (is_default_parameter()) init(epsilon); else { @@ -568,11 +564,11 @@ public: * \cgalNamedParamsEnd * */ - template + template Polyhedral_envelope(const PointRange& points, const TriangleRange& triangles, double epsilon, - const NamedParameters& np + const NamedParameters& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename std::enable_if::value>::type* = 0 #endif @@ -599,7 +595,7 @@ public: env_faces.emplace_back(face); } - if (is_default_parameter(get_parameter(np, internal_np::face_epsilon_map))) + if (is_default_parameter()) init(epsilon); else { @@ -623,30 +619,6 @@ public: /// @} -#ifndef DOXYGEN_RUNNING - template - Polyhedral_envelope(const TriangleMesh& tmesh, - double epsilon) - : Polyhedral_envelope(tmesh, epsilon, parameters::all_default()) - {} - - template - Polyhedral_envelope(const FaceRange& face_range, - const TriangleMesh& tmesh, - double epsilon, - typename std::enable_if::value>::type* = 0) - : Polyhedral_envelope(face_range, tmesh, epsilon, parameters::all_default()) - {} - - template - Polyhedral_envelope(const PointRange& points, - const TriangleRange& triangles, - double epsilon, - typename std::enable_if::value>::type* = 0) - : Polyhedral_envelope(points, triangles, epsilon, parameters::all_default()) - {} -#endif - private: template @@ -1782,7 +1754,7 @@ private: inter = Implicit_Seg_Facet_interpoint_Out_Prism_return_local_id_with_face_order_jump_over(ip, filtered_intersection, intersect_face, coverlist, jump1, check_id); - assert(inter != 2);// the point must exist because it is a seg-halfplane intersection + CGAL_assertion(inter != 2);// the point must exist because it is a seg-halfplane intersection if (inter == 1) { return true; @@ -2113,7 +2085,7 @@ private: std::cout << p.ep << " | " << p.eq << " | " << p.er << std::endl; ePoint_3 pv(ver[faces[i][0]].x(), ver[faces[i][0]].y(),ver[faces[i][0]].z()); Orientation ori = orientation(p.ep, p.eq, p.er, pv); - assert(ori == NEGATIVE); + CGAL_assertion(ori == NEGATIVE); } #endif @@ -2249,14 +2221,19 @@ public: * the initial list of prisms. * \todo apply that to the soup versions */ - template + template bool - operator()(const TriangleMesh& tmesh, const CGAL_PMP_NP_CLASS& np) const + operator()(const TriangleMesh& tmesh, + const CGAL_NP_CLASS& np = parameters::default_values() +#ifndef DOXYGEN_RUNNING + , typename std::enable_if::value>::type* = 0 +#endif + ) const { using parameters::choose_parameter; using parameters::get_parameter; - typename GetVertexPointMap::const_type + typename GetVertexPointMap::const_type vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(CGAL::vertex_point, tmesh)); @@ -2275,16 +2252,6 @@ public: return true; } -#ifndef DOXYGEN_RUNNING - template - bool - operator()(const TriangleMesh& tmesh, - typename std::enable_if::value>::type* = 0) const - { - return this->operator()(tmesh, parameters::all_default()); - } -#endif - /** * returns `true`, iff all the triangles in `triangles` are inside the polyhedral envelope. * @@ -2309,10 +2276,10 @@ public: * \cgalNamedParamsEnd * */ - template + template bool operator()(const PointRange& points, const TriangleRange& triangles, - const NamedParameters& np) const + const NamedParameters& np = parameters::default_values()) const { using parameters::choose_parameter; using parameters::get_parameter; @@ -2338,16 +2305,6 @@ public: return true; } -#ifndef DOXYGEN_RUNNING - template - bool operator()(const PointRange& points, - const TriangleRange& triangles) const - { - return this->operator()(points, triangles, parameters::all_default()); - } - -#endif - /** * returns `true`, iff all the triangles in `triangle_range` are inside the polyhedral envelope. * @tparam TriangleRange a model of `ConstRange` with `ConstRange::const_iterator` diff --git a/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h b/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h index 927fed1fe89..7b28b5d4121 100644 --- a/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h +++ b/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h @@ -240,9 +240,9 @@ public: * \cgalParamNEnd * \cgalNamedParamsEnd */ - template + template std::size_t add_mesh(const TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { // handle vpm typedef typename CGAL::GetVertexPointMap::const_type Local_vpm; @@ -299,8 +299,8 @@ public: * \cgalParamNEnd * \cgalNamedParamsEnd */ - template - std::size_t add_mesh(const AABB_tree& tree, const TriangleMesh& tm, const NamedParameters& np) + template + std::size_t add_mesh(const AABB_tree& tree, const TriangleMesh& tm, const NamedParameters& np = parameters::default_values()) { std::size_t id = get_id_for_new_mesh(); CGAL_assertion( m_aabb_trees[id] == nullptr ); @@ -546,12 +546,12 @@ public: * \cgalParamNEnd * \cgalNamedParamsEnd */ - template + template static void collect_one_point_per_connected_component( const TriangleMesh& tm, std::vector& points, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { const bool maybe_several_cc = parameters::choose_parameter( @@ -625,25 +625,6 @@ public: return id; } - - // versions without NP - static - void collect_one_point_per_connected_component( - const TriangleMesh& tm, - std::vector& points) - { - collect_one_point_per_connected_component(tm, points, parameters::all_default()); - } - - std::size_t add_mesh(const TriangleMesh& tm) - { - return add_mesh(tm, parameters::all_default()); - } - - std::size_t add_mesh(const AABB_tree& tree, const TriangleMesh& tm) - { - return add_mesh(tree, tm, parameters::all_default()); - } #endif }; diff --git a/Polygon_mesh_processing/include/CGAL/polygon_mesh_processing.h b/Polygon_mesh_processing/include/CGAL/polygon_mesh_processing.h index dcea23d7177..4eec2ff467f 100644 --- a/Polygon_mesh_processing/include/CGAL/polygon_mesh_processing.h +++ b/Polygon_mesh_processing/include/CGAL/polygon_mesh_processing.h @@ -57,6 +57,7 @@ namespace Polygon_mesh_processing { namespace parameters { /*! \ingroup namedparameters +\deprecated This function is deprecated and `default_values()` should be used instead. This function can be used to indicate that all optional named parameters to be used are the default ones. This is particularly useful when a function requires more than one sequence of named parameters and default values is diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index 6434fe6987b..82a8dffe5e4 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -106,6 +106,7 @@ create_single_source_cgal_program("test_remove_caps_needles.cpp") create_single_source_cgal_program("test_simplify_polylines_pmp.cpp") create_single_source_cgal_program("triangulate_hole_with_cdt_2_test.cpp") create_single_source_cgal_program("test_pmp_polyhedral_envelope.cpp") +create_single_source_cgal_program("test_pmp_np_function.cpp") # create_single_source_cgal_program("test_pmp_repair_self_intersections.cpp") find_package(METIS) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp index 234200bd6ac..e0290c027be 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp @@ -104,7 +104,7 @@ void mesh_no_id(const std::string argv1, const bool save_output) // std::cout << &*f << " in connected component " << fccmap[f] << std::endl; //} - PMP::keep_largest_connected_components(sm, 2, PMP::parameters::vertex_index_map(vim)); + PMP::keep_largest_connected_components(sm, 2, CGAL::parameters::vertex_index_map(vim)); if (save_output) return; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp index 5873e6073eb..ec64f753d63 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp @@ -126,18 +126,18 @@ void test_CC_with_default_size_map(Mesh sm, // default face size map, but explicitely passed PMP::keep_connected_components(copy1, ff, - PMP::parameters::edge_is_constrained_map(Constraint(copy1, k, bound)) - .face_size_map(CGAL::Constant_property_map(1))); + CGAL::parameters::edge_is_constrained_map(Constraint(copy1, k, bound)) + .face_size_map(CGAL::Constant_property_map(1))); // remove cc from copy2 ff.clear(); ff.push_back(one_face_per_cc[id_of_cc_to_remove]); PMP::remove_connected_components(copy2, ff, - PMP::parameters::edge_is_constrained_map(Constraint(copy2, k, bound))); + CGAL::parameters::edge_is_constrained_map(Constraint(copy2, k, bound))); std::cerr << "We keep the " << num-1 << " largest components" << std::endl; PMP::keep_largest_connected_components(sm, num-1, - PMP::parameters::edge_is_constrained_map(Constraint(sm, k, bound))); + CGAL::parameters::edge_is_constrained_map(Constraint(sm, k, bound))); sm.collect_garbage(); copy1.collect_garbage(); @@ -173,9 +173,9 @@ void test_CC_with_area_size_map(Mesh sm, std::cout << "We keep the " << 2 << " largest components" << std::endl; std::size_t res = PMP::keep_largest_connected_components(sm, 2, - PMP::parameters::face_size_map(boost::make_function_property_map(f)) - .dry_run(true) - .output_iterator(std::back_inserter(faces_to_remove))); + CGAL::parameters::face_size_map(boost::make_function_property_map(f)) + .dry_run(true) + .output_iterator(std::back_inserter(faces_to_remove))); // didn't actually remove anything assert(PMP::internal::number_of_connected_components(sm) == num); @@ -188,7 +188,7 @@ void test_CC_with_area_size_map(Mesh sm, } PMP::keep_largest_connected_components(sm, 2, - PMP::parameters::face_size_map( + CGAL::parameters::face_size_map( boost::make_function_property_map(f))); assert(vertices(sm).size() == 1459); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp index 86a2e3230a5..3050a34753f 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp @@ -99,7 +99,7 @@ void test_pmesh(const Mesh& pmesh) assert(mesh_area >= patch_area); FT mesh_area_np = PMP::area(pmesh, - PMP::parameters::geom_traits(K())); + CGAL::parameters::geom_traits(K())); std::cout << "mesh area (NP) = " << mesh_area_np << std::endl; assert(mesh_area_np > 0); @@ -243,7 +243,7 @@ void test_compare() return; } input.close(); - PMP::match_faces(mesh1, mesh2, std::back_inserter(common), std::back_inserter(m1_only), std::back_inserter(m2_only), CGAL::parameters::all_default(), CGAL::parameters::all_default()); + PMP::match_faces(mesh1, mesh2, std::back_inserter(common), std::back_inserter(m1_only), std::back_inserter(m2_only), CGAL::parameters::default_values(), CGAL::parameters::default_values()); assert(common.size() == 7); assert(m1_only.size() == 11); assert(m2_only.size() == 11); @@ -283,7 +283,7 @@ void test_compare() { fim2.insert(std::make_pair(f, id++)); } - PMP::match_faces(mesh1, mesh2, std::back_inserter(common), std::back_inserter(m1_only), std::back_inserter(m2_only), CGAL::parameters::all_default(), CGAL::parameters::all_default()); + PMP::match_faces(mesh1, mesh2, std::back_inserter(common), std::back_inserter(m1_only), std::back_inserter(m2_only), CGAL::parameters::default_values(), CGAL::parameters::default_values()); assert(common.size() == 3); assert(m1_only.size() == 3); assert(fim1[m1_only[0]] == 0); @@ -317,7 +317,7 @@ void test_compare() return; } input.close(); - PMP::match_faces(mesh1, mesh2, std::back_inserter(common), std::back_inserter(m1_only), std::back_inserter(m2_only), CGAL::parameters::all_default(), CGAL::parameters::all_default()); + PMP::match_faces(mesh1, mesh2, std::back_inserter(common), std::back_inserter(m1_only), std::back_inserter(m2_only), CGAL::parameters::default_values(), CGAL::parameters::default_values()); assert(common.size() == 17); assert(m1_only.size() == 1); assert(m2_only.size() == 0); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_compute_normals_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_compute_normals_test.cpp index ac9eba069b9..f0dc91bd25e 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_compute_normals_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_compute_normals_test.cpp @@ -42,28 +42,28 @@ void test(const Mesh& mesh, const face_descriptor first_face = *(faces(mesh).begin()); PMP::compute_face_normals(mesh, fnormals); - PMP::compute_face_normals(mesh, fnormals, PMP::parameters::vertex_point_map(vpmap)); + PMP::compute_face_normals(mesh, fnormals, CGAL::parameters::vertex_point_map(vpmap)); PMP::compute_face_normals(mesh, fnormals, CGAL::parameters::vertex_point_map(vpmap) .geom_traits(K())); Vector f0n = PMP::compute_face_normal(first_face, mesh); assert(f0n == get(fnormals, first_face)); - PMP::compute_face_normal(first_face, mesh, PMP::parameters::vertex_point_map(vpmap)); + PMP::compute_face_normal(first_face, mesh, CGAL::parameters::vertex_point_map(vpmap)); PMP::compute_vertex_normals(mesh, vnormals); - PMP::compute_vertex_normals(mesh, vnormals, PMP::parameters::vertex_point_map(vpmap)); + PMP::compute_vertex_normals(mesh, vnormals, CGAL::parameters::vertex_point_map(vpmap)); PMP::compute_vertex_normals(mesh, vnormals, CGAL::parameters::vertex_point_map(vpmap) .geom_traits(K())); Vector v0n = PMP::compute_vertex_normal(first_vertex, mesh); assert(v0n == get(vnormals, first_vertex)); - v0n = PMP::compute_vertex_normal(first_vertex, mesh, PMP::parameters::vertex_point_map(vpmap) - .face_normal_map(fnormals)); + v0n = PMP::compute_vertex_normal(first_vertex, mesh, CGAL::parameters::vertex_point_map(vpmap) + .face_normal_map(fnormals)); std::cout.precision(17); assert(v0n == get(vnormals, first_vertex)); PMP::compute_normals(mesh, vnormals, fnormals); - PMP::compute_normals(mesh, vnormals, fnormals, PMP::parameters::vertex_point_map(vpmap)); + PMP::compute_normals(mesh, vnormals, fnormals, CGAL::parameters::vertex_point_map(vpmap)); PMP::compute_normals(mesh, vnormals, fnormals, CGAL::parameters::vertex_point_map(vpmap) .geom_traits(K())); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_do_intersect_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_do_intersect_test.cpp index 3a16214305a..93bdd0fbd01 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_do_intersect_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_do_intersect_test.cpp @@ -92,8 +92,8 @@ test_faces_intersections(const std::string filename1, CGAL::Polygon_mesh_processing::internal::compute_face_face_intersection( m1, m2, std::back_inserter(intersected_tris), - CGAL::Polygon_mesh_processing::parameters::all_default(), - CGAL::Polygon_mesh_processing::parameters::all_default()); + CGAL::parameters::default_values(), + CGAL::parameters::default_values()); bool intersecting_1 = !intersected_tris.empty(); @@ -150,7 +150,7 @@ test_faces_polyline_intersections(const std::string filename1, CGAL::Polygon_mesh_processing::internal::compute_face_polyline_intersection( m, points, std::back_inserter(intersected_tris), - CGAL::Polygon_mesh_processing::parameters::all_default()); + CGAL::parameters::default_values()); bool intersecting_1 = !intersected_tris.empty(); @@ -211,7 +211,7 @@ test_faces_polylines_intersections(const std::string filename1, points, m, std::back_inserter(intersected_tris), - CGAL::Polygon_mesh_processing::parameters::all_default()); + CGAL::parameters::default_values()); bool intersecting_1 = !intersected_tris.empty(); @@ -373,7 +373,7 @@ int test_inter_in_range(const std::vector& filenames, std::size_t e } std::vector > output; CGAL::Polygon_mesh_processing::intersecting_meshes(meshes, std::back_inserter(output), - CGAL::Polygon_mesh_processing::parameters::do_overlap_test_of_bounded_sides(volume)); + CGAL::parameters::do_overlap_test_of_bounded_sides(volume)); std::cout << output.size() <<" pairs."< #include #include -#include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; typedef CGAL::Exact_predicates_inexact_constructions_kernel Epec; @@ -118,24 +118,24 @@ int test_slicer() slicer(typename K::Plane_3(0,1,0,0.5), std::back_inserter(polylines)); assert(polylines.size()==2); // two polylines int closed_id = polylines.front().front()==polylines.front().back() ? 0 : 1; - CGAL_USE(closed_id); - CGAL_assertion( is_ccw(0, 2 , polylines[closed_id]) ); + + assert( is_ccw(0, 2 , polylines[closed_id]) ); polylines.clear(); slicer(typename K::Plane_3(0,-1,0,-0.5), std::back_inserter(polylines)); assert(polylines.size()==2); // two polylines closed_id = polylines.front().front()==polylines.front().back() ? 0 : 1; - CGAL_assertion( !is_ccw(0, 2, polylines[closed_id]) ); + assert( !is_ccw(0, 2, polylines[closed_id]) ); polylines.clear(); slicer(typename K::Plane_3(0,0,1,1), std::back_inserter(polylines)); assert(polylines.size()==1); // one polyline - CGAL_assertion( is_ccw(0, 1 , polylines[0]) ); + assert( is_ccw(0, 1 , polylines[0]) ); polylines.clear(); slicer(typename K::Plane_3(0,0,-1,-1), std::back_inserter(polylines)); assert(polylines.size()==1); // one polyline - CGAL_assertion( !is_ccw(0, 1 , polylines[0]) ); + assert( !is_ccw(0, 1 , polylines[0]) ); // reverse face orientation (no need to rebuild the tree) CGAL::Polygon_mesh_processing::reverse_face_orientations(m); @@ -143,23 +143,23 @@ int test_slicer() slicer(typename K::Plane_3(0,1,0,0.5), std::back_inserter(polylines)); assert(polylines.size()==2); // two polylines closed_id = polylines.front().front()==polylines.front().back() ? 0 : 1; - CGAL_assertion( !is_ccw(0, 2 , polylines[closed_id]) ); + assert( !is_ccw(0, 2 , polylines[closed_id]) ); polylines.clear(); slicer(typename K::Plane_3(0,-1,0,-0.5), std::back_inserter(polylines)); assert(polylines.size()==2); // two polylines closed_id = polylines.front().front()==polylines.front().back() ? 0 : 1; - CGAL_assertion( is_ccw(0, 2, polylines[closed_id]) ); + assert( is_ccw(0, 2, polylines[closed_id]) ); polylines.clear(); slicer(typename K::Plane_3(0,0,1,1), std::back_inserter(polylines)); assert(polylines.size()==1); // one polyline - CGAL_assertion( !is_ccw(0, 1 , polylines[0]) ); + assert( !is_ccw(0, 1 , polylines[0]) ); polylines.clear(); slicer(typename K::Plane_3(0,0,-1,-1), std::back_inserter(polylines)); assert(polylines.size()==1); // one polyline - CGAL_assertion( is_ccw(0, 1 , polylines[0]) ); + assert( is_ccw(0, 1 , polylines[0]) ); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test.cpp index 47cd59daf7b..40067cea512 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test.cpp @@ -22,6 +22,7 @@ #include #include #include +#include namespace PMP = CGAL::Polygon_mesh_processing; @@ -95,13 +96,13 @@ void test_precondition(const char* filename, try { PMP::isotropic_remeshing(patch, 0.079, m, - PMP::parameters::protect_constraints(true)); + CGAL::parameters::protect_constraints(true)); } catch (const std::exception &) { exception_caught = true; } - CGAL_assertion(exception_caught); + assert(exception_caught); #endif } @@ -137,13 +138,13 @@ public: friend value_type get(const Constraints_pmap& map, const key_type& e) { - CGAL_assertion(map.set_ptr_ != nullptr); + assert(map.set_ptr_ != nullptr); return !map.set_ptr_->empty() && map.set_ptr_->count(e); } friend void put(Constraints_pmap& map, const key_type& e, const value_type is) { - CGAL_assertion(map.set_ptr_ != nullptr); + assert(map.set_ptr_ != nullptr); if (is) map.set_ptr_->insert(e); else if(get(map, e)) map.set_ptr_->erase(e); } @@ -203,7 +204,7 @@ Main(int argc, const char* argv[]) m, boost::make_function_output_iterator(halfedge2edge(m, border))); PMP::split_long_edges(border, target_edge_length, m - , PMP::parameters::edge_is_constrained_map(ecmap)); + , CGAL::parameters::edge_is_constrained_map(ecmap)); std::cout << "done." << std::endl; std::cout << "Collect patch..."; @@ -212,7 +213,7 @@ Main(int argc, const char* argv[]) if (is_border(halfedge(*border.begin(), m), m)) seed = face(opposite(halfedge(*border.begin(), m), m), m); PMP::connected_component(seed, m, std::back_inserter(patch), - PMP::parameters::edge_is_constrained_map(ecmap)); + CGAL::parameters::edge_is_constrained_map(ecmap)); std::cout << " done." << std::endl; std::cout << "Start remeshing of " << selection_file @@ -224,7 +225,7 @@ Main(int argc, const char* argv[]) patch, target_edge_length, m, - PMP::parameters::number_of_iterations(nb_iter) + CGAL::parameters::number_of_iterations(nb_iter) .protect_constraints(false) ); t.stop(); @@ -235,7 +236,7 @@ Main(int argc, const char* argv[]) PMP::isotropic_remeshing(faces(m), 2.*target_edge_length, m, - PMP::parameters::number_of_iterations(nb_iter) + CGAL::parameters::number_of_iterations(nb_iter) .protect_constraints(true) //only borders. they have been refined by previous remeshing .edge_is_constrained_map(ecmap) .relax_constraints(true) @@ -257,7 +258,7 @@ Main(int argc, const char* argv[]) if (sharp_angle > 0) PMP::sharp_edges_segmentation(m, sharp_angle, eif, pid, - PMP::parameters::vertex_incident_patches_map(vip)); + CGAL::parameters::vertex_incident_patches_map(vip)); std::vector sharp_edges; for (edge_descriptor e : edges(m)) @@ -275,13 +276,13 @@ Main(int argc, const char* argv[]) sharp_edges, target_edge_length, m, - PMP::parameters::edge_is_constrained_map(eif)); + CGAL::parameters::edge_is_constrained_map(eif)); PMP::isotropic_remeshing( faces(m), target_edge_length, m, - PMP::parameters::edge_is_constrained_map(eif) + CGAL::parameters::edge_is_constrained_map(eif) .number_of_iterations(nb_iter) .number_of_relaxation_steps(3) .protect_constraints(true)//i.e. protect border, here diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_P_SM_OM.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_P_SM_OM.cpp index b8b34ceb6f9..eeebc63b301 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_P_SM_OM.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_P_SM_OM.cpp @@ -45,7 +45,7 @@ int main() PMP::isotropic_remeshing(faces(p), 0.02, p, - PMP::parameters::face_index_map(boost::make_assoc_property_map(fim))); + CGAL::parameters::face_index_map(boost::make_assoc_property_map(fim))); std::ofstream out("p.off"); out << p << std::endl; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_polyhedron_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_polyhedron_test.cpp index 871a5c9dfb3..1d1991ee86b 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_polyhedron_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_polyhedron_test.cpp @@ -38,7 +38,7 @@ test_self_intersections(const std::string filename, const bool expected) CGAL::Polygon_mesh_processing::self_intersections( poly, std::back_inserter(intersected_tris), - CGAL::Polygon_mesh_processing::parameters::vertex_index_map(get(CGAL::vertex_point, poly))); + CGAL::parameters::vertex_index_map(get(CGAL::vertex_point, poly))); bool intersecting_1 = !intersected_tris.empty(); std::cout << "Self-intersection test took " << timer.time() << " sec." << std::endl; @@ -46,7 +46,7 @@ test_self_intersections(const std::string filename, const bool expected) timer.reset(); bool intersecting_2 = CGAL::Polygon_mesh_processing::does_self_intersect(poly, - CGAL::Polygon_mesh_processing::parameters::vertex_index_map(get(CGAL::vertex_point, poly))); + CGAL::parameters::vertex_index_map(get(CGAL::vertex_point, poly))); std::cout << "does_self_intersect test took " << timer.time() << " sec." << std::endl; std::cout << (intersecting_2 ? "There is a self-intersection." : diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cmd b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cmd index 0cf62f85b97..a2ffe2c2539 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cmd +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cmd @@ -1,14 +1,14 @@ data-autoref/test_01.off 0 0 4 1 4 0 data-autoref/test_02.off 1 5 13 1 5 0 data-autoref/test_03.off 4 8 18 0 18 0 -data-autoref/test_04.off 1 5 17 1 0 0 -data-autoref/test_05.off 1 5 17 1 0 0 +data-autoref/test_04.off 1 5 17 0 17 0 +data-autoref/test_05.off 1 5 17 0 17 0 data-autoref/test_06.off 3 55 141 1 76 0 data-autoref/test_07.off 1 4 10 1 4 0 data-autoref/test_08.off 1 31 87 1 52 0 data-autoref/test_09.off 1 4 5 1 4 0 data-autoref/test_10.off 1 3 13 0 13 0 -data-autoref/test_11.off 1 3 12 1 5 0 +data-autoref/test_11.off 1 3 12 0 12 0 data-autoref/test_12.off 2 2 11 1 11 0 data-autoref/test_13.off 1 5 16 1 8 0 data-autoref/test_14.off 1 5 16 1 12 0 diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cpp index 06bbfa2a147..9c908d7ec24 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cpp @@ -61,7 +61,7 @@ void test(const char* fname, std::size_t nb_polylines, std::size_t total_nb_poin try{ My_visitor visitor; PMP::experimental::autorefine(mesh, - PMP::parameters::visitor(visitor)); + CGAL::parameters::visitor(visitor)); mesh.collect_garbage(); assert( nb_vertices_after_autorefine==num_vertices(mesh)); assert( (nb_vertices_before_autorefine!=nb_vertices_after_autorefine)== (*(visitor.i) != 0) ); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cpp index 21f43723ade..31e4f9c71f2 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cpp @@ -52,7 +52,7 @@ void test(const char* f1, const char* f2) std::size_t nbv2_before=vertices(sm2).size(); std::size_t nb_v_before = num_vertices(sm1) + num_vertices(sm2); CGAL::Polygon_mesh_processing::corefine(sm1, sm2, - CGAL::Polygon_mesh_processing::parameters::visitor(sm_v)); + CGAL::parameters::visitor(sm_v)); std::size_t nb_v_after = num_vertices(sm1) + num_vertices(sm2); assert(sm1.is_valid()); @@ -74,7 +74,7 @@ void test(const char* f1, const char* f2) nb_v_before = num_vertices(P) + num_vertices(Q); CGAL::Polygon_mesh_processing::corefine(P, Q, - CGAL::Polygon_mesh_processing::parameters::visitor(sm_p)); + CGAL::parameters::visitor(sm_p)); nb_v_after = num_vertices(P) + num_vertices(Q); assert((*(sm_p.i) != 0) == (nb_v_before!=nb_v_after)); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_and_constraints.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_and_constraints.cpp index 37a133dd44e..889a92636bf 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_and_constraints.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_and_constraints.cpp @@ -6,7 +6,7 @@ #include namespace PMP = CGAL::Polygon_mesh_processing; -namespace params = PMP::parameters; +namespace params = CGAL::parameters; template std::size_t diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_detect_features.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_detect_features.cpp index 626960b6369..e2d84414b1f 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_detect_features.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_detect_features.cpp @@ -48,8 +48,8 @@ void test_cube() CGAL_USE(number_of_patches); number_of_patches = PMP::sharp_edges_segmentation(mesh, 90, eif, pid, - PMP::parameters::first_index(1) - .vertex_incident_patches_map(vip)); + CGAL::parameters::first_index(1) + .vertex_incident_patches_map(vip)); assert(number_of_patches == 6); @@ -73,7 +73,7 @@ void test_cube() = mesh.add_property_map > >("f:vip",std::set >()).first; PMP::detect_sharp_edges(mesh, 90, eif); number_of_patches = PMP::internal::detect_surface_patches(mesh, patch_id_map, eif, - PMP::parameters::first_index(1)); + CGAL::parameters::first_index(1)); PMP::detect_vertex_incident_patches(mesh, patch_id_map, vertex_incident_patch_map, eif); nb_sharp_edges =0; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_hausdorff_bounded_error_distance.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_hausdorff_bounded_error_distance.cpp index ce5c1a9c65f..055a50a32c0 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_hausdorff_bounded_error_distance.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_hausdorff_bounded_error_distance.cpp @@ -1,24 +1,24 @@ // Use it to include parallel computations in the bounded error Hausdorff distance. -// #define USE_PARALLEL_BEHD +#define USE_PARALLEL_BEHD // Use this def in order to get all DEBUG info related to the bounded-error Hausdorff code! -// #define CGAL_HAUSDORFF_DEBUG +#define CGAL_HAUSDORFF_DEBUG -#include -#include #include #include #include -#include -#include - #include #include + +#include +#include +#include #include #include #include #include #include +#include using SCK = CGAL::Simple_cartesian; using EPICK = CGAL::Exact_predicates_inexact_constructions_kernel; @@ -32,106 +32,164 @@ using Triangle_3 = typename Kernel::Triangle_3; using TAG = CGAL::Sequential_tag; using Surface_mesh = CGAL::Surface_mesh; -using Polyhedron = CGAL::Polyhedron_3; +using Polyhedron = CGAL::Surface_mesh; using Affine_transformation_3 = CGAL::Aff_transformation_3; using Timer = CGAL::Real_timer; using Face_handle = typename boost::graph_traits::face_descriptor; namespace PMP = CGAL::Polygon_mesh_processing; -struct Approximate_hd_wrapper { - const double m_num_samples; +struct Approximate_hd_wrapper +{ + const std::size_t m_num_samples; + const double m_error_bound; + std::string name() const { return "approximate"; } - Approximate_hd_wrapper(const double num_samples) : m_num_samples(num_samples) { } - double operator()(const Surface_mesh& tm1, const Surface_mesh& tm2) const { + + explicit Approximate_hd_wrapper(const std::size_t num_samples, + const double error_bound) + : m_num_samples(num_samples), m_error_bound(error_bound) + { } + + double operator()(const Surface_mesh& tm1, const Surface_mesh& tm2) const + { return PMP::approximate_Hausdorff_distance(tm1, tm2, - PMP::parameters::number_of_points_per_area_unit(m_num_samples), - PMP::parameters::number_of_points_per_area_unit(m_num_samples)); + CGAL::parameters::number_of_points_on_faces(m_num_samples).random_seed(0), + CGAL::parameters::number_of_points_on_faces(m_num_samples).random_seed(0)); } - double symmetric(const Surface_mesh& tm1, const Surface_mesh& tm2) const { + + double symmetric(const Surface_mesh& tm1, const Surface_mesh& tm2) const + { return PMP::approximate_symmetric_Hausdorff_distance(tm1, tm2, - PMP::parameters::number_of_points_per_area_unit(m_num_samples), - PMP::parameters::number_of_points_per_area_unit(m_num_samples)); + CGAL::parameters::number_of_points_on_faces(m_num_samples).random_seed(0), + CGAL::parameters::number_of_points_on_faces(m_num_samples).random_seed(0)); + } + + bool check_value(const double val, const double expected) const + { + const bool res = ((CGAL::abs(val - expected)) <= m_error_bound); + if(!res) + std::cerr << "Expected " << expected << " but got " << val << std::endl; + + return res; } }; -struct Naive_bounded_error_hd_wrapper { +struct Naive_bounded_error_hd_wrapper +{ const double m_error_bound; + std::string name() const { return "naive bounded error"; } - Naive_bounded_error_hd_wrapper(const double error_bound) : m_error_bound(error_bound) { } - double operator()(const Surface_mesh& tm1, const Surface_mesh& tm2) const { + + explicit Naive_bounded_error_hd_wrapper(const double error_bound) : m_error_bound(error_bound) { } + + double operator()(const Surface_mesh& tm1, const Surface_mesh& tm2) const + { return PMP::bounded_error_Hausdorff_distance_naive(tm1, tm2, m_error_bound); } - double symmetric(const Surface_mesh& tm1, const Surface_mesh& tm2) const { + + double symmetric(const Surface_mesh& tm1, const Surface_mesh& tm2) const + { const double dista = operator()(tm1, tm2); const double distb = operator()(tm2, tm1); return (CGAL::max)(dista, distb); } + + bool check_value(const double val, const double expected) const + { + const bool res = ((CGAL::abs(val - expected)) <= m_error_bound); + if(!res) + std::cerr << "Expected " << expected << " but got " << val << std::endl; + + return res; + } }; -struct Bounded_error_hd_wrapper { +struct Bounded_error_hd_wrapper +{ const double m_error_bound; + std::string name() const { return "bounded error"; } - Bounded_error_hd_wrapper(const double error_bound) : m_error_bound(error_bound) { } - double operator()(const Surface_mesh& tm1, const Surface_mesh& tm2) const { + + explicit Bounded_error_hd_wrapper(const double error_bound) : m_error_bound(error_bound) { } + + double operator()(const Surface_mesh& tm1, const Surface_mesh& tm2) const + { return PMP::bounded_error_Hausdorff_distance(tm1, tm2, m_error_bound); } - double symmetric(const Surface_mesh& tm1, const Surface_mesh& tm2) const { + + double symmetric(const Surface_mesh& tm1, const Surface_mesh& tm2) const + { return PMP::bounded_error_symmetric_Hausdorff_distance(tm1, tm2, m_error_bound); } + + bool check_value(const double val, const double expected) const + { + const bool res = ((CGAL::abs(val - expected)) <= m_error_bound); + if(!res) + std::cerr << "Expected " << expected << " but got " << val << std::endl; + + return res; + } }; template -void get_mesh(const std::string filepath, PolygonMesh& mesh) { - +void get_mesh(const std::string& filepath, PolygonMesh& mesh) +{ mesh.clear(); - std::ifstream input(filepath); - input >> mesh; + CGAL::IO::read_polygon_mesh(filepath, mesh); std::cout << "* getting mesh with " << faces(mesh).size() << " faces" << std::endl; } template -void get_meshes( - const std::string filepath1, const std::string filepath2, - PolygonMesh1& mesh1, PolygonMesh2& mesh2) { - +void get_meshes(const std::string& filepath1, + const std::string& filepath2, + PolygonMesh1& mesh1, + PolygonMesh2& mesh2) +{ get_mesh(filepath1, mesh1); get_mesh(filepath2, mesh2); } template -void save_mesh(const PolygonMesh& mesh, const std::string filepath) { - - if (!CGAL::IO::write_PLY(filepath + ".ply", mesh)) { +void save_mesh(const PolygonMesh& mesh, + const std::string& filepath) +{ + if(!CGAL::IO::write_PLY(filepath + ".ply", mesh)) + { std::cerr << "ERROR: cannot save this file: " << filepath << std::endl; exit(EXIT_FAILURE); } } // An easy example of a tetrahedron and its remeshed version. -void remeshing_tetrahedon_example( - const double error_bound, const bool save = false) { - +void remeshing_tetrahedon_example(const double error_bound, + const bool save = true) +{ Timer timer; Surface_mesh mesh1, mesh2; std::cout << std::endl << "* (E1) remeshing Tetrahedron example:" << std::endl; - CGAL::make_tetrahedron( - Point_3(0, 0, 0), Point_3(2, 0, 0), - Point_3(1, 1, 1), Point_3(1, 0, 2), mesh1); + CGAL::make_tetrahedron(Point_3(0, 0, 0), Point_3(2, 0, 0), + Point_3(1, 1, 1), Point_3(1, 0, 2), mesh1); mesh2 = mesh1; using edge_descriptor = typename boost::graph_traits::edge_descriptor; Surface_mesh::Property_map is_constrained_map = mesh2.add_property_map("e:is_constrained", true).first; - const double target_edge_length = 0.05; - PMP::isotropic_remeshing( - mesh2.faces(), target_edge_length, mesh2, - PMP::parameters::edge_is_constrained_map(is_constrained_map)); + const double target_edge_length = 0.1; + PMP::isotropic_remeshing(mesh2.faces(), target_edge_length, mesh2, + CGAL::parameters::edge_is_constrained_map(is_constrained_map)); - if (save) save_mesh(mesh1, "mesh1"); - if (save) save_mesh(mesh2, "mesh2"); + std::cout << "Mesh1: " << num_vertices(mesh1) << " nv " << num_faces(mesh1) << " nf" << std::endl; + std::cout << "Mesh2: " << vertices(mesh2).size() << " nv " << faces(mesh2).size() << " nf" << std::endl; + + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } timer.reset(); timer.start(); @@ -139,14 +197,13 @@ void remeshing_tetrahedon_example( std::cout << "* bounded-error Hausdorff distance: " << hdist << std::endl; timer.stop(); std::cout << "* processing time: " << timer.time() << " s." << std::endl; - assert(hdist == error_bound); + assert(hdist <= error_bound); // real theoretical distance is 0 } -// Example with a point realizing the Hausdorff distance strictly -// lying in the interior of a triangle. -void interior_triangle_example( - const double error_bound, const bool save = false) { - +// Example with a point realizing the Hausdorff distance strictly lying in the interior of a triangle. +void interior_triangle_example(const double error_bound, + const bool save = true) +{ Timer timer; Surface_mesh mesh1, mesh2; std::cout << std::endl << "* (E2) interior Triangle example:" << std::endl; @@ -162,56 +219,66 @@ void interior_triangle_example( auto v3 = mesh2.add_vertex(Point_3( 0.0, 1, -1)); auto v4 = mesh2.add_vertex(Point_3(-0.5, 0, -1)); auto v5 = mesh2.add_vertex(Point_3( 0.5, 0, -1)); - mesh2.add_face(v0, v3, v4); - mesh2.add_face(v1, v4, v5); - mesh2.add_face(v2, v5, v3); + mesh2.add_face(v3, v4, v5); + mesh2.add_face(v0, v4, v3); + mesh2.add_face(v1, v5, v4); + mesh2.add_face(v2, v3, v5); - if (save) save_mesh(mesh1, "mesh1"); - if (save) save_mesh(mesh2, "mesh2"); + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } timer.reset(); timer.start(); const double hdist = PMP::bounded_error_Hausdorff_distance(mesh1, mesh2, error_bound); - std::cout << "* bounded-error Hausdorff distance: " << hdist << std::endl; timer.stop(); + std::cout << "* bounded-error Hausdorff distance: " << hdist << std::endl; std::cout << "* processing time: " << timer.time() << " s." << std::endl; - assert(hdist >= 1.0); + + assert(1.59168 < hdist && hdist < 1.59169); } // Read a real mesh given by the user, perturb it slightly, and compute the // Hausdorff distance between the original mesh and its pertubation. -void perturbing_surface_mesh_example( - const std::string filepath, const double error_bound, const bool save = false) { - - Timer timer; +void perturbing_surface_mesh_example(const std::string& filepath, + const double error_bound, + const bool save = true) +{ std::cout << std::endl << "* (E3) perturbing Surface Mesh example:" << std::endl; Surface_mesh mesh1, mesh2; get_meshes(filepath, filepath, mesh1, mesh2); const double max_size = 0.1; - PMP::random_perturbation( - mesh2.vertices(), mesh2, max_size, CGAL::parameters::do_project(false)); - std::cout << "* perturbing the second mesh" << std::endl; + std::cout << "* perturbing the second mesh; max_size: " << max_size << std::endl; + PMP::random_perturbation(mesh2.vertices(), mesh2, max_size, CGAL::parameters::do_project(false) + .random_seed(0)); - if (save) save_mesh(mesh2, "mesh2"); + if(save) + { + save_mesh(mesh2, "mesh1"); + save_mesh(mesh1, "mesh2"); + } - timer.reset(); + Timer timer; timer.start(); const double hdist = PMP::bounded_error_Hausdorff_distance(mesh1, mesh2, error_bound); - std::cout << "* bounded-error Hausdorff distance: " << hdist << std::endl; timer.stop(); + std::cout << "* bounded-error Hausdorff distance: " << hdist << std::endl; std::cout << "* processing time: " << timer.time() << " s." << std::endl; - assert(hdist > 0.0); + + assert(hdist > 0. && hdist <= max_size); } // Read two meshes and store them in two different face graph containers, // perturb the second mesh, and compute the Hausdorff distance. -void perturbing_polyhedron_mesh_example( - const std::string filepath, const double error_bound) { - - Timer timer; - std::cout << std::endl << "* (E3) perturbing Polyhedron mesh example:" << std::endl; +void perturbing_polyhedron_mesh_example(const std::string& filepath, + const double error_bound, + const bool save = true) +{ + std::cout << std::endl << "* (E3 bis) perturbing Polyhedron mesh example:" << std::endl; Surface_mesh mesh1; Polyhedron mesh2; @@ -219,72 +286,88 @@ void perturbing_polyhedron_mesh_example( get_mesh(filepath, mesh2); const double max_size = 0.1; - PMP::random_perturbation( - vertices(mesh2), mesh2, max_size, CGAL::parameters::do_project(false)); - std::cout << "* perturbing the second mesh" << std::endl; + std::cout << "* perturbing the second mesh; max_size: " << max_size << std::endl; + PMP::random_perturbation(vertices(mesh2), mesh2, max_size, CGAL::parameters::do_project(false) + .random_seed(0)); - timer.reset(); + if(save) + { + save_mesh(mesh2, "mesh1"); + save_mesh(mesh1, "mesh2"); + } + + Timer timer; timer.start(); const double hdist1 = PMP::bounded_error_Hausdorff_distance(mesh1, mesh2, error_bound); - const double hdist2 = PMP::bounded_error_Hausdorff_distance(mesh2, mesh1, error_bound); std::cout << "* bounded-error Hausdorff distance 1->2: " << hdist1 << std::endl; + const double hdist2 = PMP::bounded_error_Hausdorff_distance(mesh2, mesh1, error_bound); std::cout << "* bounded-error Hausdorff distance 2->1: " << hdist2 << std::endl; timer.stop(); std::cout << "* processing time: " << timer.time() << " s." << std::endl; - assert(hdist1 > 0.0); - assert(hdist2 > 0.0); + assert(hdist1 > 0. && hdist1 <= max_size); + assert(hdist2 > 0.); assert(hdist2 > hdist1); const double hdist3 = PMP::bounded_error_symmetric_Hausdorff_distance(mesh1, mesh2, error_bound); + std::cout << "* symmetric bounded-error Hausdorff distance: " << hdist3 << std::endl; assert(hdist3 == (CGAL::max)(hdist1, hdist2)); } // Read two meshes given by the user, initially place them at their originally // given position. Move the second mesh in 300 steps away from the first one. // Print how the Hausdorff distance changes. -void moving_surface_mesh_example( - const std::string filepath1, const std::string filepath2, - const std::size_t n, const double error_bound, const bool save = false) { - +void moving_surface_mesh_example(const std::string& filepath1, + const std::string& filepath2, + const std::size_t n, + const double error_bound, + const bool save = true) +{ Timer timer; std::cout << std::endl << "* (E4) moving Surface Mesh example:" << std::endl; Surface_mesh mesh1, mesh2; get_meshes(filepath1, filepath2, mesh1, mesh2); - const auto bbox = PMP::bbox(mesh2); - const FT distance = CGAL::approximate_sqrt(CGAL::squared_distance( - Point_3(bbox.xmin(), bbox.ymin(), bbox.zmin()), - Point_3(bbox.xmax(), bbox.ymax(), bbox.zmax()))); + const CGAL::Bbox_3 bbox = PMP::bbox(mesh2); + const FT distance = CGAL::approximate_sqrt(CGAL::squared_distance(Point_3(bbox.xmin(), bbox.ymin(), bbox.zmin()), + Point_3(bbox.xmax(), bbox.ymax(), bbox.zmax()))); + + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } const FT t = FT(1) / FT(100); - if (save) save_mesh(mesh2, "mesh-0"); + const FT a = t * distance; + const Vector_3 v(a, a, a); + const FT vl = std::sqrt(3) * t * distance; - double curr_dist = 0.0; - for (std::size_t i = 0; i < n; ++i) { - PMP::transform(Affine_transformation_3(CGAL::Translation(), - Vector_3(t * distance, t * distance, t * distance)), mesh2); + for(std::size_t i=0; i(mesh1, mesh2, error_bound); - std::cout << "* position: " << i << std::endl; - std::cout << "* bounded-error Hausdorff distance: " << hdist << std::endl; timer.stop(); + std::cout << "* position: " << i << " translation distance: " << (i+1) * vl << std::endl; + std::cout << "* bounded-error Hausdorff distance: " << hdist << std::endl; std::cout << "* processing time: " << timer.time() << " s." << std::endl; - if (save) save_mesh(mesh2, "mesh-" + std::to_string(i + 1)); - assert(hdist > curr_dist); - curr_dist = hdist; + const FT l = (i+1) * vl - error_bound, u = (i+1) * vl + error_bound; + assert(hdist >= l && hdist <= u); } } template -void test_0(const FunctionWrapper& functor, const bool save = false) { - +void test_0(const FunctionWrapper& functor, + const bool save = true) +{ // The same triangle. // Expected distance is 0. - std::cout.precision(20); Surface_mesh mesh1, mesh2; std::cout << " ---- testing 0 ---- " << std::endl; @@ -292,32 +375,35 @@ void test_0(const FunctionWrapper& functor, const bool save = false) { mesh1.add_vertex(Point_3(2, 0, 0)); mesh1.add_vertex(Point_3(1, 1, 0)); mesh1.add_face(mesh1.vertices()); - if (save) save_mesh(mesh1, "mesh1"); - mesh2 = mesh1; - if (save) save_mesh(mesh2, "mesh2"); + + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } const double dista = functor(mesh1, mesh2); const double distb = functor(mesh2, mesh1); - const double naive = (CGAL::max)(dista, distb); + const double disto = (CGAL::max)(dista, distb); const double distc = functor.symmetric(mesh1, mesh2); std::cout << "* Hausdorff distance (expected 0): " << dista << std::endl; std::cout << "* HInverted distance (expected 0): " << distb << std::endl; std::cout << "* Symmetric distance (expected 0): " << distc << std::endl; - assert(dista == 0.0); - assert(distb == 0.0); - assert(distc == naive); + assert(functor.check_value(dista, 0)); + assert(functor.check_value(distb, 0)); + assert(functor.check_value(disto, distc)); } template -void test_1(const FunctionWrapper& functor, const bool save = false) { - - // Two triangles are parallel and 1 unit distance away from each other. +void test_1(const FunctionWrapper& functor, + const bool save = true) +{ + // Two parallel triangles, 1 unit distance away from each other. // Expected distance is 1. - std::cout.precision(20); Surface_mesh mesh1, mesh2; std::cout << " ---- testing 1 ---- " << std::endl; @@ -325,35 +411,39 @@ void test_1(const FunctionWrapper& functor, const bool save = false) { mesh1.add_vertex(Point_3(2, 0, 0)); mesh1.add_vertex(Point_3(1, 1, 0)); mesh1.add_face(mesh1.vertices()); - if (save) save_mesh(mesh1, "mesh1"); mesh2.add_vertex(Point_3(0, 0, 1)); mesh2.add_vertex(Point_3(2, 0, 1)); mesh2.add_vertex(Point_3(1, 1, 1)); mesh2.add_face(mesh2.vertices()); - if (save) save_mesh(mesh2, "mesh2"); + + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } const double dista = functor(mesh1, mesh2); const double distb = functor(mesh2, mesh1); - const double naive = (CGAL::max)(dista, distb); + const double disto = (CGAL::max)(dista, distb); const double distc = functor.symmetric(mesh1, mesh2); std::cout << "* Hausdorff distance (expected 1): " << dista << std::endl; std::cout << "* HInverted distance (expected 1): " << distb << std::endl; std::cout << "* Symmetric distance (expected 1): " << distc << std::endl; - assert(dista == 1.0); - assert(distb == 1.0); - assert(distc == naive); + assert(functor.check_value(dista, 1.)); + assert(functor.check_value(distb, 1.)); + assert(functor.check_value(disto, distc)); } template -void test_2(const FunctionWrapper& functor, const bool save = false) { - +void test_2(const FunctionWrapper& functor, + const bool save = true) +{ // One triangle is orthogonal to the other one and shares a common edge. // Expected distance is 1. - std::cout.precision(20); Surface_mesh mesh1, mesh2; std::cout << " ---- testing 2 ---- " << std::endl; @@ -361,36 +451,40 @@ void test_2(const FunctionWrapper& functor, const bool save = false) { mesh1.add_vertex(Point_3(2, 0, 0)); mesh1.add_vertex(Point_3(1, 1, 0)); mesh1.add_face(mesh1.vertices()); - if (save) save_mesh(mesh1, "mesh1"); mesh2.add_vertex(Point_3(0, 0, 0)); mesh2.add_vertex(Point_3(2, 0, 0)); mesh2.add_vertex(Point_3(1, 0, 1)); mesh2.add_face(mesh2.vertices()); - if (save) save_mesh(mesh2, "mesh2"); + + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } const double dista = functor(mesh1, mesh2); const double distb = functor(mesh2, mesh1); - const double naive = (CGAL::max)(dista, distb); + const double disto = (CGAL::max)(dista, distb); const double distc = functor.symmetric(mesh1, mesh2); std::cout << "* Hausdorff distance (expected 1): " << dista << std::endl; std::cout << "* HInverted distance (expected 1): " << distb << std::endl; std::cout << "* Symmetric distance (expected 1): " << distc << std::endl; - assert(dista == 1.0); - assert(distb == 1.0); - assert(distc == naive); + assert(functor.check_value(dista, 1.)); + assert(functor.check_value(distb, 1.)); + assert(functor.check_value(disto, distc)); } template -void test_3(const FunctionWrapper& functor, const bool save = false) { - +void test_3(const FunctionWrapper& functor, + const bool save = true) +{ // One triangle is orthogonal to the other one and shares a common edge // that is moved 1 unit distance away. - // Expected distances are sqrt(2) and 2. + // Expected distances are 2 and sqrt(2) ~= 1.4142135623730951. - std::cout.precision(20); Surface_mesh mesh1, mesh2; std::cout << " ---- testing 3 ---- " << std::endl; @@ -398,35 +492,39 @@ void test_3(const FunctionWrapper& functor, const bool save = false) { mesh1.add_vertex(Point_3(2, 0, 0)); mesh1.add_vertex(Point_3(1, 1, 0)); mesh1.add_face(mesh1.vertices()); - if (save) save_mesh(mesh1, "mesh1"); mesh2.add_vertex(Point_3(0, 0, 1)); mesh2.add_vertex(Point_3(2, 0, 1)); mesh2.add_vertex(Point_3(1, 0, 2)); mesh2.add_face(mesh2.vertices()); - if (save) save_mesh(mesh2, "mesh2"); + + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } const double dista = functor(mesh1, mesh2); const double distb = functor(mesh2, mesh1); - const double naive = (CGAL::max)(dista, distb); + const double disto = (CGAL::max)(dista, distb); const double distc = functor.symmetric(mesh1, mesh2); - std::cout << "* Hausdorff distance (expected sqrt(2)): " << dista << std::endl; - std::cout << "* HInverted distance (expected 2 ): " << distb << std::endl; - std::cout << "* Symmetric distance (expected 2 ): " << distc << std::endl; + std::cout << "* Hausdorff distance (expected 1.4142135623730951): " << dista << std::endl; + std::cout << "* HInverted distance (expected 2): " << distb << std::endl; + std::cout << "* Symmetric distance (expected 2): " << distc << std::endl; - assert(CGAL::abs(dista - CGAL::sqrt(2.0)) < 1e-5); // error bound is 1e-4 - assert(distb == 2.0); - assert(distc == naive); + assert(functor.check_value(dista, std::sqrt(2.))); + assert(functor.check_value(distb, 2.)); + assert(functor.check_value(disto, distc)); } template -void test_4(const FunctionWrapper& functor, const bool save = false) { - +void test_4(const FunctionWrapper& functor, + const bool save = true) +{ // One triangle is orthogonal to the other one and shares a common vertex. - // Expected distance is 1.2247448713915889407. + // Expected distance is std::sqrt(2) * std::sin(60°) ~= 1.2247448713915892 - std::cout.precision(20); Surface_mesh mesh1, mesh2; std::cout << " ---- testing 4 ---- " << std::endl; @@ -434,37 +532,39 @@ void test_4(const FunctionWrapper& functor, const bool save = false) { mesh1.add_vertex(Point_3(2, 0, 0)); mesh1.add_vertex(Point_3(1, 1, 0)); mesh1.add_face(mesh1.vertices()); - if (save) save_mesh(mesh1, "mesh1"); mesh2.add_vertex(Point_3(0, 1, 1)); mesh2.add_vertex(Point_3(2, 1, 1)); mesh2.add_vertex(Point_3(1, 1, 0)); mesh2.add_face(mesh2.vertices()); - if (save) save_mesh(mesh2, "mesh2"); + + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } const double dista = functor(mesh1, mesh2); const double distb = functor(mesh2, mesh1); - const double naive = (CGAL::max)(dista, distb); + const double disto = (CGAL::max)(dista, distb); const double distc = functor.symmetric(mesh1, mesh2); - std::cout << "* Hausdorff distance (expected 1.22): " << dista << std::endl; - std::cout << "* HInverted distance (expected 1.22): " << distb << std::endl; - std::cout << "* Symmetric distance (expected 1.22): " << distc << std::endl; + std::cout << "* Hausdorff distance (expected 1.2247448713915892): " << dista << std::endl; + std::cout << "* HInverted distance (expected 1.2247448713915892): " << distb << std::endl; + std::cout << "* Symmetric distance (expected 1.2247448713915892): " << distc << std::endl; - assert(CGAL::abs(dista - 1.224744) < 1e-5); // error bound is 1e-4 - assert(CGAL::abs(distb - 1.224744) < 1e-5); // error bound is 1e-4 - assert(dista == distb); - assert(distc == naive); + assert(functor.check_value(dista, 1.2247448713915892)); + assert(functor.check_value(distb, 1.2247448713915892)); + assert(functor.check_value(disto, distc)); } template -void test_5(const FunctionWrapper& functor, const bool save = false) { +void test_5(const FunctionWrapper& functor, const bool save = true) { // One triangle is orthogonal to the other one and shares a common vertex // that is moved 1 unit distance away. - // Expected distances are 1.7320508075688771932 and 2.1213203435596423851. + // Expected distances are sqrt(3) ~= 1.7320508075688771 and sqrt(4.5) ~= 2.1213203435596423. - std::cout.precision(20); Surface_mesh mesh1, mesh2; std::cout << " ---- testing 5 ---- " << std::endl; @@ -472,36 +572,40 @@ void test_5(const FunctionWrapper& functor, const bool save = false) { mesh1.add_vertex(Point_3(2, 0, 0)); mesh1.add_vertex(Point_3(1, 1, 0)); mesh1.add_face(mesh1.vertices()); - if (save) save_mesh(mesh1, "mesh1"); mesh2.add_vertex(Point_3(0, 1, 2)); mesh2.add_vertex(Point_3(2, 1, 2)); mesh2.add_vertex(Point_3(1, 1, 1)); mesh2.add_face(mesh2.vertices()); - if (save) save_mesh(mesh2, "mesh2"); + + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } const double dista = functor(mesh1, mesh2); const double distb = functor(mesh2, mesh1); - const double naive = (CGAL::max)(dista, distb); + const double disto = (CGAL::max)(dista, distb); const double distc = functor.symmetric(mesh1, mesh2); - std::cout << "* Hausdorff distance (expected 1.73): " << dista << std::endl; - std::cout << "* HInverted distance (expected 2.12): " << distb << std::endl; - std::cout << "* Symmetric distance (expected 2.12): " << distc << std::endl; + std::cout << "* Hausdorff distance (expected 1.7320508075688771): " << dista << std::endl; + std::cout << "* HInverted distance (expected 2.1213203435596423): " << distb << std::endl; + std::cout << "* Symmetric distance (expected 2.1213203435596423): " << distc << std::endl; - assert(CGAL::abs(dista - 1.732050) < 1e-5); // error bound is 1e-4 - assert(CGAL::abs(distb - 2.121320) < 1e-5); // error bound is 1e-4 - assert(distc == naive); + assert(functor.check_value(dista, 1.7320508075688771)); + assert(functor.check_value(distb, 2.1213203435596423)); + assert(functor.check_value(disto, distc)); } template -void test_6(const FunctionWrapper& functor, const bool save = false) { - +void test_6(const FunctionWrapper& functor, + const bool save = true) +{ // The first and second mesh have different number of triangles. - // They are parallel and lie at the same plane. The middle triangle is overlapping. - // Expected distances are 0 and 0.70710678118654757274. + // They are parallel and lie in the same plane. The middle triangle is common to both meshes. + // Expected distances are 0 and 1/sqrt(2) ~=0.70710678118654746. - std::cout.precision(20); Surface_mesh mesh1, mesh2; std::cout << " ---- testing 6 ---- " << std::endl; @@ -509,7 +613,6 @@ void test_6(const FunctionWrapper& functor, const bool save = false) { mesh1.add_vertex(Point_3(2, 0, 0)); mesh1.add_vertex(Point_3(1, 1, 0)); mesh1.add_face(mesh1.vertices()); - if (save) save_mesh(mesh1, "mesh1"); const auto v0 = mesh2.add_vertex(Point_3(0, 0, 0)); const auto v1 = mesh2.add_vertex(Point_3(2, 0, 0)); @@ -520,30 +623,35 @@ void test_6(const FunctionWrapper& functor, const bool save = false) { mesh2.add_face(v0, v1, v2); mesh2.add_face(v2, v1, v3); mesh2.add_face(v0, v2, v4); - if (save) save_mesh(mesh2, "mesh2"); + + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } const double dista = functor(mesh1, mesh2); const double distb = functor(mesh2, mesh1); - const double naive = (CGAL::max)(dista, distb); + const double disto = (CGAL::max)(dista, distb); const double distc = functor.symmetric(mesh1, mesh2); - std::cout << "* Hausdorff distance (expected 0.0): " << dista << std::endl; - std::cout << "* HInverted distance (expected 0.7): " << distb << std::endl; - std::cout << "* Symmetric distance (expected 0.7): " << distc << std::endl; + std::cout << "* Hausdorff distance (expected 0): " << dista << std::endl; + std::cout << "* HInverted distance (expected 0.70710678118654746): " << distb << std::endl; + std::cout << "* Symmetric distance (expected 0.70710678118654746): " << distc << std::endl; - assert(dista == 0.0); - assert(CGAL::abs(distb - 0.707106) < 1e-5); // error bound is 1e-4 - assert(distc == naive); + assert(functor.check_value(dista, 0.)); + assert(functor.check_value(distb, 0.70710678118654746)); + assert(functor.check_value(disto, distc)); } template -void test_7(const FunctionWrapper& functor, const bool save = false) { - +void test_7(const FunctionWrapper& functor, + const bool save = true) +{ // One triangle is moved to 0.5 unit distance away from 3 other triangles. // The first and second meshes are parallel. - // Expected distances are 0.5 and 0.86602540378443859659. + // Expected distances are 0.5 and sqrt(0.75) ~= 0.8660254037844386. - std::cout.precision(20); Surface_mesh mesh1, mesh2; std::cout << " ---- testing 7 ---- " << std::endl; @@ -551,41 +659,44 @@ void test_7(const FunctionWrapper& functor, const bool save = false) { mesh1.add_vertex(Point_3(2, 0, 0)); mesh1.add_vertex(Point_3(1, 1, 0)); mesh1.add_face(mesh1.vertices()); - if (save) save_mesh(mesh1, "mesh1"); const auto v0 = mesh2.add_vertex(Point_3(0, 0, 0.5)); const auto v1 = mesh2.add_vertex(Point_3(2, 0, 0.5)); const auto v2 = mesh2.add_vertex(Point_3(1, 1, 0.5)); const auto v3 = mesh2.add_vertex(Point_3(2, 1, 0.5)); const auto v4 = mesh2.add_vertex(Point_3(0, 1, 0.5)); - mesh2.add_face(v0, v1, v2); mesh2.add_face(v2, v1, v3); mesh2.add_face(v0, v2, v4); - if (save) save_mesh(mesh2, "mesh2"); + + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } const double dista = functor(mesh1, mesh2); const double distb = functor(mesh2, mesh1); - const double naive = (CGAL::max)(dista, distb); + const double disto = (CGAL::max)(dista, distb); const double distc = functor.symmetric(mesh1, mesh2); - std::cout << "* Hausdorff distance (expected 0.50): " << dista << std::endl; - std::cout << "* HInverted distance (expected 0.86): " << distb << std::endl; - std::cout << "* Symmetric distance (expected 0.86): " << distc << std::endl; + std::cout << "* Hausdorff distance (expected 0.5): " << dista << std::endl; + std::cout << "* HInverted distance (expected 0.8660254037844386): " << distb << std::endl; + std::cout << "* Symmetric distance (expected 0.8660254037844386): " << distc << std::endl; - assert(dista == 0.5); - assert(CGAL::abs(distb - 0.866025) < 1e-5); // error bound is 1e-4 - assert(distc == naive); + assert(functor.check_value(dista, 0.5)); + assert(functor.check_value(distb, 0.8660254037844386)); + assert(functor.check_value(disto, distc)); } template -void test_8(const FunctionWrapper& functor, const bool save = false) { - +void test_8(const FunctionWrapper& functor, + const bool save = true) +{ // One mesh has one triangle at zero level, another mesh has two triangles // where the first one is at level 1 and the second one is at level 2. // Expected distances are 1 and 2. - std::cout.precision(20); Surface_mesh mesh1, mesh2; std::cout << " ---- testing 8 ---- " << std::endl; @@ -593,7 +704,6 @@ void test_8(const FunctionWrapper& functor, const bool save = false) { mesh1.add_vertex(Point_3(2, 0, 0)); mesh1.add_vertex(Point_3(1, 1, 0)); mesh1.add_face(mesh1.vertices()); - if (save) save_mesh(mesh1, "mesh1"); const auto v0 = mesh2.add_vertex(Point_3(0, 0, 1)); const auto v1 = mesh2.add_vertex(Point_3(2, 0, 1)); @@ -601,33 +711,37 @@ void test_8(const FunctionWrapper& functor, const bool save = false) { const auto v3 = mesh2.add_vertex(Point_3(0, 0, 2)); const auto v4 = mesh2.add_vertex(Point_3(2, 0, 2)); const auto v5 = mesh2.add_vertex(Point_3(1, 1, 2)); - mesh2.add_face(v0, v1, v2); mesh2.add_face(v3, v4, v5); - if (save) save_mesh(mesh2, "mesh2"); + + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } const double dista = functor(mesh1, mesh2); const double distb = functor(mesh2, mesh1); - const double naive = (CGAL::max)(dista, distb); + const double disto = (CGAL::max)(dista, distb); const double distc = functor.symmetric(mesh1, mesh2); std::cout << "* Hausdorff distance (expected 1): " << dista << std::endl; std::cout << "* HInverted distance (expected 2): " << distb << std::endl; std::cout << "* Symmetric distance (expected 2): " << distc << std::endl; - assert(dista == 1.0); - assert(distb == 2.0); - assert(distc == naive); + assert(functor.check_value(dista, 1.)); + assert(functor.check_value(distb, 2.)); + assert(functor.check_value(disto, distc)); } template -void test_9(const FunctionWrapper& functor, const bool save = false) { - +void test_9(const FunctionWrapper& functor, + const bool save = true) +{ // Two meshes partially overlap, have 2 triangles in common and each one has // two its own trianles. All triangles form a Z shape where the height is 1. // The expected result is 1. - std::cout.precision(20); Surface_mesh mesh1, mesh2; std::cout << " ---- testing 9 ---- " << std::endl; @@ -641,7 +755,6 @@ void test_9(const FunctionWrapper& functor, const bool save = false) { mesh1.add_face(v2, v1, v3); mesh1.add_face(v1, v4, v3); mesh1.add_face(v3, v4, v5); - if (save) save_mesh(mesh1, "mesh1"); v0 = mesh2.add_vertex(Point_3(2, 0, 1)); v1 = mesh2.add_vertex(Point_3(1, 0, 0)); @@ -653,25 +766,30 @@ void test_9(const FunctionWrapper& functor, const bool save = false) { mesh2.add_face(v3, v4, v5); mesh2.add_face(v4, v0, v5); mesh2.add_face(v5, v0, v2); - if (save) save_mesh(mesh2, "mesh2"); + + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } const double dista = functor(mesh1, mesh2); const double distb = functor(mesh2, mesh1); - const double naive = (CGAL::max)(dista, distb); + const double disto = (CGAL::max)(dista, distb); const double distc = functor.symmetric(mesh1, mesh2); std::cout << "* Hausdorff distance (expected 1): " << dista << std::endl; std::cout << "* HInverted distance (expected 1): " << distb << std::endl; std::cout << "* Symmetric distance (expected 1): " << distc << std::endl; - assert(dista == 1.0); - assert(distb == 1.0); - assert(distc == naive); + assert(functor.check_value(dista, 1.)); + assert(functor.check_value(distb, 1.)); + assert(functor.check_value(disto, distc)); } template -void test_synthetic_data(const FunctionWrapper& functor) { - +void test_synthetic_data(const FunctionWrapper& functor) +{ std::cout << std::endl << "-- test synthetic data:" << std::endl << std::endl; std::cout << "* name -> " << functor.name() << std::endl; @@ -687,14 +805,12 @@ void test_synthetic_data(const FunctionWrapper& functor) { test_9(functor); // overlapping } -template< -typename FunctionWrapper1, -typename FunctionWrapper2> -void test_one_versus_another( - const FunctionWrapper1& functor1, - const FunctionWrapper2& functor2) { - - std::cout.precision(20); +template +void test_one_versus_another(const FunctionWrapper1& functor1, + const FunctionWrapper2& functor2, + const double error_bound) +{ const std::string filepath1 = "data/tetrahedron.off"; const std::string filepath2 = "data/tetrahedron-remeshed.off"; @@ -710,287 +826,126 @@ void test_one_versus_another( // The expected distance is 0. std::cout << " ---- testing 0 ---- " << std::endl; const double dista0 = functor1(mesh1, mesh2); - const double distb0 = functor2(mesh1, mesh2); std::cout << "* Hausdorff distance1: " << dista0 << std::endl; + const double distb0 = functor2(mesh1, mesh2); std::cout << "* Hausdorff distance2: " << distb0 << std::endl; + assert(dista0 <= error_bound); + assert(distb0 <= error_bound); - std::cout << "* traslating by 1 unit ..." << std::endl; - PMP::transform(Affine_transformation_3(CGAL::Translation(), - Vector_3(FT(0), FT(0), FT(1))), mesh2); + std::cout << "* translating by 1 unit ..." << std::endl; + PMP::transform(Affine_transformation_3(CGAL::Translation(), Vector_3(FT(0), FT(0), FT(1))), mesh2); // TEST 1. // Translate by 1 unit distance and compare. // The expected distance is 1. std::cout << " ---- testing 1 ---- " << std::endl; const double dista1 = functor1(mesh1, mesh2); - const double distb1 = functor2(mesh1, mesh2); std::cout << "* Hausdorff distance1: " << dista1 << std::endl; + const double distb1 = functor2(mesh1, mesh2); std::cout << "* Hausdorff distance2: " << distb1 << std::endl; - assert(CGAL::abs(dista0 - distb0) < 1e-3); // error bound is 1e-4 - assert(CGAL::abs(dista1 - distb1) < 1e-3); // error bound is 1e-4 + assert(std::abs(dista0 - distb0) <= 2. * error_bound); + assert(std::abs(dista1 - distb1) <= 2. * error_bound); } -template< -typename FunctionWrapper1, -typename FunctionWrapper2> -void test_real_meshes( - const std::string filepath1, - const std::string filepath2, - const FunctionWrapper1& functor1, - const FunctionWrapper2& functor2) { - - std::cout.precision(20); +template +void test_real_meshes(const std::string& filepath1, + const std::string& filepath2, + const FunctionWrapper1& functor1, + const FunctionWrapper2& functor2, + const double error_bound) +{ std::cout << std::endl << "-- test real meshes:" << std::endl << std::endl; + std::cout << "* name 1 -> " << functor1.name() << std::endl; + std::cout << "* name 2 -> " << functor2.name() << std::endl; std::cout << "* input path 1: " << filepath1 << std::endl; std::cout << "* input path 2: " << filepath2 << std::endl; Surface_mesh mesh1, mesh2; get_meshes(filepath1, filepath2, mesh1, mesh2); - std::cout << std::endl; - std::cout << "* name 1 -> " << functor1.name() << std::endl; - std::cout << "* name 2 -> " << functor2.name() << std::endl; - // Load and compare. - std::cout << std::endl; - std::cout << " ---- testing ---- " << std::endl; - const double dista0 = functor1(mesh1, mesh2); - const double dista1 = functor1(mesh2, mesh1); - const double distb0 = functor2(mesh1, mesh2); - const double distb1 = functor2(mesh2, mesh1); - std::cout << std::endl; - std::cout << "* Hausdorff distance1 f: " << dista0 << std::endl; - std::cout << "* Hausdorff distance1 b: " << dista1 << std::endl; - std::cout << std::endl; - std::cout << "* Hausdorff distance2 f: " << distb0 << std::endl; - std::cout << "* Hausdorff distance2 b: " << distb1 << std::endl; - - assert(CGAL::abs(dista0 - distb0) < 1e-3); // error bound is 1e-4 - assert(CGAL::abs(dista1 - distb1) < 1e-3); // error bound is 1e-4 -} - -template -void test_timings(const std::string filepath, const FunctionWrapper& functor) { - - std::cout.precision(20); - std::cout << std::endl << "-- test timings: " << functor.name() << std::endl << std::endl; - - Timer timer; - Surface_mesh mesh1, mesh2; - get_mesh(filepath, mesh1); - PMP::isotropic_remeshing(faces(mesh1), 0.005, mesh1); - mesh1.collect_garbage(); - mesh2 = mesh1; - - timer.reset(); - timer.start(); - const double dista1 = functor(mesh1, mesh2); - timer.stop(); - double timea = timer.time(); - - timer.reset(); - timer.start(); - const double distb1 = functor(mesh2, mesh1); - timer.stop(); - double timeb = timer.time(); - - timer.reset(); - timer.start(); - const double distc1 = functor.symmetric(mesh1, mesh2); - timer.stop(); - double timeab = timer.time(); - - std::cout << "* time a1 (sec.): " << timea << std::endl; - std::cout << "* time b1 (sec.): " << timeb << std::endl; - std::cout << "* time ab1 naive (sec.): " << timea + timeb << std::endl; - std::cout << "* time ab1 optimized (sec.): " << timeab << std::endl; - - assert(timea > 0.0); - assert(timeb > 0.0); - - // If the machine is loaded, this assert may go false. - // assert(timeab < timea + timeb); - - PMP::transform(Affine_transformation_3(CGAL::Translation(), - Vector_3(FT(0), FT(0), FT(1))), mesh2); - - timer.reset(); - timer.start(); - const double dista2 = functor(mesh1, mesh2); - timer.stop(); - timea = timer.time(); - - timer.reset(); - timer.start(); - const double distb2 = functor(mesh2, mesh1); - timer.stop(); - timeb = timer.time(); - - timer.reset(); - timer.start(); - const double distc2 = functor.symmetric(mesh1, mesh2); - timer.stop(); - timeab = timer.time(); - - std::cout << "* time a2 (sec.): " << timea << std::endl; - std::cout << "* time b2 (sec.): " << timeb << std::endl; - std::cout << "* time ab2 naive (sec.): " << timea + timeb << std::endl; - std::cout << "* time ab2 optimized (sec.): " << timeab << std::endl; - - assert(timea > 0.0); - assert(timeb > 0.0); - - // If the machine is loaded, this assert may go false. - // assert(timeab < timea + timeb); - - std::cout << "* dista = " << dista1 << " , " << dista2 << std::endl; - std::cout << "* distb = " << distb1 << " , " << distb2 << std::endl; - std::cout << "* distab = " << distc1 << " , " << distc2 << std::endl; - - assert(dista1 == distb1 && distb1 == distc1); - assert(dista2 == distb2 && distb2 == distc2); -} - -template -void test_bunny( - const FunctionWrapper& functor, const int n = 5, const bool save = false) { - - std::cout.precision(20); - const std::string filepath1 = "data/bunny_16300.off"; // approx 16.3K - const std::string filepath2 = "data/bunny_69400.off"; // approx 69.4K - - std::cout << std::endl << "-- test bunny:" << std::endl << std::endl; - std::cout << "* name -> " << functor.name() << std::endl; - - Surface_mesh mesh1, mesh2; - get_meshes(filepath1, filepath2, mesh1, mesh2); - if (save) save_mesh(mesh1, "mesh1"); - if (save) save_mesh(mesh2, "mesh2"); - - // Get 3 times longest dimension. - const auto bbox = PMP::bbox(mesh2); - const FT dist1 = static_cast(CGAL::abs(bbox.xmax() - bbox.xmin())); - const FT dist2 = static_cast(CGAL::abs(bbox.ymax() - bbox.ymin())); - const FT dist3 = static_cast(CGAL::abs(bbox.zmax() - bbox.zmin())); - const FT dim = FT(3) * (CGAL::max)((CGAL::max)(dist1, dist2), dist3); - - // Get timings. - Timer timer; - std::vector times; - times.reserve(n); - - if (n == 0) { - - const FT distance = dim; - PMP::transform(Affine_transformation_3(CGAL::Translation(), - Vector_3(distance, distance, distance)), mesh2); - if (save) save_mesh(mesh2, "mesh2"); - timer.reset(); + auto run = [&](auto f, const Surface_mesh& m1, const Surface_mesh& m2) -> std::pair + { + Timer timer; timer.start(); - // const double dista = functor(mesh1, mesh2); - const double distb = functor(mesh2, mesh1); - const double distc = distb; // (CGAL::max)(dista, distb); + const double dist = f(m1, m2); timer.stop(); - times.push_back(timer.time()); - std::cout << "* distance / Hausdorff / time (sec.) : " << - distance << " / " << distc << " / " << times.back() << std::endl; - assert(distc > 0.0); + return std::make_pair(dist, timer.time()); + }; - } else { + double timea0, timeb0, timea1, timeb1; + double dista0, distb0, dista1, distb1; + std::tie(dista0, timea0) = run(functor1, mesh1, mesh2); + std::tie(distb0, timeb0) = run(functor2, mesh1, mesh2); + std::tie(dista1, timea1) = run(functor1, mesh2, mesh1); + std::tie(distb1, timeb1) = run(functor2, mesh2, mesh1); - // t is the step where n is the number of steps. - double curr_dist = 1.0; - const FT t = FT(1) / static_cast(n); - for (int k = n; k >= 0; --k) { - auto mesh = mesh2; - const FT distance = k * t * dim; - PMP::transform(Affine_transformation_3(CGAL::Translation(), - Vector_3(distance, distance, distance)), mesh); - if (save) save_mesh(mesh, "mesh2-" + std::to_string(k)); + std::cout << std::endl; + std::cout << "* Hausdorff distance1-2 " << functor1.name() << " dist " << dista0 << " runtime: " << timea0 << std::endl; + std::cout << "* Hausdorff distance1-2 " << functor2.name() << " dist " << distb0 << " runtime: " << timeb0 << std::endl; + std::cout << std::endl; + std::cout << "* Hausdorff distance2-1 " << functor1.name() << " dist " << dista1 << " runtime: " << timea1 << std::endl; + std::cout << "* Hausdorff distance2-1 " << functor2.name() << " dist " << distb1 << " runtime: " << timeb1 << std::endl; - timer.reset(); - timer.start(); - const double dista = functor(mesh1, mesh); - const double distb = functor(mesh, mesh1); - const double distc = (CGAL::max)(dista, distb); - timer.stop(); - times.push_back(timer.time()); - std::cout << "* distance / Hausdorff / time (sec.) " << k << " : " << - distance << " / " << distc << " / " << times.back() << std::endl; - assert(distc < curr_dist); - curr_dist = distc; - } - } - - double min_time = +std::numeric_limits::infinity(); - double max_time = -std::numeric_limits::infinity(); - double avg_time = 0.0; - for (const double time : times) { - min_time = (CGAL::min)(min_time, time); - max_time = (CGAL::max)(max_time, time); - avg_time += time; - } - avg_time /= static_cast(times.size()); - - std::cout << std::endl << "* timings (msec.): " << std::endl; - std::cout << "* avg time: " << avg_time * 1000.0 << std::endl; - std::cout << "* min time: " << min_time * 1000.0 << std::endl; - std::cout << "* max time: " << max_time * 1000.0 << std::endl; - - assert(min_time <= max_time); - assert(min_time <= avg_time); - assert(avg_time <= max_time); + assert(std::abs(dista0 - distb0) <= 2. * error_bound); + assert(std::abs(dista1 - distb1) <= 2. * error_bound); } -Triangle_3 get_triangle(const int index, const Surface_mesh& mesh) { - +Triangle_3 get_triangle(const int index, + const Surface_mesh& mesh) +{ const auto mfaces = faces(mesh); assert(index >= 0); assert(index < static_cast(mfaces.size())); - const auto face = *(mfaces.begin() + index); + const auto face = *(std::next(mfaces.begin(), index)); const auto he = halfedge(face, mesh); const auto vertices = vertices_around_face(he, mesh); assert(vertices.size() >= 3); + auto vit = vertices.begin(); - const auto& p0 = mesh.point(*vit); ++vit; - const auto& p1 = mesh.point(*vit); ++vit; - const auto& p2 = mesh.point(*vit); + const Point_3& p0 = mesh.point(*vit); ++vit; + const Point_3& p1 = mesh.point(*vit); ++vit; + const Point_3& p2 = mesh.point(*vit); + return Triangle_3(p0, p1, p2); } -void compute_realizing_triangles( - const Surface_mesh& mesh1, const Surface_mesh& mesh2, - const double error_bound, const std::string prefix, const bool save = false) { - +void compute_realizing_triangles(const Surface_mesh& mesh1, + const Surface_mesh& mesh2, + const double error_bound, + const int expected_f1, + const int expected_f2, + const std::string& prefix, + const bool save = true) +{ std::cout << "* getting realizing triangles: " << std::endl; std::vector< std::pair > fpairs; - const double hdist = - PMP::bounded_error_Hausdorff_distance(mesh1, mesh2, error_bound, - CGAL::parameters::output_iterator(std::back_inserter(fpairs))); + const double hdist = PMP::bounded_error_Hausdorff_distance( + mesh1, mesh2, error_bound, + CGAL::parameters::output_iterator(std::back_inserter(fpairs))); assert(fpairs.size() == 2); // lower bound face pair + upper bound face pair + const int f1 = static_cast(fpairs.back().first); // f1 / f2: upper bound const int f2 = static_cast(fpairs.back().second); std::cout << "* Hausdorff: " << hdist << std::endl; std::cout << "* f1 / f2: " << f1 << " / " << f2 << std::endl; + std::cout << "* expected f1 / f2: " << expected_f1 << " / " << expected_f2 << std::endl; - assert(f1 == 0); - assert(f2 == 0 || f2 == 161); - - if (f1 != -1 && save) { - const auto triangle = get_triangle(f1, mesh1); + if(save) + { + auto triangle = get_triangle(f1, mesh1); Surface_mesh sm1; sm1.add_vertex(triangle[0]); sm1.add_vertex(triangle[1]); sm1.add_vertex(triangle[2]); sm1.add_face(sm1.vertices()); save_mesh(sm1, prefix + "triangle1"); - } - if (f2 != -1 && save) { - const auto triangle = get_triangle(f2, mesh2); + triangle = get_triangle(f2, mesh2); Surface_mesh sm2; sm2.add_vertex(triangle[0]); sm2.add_vertex(triangle[1]); @@ -998,12 +953,14 @@ void compute_realizing_triangles( sm2.add_face(sm2.vertices()); save_mesh(sm2, prefix + "triangle2"); } + + assert(f1 == expected_f1); + assert(f2 == expected_f2); } -void test_realizing_triangles( - const double error_bound, const bool save = false) { - - std::cout.precision(20); +void test_realizing_triangles(const double error_bound, + const bool save = true) +{ std::cout << std::endl << "-- test realizing triangles:" << std::endl << std::endl; // Basic test. @@ -1015,66 +972,63 @@ void test_realizing_triangles( mesh1.add_vertex(Point_3(1, 1, 0)); mesh1.add_face(mesh1.vertices()); - mesh2.add_vertex(Point_3(0, 0, error_bound / 2.0)); - mesh2.add_vertex(Point_3(2, 0, error_bound / 2.0)); - mesh2.add_vertex(Point_3(1, 1, error_bound / 2.0)); + mesh2.add_vertex(Point_3(0, 0, error_bound / 2.)); + mesh2.add_vertex(Point_3(2, 0, error_bound / 2.)); + mesh2.add_vertex(Point_3(1, 1, error_bound / 2.)); mesh2.add_face(mesh2.vertices()); - if (save) save_mesh(mesh1, "1mesh1"); - if (save) save_mesh(mesh2, "1mesh2"); + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } - compute_realizing_triangles(mesh1, mesh2, error_bound, "1", save); + compute_realizing_triangles(mesh1, mesh2, error_bound, 0, 0, "1", save); - mesh2.clear(); - mesh2.add_vertex(Point_3(0, 0, 1)); - mesh2.add_vertex(Point_3(2, 0, 1)); - mesh2.add_vertex(Point_3(1, 1, 1)); - mesh2.add_face(mesh2.vertices()); - - if (save) save_mesh(mesh2, "1mesh2"); - compute_realizing_triangles(mesh1, mesh2, error_bound, "1", save); - - // Complex test. std::cout << std::endl << " ---- complex test ---- " << std::endl; - mesh1.clear(); - mesh2.clear(); - const std::string filepath1 = "data/tetrahedron.off"; - const std::string filepath2 = "data/tetrahedron-remeshed.off"; - - std::array vhs1 = { - mesh1.add_vertex(Point_3(0, 1, 3)), - mesh1.add_vertex(Point_3(1, 1, 3)), - mesh1.add_vertex(Point_3(1, 0, 3)) - }; - mesh1.add_face(vhs1); - - std::array vhs2 = { - mesh2.add_vertex(Point_3(0, 1, 3.5)), - mesh2.add_vertex(Point_3(1, 1, 3.5)), - mesh2.add_vertex(Point_3(1, 0, 3.5)) - }; - mesh2.add_face(vhs2); Surface_mesh tmp1,tmp2; - get_meshes(filepath1, filepath2, tmp1, tmp2); + std::array vhs1 = + { + tmp1.add_vertex(Point_3(0, 1, 3)), + tmp1.add_vertex(Point_3(1, 1, 3)), + tmp1.add_vertex(Point_3(1, 0, 3)) + }; + tmp1.add_face(vhs1); - PMP::transform(Affine_transformation_3( - CGAL::Translation(), Vector_3(0, 0, 10 * error_bound)), tmp2); + std::array vhs2 = + { + tmp2.add_vertex(Point_3(0, 1, 3.5)), + tmp2.add_vertex(Point_3(1, 1, 3.5)), + tmp2.add_vertex(Point_3(1, 0, 3.5)) + }; + tmp2.add_face(vhs2); + + const std::string filepath1 = "data/tetrahedron.off"; + const std::string filepath2 = "data/tetrahedron-remeshed.off"; + mesh1.clear(); + mesh2.clear(); + get_meshes(filepath1, filepath2, mesh1, mesh2); + PMP::transform(Affine_transformation_3(CGAL::Translation(), Vector_3(0, 0, 10 * error_bound)), tmp2); mesh1.join(tmp1); mesh2.join(tmp2); - if (save) save_mesh(mesh1, "2mesh1"); - if (save) save_mesh(mesh2, "2mesh2"); + if(save) + { + save_mesh(mesh1, "mesh1-2"); + save_mesh(mesh2, "mesh2-2"); + } - compute_realizing_triangles(mesh1, mesh2, error_bound, "2", save); + const int expected_f1 = static_cast(faces(mesh1).size() - 1); + const int expected_f2 = static_cast(faces(mesh2).size() - 1); + compute_realizing_triangles(mesh1, mesh2, error_bound, expected_f1, expected_f2, "2", save); } #if defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) && defined(USE_PARALLEL_BEHD) -void test_parallel_version( - const std::string filepath, const double error_bound) { - - std::cout.precision(20); +void test_parallel_version(const std::string& filepath, + const double error_bound) +{ std::cout << std::endl << "-- test parallel version:" << std::endl << std::endl; Timer timer; @@ -1085,7 +1039,7 @@ void test_parallel_version( std::cout << " ---- one-sided distance ---- " << std::endl; PMP::transform(Affine_transformation_3(CGAL::Translation(), - Vector_3(FT(0), FT(0), FT(1))), mesh2); + Vector_3(FT(0), FT(0), FT(1))), mesh2); std::cout << " ---- SEQUENTIAL ---- " << std::endl; timer.reset(); @@ -1113,72 +1067,57 @@ void test_parallel_version( std::cout << "* dista seq = " << dista << std::endl; std::cout << "* distb par = " << distb << std::endl; - assert(timea > 0.0); - assert(timeb > 0.0); assert(dista == distb); } #endif // defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) -void test_early_quit(const std::string filepath) { - - std::cout.precision(20); +void test_early_quit(const std::string& filepath, + const bool save = true) +{ std::cout << std::endl << "-- test early quit:" << std::endl << std::endl; Timer timer; Surface_mesh mesh1, mesh2; get_meshes(filepath, filepath, mesh1, mesh2); - std::cout << std::endl; - std::cout << " ---- distance 0.0 = 0.0 ---- " << std::endl; - timer.reset(); - timer.start(); - assert(!PMP::is_Hausdorff_distance_larger(mesh1, mesh2, 0.0)); - timer.stop(); - const double timea = timer.time(); - PMP::transform(Affine_transformation_3(CGAL::Translation(), - Vector_3(0.0, 0.0, 0.5)), mesh2); + Vector_3(0.0, 0.0, 0.5)), mesh2); + + if(save) + { + save_mesh(mesh1, "mesh1"); + save_mesh(mesh2, "mesh2"); + } std::cout << " ---- distance 0.5 < 1.0 ---- " << std::endl; timer.reset(); timer.start(); - assert(!PMP::is_Hausdorff_distance_larger(mesh1, mesh2, 1.0)); + assert(!PMP::is_Hausdorff_distance_larger(mesh1, mesh2, 1.0, 0.0001)); timer.stop(); const double timeb = timer.time(); - std::cout << " ---- distance 0.5 < 0.6 ---- " << std::endl; + + std::cout << std::endl << " ---- distance 0.5 < 0.6 ---- " << std::endl; timer.reset(); timer.start(); - assert(!PMP::is_Hausdorff_distance_larger(mesh1, mesh2, 0.6)); + assert(!PMP::is_Hausdorff_distance_larger(mesh1, mesh2, 0.6, 0.0001)); timer.stop(); const double timec = timer.time(); - std::cout << " ---- distance 0.5 > 0.4 ---- " << std::endl; + + std::cout << std::endl << " ---- distance 0.5 > 0.4 ---- " << std::endl; timer.reset(); timer.start(); - assert(PMP::is_Hausdorff_distance_larger(mesh1, mesh2, 0.4)); + assert(PMP::is_Hausdorff_distance_larger(mesh1, mesh2, 0.4, 0.0001)); timer.stop(); const double timed = timer.time(); - std::cout << " ---- distance 0.5 > 0.0 ---- " << std::endl; - timer.reset(); - timer.start(); - assert(PMP::is_Hausdorff_distance_larger(mesh1, mesh2, 0.0)); - timer.stop(); - const double timee = timer.time(); - std::cout << "* timea 0.0 = 0.0 = " << timea << std::endl; - std::cout << "* timeb 0.5 < 1.0 = " << timeb << std::endl; - std::cout << "* timec 0.5 < 0.6 = " << timec << std::endl; - std::cout << "* timed 0.5 > 0.4 = " << timed << std::endl; - std::cout << "* timee 0.5 > 0.0 = " << timee << std::endl; - - assert(timea > 0.0); - assert(timeb > 0.0); - assert(timec > 0.0); - assert(timed > 0.0); - assert(timee > 0.0); + std::cout << "* timeb 0.5 < 1.0; time: " << timeb << std::endl; + std::cout << "* timec 0.5 < 0.6; time: " << timec << std::endl; + std::cout << "* timed 0.5 > 0.4; time: " << timed << std::endl; } -void run_examples(const double error_bound, const std::string filepath) { - +void run_examples(const double error_bound, + const std::string& filepath) +{ remeshing_tetrahedon_example(error_bound); interior_triangle_example(error_bound); perturbing_surface_mesh_example(filepath, error_bound); @@ -1186,73 +1125,58 @@ void run_examples(const double error_bound, const std::string filepath) { moving_surface_mesh_example(filepath, filepath, 5, error_bound); } -int main(int argc, char** argv) { - - // std::string name; - // std::cin >> name; +int main(int argc, char** argv) +{ + std::cout.precision(17); + std::cerr.precision(17); const double error_bound = 1e-4; - const double num_samples = 10.; + const std::size_t num_samples = 1000; std::cout << std::endl << "* error bound: " << error_bound << std::endl; - // std::cout << std::endl << "* number of samples: " << num_samples << std::endl; - std::string filepath = (argc > 1 ? argv[1] : CGAL::data_file_path("meshes/blobby.off")); + std::cout << std::endl << "* number of samples: " << num_samples << std::endl; + + const std::string filepath = (argc > 1 ? argv[1] : CGAL::data_file_path("meshes/blobby.off")); run_examples(error_bound, filepath); // ------------------------------------------------------------------------ // // Tests. - // Approximate_hd_wrapper does not work with EPECK! - Approximate_hd_wrapper apprx_hd(num_samples); + Approximate_hd_wrapper apprx_hd(num_samples, error_bound); Naive_bounded_error_hd_wrapper naive_hd(error_bound); Bounded_error_hd_wrapper bound_hd(error_bound); // --- Testing basic properties. - - // test_synthetic_data(apprx_hd); - // test_synthetic_data(naive_hd); + test_synthetic_data(apprx_hd); +// test_synthetic_data(naive_hd); // naive takes too long test_synthetic_data(bound_hd); // --- Compare on common meshes. - - // test_one_versus_another(apprx_hd, naive_hd); - // test_one_versus_another(naive_hd, bound_hd); - test_one_versus_another(bound_hd, apprx_hd); +// test_one_versus_another(apprx_hd, naive_hd, error_bound); // naive takes too long +// test_one_versus_another(naive_hd, bound_hd, error_bound); // naive takes too long + test_one_versus_another(bound_hd, apprx_hd, error_bound); // --- Compare on real meshes. - const std::string filepath1 = (argc > 1 ? argv[1] : CGAL::data_file_path("meshes/blobby.off")); const std::string filepath2 = (argc > 2 ? argv[2] : "data/tetrahedron-remeshed.off"); - // test_real_meshes(filepath1, filepath2, apprx_hd, naive_hd); - // test_real_meshes(filepath1, filepath2, naive_hd, bound_hd); - test_real_meshes(filepath1, filepath2, bound_hd, apprx_hd); - - // --- Compare timings. - - filepath = (argc > 1 ? argv[1] : CGAL::data_file_path("meshes/blobby.off")); - // test_timings(filepath, apprx_hd); - // test_timings(filepath, naive_hd); - test_timings(filepath, bound_hd); - - // --- Compare with the paper. - - // test_bunny(apprx_hd); - // test_bunny(naive_hd); - // test_bunny(bound_hd, 3); +// test_real_meshes(filepath1, filepath2, apprx_hd, naive_hd, error_bound); +// test_real_meshes(filepath1, filepath2, naive_hd, bound_hd, error_bound); + test_real_meshes(filepath1, filepath2, bound_hd, apprx_hd, error_bound); +// test_real_meshes("data/elephant_concave_hole.off", CGAL::data_file_path("meshes/mech-holes-shark.off"), bound_hd, apprx_hd, error_bound); // commenting because approx hausdorff is annoyingly rough + test_real_meshes("data/small_spheres.off", "data/overlapping_triangles.off", bound_hd, apprx_hd, error_bound); // --- Test realizing triangles. test_realizing_triangles(error_bound); - #if defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) && defined(USE_PARALLEL_BEHD) +#if defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) && defined(USE_PARALLEL_BEHD) // --- Test parallelization. test_parallel_version(filepath, error_bound); - #endif // defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) +#endif // defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) // --- Test early quit. test_early_quit(filepath); - // ------------------------------------------------------------------------ // + std::cout << "Done!" << std::endl; - std::cout << std::endl; return EXIT_SUCCESS; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp index b790acc0202..ae913ff8f5a 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp @@ -44,7 +44,7 @@ bool test_orientation(const TriangleMesh& tm, bool is_positive, const NamedParam // set the connected component id of each face std::size_t nb_cc = PMP::connected_components(tm, CGAL::bind_property_maps(fid_map,CGAL::make_property_map(face_cc)), - PMP::parameters::face_index_map(fid_map)); + CGAL::parameters::face_index_map(fid_map)); // extract a vertex with max z coordinate for each connected component std::vector xtrm_vertices(nb_cc, Graph_traits::null_vertex()); @@ -95,24 +95,24 @@ int main() volume = sm1; volume_copy = volume; PMP::orient(sm1); - if(!test_orientation(sm1, true, PMP::parameters::all_default())) + if(!test_orientation(sm1, true, CGAL::parameters::default_values())) return 1; typedef boost::property_map::type Ppmap; typedef boost::property_map::type Fidmap; Ppmap vpmap2 = get(CGAL::vertex_point, sm2); Fidmap fidmap2 = get(CGAL::face_index, sm2); - PMP::orient(sm2, PMP::parameters::vertex_point_map(vpmap2) - .face_index_map(fidmap2)); - if(!test_orientation(sm2, true, PMP::parameters::vertex_point_map(vpmap2) - .face_index_map(fidmap2))) + PMP::orient(sm2, CGAL::parameters::vertex_point_map(vpmap2) + .face_index_map(fidmap2)); + if(!test_orientation(sm2, true, CGAL::parameters::vertex_point_map(vpmap2) + .face_index_map(fidmap2))) { std::cerr << "ERROR for test1\n"; return 1; } - PMP::orient(sm3, PMP::parameters::outward_orientation(false)); - if(!test_orientation(sm3, false, PMP::parameters::all_default())) + PMP::orient(sm3, CGAL::parameters::outward_orientation(false)); + if(!test_orientation(sm3, false, CGAL::parameters::default_values())) { std::cerr << "ERROR for test2\n"; return 1; @@ -121,11 +121,11 @@ int main() Ppmap vpmap4 = get(CGAL::vertex_point, sm4); Fidmap fidmap4 = get(CGAL::face_index, sm4); - PMP::orient(sm4, PMP::parameters::vertex_point_map(vpmap4) - .face_index_map(fidmap4) - .outward_orientation(false)); - if(!test_orientation(sm4, false, PMP::parameters::vertex_point_map(vpmap4) - .face_index_map(fidmap4))) + PMP::orient(sm4, CGAL::parameters::vertex_point_map(vpmap4) + .face_index_map(fidmap4) + .outward_orientation(false)); + if(!test_orientation(sm4, false, CGAL::parameters::vertex_point_map(vpmap4) + .face_index_map(fidmap4))) { std::cerr << "ERROR for test3\n"; return 1; 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 21e55aef389..c564403312a 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 @@ -12,7 +12,7 @@ #include namespace PMP = CGAL::Polygon_mesh_processing; -namespace params = PMP::parameters; +namespace params = CGAL::parameters; typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Surface_mesh Surface_mesh; @@ -63,7 +63,7 @@ void test() params::throw_on_self_intersection(true), params::do_not_modify(true)); std::vector meshes; - PMP::split_connected_components(tm1, meshes, params::all_default()); + PMP::split_connected_components(tm1, meshes, params::default_values()); assert(meshes.size() == 2); //if the order is not deterministc, put the num_vertices in a list and check //if the list does contain all those numbers. @@ -576,7 +576,7 @@ void test_split_plane() PMP::split(tm1,K::Plane_3(0,0,1,0)); std::vector meshes; - PMP::split_connected_components(tm1, meshes, params::all_default()); + PMP::split_connected_components(tm1, meshes, params::default_values()); assert(meshes.size() == 3); //if the order is not deterministc, put the num_vertices in a list and check //if the list does contain all those numbers. @@ -600,7 +600,7 @@ void test_split_plane() input.close(); PMP::split(tm1,K::Plane_3(0,0,1,-1)); - PMP::split_connected_components(tm1, meshes, params::all_default()); + PMP::split_connected_components(tm1, meshes, params::default_values()); assert(meshes.size() == 281); CGAL::clear(tm1); @@ -619,7 +619,7 @@ void test_split_plane() input.close(); PMP::split(tm1,K::Plane_3(0,-1,0,0.3)); - PMP::split_connected_components(tm1, meshes, params::all_default()); + PMP::split_connected_components(tm1, meshes, params::default_values()); assert(meshes.size() == 2); CGAL::clear(tm1); @@ -637,7 +637,7 @@ void test_split_plane() PMP::split(tm1, K::Plane_3(0,0,1,-0.5), params::throw_on_self_intersection(true) .allow_self_intersections(true)); - PMP::split_connected_components(tm1, meshes, params::all_default()); + PMP::split_connected_components(tm1, meshes, params::default_values()); assert(meshes.size() == 2); //if the order is not deterministc, put the num_vertices in a list and check //if the list does contain all those numbers. @@ -687,7 +687,7 @@ void test_split() TriangleMesh, CGAL::dynamic_face_property_t >::type pidmap = get(CGAL::dynamic_face_property_t(), tm1); CGAL::Polygon_mesh_processing::connected_components( - tm1, pidmap, CGAL::parameters::all_default()); + tm1, pidmap, CGAL::parameters::default_values()); PMP::split_connected_components(tm1, meshes, params::face_patch_map(pidmap)); @@ -734,7 +734,7 @@ void test_split() PMP::split(tm1, tm2); PMP::split_connected_components(tm1, meshes, - params::all_default()); + params::default_values()); assert(meshes.size() == 2); //if the order is not deterministc, put the num_vertices in a list and check @@ -761,7 +761,7 @@ void test_split() PMP::split(tm1, tm2, params::throw_on_self_intersection(true), params::do_not_modify(true)); - PMP::split_connected_components(tm1, meshes, params::all_default()); + PMP::split_connected_components(tm1, meshes, params::default_values()); assert(meshes.size() == 3); //if the order is not deterministc, put the num_vertices in a list and check //if the list does contain all those numbers. @@ -829,7 +829,7 @@ void test_isocuboid() PMP::split(tm, splitter, params::throw_on_self_intersection(true) .allow_self_intersections(true)); - PMP::split_connected_components(tm, meshes, params::all_default()); + PMP::split_connected_components(tm, meshes, params::default_values()); assert(meshes.size() == 4); std::set sizes; @@ -848,7 +848,7 @@ void test_isocuboid() PMP::clip(tm, splitter, params::throw_on_self_intersection(true) .allow_self_intersections(true)); - PMP::split_connected_components(tm, meshes, params::all_default()); + PMP::split_connected_components(tm, meshes, params::default_values()); assert(meshes.size() == 2); //if the order is not deterministc, put the num_vertices in a list and check //if the list does contain all those numbers. diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_distance.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_distance.cpp index c8d1040383d..731d45515c8 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_distance.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_distance.cpp @@ -256,8 +256,8 @@ void general_tests(const TriangleMesh& m1, std::cout << "Symmetric distance between meshes (sequential) " << PMP::approximate_symmetric_Hausdorff_distance( m1,m2, - PMP::parameters::number_of_points_per_area_unit(4000), - PMP::parameters::number_of_points_per_area_unit(4000)) + CGAL::parameters::number_of_points_per_area_unit(4000), + CGAL::parameters::number_of_points_per_area_unit(4000)) << "\n"; std::cout << "Max distance to point set " @@ -269,7 +269,7 @@ void general_tests(const TriangleMesh& m1, << "\n"; std::vector samples; - PMP::sample_triangle_mesh(m1, std::back_inserter(samples)); + PMP::sample_triangle_mesh(m1, std::back_inserter(samples), CGAL::parameters::random_seed(0)); std::cout << samples.size()<<" points sampled on mesh."<( - m1,m2,PMP::parameters::number_of_points_per_area_unit(4000)) + m1,m2,CGAL::parameters::number_of_points_per_area_unit(4000)) << "\n"; time.stop(); std::cout << "done in " << time.time() << "s.\n"; @@ -314,7 +314,7 @@ int main(int argc, char** argv) time.start(); std::cout << "Distance between meshes (sequential) " << PMP::approximate_Hausdorff_distance( - m1,m2,PMP::parameters::number_of_points_per_area_unit(4000)) + m1,m2,CGAL::parameters::number_of_points_per_area_unit(4000)) << "\n"; time.stop(); std::cout << "done in " << time.time() << "s.\n"; 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 3f42914b172..9102d733047 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 @@ -223,7 +223,7 @@ void test_constructions(const G& g, // --------------------------------------------------------------------------- // just to check the API PMP::construct_point(loc, g); - PMP::construct_point(loc, g, CGAL::parameters::all_default()); + PMP::construct_point(loc, g, CGAL::parameters::default_values()); } template diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_np_function.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_np_function.cpp new file mode 100644 index 00000000000..8d5cea3c6da --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_np_function.cpp @@ -0,0 +1,104 @@ +#include +#include +#include +#include +#include + +#include +#include + +namespace CGAL { +template +void my_function_with_named_parameters(PolygonMesh& mesh, const NamedParameters& np = parameters::default_values()) +{ + //The class containing all the geometric definitions for the PolygonMesh + typedef typename GetGeomTraits::type Traits; + Traits t; + CGAL_USE(t); + //A vertex-index-map that is either taken from the NPs, either an already initialized map for vertex-indices. + //Also exists for Faces, Edges and Halfedges + typedef typename CGAL::GetInitializedVertexIndexMap::type VertexIndexMap; + //A vertex-point-map either taken from the NPs, either a specified default map. + typedef typename GetVertexPointMap < PolygonMesh, NamedParameters>::type VPM; + + //The class defining all boost-graph types for the PolygonMesh, like vertex_descriptor and so. + typedef boost::graph_traits Graph_traits; + typedef typename Graph_traits::vertex_descriptor vertex_descriptor; + + //in the case no helper function exists, this is how you get a type from a NP + typedef Static_boolean_property_map Default_VCM; + typedef typename internal_np::Lookup_named_param_def::type VCM; + + using parameters::choose_parameter; + using parameters::get_parameter; + using parameters::is_default_parameter; + + //If the NPs provide a vertex-index-map, returns it. Else, returns an initialized vertex-index map. + VertexIndexMap vim = CGAL::get_initialized_vertex_index_map(mesh, np); + //If the NPs provide a vertex-point-map, returns it. Else, returns the default boost-graph vpm. + VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), + get_property_map(vertex_point, mesh)); + //boolean NP example. Default value is `false` + bool do_project = choose_parameter(get_parameter(np, internal_np::do_project), false); + + // check is a parameter has been given by the user + constexpr bool do_project_is_default = is_default_parameter(); + + VCM vcm_np = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), Default_VCM()); + + + //demonstrates usage for those values. + for(auto v : vertices(mesh)) + { + std::cout<<"vertex #"< SMesh; + SMesh sm; + std::stringstream poly("OFF\n" + "4 4 0\n" + "0 0 0\n" + "0 0 1\n" + "0 1 0\n" + "1 0 0\n" + "3 3 1 2\n" + "3 0 1 3\n" + "3 0 3 2\n" + "3 0 2 1\n"); + poly >> sm; + + typedef std::map::vertex_descriptor,bool> VCmap; + VCmap vcm; + for(auto v : vertices(sm)) + { + if ((int)v %2 ==0) + vcm[v] = true; + else + vcm[v] = false; + } + typedef boost::associative_property_map Vertex_constrained_pmap; + Vertex_constrained_pmap vcm_pmap(vcm); + CGAL::my_function_with_named_parameters(sm); + CGAL::my_function_with_named_parameters(sm, CGAL::parameters::vertex_is_constrained_map(vcm_pmap) + .do_project(true)); + return 0; +} diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_remove_border_edge.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_remove_border_edge.cpp index 6b9929eb466..a94e1adadc6 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_remove_border_edge.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_remove_border_edge.cpp @@ -4,6 +4,7 @@ #include #include +#include typedef CGAL::Simple_cartesian K; typedef K::Point_3 Point; @@ -30,11 +31,11 @@ void test_middle_edge() break; } } - CGAL_assertion( h!=GT::null_halfedge() ); + assert( h!=GT::null_halfedge() ); CGAL::Polygon_mesh_processing::remove_a_border_edge(edge(h,tm), tm); - CGAL_assertion(is_valid_polygon_mesh(tm)); - CGAL_assertion(is_triangle_mesh(tm)); + assert(is_valid_polygon_mesh(tm)); + assert(is_triangle_mesh(tm)); std::ofstream out("edge_middle_out.off"); out << tm; } @@ -59,11 +60,11 @@ void test_edge_border_case1() break; } } - CGAL_assertion( h!=GT::null_halfedge() ); + assert( h!=GT::null_halfedge() ); CGAL::Polygon_mesh_processing::remove_a_border_edge(edge(h,tm), tm); - CGAL_assertion(is_valid_polygon_mesh(tm)); - CGAL_assertion(is_triangle_mesh(tm)); + assert(is_valid_polygon_mesh(tm)); + assert(is_triangle_mesh(tm)); std::ofstream out("edge_border_case1_out.off"); out << tm; } @@ -88,11 +89,11 @@ void test_edge_border_case2() break; } } - CGAL_assertion( h!=GT::null_halfedge() ); + assert( h!=GT::null_halfedge() ); CGAL::Polygon_mesh_processing::remove_a_border_edge(edge(h,tm), tm); - CGAL_assertion(is_valid_polygon_mesh(tm)); - CGAL_assertion(is_triangle_mesh(tm)); + assert(is_valid_polygon_mesh(tm)); + assert(is_triangle_mesh(tm)); std::ofstream out("edge_border_case2_out.off"); out << tm; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_repair_degeneracies.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_repair_degeneracies.cpp index 001ec6d8614..94857b088bb 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_repair_degeneracies.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_repair_degeneracies.cpp @@ -38,10 +38,10 @@ void detect_degeneracies(const EdgeRange& edge_range, std::set dedges; PMP::degenerate_edges(mesh, std::inserter(dedges, dedges.end())); PMP::degenerate_edges(edge_range, mesh, std::inserter(dedges, dedges.begin())); - PMP::degenerate_edges(mesh, std::inserter(dedges, dedges.end()), CP::all_default()); + PMP::degenerate_edges(mesh, std::inserter(dedges, dedges.end()), CP::default_values()); dedges.clear(); - PMP::degenerate_edges(edge_range, mesh, std::inserter(dedges, dedges.begin()), CP::all_default()); + PMP::degenerate_edges(edge_range, mesh, std::inserter(dedges, dedges.begin()), CP::default_values()); std::cout << "\t" << dedges.size() << " degenerate edges vs " << expected_dedges_n << std::endl; assert(dedges.size() == expected_dedges_n); @@ -49,10 +49,10 @@ void detect_degeneracies(const EdgeRange& edge_range, std::vector dfaces; PMP::degenerate_faces(mesh, std::back_inserter(dfaces)); PMP::degenerate_faces(face_range, mesh, std::back_inserter(dfaces)); - PMP::degenerate_faces(mesh, std::back_inserter(dfaces), CP::all_default()); + PMP::degenerate_faces(mesh, std::back_inserter(dfaces), CP::default_values()); dfaces.clear(); - PMP::degenerate_faces(face_range, mesh, std::back_inserter(dfaces), CP::all_default()); + PMP::degenerate_faces(face_range, mesh, std::back_inserter(dfaces), CP::default_values()); std::cout << "\t" << dfaces.size() << " degenerate faces vs " << expected_dfaces_n << std::endl; assert(dfaces.size() == expected_dfaces_n); } @@ -103,7 +103,7 @@ bool remove_dedges(const std::vector& edges_selection_ids, for(std::size_t edge_id : edges_selection_ids) edge_range.push_back(all_edges[edge_id]); - return CGAL::Polygon_mesh_processing::remove_degenerate_edges(edge_range, mesh, CP::all_default()); + return CGAL::Polygon_mesh_processing::remove_degenerate_edges(edge_range, mesh, CP::default_values()); } template @@ -119,7 +119,7 @@ bool remove_dfaces(const std::vector& faces_selection_ids, for(std::size_t face_id : faces_selection_ids) face_range.push_back(all_faces[face_id]); - return CGAL::Polygon_mesh_processing::remove_degenerate_faces(face_range, mesh, CP::all_default()); + return CGAL::Polygon_mesh_processing::remove_degenerate_faces(face_range, mesh, CP::default_values()); } template @@ -153,12 +153,12 @@ void remove_degeneracies(const std::string filename, // Complete remove std::cout << " Remove all..." << std::endl; mesh = mesh_cpy; - /* bool all_removed = */ CGAL::Polygon_mesh_processing::remove_degenerate_edges(mesh, CP::all_default()); + /* bool all_removed = */ CGAL::Polygon_mesh_processing::remove_degenerate_edges(mesh, CP::default_values()); //assert(all_removed); assert(CGAL::is_valid_polygon_mesh(mesh)); mesh = mesh_cpy; - /* all_removed = */ CGAL::Polygon_mesh_processing::remove_degenerate_faces(mesh, CP::all_default()); + /* all_removed = */ CGAL::Polygon_mesh_processing::remove_degenerate_faces(mesh, CP::default_values()); // assert(all_removed); assert(CGAL::is_valid_polygon_mesh(mesh)); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_snapping.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_snapping.cpp index 5a9a535275d..fa5fd3ba479 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_snapping.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_snapping.cpp @@ -116,7 +116,7 @@ void test_1() CGAL::Constant_property_map tol_map_good(0.001); res = PMP::experimental::snap_vertices(border_vertices, fg_source_cpy, tol_map_good, target_halfedge_range, fg_target, tol_map_good, - params::all_default(), params::do_lock_mesh(true)); + params::default_values(), params::do_lock_mesh(true)); std::cout << "res: " << res << " vertices" << std::endl; assert(res == 76); @@ -129,7 +129,7 @@ void test_1() res = PMP::experimental::snap_vertices(border_vertices, fg_source_cpy, target_halfedge_range, fg_target, - params::all_default(), params::do_lock_mesh(true)); + params::default_values(), params::do_lock_mesh(true)); std::cout << "res: " << res << " vertices" << std::endl; assert(res == 77); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_transform.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_transform.cpp index fe1532db11b..65d64eb1cbe 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_transform.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_transform.cpp @@ -9,7 +9,7 @@ namespace PMP = CGAL::Polygon_mesh_processing; -namespace params = PMP::parameters; +namespace params = CGAL::parameters; typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef K::Point_3 Point; typedef CGAL::Surface_mesh Mesh; @@ -21,13 +21,13 @@ int main() Mesh m; CGAL::make_tetrahedron(Point(0,0,0), Point(0,0,1), Point(0,1,2), Point(1,0,3), m); CGAL::Aff_transformation_3 trans(0,0,0,1,0,1,0,0,0,0,1,1); - PMP::transform(trans, m, params::all_default()); + PMP::transform(trans, m, params::default_values()); bool ok = true; for(Mesh::size_type i = 0; i namespace PMP = CGAL::Polygon_mesh_processing; -namespace params = PMP::parameters; +namespace params = CGAL::parameters; typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef K::Point_3 Point_3; @@ -259,7 +259,7 @@ void test_merge_duplicate_polygons(const bool /*verbose*/ = false) // Keep one for each duplicate std::vector polygons_copy(polygons); res = PMP::merge_duplicate_polygons_in_polygon_soup(points, polygons_copy, - params::all_default()); + params::default_values()); assert(res == 3 && polygons_copy.size() == 3); // Remove all duplicates diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_split_volume.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_split_volume.cpp index 2270a34c4cb..167625a4bb5 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_split_volume.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_split_volume.cpp @@ -14,7 +14,8 @@ typedef CGAL::Surface_mesh Surface_mesh; typedef Kernel::Aff_transformation_3 Trsfrm; namespace PMP = CGAL::Polygon_mesh_processing; -namespace params = PMP::parameters; +namespace params = CGAL::parameters; + int main() { Surface_mesh base_cube; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp index 0b1ea949136..1dcb214fe39 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp @@ -112,7 +112,7 @@ void test_triangulate_hole_weight(const std::string file_name, std::size_t nb_re for(typename std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it) { std::vector patch; CGAL::Polygon_mesh_processing::triangulate_hole( - poly, *it, back_inserter(patch),CGAL::Polygon_mesh_processing::parameters::use_delaunay_triangulation(true)); + poly, *it, back_inserter(patch),CGAL::parameters::use_delaunay_triangulation(true)); if(patch.empty()) { continue; } } @@ -162,14 +162,14 @@ void test_triangulate_hole_should_be_no_output(const std::string file_name) { for(typename std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it) { std::vector patch; CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch), - CGAL::Polygon_mesh_processing::parameters::use_delaunay_triangulation(false)); + CGAL::parameters::use_delaunay_triangulation(false)); if(!patch.empty()) { std::cerr << " Error: patch should be empty" << std::endl; assert(false); } CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch), - CGAL::Polygon_mesh_processing::parameters::use_delaunay_triangulation(true)); + CGAL::parameters::use_delaunay_triangulation(true)); if(!patch.empty()) { std::cerr << " Error: patch should be empty" << std::endl; assert(false); @@ -338,7 +338,7 @@ void test_triangulate_refine_and_fair_hole_compile() { read_poly_with_borders("elephant_quad_hole.off", poly, border_reps); CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole (poly, border_reps[0], back_inserter(patch_facets), back_inserter(patch_vertices), - CGAL::Polygon_mesh_processing::parameters:: + CGAL::parameters:: weight_calculator(CGAL::Weights::Uniform_weight()). sparse_linear_solver(Default_solver())); @@ -346,7 +346,7 @@ void test_triangulate_refine_and_fair_hole_compile() { read_poly_with_borders("elephant_quad_hole.off", poly, border_reps); CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole (poly, border_reps[0], back_inserter(patch_facets), back_inserter(patch_vertices), - CGAL::Polygon_mesh_processing::parameters:: + CGAL::parameters:: weight_calculator(CGAL::Weights::Uniform_weight())); // default solver and weight diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp index 0f1429f051c..d47ef45055d 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp @@ -108,7 +108,7 @@ void test_triangulate_hole_weight(const std::string file_name, bool use_DT, std: for(std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it) { std::vector patch; Weight w_algo = CGAL::Polygon_mesh_processing::internal::triangulate_hole_polygon_mesh( - poly, *it, back_inserter(patch), get(CGAL::vertex_point, poly), use_DT, Kernel(), false, 0).second; + poly, *it, back_inserter(patch), get(CGAL::vertex_point, poly), use_DT, Kernel(), false/*use_cdt*/, false/*skip_cubic*/, 0).second; if(patch.empty()) { continue; } Weight w_test = calculate_weight_for_patch(poly, patch.begin(), patch.end()); @@ -163,7 +163,7 @@ void test_triangulate_hole_should_be_no_output(const std::string file_name, bool for(std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it) { std::vector patch; CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch), - CGAL::Polygon_mesh_processing::parameters::use_delaunay_triangulation(false) + CGAL::parameters::use_delaunay_triangulation(false) .use_2d_constrained_delaunay_triangulation(use_cdt)); if(!patch.empty()) { std::cerr << " Error: patch should be empty" << std::endl; @@ -171,7 +171,7 @@ void test_triangulate_hole_should_be_no_output(const std::string file_name, bool } CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch), - CGAL::Polygon_mesh_processing::parameters::use_delaunay_triangulation(true)); + CGAL::parameters::use_delaunay_triangulation(true)); if(!patch.empty()) { std::cerr << " Error: patch should be empty" << std::endl; assert(false); @@ -327,7 +327,7 @@ void test_triangulate_refine_and_fair_hole_compile() { read_poly_with_borders("elephant_quad_hole.off", poly, border_reps); CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole (poly, border_reps[0], back_inserter(patch_facets), back_inserter(patch_vertices), - CGAL::Polygon_mesh_processing::parameters:: + CGAL::parameters:: weight_calculator(CGAL::Weights::Uniform_weight()). sparse_linear_solver(Default_solver()). use_2d_constrained_delaunay_triangulation(false)); @@ -336,7 +336,7 @@ void test_triangulate_refine_and_fair_hole_compile() { read_poly_with_borders("elephant_quad_hole.off", poly, border_reps); CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole (poly, border_reps[0], back_inserter(patch_facets), back_inserter(patch_vertices), - CGAL::Polygon_mesh_processing::parameters:: + CGAL::parameters:: weight_calculator(CGAL::Weights::Uniform_weight())); // default solver and weight diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp index a3243deb085..7e96e187d91 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include @@ -20,7 +20,7 @@ template class Polyhedron_builder : public CGAL::Modifier_base { typedef typename K::Point_3 Point_3; public: - Polyhedron_builder(std::vector >* triangles, + Polyhedron_builder(std::vector >* triangles, std::vector* polyline) : triangles(triangles), polyline(polyline) { } @@ -34,12 +34,12 @@ public: B.add_vertex(*it); } - for(typename std::vector >::iterator it = triangles->begin(); + for(typename std::vector >::iterator it = triangles->begin(); it != triangles->end(); ++it) { B.begin_facet(); - B.add_vertex_to_facet(it->get<0>()); - B.add_vertex_to_facet(it->get<1>()); - B.add_vertex_to_facet(it->get<2>()); + B.add_vertex_to_facet(std::get<0>(*it)); + B.add_vertex_to_facet(std::get<1>(*it)); + B.add_vertex_to_facet(std::get<2>(*it)); B.end_facet(); } @@ -47,7 +47,7 @@ public: } private: - std::vector >* triangles; + std::vector >* triangles; std::vector* polyline; }; @@ -92,25 +92,25 @@ void read_polyline_with_extra_points( } } -void check_triangles(std::vector& points, std::vector >& tris) { +void check_triangles(std::vector& points, std::vector >& tris) { if(points.size() - 3 != tris.size()) { std::cerr << " Error: there should be n-2 triangles in generated patch." << std::endl; assert(false); } const int max_index = static_cast(points.size())-1; - for(std::vector >::iterator it = tris.begin(); it != tris.end(); ++it) { - if(it->get<0>() == it->get<1>() || - it->get<0>() == it->get<2>() || - it->get<1>() == it->get<2>() ) + for(std::vector >::iterator it = tris.begin(); it != tris.end(); ++it) { + if(std::get<0>(*it) == std::get<1>(*it) || + std::get<0>(*it) == std::get<2>(*it) || + std::get<1>(*it) == std::get<2>(*it) ) { std::cerr << "Error: indices of triangles should be all different." << std::endl; assert(false); } - if(it->get<0>() >= max_index || - it->get<1>() >= max_index || - it->get<2>() >= max_index ) + if(std::get<0>(*it) >= max_index || + std::get<1>(*it) >= max_index || + std::get<2>(*it) >= max_index ) { std::cerr << " Error: max possible index check failed." << std::endl; assert(false); @@ -119,7 +119,7 @@ void check_triangles(std::vector& points, std::vector >* triangles, + std::vector >* triangles, std::vector* polyline, const bool save_poly) { @@ -147,10 +147,10 @@ void test_1(const char* file_name, bool use_DT, bool save_output) { std::vector points; // this will contain n and +1 repeated point read_polyline_one_line(file_name, points); - std::vector > tris; + std::vector > tris; CGAL::Polygon_mesh_processing::triangulate_hole_polyline( points, std::back_inserter(tris), - CGAL::Polygon_mesh_processing::parameters::use_delaunay_triangulation(use_DT) + CGAL::parameters::use_delaunay_triangulation(use_DT) .use_2d_constrained_delaunay_triangulation(true)); check_triangles(points, tris); @@ -166,10 +166,10 @@ void test_2(const char* file_name, bool use_DT, bool save_output) { std::vector extras; read_polyline_with_extra_points(file_name, points, extras); - std::vector > tris; + std::vector > tris; CGAL::Polygon_mesh_processing::triangulate_hole_polyline( points, extras, std::back_inserter(tris), - CGAL::Polygon_mesh_processing::parameters::use_delaunay_triangulation(use_DT) + CGAL::parameters::use_delaunay_triangulation(use_DT) .use_2d_constrained_delaunay_triangulation(true)); check_triangles(points, tris); @@ -184,10 +184,10 @@ void test_should_be_no_output(const char* file_name, bool use_DT) { std::vector points; // this will contain n and +1 repeated point read_polyline_one_line(file_name, points); - std::vector > tris; + std::vector > tris; CGAL::Polygon_mesh_processing::triangulate_hole_polyline( points, std::back_inserter(tris), - CGAL::Polygon_mesh_processing::parameters::use_delaunay_triangulation(use_DT) + CGAL::parameters::use_delaunay_triangulation(use_DT) .use_2d_constrained_delaunay_triangulation(true)); if(!tris.empty()) { diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_with_cdt_2_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_with_cdt_2_test.cpp index 4a3c8ca9126..8ab2e2afd71 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_with_cdt_2_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_with_cdt_2_test.cpp @@ -87,7 +87,7 @@ void test_triangulate_hole_with_cdt_2( pmesh, h, std::back_inserter(patch_faces), - CGAL::Polygon_mesh_processing::parameters::vertex_point_map( + CGAL::parameters::vertex_point_map( get(CGAL::vertex_point, pmesh)). use_2d_constrained_delaunay_triangulation(true). geom_traits(GeomTraits())); @@ -99,8 +99,7 @@ void test_triangulate_hole_with_cdt_2( assert(patch_faces.size() == num_patch_faces); } assert(pmesh.is_valid() && is_closed(pmesh)); - assert(CGAL::Polygon_mesh_processing::is_outward_oriented(pmesh, - CGAL::parameters::all_default())); + assert(CGAL::Polygon_mesh_processing::is_outward_oriented(pmesh)); // Writing the file. if (verbose) { diff --git a/Polyhedron/demo/Polyhedron/C3t3_type.h b/Polyhedron/demo/Polyhedron/C3t3_type.h index d37bf5306f7..d666f6546b5 100644 --- a/Polyhedron/demo/Polyhedron/C3t3_type.h +++ b/Polyhedron/demo/Polyhedron/C3t3_type.h @@ -28,6 +28,8 @@ #include #include +#include + #include #ifdef CGAL_MESH_3_DEMO_ACTIVATE_IMPLICIT_FUNCTIONS @@ -52,6 +54,8 @@ typedef CGAL::Polyhedral_mesh_domain_with_features_3< EPICK, SMesh, CGAL::Default, int> Polyhedral_mesh_domain; // The last `Tag_true` says the Patch_id type will be int, and not pair +typedef CGAL::Polyhedral_complex_mesh_domain_3 Polyhedral_complex_mesh_domain; + #ifdef CGAL_MESH_3_DEMO_ACTIVATE_SEGMENTED_IMAGES typedef CGAL::Labeled_mesh_domain_3 Image_domain; typedef CGAL::Mesh_domain_with_polyline_features_3 Image_mesh_domain; diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 641e3a1a9a1..e1520ae5590 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -139,6 +139,12 @@ QScriptValue myPrintFunction(QScriptContext *context, QScriptEngine *engine) return engine->undefinedValue(); } +inline +QKeySequence combine(Qt::Modifier m, Qt::Key k) +{ + return QKeySequence(static_cast(m)+static_cast(k)); +} + MainWindow::~MainWindow() { searchAction->deleteLater(); @@ -185,7 +191,7 @@ MainWindow::MainWindow(const QStringList &keywords, bool verbose, QWidget* paren CGAL::Three::Three::s_scene = scene; CGAL::Three::Three::s_connectable_scene = scene; { - QShortcut* shortcut = new QShortcut(QKeySequence(Qt::ALT,Qt::Key_Q), this); + QShortcut* shortcut = new QShortcut(combine(Qt::ALT,Qt::Key_Q), this); connect(shortcut, SIGNAL(activated()), this, SLOT(setFocusToQuickSearch())); shortcut = new QShortcut(QKeySequence(Qt::Key_F5), this); @@ -194,10 +200,10 @@ MainWindow::MainWindow(const QStringList &keywords, bool verbose, QWidget* paren shortcut = new QShortcut(QKeySequence(Qt::Key_F11), this); connect(shortcut, SIGNAL(activated()), this, SLOT(toggleFullScreen())); - shortcut = new QShortcut(QKeySequence(Qt::CTRL,Qt::Key_R), this); + shortcut = new QShortcut(combine(Qt::CTRL,Qt::Key_R), this); connect(shortcut, &QShortcut::activated, this, &MainWindow::recenterScene); - shortcut = new QShortcut(QKeySequence(Qt::CTRL,Qt::Key_T), this); + shortcut = new QShortcut(combine(Qt::CTRL,Qt::Key_T), this); connect(shortcut, &QShortcut::activated, this, [](){ diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index c787c901e5b..0d8687bd635 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -22,7 +22,6 @@ #include "Scene_surface_mesh_item.h" #include "Color_ramp.h" #include "Color_map.h" -#include #include "ui_Display_property.h" #include "id_printing.h" #include "Scene.h" @@ -1223,7 +1222,7 @@ private Q_SLOTS: scene->addItem(source_points); connect(source_points, &Scene_points_with_normal_item::aboutToBeDestroyed, [this](){ - boost::unordered_map::iterator it; + std::unordered_map::iterator it; for(it = mesh_sources_map.begin(); it != mesh_sources_map.end(); ++it) @@ -1432,12 +1431,12 @@ private: double bm; double bM; double bI; - boost::unordered_map > jacobian_min; - boost::unordered_map > jacobian_max; + std::unordered_map > jacobian_min; + std::unordered_map > jacobian_max; - boost::unordered_map > angles_min; - boost::unordered_map > angles_max; - boost::unordered_map is_source; + std::unordered_map > angles_min; + std::unordered_map > angles_max; + std::unordered_map is_source; double minBox; @@ -1446,11 +1445,11 @@ private: Scene_surface_mesh_item* current_item; Scene_points_with_normal_item* source_points; - boost::unordered_map mesh_sources_map; - boost::unordered_map mesh_heat_item_map; + std::unordered_map mesh_sources_map; + std::unordered_map mesh_heat_item_map; - boost::unordered_map mesh_heat_method_map; - boost::unordered_map mesh_heat_method_idt_map; + std::unordered_map mesh_heat_method_map; + std::unordered_map mesh_heat_method_idt_map; template friend class PropertyDisplayer; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp index 97949de6535..e990ee9d6e1 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp @@ -104,6 +104,14 @@ CGAL::Three::Scene_item* Surf_io_plugin::actual_load(QFileInfo fileinfo) FaceGraphItem *patch = new FaceGraphItem(patches[i]); patch->setName(QString("Patch #%1").arg(i)); patch->setColor(colors_[i]); + + patch->setProperty("inner material id", material_data[i].innerRegion.first); + patch->setProperty("inner material name", + QString(material_data[i].innerRegion.second.data())); + patch->setProperty("outer material id", material_data[i].outerRegion.first); + patch->setProperty("outer material name", + QString(material_data[i].outerRegion.second.data())); + CGAL::Three::Three::scene()->addItem(patch); CGAL::Three::Three::scene()->changeGroup(patch, group); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp index 12616332198..04af9bf3621 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include @@ -67,7 +67,7 @@ #include #include -#include +#include #include typedef Scene_surface_mesh_item Scene_facegraph_item; typedef Scene_facegraph_item::Face_graph FaceGraph; @@ -355,7 +355,7 @@ public: if(is_polygon_mesh) { FaceGraph* poly = new FaceGraph(); - if (CGAL::IO::internal::vtkPointSet_to_polygon_mesh(data, *poly, CGAL::parameters::all_default())) + if (CGAL::IO::internal::vtkPointSet_to_polygon_mesh(data, *poly, CGAL::parameters::default_values())) { Scene_facegraph_item* poly_item = new Scene_facegraph_item(poly); if(group) 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 e2139eb1b14..246a0fd2f8d 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp @@ -4,6 +4,7 @@ #ifdef CGAL_POLYHEDRON_DEMO_USE_SURFACE_MESHER #include #include +#include #include "Messages_interface.h" #include @@ -16,6 +17,7 @@ #include #include #include +#include #include #include @@ -214,6 +216,7 @@ private: QList> sm_items; Scene_surface_mesh_item* bounding_sm_item; Scene_polylines_item* polylines_item; + QList> incident_subdomains; }; struct Image_mesh_items { Image_mesh_items(gsl::not_null ptr) : image_item(ptr) {} @@ -328,7 +331,12 @@ boost::optional Mesh_3_plugin::get_items_or_return_error_string() const image_items.polylines_item = polylines_item; } } - } else { + } + else if (nullptr != + qobject_cast(scene->item(ind))) { + continue; + } + else { return tr("Wrong selection of items"); } } catch (const boost::bad_get&) { return tr("Wrong selection of items"); } @@ -663,20 +671,44 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, const auto bounding_sm_item = poly_items.bounding_sm_item; const auto polylines_item = poly_items.polylines_item; QList polyhedrons; - if(mesh_type != Mesh_type::SURFACE_ONLY) { + QList > incident_sub; + + bool material_ids_valid = true; + for (auto sm_item : sm_items) + { + if(!sm_item->property("inner material id").isValid() + || !sm_item->property("outer material id").isValid()) + { + material_ids_valid = false; + break; + } + else + { + incident_sub.append(std::make_pair( + sm_item->property("inner material id").toInt(), + sm_item->property("outer material id").toInt())); + } + } + + if(mesh_type != Mesh_type::SURFACE_ONLY && !material_ids_valid) + { sm_items.removeAll(make_not_null(bounding_sm_item)); } - std::transform(sm_items.begin(), sm_items.end(), - std::back_inserter(polyhedrons), - [](Scene_surface_mesh_item* item) { - return item->polyhedron(); - }); + Scene_polylines_item::Polylines_container plc; SMesh* bounding_polyhedron = (bounding_sm_item == nullptr) ? nullptr : bounding_sm_item->polyhedron(); - thread = cgal_code_mesh_3( + std::transform(sm_items.begin(), sm_items.end(), + std::back_inserter(polyhedrons), + [](Scene_surface_mesh_item* item) { + return item->polyhedron(); + }); + + if(bounding_polyhedron != nullptr) + { + thread = cgal_code_mesh_3( polyhedrons, (polylines_item == nullptr) ? plc : polylines_item->polylines, bounding_polyhedron, @@ -692,8 +724,27 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, sharp_edges_angle_bound, manifold, mesh_type == Mesh_type::SURFACE_ONLY); + } + else if(!incident_sub.empty()) + { + thread = cgal_code_mesh_3( + polyhedrons, + incident_sub, + item_name, + angle, + facets_sizing, + approx, + tets_sizing, + edges_sizing, + tets_shape, + protect_features, + protect_borders, + sharp_edges_angle_bound, + manifold, + mesh_type == Mesh_type::SURFACE_ONLY); + } break; - } + }//end case POLYHEDRAL_MESH_ITEMS // Image # ifdef CGAL_MESH_3_DEMO_ACTIVATE_IMPLICIT_FUNCTIONS case IMPLICIT_MESH_ITEMS: { diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp index f51c46022ed..fecc73c41ea 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp @@ -131,6 +131,101 @@ Meshing_thread* cgal_code_mesh_3(QList pMeshes, return new Meshing_thread(p_mesh_function, p_new_item); } +Meshing_thread* cgal_code_mesh_3(const QList pMeshes, + const QList >& incident_subdomains, + QString filename, + const double facet_angle, + const double facet_sizing, + const double facet_approx, + const double tet_sizing, + const double edge_size, + const double tet_shape, + bool protect_features, + bool protect_borders, + const double sharp_edges_angle, + const int manifold, + const bool surface_only) +{ + if (pMeshes.empty() && incident_subdomains.empty()) return 0; + + std::cerr << "Meshing file \"" << qPrintable(filename) << "\"\n"; + std::cerr << " angle: " << facet_angle << std::endl + << " edge size bound: " << edge_size << std::endl + << " facets size bound: " << facet_sizing << std::endl + << " approximation bound: " << facet_approx << std::endl; + if (!surface_only) + std::cerr << " tetrahedra size bound: " << tet_sizing << std::endl; + + CGAL::Real_timer timer; + timer.start(); + + std::vector patches; + std::transform(pMeshes.begin(), pMeshes.end(), + std::back_inserter(patches), + [](const SMesh* sm) { + return *sm; + }); + + // Create domain + Polyhedral_complex_mesh_domain* p_domain + = new Polyhedral_complex_mesh_domain(patches.begin(), + patches.end(), + incident_subdomains.begin(), + incident_subdomains.end()); + + // Features + if (protect_features) { + //includes detection of borders in the surface case + p_domain->detect_features(sharp_edges_angle); + } + else if (protect_borders) { + p_domain->detect_borders(); + } + + Scene_c3t3_item* p_new_item = new Scene_c3t3_item(surface_only); + if (protect_features) { + p_new_item->set_sharp_edges_angle(sharp_edges_angle); + } + else if (protect_borders) { + p_new_item->set_detect_borders(true); + } + + QString tooltip = QString("

      From \"") + filename + + QString("\" with the following mesh parameters" + "
        " + "
      • Angle: %1
      • " + "
      • Edge size bound: %2
      • " + "
      • Facets size bound: %3
      • " + "
      • Approximation bound: %4
      • ") + .arg(facet_angle) + .arg(edge_size) + .arg(facet_sizing) + .arg(facet_approx); + if (!surface_only) + tooltip += QString("
      • Tetrahedra size bound: %1
      • ") + .arg(tet_sizing); + tooltip += "
      "; + + p_new_item->setProperty("toolTip", tooltip); + Mesh_parameters param; + param.facet_angle = facet_angle; + param.facet_sizing = facet_sizing; + param.facet_approx = facet_approx; + param.tet_sizing = tet_sizing; + param.tet_shape = tet_shape; + param.edge_sizing = edge_size; + param.manifold = manifold; + param.protect_features = protect_features || protect_borders; + param.use_sizing_field_with_aabb_tree = protect_features; + + typedef ::Mesh_function Mesh_function; + Mesh_function* p_mesh_function = new Mesh_function(p_new_item->c3t3(), + p_domain, + param); + return new Meshing_thread(p_mesh_function, p_new_item); +} + #ifdef CGAL_MESH_3_DEMO_ACTIVATE_IMPLICIT_FUNCTIONS Meshing_thread* cgal_code_mesh_3(const Implicit_function_interface* pfunction, diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h index 5a0e5cc0a1d..4928982cf1e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h @@ -35,6 +35,22 @@ Meshing_thread* cgal_code_mesh_3(QList pMeshes, const double sharp_edges_angle, const int manifold, const bool surface_only); + +Meshing_thread* cgal_code_mesh_3(const QList pMeshes, + const QList >& incident_subdomains, + QString filename, + const double facet_angle, + const double facet_sizing, + const double facet_approx, + const double tet_sizing, + const double edge_size, + const double tet_shape, + bool protect_features, + bool protect_border, + const double sharp_edges_angle, + const int manifold, + const bool surface_only); + #ifdef CGAL_MESH_3_DEMO_ACTIVATE_IMPLICIT_FUNCTIONS Meshing_thread* cgal_code_mesh_3(const Implicit_function_interface* pfunction, const double facet_angle, diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Optimization_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Optimization_plugin.cpp index ecddec2f9e4..3c0a56a87f3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Optimization_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Optimization_plugin.cpp @@ -242,7 +242,7 @@ Mesh_3_optimization_plugin::odt() ui.objectName->setText(item->name()); - namespace cgpd = CGAL::parameters::default_values; + namespace cgpd = CGAL::parameters::default_values_for_mesh_3; ui.convergenceRatio->setValue(cgpd::odt_convergence_ratio); ui.freezeRatio->setValue(cgpd::odt_freeze_ratio); @@ -310,7 +310,7 @@ Mesh_3_optimization_plugin::lloyd() ui.objectName->setText(item->name()); - namespace cgpd = CGAL::parameters::default_values; + namespace cgpd = CGAL::parameters::default_values_for_mesh_3; ui.convergenceRatio->setValue(cgpd::lloyd_convergence_ratio); ui.freezeRatio->setValue(cgpd::lloyd_freeze_ratio); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Clip_polyhedron_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Clip_polyhedron_plugin.cpp index 457ebdc7b44..6001c47738a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Clip_polyhedron_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Clip_polyhedron_plugin.cpp @@ -255,7 +255,7 @@ public Q_SLOTS: { CGAL::Polygon_mesh_processing::clip(*(sm_item->face_graph()), plane->plane(), - CGAL::Polygon_mesh_processing::parameters::clip_volume( + CGAL::parameters::clip_volume( ui_widget.close_checkBox->isChecked()). throw_on_self_intersection(true). use_compact_clipper( @@ -279,7 +279,7 @@ public Q_SLOTS: { CGAL::Polygon_mesh_processing::split(*(sm_item->face_graph()), plane->plane(), - CGAL::Polygon_mesh_processing::parameters::throw_on_self_intersection(true) + CGAL::parameters::throw_on_self_intersection(true) .allow_self_intersections(ui_widget.do_not_modify_CheckBox->isChecked())); } } @@ -411,12 +411,12 @@ public Q_SLOTS: try { CGAL::Polygon_mesh_processing::clip(*(sm_item->face_graph()), clipper, - CGAL::Polygon_mesh_processing::parameters::clip_volume( + CGAL::parameters::clip_volume( ui_widget.close_checkBox->isChecked()). throw_on_self_intersection(true). use_compact_clipper( !ui_widget.coplanarCheckBox->isChecked()), - CGAL::Polygon_mesh_processing::parameters::do_not_modify(ui_widget.do_not_modify_CheckBox->isChecked())); + CGAL::parameters::do_not_modify(ui_widget.do_not_modify_CheckBox->isChecked())); } catch(const CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception&) { @@ -430,8 +430,8 @@ public Q_SLOTS: try { CGAL::Polygon_mesh_processing::split(*pos_side, clipper, - CGAL::Polygon_mesh_processing::parameters::throw_on_self_intersection(true), - CGAL::Polygon_mesh_processing::parameters::do_not_modify(ui_widget.do_not_modify_CheckBox->isChecked())); + CGAL::parameters::throw_on_self_intersection(true), + CGAL::parameters::do_not_modify(ui_widget.do_not_modify_CheckBox->isChecked())); } catch(const CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception&) { diff --git a/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_plugin.cpp index d6025740c6a..8bf98735fc4 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_plugin.cpp @@ -772,7 +772,7 @@ void Basic_generator_plugin::generateLines() std::vector patch; CGAL::Polygon_mesh_processing::triangulate_hole_polyline(polyline, std::back_inserter(patch), - CGAL::Polygon_mesh_processing::parameters::use_delaunay_triangulation(true)); + CGAL::parameters::use_delaunay_triangulation(true)); if(patch.empty()) { QMessageBox::warning(mw, "Warning", "Triangulation failed."); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Corefinement_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Corefinement_plugin.cpp index 8228ea5409b..7df1bd37920 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Corefinement_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Corefinement_plugin.cpp @@ -11,7 +11,7 @@ using namespace CGAL::Three; namespace PMP = CGAL::Polygon_mesh_processing; -namespace params = PMP::parameters; +namespace params = CGAL::parameters; class Polyhedron_demo_corefinement_sm_plugin : public QObject, diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Detect_sharp_edges_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Detect_sharp_edges_plugin.cpp index 6e16daf7579..38dfc613c25 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Detect_sharp_edges_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Detect_sharp_edges_plugin.cpp @@ -129,7 +129,7 @@ void Polyhedron_demo_detect_sharp_edges_plugin::detectSharpEdges(bool input_dial VIP vip = get(CGAL::vertex_incident_patches_t(), *pMesh); first_patch+=PMP::sharp_edges_segmentation(*pMesh, angle, eif, pid, - PMP::parameters::first_index(first_patch) + CGAL::parameters::first_index(first_patch) .vertex_incident_patches_map(vip)); //update item item->setItemIsMulticolor(true); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp index a303bbbe8b7..d6d3c6a1a45 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp @@ -195,7 +195,7 @@ private: //compute distance with other polyhedron //sample facet std::vector sampled_points; - std::size_t nb_points = (std::max)((int)std::ceil(nb_pts_per_face * PMP::face_area(f,*poly,PMP::parameters::geom_traits(Kernel()))), + std::size_t nb_points = (std::max)((int)std::ceil(nb_pts_per_face * PMP::face_area(f,*poly,CGAL::parameters::geom_traits(Kernel()))), 1); Kernel::Point_3 &p = get(vpmap,target(halfedge(f,*poly),*poly)); Kernel::Point_3 &q = get(vpmap,target(next(halfedge(f,*poly),*poly),*poly)); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Engrave_text_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Engrave_text_plugin.cpp index 0c297a0b14d..1b18fade896 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Engrave_text_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Engrave_text_plugin.cpp @@ -52,8 +52,8 @@ halfedge_descriptor halfedge_descriptor; typedef boost::graph_traits:: vertex_descriptor vertex_descriptor; -typedef boost::unordered_set:: -face_descriptor> Component; +typedef std::unordered_set:: + face_descriptor> Component; struct FaceInfo2 { @@ -492,8 +492,8 @@ public Q_SLOTS: sm->add_property_map("v:uv").first; // Parameterized bool pmap - boost::unordered_set vs; - SMP::internal::Bool_property_map< boost::unordered_set > vpm(vs); + std::unordered_set vs; + SMP::internal::Bool_property_map< std::unordered_set > vpm(vs); // Parameterizer SMP::ARAP_parameterizer_3 parameterizer; diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Fairing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Fairing_plugin.cpp index d20d302e43f..ade3641a6fc 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Fairing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Fairing_plugin.cpp @@ -99,13 +99,13 @@ public Q_SLOTS: if(weight_index == 1) CGAL::Polygon_mesh_processing::fair(*selection_item->polyhedron(), selection_item->selected_vertices, - CGAL::Polygon_mesh_processing::parameters:: + CGAL::parameters:: weight_calculator(CGAL::Weights::Uniform_weight()). fairing_continuity(continuity)); if(weight_index == 0) CGAL::Polygon_mesh_processing::fair(*selection_item->polyhedron(), selection_item->selected_vertices, - CGAL::Polygon_mesh_processing::parameters::fairing_continuity(continuity)); + CGAL::parameters::fairing_continuity(continuity)); selection_item->polyhedron_item()->resetColors(); selection_item->changed_with_poly_item(); selection_item->invalidateOpenGLBuffers(); @@ -127,7 +127,7 @@ public Q_SLOTS: selection_item->selected_facets, std::back_inserter(new_facets), CGAL::Emptyset_iterator(), - CGAL::Polygon_mesh_processing::parameters::density_control_factor(alpha)); + CGAL::parameters::density_control_factor(alpha)); // add new facets to selection for(std::vector::face_descriptor>::iterator it = new_facets.begin(); it != new_facets.end(); ++it) { selection_item->selected_facets.insert(*it); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp index c4a6207c968..94300e439fa 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -44,7 +44,7 @@ #include #include "Kernel_type.h" -#include +#include #include #include #include @@ -240,7 +240,7 @@ private: Face_graph& poly = *poly_item->polyhedron(); - boost::unordered_set visited; + std::unordered_set visited; boost::property_map::type vpm = get(CGAL::vertex_point,poly); for(fg_halfedge_descriptor hd : halfedges(poly)){ @@ -703,12 +703,12 @@ bool Polyhedron_demo_hole_filling_plugin::fill if(action_index == 0) { CGAL::Polygon_mesh_processing::triangulate_hole(poly, it, std::back_inserter(patch), - CGAL::Polygon_mesh_processing::parameters::use_delaunay_triangulation(use_DT)); + CGAL::parameters::use_delaunay_triangulation(use_DT)); } else if(action_index == 1) { CGAL::Polygon_mesh_processing::triangulate_and_refine_hole(poly, it, std::back_inserter(patch), CGAL::Emptyset_iterator(), - CGAL::Polygon_mesh_processing::parameters::density_control_factor(alpha). + CGAL::parameters::density_control_factor(alpha). use_delaunay_triangulation(use_DT)); } else { @@ -718,7 +718,7 @@ bool Polyhedron_demo_hole_filling_plugin::fill if(weight_index == 0) { success = std::get<0>(CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole(poly, it, std::back_inserter(patch), CGAL::Emptyset_iterator(), - CGAL::Polygon_mesh_processing::parameters:: + CGAL::parameters:: weight_calculator(CGAL::Weights::Uniform_weight()). density_control_factor(alpha). fairing_continuity(continuity). @@ -728,7 +728,7 @@ bool Polyhedron_demo_hole_filling_plugin::fill auto pmap = get_property_map(CGAL::vertex_point, poly); success = std::get<0>(CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole(poly, it, std::back_inserter(patch), CGAL::Emptyset_iterator(), - CGAL::Polygon_mesh_processing::parameters:: + CGAL::parameters:: weight_calculator(CGAL::Weights::Secure_cotangent_weight_with_voronoi_area(poly, pmap)). density_control_factor(alpha). fairing_continuity(continuity). @@ -753,7 +753,7 @@ bool Polyhedron_demo_hole_filling_plugin::fill Intersected_facets intersected_facets; CGAL::Polygon_mesh_processing::self_intersections(poly, std::back_inserter(intersected_facets), - CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, poly))); + CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, poly))); print_message(QString("Self intersecting test: finding intersecting triangles in %1 sec.").arg(timer.time())); timer.reset(); @@ -800,7 +800,7 @@ void Polyhedron_demo_hole_filling_plugin::on_Fill_from_selection_button() { normalize_border(*poly); // fill hole - boost::unordered_set buffer; + std::unordered_set buffer; //check if all selected edges are boder //to do check that the seection is closed for(fg_edge_descriptor ed : edge_selection->selected_edges) @@ -887,7 +887,7 @@ void Polyhedron_demo_hole_filling_plugin::on_Fill_from_selection_button() { std::vector > patch; CGAL::Polygon_mesh_processing::triangulate_hole_polyline(points, std::back_inserter(patch), - CGAL::Polygon_mesh_processing::parameters::use_delaunay_triangulation(use_DT)); + CGAL::parameters::use_delaunay_triangulation(use_DT)); if(patch.size()<3) print_message("There is not enough points. Please try again."); for(std::size_t i=0; i patch; CGAL::Polygon_mesh_processing::triangulate_hole_polyline(*it, std::back_inserter(patch), - PMP::parameters::use_delaunay_triangulation(use_DT)); + CGAL::parameters::use_delaunay_triangulation(use_DT)); print_message(QString("Triangulated in %1 sec.").arg(timer.time())); if(patch.empty()) { @@ -975,7 +975,7 @@ void Polyhedron_demo_hole_filling_plugin::hole_filling_polyline_action() { timer.reset(); CGAL::Polygon_mesh_processing::refine(*poly, faces(*poly), Nop_out(), Nop_out(), - CGAL::Polygon_mesh_processing::parameters::density_control_factor(density_control_factor)); + CGAL::parameters::density_control_factor(density_control_factor)); print_message(QString("Refined in %1 sec.").arg(timer.time())); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp index d3a38f572fa..92e27e67b66 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp @@ -18,10 +18,9 @@ #include #include #include +#include #include -#include -#include #include #include @@ -37,6 +36,7 @@ #include #include #include +#include #ifdef CGAL_LINKED_WITH_TBB #include "tbb/parallel_for.h" @@ -177,7 +177,7 @@ class Polyhedron_demo_isotropic_remeshing_plugin : typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef boost::graph_traits::face_descriptor face_descriptor; - typedef boost::unordered_set Edge_set; + typedef std::unordered_set Edge_set; typedef Scene_polyhedron_selection_item::Is_constrained_map Edge_constrained_pmap; struct Visitor @@ -318,7 +318,7 @@ public: p_edges , target_length , *selection_item->polyhedron() - , PMP::parameters::geom_traits(EPICK()) + , CGAL::parameters::geom_traits(EPICK()) .edge_is_constrained_map(selection_item->constrained_edges_pmap())); else std::cout << "No selected or boundary edges to be split" << std::endl; @@ -462,7 +462,7 @@ public Q_SLOTS: CGAL::Polygon_mesh_processing::isotropic_remeshing(faces(*selection_item->polyhedron()) , target_length , *selection_item->polyhedron() - , CGAL::Polygon_mesh_processing::parameters::number_of_iterations(nb_iter) + , CGAL::parameters::number_of_iterations(nb_iter) .protect_constraints(protect) .edge_is_constrained_map(selection_item->constrained_edges_pmap()) .relax_constraints(smooth_features) @@ -473,7 +473,7 @@ public Q_SLOTS: CGAL::Polygon_mesh_processing::isotropic_remeshing(faces(*selection_item->polyhedron()) , target_length , *selection_item->polyhedron() - , CGAL::Polygon_mesh_processing::parameters::number_of_iterations(nb_iter) + , CGAL::parameters::number_of_iterations(nb_iter) .protect_constraints(protect) .edge_is_constrained_map(selection_item->constrained_edges_pmap()) .relax_constraints(smooth_features) @@ -498,7 +498,7 @@ public Q_SLOTS: Visitor visitor(selection_item->selected_facets); CGAL::Polygon_mesh_processing::triangulate_faces(selection_item->selected_facets, pmesh, - CGAL::Polygon_mesh_processing::parameters::visitor(visitor)); + CGAL::parameters::visitor(visitor)); break; } else @@ -512,7 +512,7 @@ public Q_SLOTS: CGAL::Polygon_mesh_processing::isotropic_remeshing(selection_item->selected_facets , target_length , *selection_item->polyhedron() - , CGAL::Polygon_mesh_processing::parameters::number_of_iterations(nb_iter) + , CGAL::parameters::number_of_iterations(nb_iter) .protect_constraints(protect) .edge_is_constrained_map(selection_item->constrained_edges_pmap()) .relax_constraints(smooth_features) @@ -523,7 +523,7 @@ public Q_SLOTS: CGAL::Polygon_mesh_processing::isotropic_remeshing(selection_item->selected_facets , target_length , *selection_item->polyhedron() - , CGAL::Polygon_mesh_processing::parameters::number_of_iterations(nb_iter) + , CGAL::parameters::number_of_iterations(nb_iter) .protect_constraints(protect) .edge_is_constrained_map(selection_item->constrained_edges_pmap()) .relax_constraints(smooth_features) @@ -569,7 +569,7 @@ public Q_SLOTS: edges_to_split , target_length , pmesh - , PMP::parameters::geom_traits(EPICK()) + , CGAL::parameters::geom_traits(EPICK()) . edge_is_constrained_map(eif) . face_patch_map(fpmap)); else @@ -577,7 +577,7 @@ public Q_SLOTS: edges_to_split , target_length , pmesh - , PMP::parameters::geom_traits(EPICK()) + , CGAL::parameters::geom_traits(EPICK()) . edge_is_constrained_map(eif)); } else @@ -640,7 +640,7 @@ public Q_SLOTS: faces(*poly_item->polyhedron()) , target_length , *poly_item->polyhedron() - , CGAL::Polygon_mesh_processing::parameters::number_of_iterations(nb_iter) + , CGAL::parameters::number_of_iterations(nb_iter) .protect_constraints(protect) .number_of_relaxation_steps(nb_smooth) .edge_is_constrained_map(ecm) @@ -651,7 +651,7 @@ public Q_SLOTS: faces(*poly_item->polyhedron()) , target_length , *poly_item->polyhedron() - , CGAL::Polygon_mesh_processing::parameters::number_of_iterations(nb_iter) + , CGAL::parameters::number_of_iterations(nb_iter) .protect_constraints(protect) .number_of_relaxation_steps(nb_smooth) .edge_is_constrained_map(ecm) @@ -861,7 +861,7 @@ private: faces(*poly_item->polyhedron()) , target_length_ , *poly_item->polyhedron() - , CGAL::Polygon_mesh_processing::parameters::number_of_iterations(nb_iter_) + , CGAL::parameters::number_of_iterations(nb_iter_) .protect_constraints(protect_) .edge_is_constrained_map(ecm) .face_patch_map(get(CGAL::face_patch_id_t(), *poly_item->polyhedron())) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp index 2c9683fbe7d..4a4710cdb2d 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include "Color_map.h" typedef Scene_surface_mesh_item Scene_facegraph_item; @@ -253,7 +253,7 @@ void Polyhedron_demo_join_and_split_polyhedra_plugin::on_actionColorConnectedCom int nb_patch_ids = PMP::connected_components(pmesh , fccmap - , PMP::parameters::edge_is_constrained_map(selection_item->constrained_edges_pmap()) + , CGAL::parameters::edge_is_constrained_map(selection_item->constrained_edges_pmap()) .face_index_map(fim)); for(face_descriptor f : faces(pmesh)) 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 77074c05704..be6a1ac02e8 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 @@ -236,7 +236,7 @@ public: // the algorithm is only applicable on a mesh // that has only one connected component - boost::unordered_map::face_descriptor,int> cc(num_faces(*pMesh)); + std::unordered_map::face_descriptor,int> cc(num_faces(*pMesh)); std::size_t num_component = PMP::connected_components(*pMesh, boost::make_assoc_property_map(cc)); if (num_component != 1) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Polyhedron_stitching_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Polyhedron_stitching_plugin.cpp index aaf56a247b4..40fed3f5a24 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Polyhedron_stitching_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Polyhedron_stitching_plugin.cpp @@ -146,7 +146,7 @@ void Polyhedron_demo_polyhedron_stitching_plugin::on_actionStitchByCC_triggered( if(!item) return; CGAL::Polygon_mesh_processing::stitch_borders(*item->polyhedron(), - CGAL::Polygon_mesh_processing::parameters::apply_per_connected_component(true)); + CGAL::parameters::apply_per_connected_component(true)); item->invalidateOpenGLBuffers(); scene->itemChanged(item); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp index 49063e703b7..32724c409f4 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp @@ -108,13 +108,13 @@ public Q_SLOTS: { unsigned int seed = static_cast(ui.seed_spinbox->value()); PMP::random_perturbation(pmesh, max_move, - PMP::parameters::do_project(project) + CGAL::parameters::do_project(project) .random_seed(seed)); } else { PMP::random_perturbation(pmesh, max_move, - PMP::parameters::do_project(project)); + CGAL::parameters::do_project(project)); } poly_item->invalidateOpenGLBuffers(); @@ -141,7 +141,7 @@ public Q_SLOTS: selection_item->selected_vertices, pmesh, max_move, - PMP::parameters::do_project(project) + CGAL::parameters::do_project(project) .random_seed(seed)); } else @@ -152,7 +152,7 @@ public Q_SLOTS: selection_item->selected_vertices, pmesh, max_move, - PMP::parameters::do_project(project)); + CGAL::parameters::do_project(project)); } selection_item->invalidateOpenGLBuffers(); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Scene_facegraph_item_k_ring_selection.h b/Polyhedron/demo/Polyhedron/Plugins/PMP/Scene_facegraph_item_k_ring_selection.h index 361c4a0d7d3..99cd3b27fe9 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Scene_facegraph_item_k_ring_selection.h +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Scene_facegraph_item_k_ring_selection.h @@ -280,7 +280,7 @@ public Q_SLOTS: //std::vector cc; std::size_t nb_cc = CGAL::Polygon_mesh_processing::connected_components(poly , fccmap - , CGAL::Polygon_mesh_processing::parameters::edge_is_constrained_map(spmap)); + , CGAL::parameters::edge_is_constrained_map(spmap)); std::vector is_cc_done(nb_cc, false); for(fg_face_descriptor f : face_sel) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp index b4a495d9422..c2150d90688 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp @@ -394,7 +394,7 @@ public Q_SLOTS: if (dialog.exec() != QDialog::Accepted) return; - boost::unordered_map is_selected_map; + std::unordered_map is_selected_map; for(fg_face_descriptor fh : faces(*selection_item->polyhedron())) { if(selection_item->selected_facets.find(fh) @@ -752,7 +752,7 @@ public Q_SLOTS: print_message("Error: Please select a selection item with a selection of faces."); return; } - boost::unordered_map is_selected_map; + std::unordered_map is_selected_map; int index = 0; for(fg_face_descriptor fh : faces(*selection_item->polyhedron())) { @@ -1171,7 +1171,7 @@ private: Ui::Selection ui_widget; std::map operations_map; std::vector operations_strings; -typedef boost::unordered_map Selection_item_map; + typedef std::unordered_map Selection_item_map; Selection_item_map selection_item_map; int last_mode; bool from_plugin; @@ -1189,7 +1189,7 @@ bool selfIntersect(Mesh* mesh, std::vectorpolyhedron(), *itemB->polyhedron(), std::back_inserter(new_item->polylines), - PMP::parameters::throw_on_self_intersection(true)); + CGAL::parameters::throw_on_self_intersection(true)); } catch(const CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception&) { @@ -311,7 +311,7 @@ void Polyhedron_demo_intersection_plugin::intersectionSurfacePolyline() polylines, *itemA->face_graph(), std::back_inserter(poly_intersections), - CGAL::Polygon_mesh_processing::parameters::all_default()); + CGAL::parameters::default_values()); Q_FOREACH(const Poly_intersection& inter, poly_intersections) { diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Triangulate_facets_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Triangulate_facets_plugin.cpp index 2423d268562..3f86836f4bf 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Triangulate_facets_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Triangulate_facets_plugin.cpp @@ -103,7 +103,7 @@ public Q_SLOTS: if (!CGAL::Polygon_mesh_processing::triangulate_faces( selection_item->selected_facets, *pMesh, - CGAL::Polygon_mesh_processing::parameters::visitor(visitor))) + CGAL::parameters::visitor(visitor))) CGAL::Three::Three::warning(tr("Some facets could not be triangulated.")); sm_item = selection_item->polyhedron_item(); 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 a2b0cc261dc..cc5431609ac 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 @@ -49,17 +49,20 @@ struct Grid_simplify_functor { Point_set* points; double grid_size; + unsigned int min_points_per_cell; boost::shared_ptr result; - Grid_simplify_functor (Point_set* points, double grid_size) - : points (points), grid_size (grid_size), result (new Point_set::iterator) { } + Grid_simplify_functor (Point_set* points, double grid_size, unsigned min_points_per_cell) + : points (points), grid_size (grid_size), min_points_per_cell(min_points_per_cell) + , result (new Point_set::iterator) { } void operator()() { *result = CGAL::grid_simplify_point_set(*points, grid_size, points->parameters(). - callback (*(this->callback()))); + callback (*(this->callback())). + min_points_per_cell (min_points_per_cell)); } }; @@ -144,6 +147,7 @@ class Point_set_demo_point_set_simplification_dialog : public QDialog, private U } double randomSimplificationPercentage() const { return m_randomSimplificationPercentage->value(); } double gridCellSize() const { return m_gridCellSize->value(); } + unsigned int minPointsPerCell() const { return m_minPointsPerCell->value(); } unsigned int maximumClusterSize() const { return m_maximumClusterSize->value(); } double maximumSurfaceVariation() const { return m_maximumSurfaceVariation->value(); } @@ -153,6 +157,7 @@ public Q_SLOTS: { m_randomSimplificationPercentage->setEnabled (toggled); m_gridCellSize->setEnabled (!toggled); + m_minPointsPerCell->setEnabled (!toggled); m_maximumClusterSize->setEnabled (!toggled); m_maximumSurfaceVariation->setEnabled (!toggled); } @@ -160,6 +165,7 @@ public Q_SLOTS: { m_randomSimplificationPercentage->setEnabled (!toggled); m_gridCellSize->setEnabled (toggled); + m_minPointsPerCell->setEnabled (toggled); m_maximumClusterSize->setEnabled (!toggled); m_maximumSurfaceVariation->setEnabled (!toggled); } @@ -167,6 +173,7 @@ public Q_SLOTS: { m_randomSimplificationPercentage->setEnabled (!toggled); m_gridCellSize->setEnabled (!toggled); + m_minPointsPerCell->setEnabled (!toggled); m_maximumClusterSize->setEnabled (toggled); m_maximumSurfaceVariation->setEnabled (toggled); } @@ -211,7 +218,8 @@ void Polyhedron_demo_point_set_simplification_plugin::on_actionSimplify_triggere } else if (method == 1) { - std::cerr << "Point set grid simplification (cell size = " << dialog.gridCellSize() <<" * average spacing)...\n"; + std::cerr << "Point set grid simplification (cell size = " << dialog.gridCellSize() <<" * average spacing, " + << dialog.minPointsPerCell() << " minimum point(s) per cell)" << std::endl; // Computes average spacing Compute_average_spacing_functor functor_as (points, 6); @@ -219,7 +227,7 @@ void Polyhedron_demo_point_set_simplification_plugin::on_actionSimplify_triggere double average_spacing = *functor_as.result; - Grid_simplify_functor functor (points, dialog.gridCellSize() * average_spacing); + Grid_simplify_functor functor (points, dialog.gridCellSize() * average_spacing, dialog.minPointsPerCell()); run_with_qprogressdialog (functor, "Grid simplyfing...", mw); // Computes points to remove by Grid Clustering 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 45b189faf13..11132e68fb4 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 @@ -6,73 +6,18 @@ 0 0 - 392 - 249 + 361 + 286 Simplification - - + + - Random - - - true - - - - - - - false - - - 1 - - - 2147483647 - - - 10 - - - - - - - Grid Cell Size - - - - - - - % - - - 2 - - - 0.100000000000000 - - - 100.000000000000000 - - - 0.100000000000000 - - - 50.000000000000000 - - - - - - - Maximum Surface Variation + 0.333333 @@ -101,7 +46,48 @@ - + + + + Grid + + + + + + + Random + + + true + + + + + + + Grid Cell Size + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Hierarchy + + + + Qt::Vertical @@ -114,13 +100,36 @@ - + Maximum Cluster Size + + + + false + + + 1 + + + 2147483647 + + + 10 + + + + + + + Maximum Surface Variation + + + @@ -128,34 +137,45 @@ - - - - Grid + + + + % + + + 2 + + + 0.100000000000000 + + + 100.000000000000000 + + + 0.100000000000000 + + + 50.000000000000000 - + - Hierarchy + Minimum points per cell - - - - Qt::Horizontal + + + + false - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + 1 - - - - - - 0.333333 + + 400000000 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 83e70119a77..4ef6a35b7a1 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Offset_meshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Offset_meshing_plugin.cpp @@ -291,9 +291,10 @@ SMesh* cgal_off_meshing(QWidget*, p::relative_error_bound = 1e-7, p::construct_surface_patch_index = [](int i, int j) { return (i * 1000 + j); }); - CGAL::Mesh_facet_topology topology = CGAL::FACET_VERTICES_ON_SAME_SURFACE_PATCH; - if(tag == 1) topology = CGAL::Mesh_facet_topology(topology | CGAL::MANIFOLD_WITH_BOUNDARY); - if(tag == 2) topology = CGAL::Mesh_facet_topology(topology | CGAL::MANIFOLD); + const CGAL::Mesh_facet_topology topology = CGAL::FACET_VERTICES_ON_SAME_SURFACE_PATCH; + auto manifold_option = p::non_manifold(); + if(tag == 1) manifold_option = p::manifold_with_boundary(); + if(tag == 2) manifold_option = p::manifold(); Mesh_criteria criteria(p::facet_angle = angle, p::facet_size = sizing, p::facet_distance = approx, @@ -314,7 +315,8 @@ SMesh* cgal_off_meshing(QWidget*, C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria, p::no_perturb(), - p::no_exude()); + p::no_exude(), + manifold_option); const Tr& tr = c3t3.triangulation(); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Parameterization_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Parameterization_plugin.cpp index e9e226dad27..448c9b27027 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Parameterization_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Parameterization_plugin.cpp @@ -37,16 +37,14 @@ #include #include - -#include -#include #include #include #include #include #include - +#include +#include #include #include @@ -63,7 +61,7 @@ typedef EPICK Traits; namespace SMP = CGAL::Surface_mesh_parameterization; -typedef boost::unordered_set::face_descriptor> Component; +typedef std::unordered_set::face_descriptor> Component; typedef std::vector Components; struct Is_selected_property_map{ @@ -209,11 +207,11 @@ typedef boost::graph_traits::face_descriptor s_face_descr typedef boost::graph_traits::edges_size_type s_edges_size_type; -typedef boost::unordered_set:: +typedef std::unordered_set:: face_descriptor> Component; typedef std::vector Components; -typedef boost::unordered_set SComponent; +typedef std::unordered_set SComponent; typedef std::vector SComponents; class UVItem : public QGraphicsItem @@ -665,7 +663,7 @@ void Polyhedron_demo_parameterization_plugin::parameterize(const Parameterizatio } // map the cones from the selection plugin to the textured polyhedron - boost::unordered_set unordered_cones; + std::unordered_set unordered_cones; if(method == PARAM_OTE) { for(P_vertex_descriptor vd : sel_item->selected_vertices) { boost::graph_traits::vertex_descriptor pvd(vd); @@ -698,7 +696,7 @@ void Polyhedron_demo_parameterization_plugin::parameterize(const Parameterizatio CGAL::Polygon_mesh_processing::connected_components( tMesh, fccmap, - CGAL::Polygon_mesh_processing::parameters::edge_is_constrained_map( + CGAL::parameters::edge_is_constrained_map( edge_pmap)); // Next is the gathering of the border halfedges of the connected component. @@ -736,7 +734,7 @@ void Polyhedron_demo_parameterization_plugin::parameterize(const Parameterizatio // find longest border in the connected component s_halfedge_descriptor bhd; // a halfedge on the (possibly virtual) border - boost::unordered_set visited; + std::unordered_set visited; FT result_len = 0; for(s_halfedge_descriptor hd : border) { @@ -877,7 +875,7 @@ void Polyhedron_demo_parameterization_plugin::parameterize(const Parameterizatio Parameterizer parameterizer(orb); // Mark cones in the seam mesh - boost::unordered_map cmap; + std::unordered_map cmap; if(!SMP::locate_unordered_cones(sMesh, unordered_cones.begin(), unordered_cones.end(), cmap)) { std::cerr << "Error: invalid cone or seam selection" << std::endl; @@ -888,7 +886,7 @@ void Polyhedron_demo_parameterization_plugin::parameterize(const Parameterizatio QApplication::setOverrideCursor(Qt::WaitCursor); // Fill the index property map - typedef boost::unordered_map Indices; + typedef std::unordered_map Indices; Indices indices; CGAL::Polygon_mesh_processing::connected_component( face(opposite(bhd, sMesh), sMesh), diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.cpp index 10ed28c0d1c..903e6977073 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.cpp @@ -671,7 +671,7 @@ void Scene_edit_polyhedron_item_priv::remesh(Mesh* mesh) roi_facets , target_length , *mesh - , CGAL::Polygon_mesh_processing::parameters::number_of_iterations(nb_iter) + , CGAL::parameters::number_of_iterations(nb_iter) .protect_constraints(false) .vertex_point_map(vpmap) .edge_is_constrained_map(border_pmap) diff --git a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp index a18f10211bf..ba71e754425 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp @@ -421,6 +421,3 @@ void Scene_c3t3_item::copyProperties(Scene_item *item) show_cnc(c3t3_item->has_cnc()); } - -#include "Scene_c3t3_item.moc" - diff --git a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp index e403b2dcda1..dbbda5a8edd 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp @@ -885,7 +885,7 @@ void Scene_polygon_soup_item::repair(bool erase_dup, bool req_same_orientation) CGAL::Polygon_mesh_processing::repair_polygon_soup( d->soup->points, d->soup->polygons, - CGAL::Polygon_mesh_processing::parameters:: + CGAL::parameters:: erase_all_duplicates(erase_dup) .require_same_orientation(req_same_orientation)); QApplication::restoreOverrideCursor(); diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp index dac9a06690a..7424e2cdde3 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp @@ -12,8 +12,6 @@ #include #include -#include -#include #include #include #include @@ -27,6 +25,8 @@ #include #include #include +#include +#include #include "triangulate_primitive.h" #include @@ -77,12 +77,9 @@ public: struct Scene_polyhedron_selection_item_priv{ typedef Scene_facegraph_item_k_ring_selection::Active_handle Active_handle; - typedef boost::unordered_set Selection_set_vertex; - typedef boost::unordered_set Selection_set_facet; - typedef boost::unordered_set Selection_set_edge; + typedef std::unordered_set Selection_set_vertex; + typedef std::unordered_set Selection_set_facet; + typedef std::unordered_set Selection_set_edge; struct vertex_on_path { fg_vertex_descriptor vertex; @@ -322,7 +319,7 @@ void Scene_polyhedron_selection_item_priv::compute_any_elements(std::vectortemp_selected_edges.clear(); path.clear(); - typedef boost::unordered_map Pred_umap; + typedef std::unordered_map Pred_umap; typedef boost::associative_property_map Pred_pmap; Pred_umap predecessor; diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h index 3c573bf74ef..d4482dda9c8 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -253,9 +253,9 @@ protected: void set_is_insert(bool i) { is_insert = i; } public: - typedef boost::unordered_set Selection_set_vertex; - typedef boost::unordered_set Selection_set_facet; - typedef boost::unordered_set Selection_set_edge; + typedef std::unordered_set Selection_set_vertex; + typedef std::unordered_set Selection_set_facet; + typedef std::unordered_set Selection_set_edge; Vertex_selection_map vertex_selection_map() { @@ -967,8 +967,8 @@ template get_face(*selection.begin()), *polyhedron(), std::back_inserter(selected_cc), - CGAL::Polygon_mesh_processing::parameters::edge_is_constrained_map( - Is_selected_property_map(mark, get(boost::edge_index,*polyhedron())))); + CGAL::parameters::edge_is_constrained_map( + Is_selected_property_map(mark, get(boost::edge_index,*polyhedron())))); treat_selection(selected_cc); } else diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index 6de2a6ae9f9..7e5d45a15b2 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -1144,7 +1144,6 @@ void* Scene_surface_mesh_item_priv::get_aabb_tree() sm->collect_garbage(); Input_facets_AABB_tree* tree = new Input_facets_AABB_tree(); - int index =0; for(face_descriptor f : faces(*sm)) { //if face is degenerate, skip it @@ -1155,7 +1154,6 @@ void* Scene_surface_mesh_item_priv::get_aabb_tree() if(!CGAL::is_triangle(halfedge(f, *sm), *sm)) { EPICK::Vector_3 normal = CGAL::Polygon_mesh_processing::compute_face_normal(f, *sm); - index +=3; Q_FOREACH(EPICK::Triangle_3 triangle, triangulate_primitive(f,normal)) { Primitive primitive(triangle, f); @@ -1551,7 +1549,7 @@ Scene_surface_mesh_item::save(std::ostream& out) const } else { - CGAL::IO::internal::write_OFF_BGL(out,*d->smesh_, CGAL::parameters::all_default()); + CGAL::IO::internal::write_OFF_BGL(out,*d->smesh_, CGAL::parameters::default_values()); } QApplication::restoreOverrideCursor(); return (bool) out; @@ -1937,8 +1935,7 @@ void Scene_surface_mesh_item::zoomToPosition(const QPoint &point, CGAL::Three::V //compute new position and orientation EPICK::Vector_3 face_normal = CGAL::Polygon_mesh_processing:: compute_face_normal(selected_fh, - *d->smesh_, - CGAL::Polygon_mesh_processing::parameters::all_default()); + *d->smesh_); double x(0), y(0), z(0), diff --git a/Polyhedron/demo/Polyhedron/include/CGAL/IO/read_surf_trianglemesh.h b/Polyhedron/demo/Polyhedron/include/CGAL/IO/read_surf_trianglemesh.h index fc2ac29aeb3..f2bd4e37871 100644 --- a/Polyhedron/demo/Polyhedron/include/CGAL/IO/read_surf_trianglemesh.h +++ b/Polyhedron/demo/Polyhedron/include/CGAL/IO/read_surf_trianglemesh.h @@ -8,7 +8,7 @@ #include #include -#include +#include #include //a material is composed of an material Id and a material name. @@ -388,13 +388,13 @@ bool build_binary_surf_patch(DuplicatedPointsOutIterator& out, * read_surf reads a file which extension is .surf and fills `output` with one `Mesh` per patch. * Mesh is a model of FaceListGraph. */ -template +template bool read_surf(std::istream& input, std::vector& output, std::vector& metadata, CGAL::Bbox_3& grid_box, std::array& grid_size, DuplicatedPointsOutIterator out, - const NamedParameters&) + const NamedParameters& = CGAL::parameters::default_values()) { typedef typename CGAL::GetGeomTraits::type Kernel; typedef typename Kernel::Point_3 Point_3; @@ -571,15 +571,3 @@ bool read_surf(std::istream& input, std::vector& output, } return true; } - -template -bool read_surf(std::istream& input, std::vector& output, - std::vector& metadata, - CGAL::Bbox_3& grid_box, - std::array& grid_size, - DuplicatedPointsOutIterator out) -{ - return read_surf(input, output, metadata, grid_box, grid_size, out, - CGAL::Polygon_mesh_processing::parameters::all_default()); -} - diff --git a/Polyhedron/demo/Polyhedron/include/Point_set_3.h b/Polyhedron/demo/Polyhedron/include/Point_set_3.h index ef82febaf50..e347e5bddb3 100644 --- a/Polyhedron/demo/Polyhedron/include/Point_set_3.h +++ b/Polyhedron/demo/Polyhedron/include/Point_set_3.h @@ -577,33 +577,13 @@ private: namespace CGAL { -namespace Point_set_processing_3 -{ - template - class GetFT< ::Point_set_3 > - { - public: - typedef typename Kernel::FT type; - }; - namespace parameters - { - template - Named_function_parameters - ::template Property_map, - internal_np::normal_t, - Named_function_parameters - ::template Property_map, - internal_np::point_t> > > - inline all_default(const ::Point_set_3& ps) - { - return ps.parameters(); - } - } -} +// specialization for default named parameters +template +struct Point_set_processing_3_np_helper<::Point_set_3, NamedParameters, NP_TAG> + : public Point_set_processing_3_np_helper::Base, NamedParameters, NP_TAG> +{}; + } #endif // POINT_SET_3_H diff --git a/Polyhedron/doc/Polyhedron/Polyhedron.txt b/Polyhedron/doc/Polyhedron/Polyhedron.txt index 5526de883c3..a18c74af274 100644 --- a/Polyhedron/doc/Polyhedron/Polyhedron.txt +++ b/Polyhedron/doc/Polyhedron/Polyhedron.txt @@ -319,9 +319,7 @@ CGAL::Polyhedron_3& P); Additional formats supported for writing are OpenInventor (.iv) \cgalCite{cgal:w-impoo-94}, VRML 1.0 and 2.0 (.wrl) \cgalCite{cgal:bpp-vrml-95}, \cgalCite{cgal:vrmls-97}, \cgalCite{cgal:hw-vrml2h-96}, -and \ref IOStreamOBJ (.obj). Another convenient output -function writes a polyhedral surface to a Geomview process spawned -from the \cgal program. These output functions are provided as +and \ref IOStreamOBJ (.obj). These output functions are provided as stream operators, now acting on the stream type of the respective format. @@ -329,7 +327,6 @@ format. #include #include #include -#include template Inventor_ostream& operator<<( Inventor_ostream& out, @@ -343,10 +340,6 @@ template VRML_2_ostream& operator<<( VRML_2_ostream& out, const CGAL::Polyhedron_3& P); -template -Geomview_stream& operator<<( Geomview_stream& out, -const CGAL::Polyhedron_3& P); - \endcode All these file formats have in common that they represent a surface as @@ -563,4 +556,3 @@ create the triangle in the halfedge data structure. */ } /* namespace CGAL */ - diff --git a/Polyhedron/examples/Polyhedron/polyhedron_prog_incr_builder.cpp b/Polyhedron/examples/Polyhedron/polyhedron_prog_incr_builder.cpp index a5f62cce5a1..f43e5b4e6a8 100644 --- a/Polyhedron/examples/Polyhedron/polyhedron_prog_incr_builder.cpp +++ b/Polyhedron/examples/Polyhedron/polyhedron_prog_incr_builder.cpp @@ -1,6 +1,7 @@ #include #include #include +#include // A modifier creating a triangle with the incremental builder. template @@ -33,6 +34,6 @@ int main() { Polyhedron P; Build_triangle triangle; P.delegate( triangle); - CGAL_assertion( P.is_triangle( P.halfedges_begin())); + assert( P.is_triangle( P.halfedges_begin())); return 0; } diff --git a/Polyhedron/examples/Polyhedron/polyhedron_prog_off.cpp b/Polyhedron/examples/Polyhedron/polyhedron_prog_off.cpp index d1fdd179c41..ff7a3209571 100644 --- a/Polyhedron/examples/Polyhedron/polyhedron_prog_off.cpp +++ b/Polyhedron/examples/Polyhedron/polyhedron_prog_off.cpp @@ -26,7 +26,6 @@ int main() { for ( Facet_iterator i = P.facets_begin(); i != P.facets_end(); ++i) { Halfedge_facet_circulator j = i->facet_begin(); // Facets in polyhedral surfaces are at least triangles. - CGAL_assertion( CGAL::circulator_size(j) >= 3); std::cout << CGAL::circulator_size(j) << ' '; do { std::cout << ' ' << std::distance(P.vertices_begin(), j->vertex()); diff --git a/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv.cpp b/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv.cpp index 0a2c85b4c8c..e972a9f92d8 100644 --- a/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv.cpp +++ b/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv.cpp @@ -5,6 +5,7 @@ #include #include #include +#include typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Vector_3 Vector; @@ -27,7 +28,7 @@ void create_center_vertex( Polyhedron& P, Facet_iterator f) { vec = vec + ( h->vertex()->point() - CGAL::ORIGIN); ++ order; } while ( ++h != f->facet_begin()); - CGAL_assertion( order >= 3); // guaranteed by definition of polyhedron + assert( order >= 3); // guaranteed by definition of polyhedron Point center = CGAL::ORIGIN + (vec / static_cast(order)); Halfedge_handle new_center = P.create_center_vertex( f->halfedge()); new_center->vertex()->point() = center; @@ -44,7 +45,7 @@ struct Smooth_old_vertex { vec = vec + ( h->opposite()->vertex()->point() - CGAL::ORIGIN) * alpha / static_cast(degree); ++ h; - CGAL_assertion( h != v.vertex_begin()); // even degree guaranteed + assert( h != v.vertex_begin()); // even degree guaranteed ++ h; } while ( h != v.vertex_begin()); return (CGAL::ORIGIN + vec); diff --git a/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv_with_boundary.cpp b/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv_with_boundary.cpp index f1d0de4f8f5..d8c7c05c2e5 100644 --- a/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv_with_boundary.cpp +++ b/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv_with_boundary.cpp @@ -7,6 +7,7 @@ #include #include #include +#include typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Vector_3 Vector; @@ -29,7 +30,7 @@ void create_center_vertex( Polyhedron& P, Facet_iterator f) { vec = vec + ( h->vertex()->point() - CGAL::ORIGIN); ++ order; } while ( ++h != f->facet_begin()); - CGAL_assertion( order >= 3); // guaranteed by definition of polyhedron + assert( order >= 3); // guaranteed by definition of polyhedron Point center = CGAL::ORIGIN + (vec / static_cast(order)); Halfedge_handle new_center = P.create_center_vertex( f->halfedge()); new_center->vertex()->point() = center; @@ -55,7 +56,7 @@ struct Smooth_old_vertex { vec = vec + ( h->opposite()->vertex()->point() - CGAL::ORIGIN) * alpha / static_cast(degree); ++ h; - CGAL_assertion( h != v.vertex_begin()); // even degree guaranteed + assert( h != v.vertex_begin()); // even degree guaranteed ++ h; } while ( h != v.vertex_begin()); return (CGAL::ORIGIN + vec); @@ -101,11 +102,10 @@ void subdiv( Polyhedron& P) { ++e; // careful, incr. before flip since flip destroys current edge flip_edge( P, h); }; - CGAL_postcondition( P.is_valid()); } void trisect_border_halfedge( Polyhedron& P, Halfedge_handle e) { - CGAL_precondition( e->is_border()); + assert( e->is_border()); // Create two new vertices on e. e = e->prev(); P.split_vertex( e, e->next()->opposite()); @@ -121,7 +121,7 @@ void trisect_border_halfedge( Polyhedron& P, Halfedge_handle e) { template void smooth_border_vertices( Halfedge_handle e, OutputIterator out) { - CGAL_precondition( e->is_border()); + assert( e->is_border()); // We know that the vertex at this edge is from the unrefined mesh. // Get the locus vectors of the unrefined vertices in the neighborhood. Vector v0 = e->prev()->prev()->opposite()->vertex()->point() -CGAL::ORIGIN; @@ -166,8 +166,6 @@ void subdiv_border( Polyhedron& P) { e->next()->vertex()->point() = *i++; } } while ( e++ != last_e); - CGAL_assertion( i == pts.end()); - CGAL_postcondition( P.is_valid()); } using namespace std; diff --git a/Polyhedron/examples/Polyhedron/polyhedron_self_intersection.cpp b/Polyhedron/examples/Polyhedron/polyhedron_self_intersection.cpp index 4561bd14770..909531d09eb 100644 --- a/Polyhedron/examples/Polyhedron/polyhedron_self_intersection.cpp +++ b/Polyhedron/examples/Polyhedron/polyhedron_self_intersection.cpp @@ -6,6 +6,7 @@ #include #include #include +#include using std::cerr; using std::endl; @@ -63,7 +64,7 @@ struct Intersect_facets { } if ( v != Halfedge_const_handle()) { // found shared vertex: - CGAL_assertion( h->vertex() == v->vertex()); + assert( h->vertex() == v->vertex()); // geomtric check if the opposite segments intersect the triangles Triangle t1( h->vertex()->point(), h->next()->vertex()->point(), diff --git a/Polyhedron/include/CGAL/IO/Polyhedron_OFF_iostream.h b/Polyhedron/include/CGAL/IO/Polyhedron_OFF_iostream.h index bb413897c51..1bbe27f4999 100644 --- a/Polyhedron/include/CGAL/IO/Polyhedron_OFF_iostream.h +++ b/Polyhedron/include/CGAL/IO/Polyhedron_OFF_iostream.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include @@ -40,10 +40,10 @@ namespace IO { template class HDS, - class Alloc, class CGAL_BGL_NP_TEMPLATE_PARAMETERS> + class Alloc, class CGAL_NP_TEMPLATE_PARAMETERS> bool read_OFF(std::istream& in, Polyhedron_3& P, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { typedef typename boost::graph_traits >::vertex_descriptor Vertex; @@ -54,7 +54,7 @@ bool read_OFF(std::istream& in, typedef typename Kernel_traits::Kernel Def_kernel; typedef typename CGAL::GetVertexPointMap, - CGAL_BGL_NP_CLASS>::type VPM; + CGAL_NP_CLASS>::type VPM; typedef typename boost::property_traits::value_type Point; typedef typename Kernel_traits::Kernel Kernel; @@ -66,17 +66,17 @@ bool read_OFF(std::istream& in, const bool verbose = choose_parameter(get_parameter(np, internal_np::verbose), true); - if(!(is_default_parameter(get_parameter(np, internal_np::vertex_color_map))) || - !(is_default_parameter(get_parameter(np, internal_np::face_color_map))) || - !(is_default_parameter(get_parameter(np, internal_np::vertex_normal_map))) || - !(is_default_parameter(get_parameter(np, internal_np::vertex_texture_map)))) + if(!(is_default_parameter()) || + !(is_default_parameter()) || + !(is_default_parameter()) || + !(is_default_parameter())) { return CGAL::IO::internal::read_OFF_BGL(in, P, np); } CGAL::scan_OFF(in, P, verbose); - if(!parameters::is_default_parameter(get_parameter(np, internal_np::vertex_point))) + if(!parameters::is_default_parameter()) { Def_VPM def_vpm = get_property_map(CGAL::vertex_point, P); VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), @@ -93,34 +93,15 @@ bool read_OFF(std::istream& in, template class HDS, - class Alloc> -bool read_OFF(std::istream& in, Polyhedron_3& P) -{ - return read_OFF(in, P, parameters::all_default()); -} - -template class HDS, - class Alloc, class CGAL_BGL_NP_TEMPLATE_PARAMETERS> + class Alloc, class CGAL_NP_TEMPLATE_PARAMETERS> bool read_OFF(const std::string& fname, Polyhedron_3& P, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { std::ifstream in(fname); return read_OFF(in, P, np); } -template class HDS, - class Alloc> -bool read_OFF(const std::string& fname, Polyhedron_3& P) -{ - std::ifstream in(fname); - return read_OFF(in, P, parameters::all_default()); -} - } // namespace IO template class HDS, - class Alloc, class CGAL_BGL_NP_TEMPLATE_PARAMETERS> + class Alloc, class CGAL_NP_TEMPLATE_PARAMETERS> bool write_OFF(std::ostream& out, const Polyhedron_3& P, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; using parameters::is_default_parameter; - if(!(is_default_parameter(get_parameter(np, internal_np::vertex_color_map))) || - !(is_default_parameter(get_parameter(np, internal_np::face_color_map))) || - !(is_default_parameter(get_parameter(np, internal_np::vertex_normal_map))) || - !(is_default_parameter(get_parameter(np, internal_np::vertex_texture_map)))) + if(!(is_default_parameter()) || + !(is_default_parameter()) || + !(is_default_parameter()) || + !(is_default_parameter())) { return CGAL::IO::internal::write_OFF_BGL(out, P, np); } // writes P to `out' in PRETTY, ASCII or BINARY format as the stream indicates. File_header_OFF header(is_binary(out), ! is_pretty(out), false); - typename CGAL::GetVertexPointMap, CGAL_BGL_NP_CLASS>::const_type + typename CGAL::GetVertexPointMap, CGAL_NP_CLASS>::const_type vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(CGAL::vertex_point, P)); return CGAL::print_polyhedron_with_header_OFF(out, P, header, vpm); } -template class HDS, - class Alloc> -bool write_OFF(std::ostream& out, const Polyhedron_3& P) -{ - return write_OFF(out, P, parameters::all_default()); -} - } // namespace IO template - -#ifndef CGAL_IO_POLYHEDRON_GEOMVIEW_OSTREAM_H -#define CGAL_IO_POLYHEDRON_GEOMVIEW_OSTREAM_H - -#include - -#include - -#include -#include -#include - -namespace CGAL { - -class Polyhedron_writer_geomview -{ - Geomview_stream* out; - -public: - void write_header(Geomview_stream& os, - std::size_t vertices, - std::size_t, - std::size_t facets, - bool = false, - bool = false, - bool = false) - { - out = &os; - - // Print header. - out->set_ascii_mode(); - *out << "(geometry " << out->get_new_id("polyhedron") - << " {appearance {}{ "; - out->set_binary_mode(); - *out << "OFF BINARY\n" << int(vertices) << int(facets) << 0 ; - } - - void write_footer() - { - *out << "}})"; - out->set_ascii_mode(); - } - - void write_vertex( const double& x, const double& y, const double& z) { *out << x << y << z; } - void write_vertex_normal(const double, const double, const double) { } - void write_vertex_color(const double, const double, const double) { } - void write_vertex_texture(const double, const double) { } - - void write_facet_header() {} - void write_facet_begin(std::size_t no) { *out << int(no); } - void write_facet_vertex_index( std::size_t index) { *out << int(index); } - void write_face_color(const double, const double, const double) { } - void write_facet_end() - { - double r = out->fcr(), - g = out->fcg(), - b = out->fcb(); - *out << 4 << r << g << b << 1.0; - } -}; - -template - class HDS, class Alloc> -Geomview_stream& operator<<(Geomview_stream &gv, - const Polyhedron_3& P) -{ - IO::internal::Generic_facegraph_printer, - Polyhedron_writer_geomview> printer(gv); - printer(P); - - return gv; -} - -} //namespace CGAL - -#endif // CGAL_IO_POLYHEDRON_GEOMVIEW_OSTREAM_H // -// EOF // diff --git a/Polyhedron/include/CGAL/IO/Polyhedron_iostream.h b/Polyhedron/include/CGAL/IO/Polyhedron_iostream.h index 97a22be7a4f..abb91c44506 100644 --- a/Polyhedron/include/CGAL/IO/Polyhedron_iostream.h +++ b/Polyhedron/include/CGAL/IO/Polyhedron_iostream.h @@ -18,9 +18,6 @@ #include #include #include -#ifdef CGAL_USE_GEOMVIEW -#include -#endif #include diff --git a/Polyhedron/test/Polyhedron/test_polyhedron.cpp b/Polyhedron/test/Polyhedron/test_polyhedron.cpp index 0ac4ea66945..0f565b2f046 100644 --- a/Polyhedron/test/Polyhedron/test_polyhedron.cpp +++ b/Polyhedron/test/Polyhedron/test_polyhedron.cpp @@ -221,7 +221,7 @@ typename Poly::Halfedge_handle make_cube_3( Poly& P) { Halfedge_handle e = P.split_edge( f); e->vertex()->point() = Point( 1, 1, 1); // Fig. (e) P.split_facet( e, f->next()->next()); // Fig. (f) - CGAL_postcondition( P.is_valid()); + assert( P.is_valid()); return h; } diff --git a/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/simplify.h b/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/simplify.h index ad9e75cf178..d5497788a02 100644 --- a/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/simplify.h +++ b/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/simplify.h @@ -335,7 +335,7 @@ operator()() } else { (*u)->set_cost(*dist); if(mpq->contains(*u)){ - mpq->update(*u, true); + mpq->update(*u); } else{ mpq->push(*u); @@ -353,7 +353,7 @@ operator()() } else { (*w)->set_cost(*dist); if(mpq->contains(*w)){ - mpq->update(*w, true); + mpq->update(*w); } else{ mpq->push(*w); diff --git a/Polynomial/test/Polynomial/include/CGAL/gen_sparse_polynomial.h b/Polynomial/test/Polynomial/include/CGAL/gen_sparse_polynomial.h index ad52f1c95cc..a797ebb5d9e 100644 --- a/Polynomial/test/Polynomial/include/CGAL/gen_sparse_polynomial.h +++ b/Polynomial/test/Polynomial/include/CGAL/gen_sparse_polynomial.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace CGAL { @@ -36,7 +37,7 @@ generate_sparse_random_polynomial(CGAL::Random random, int max_degree = 6){ Monom_rep monom_rep; monom_rep.push_back(Monom(exps,c)); result += construct(monom_rep.begin(), monom_rep.end()); - CGAL_postcondition(result.degree() >= 0); + assert(result.degree() >= 0); } // std::cout << result << std::endl; return result; diff --git a/Polynomial/test/Polynomial/test_polynomial.h b/Polynomial/test/Polynomial/test_polynomial.h index a8a07ba92d0..8a3bb3bbda9 100644 --- a/Polynomial/test/Polynomial/test_polynomial.h +++ b/Polynomial/test/Polynomial/test_polynomial.h @@ -285,12 +285,20 @@ void division(CGAL::Integral_domain_tag) { template void io() { + + // https://github.com/CGAL/cgal/issues/6272#issuecomment-1022005703 + // VCbug: Setting the rounding mode influences output of double + // The rounding mode is set to CGAL_FE_UPWARD in the test ccp files + // in order to test Modular Arithmetic + // Without this change which is local to the function p == q will fail + CGAL::Protect_FPU_rounding pfr(CGAL_FE_TONEAREST); typedef CGAL::Polynomial POLY; { // successful re-reading of output POLY p(NT(-3), NT(5), NT(0), NT(0), NT(-7), NT(9)), q; std::ostringstream os; + os.precision(17); os << p; std::istringstream is(os.str()); is >> q; diff --git a/Polytope_distance_d/package_info/Polytope_distance_d/dependencies b/Polytope_distance_d/package_info/Polytope_distance_d/dependencies index d88bbdd6e12..2ec81fe38f8 100644 --- a/Polytope_distance_d/package_info/Polytope_distance_d/dependencies +++ b/Polytope_distance_d/package_info/Polytope_distance_d/dependencies @@ -32,4 +32,3 @@ Random_numbers STL_Extension Stream_support TDS_2 -Triangulation_2 diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h index d6abf3d1482..53acc3d02e4 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h @@ -88,7 +88,7 @@ linear_least_squares_fitting_2(InputIterator first, 0.0, radius}; Matrix transformation = init_matrix(2,delta); FT area = t.squared_radius(); - CGAL_assertion(area != 0.0); + CGAL_assertion(!CGAL::is_zero(area)); // Find the 2nd order moment for the circle wrt to the origin by an affine transformation. @@ -100,9 +100,9 @@ linear_least_squares_fitting_2(InputIterator first, FT y0 = t.center().y(); // and add to covariance matrix - covariance[0] += transformation[0][0] + area * x0*x0; + covariance[0] += transformation[0][0] + area * CGAL::square(x0); covariance[1] += transformation[0][1] + area * x0*y0; - covariance[2] += transformation[1][1] + area * y0*y0; + covariance[2] += transformation[1][1] + area * CGAL::square(y0); mass += area; } @@ -111,9 +111,9 @@ linear_least_squares_fitting_2(InputIterator first, // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += -mass * (c.x() * c.x()); - covariance[1] += -mass * (c.x() * c.y()); - covariance[2] += -mass * (c.y() * c.y()); + covariance[0] -= mass * (CGAL::square(c.x())); + covariance[1] -= mass * (c.x() * c.y()); + covariance[2] -= mass * (CGAL::square(c.y())); // solve for eigenvalues and eigenvectors. // eigen values are sorted in ascending order, @@ -194,7 +194,7 @@ linear_least_squares_fitting_2(InputIterator first, 0.0, radius}; Matrix transformation = init_matrix(2,delta); FT length = 2 * radius; - CGAL_assertion(length != 0.0); + CGAL_assertion(!CGAL::is_zero(length)); // Find the 2nd order moment for the circle wrt to the origin by an affine transformation. @@ -206,9 +206,9 @@ linear_least_squares_fitting_2(InputIterator first, FT y0 = t.center().y(); // and add to covariance matrix - covariance[0] += transformation[0][0] + length * x0*x0; + covariance[0] += transformation[0][0] + length * CGAL::square(x0); covariance[1] += transformation[0][1] + length * x0*y0; - covariance[2] += transformation[1][1] + length * y0*y0; + covariance[2] += transformation[1][1] + length * CGAL::square(y0); mass += length; } @@ -217,9 +217,9 @@ linear_least_squares_fitting_2(InputIterator first, // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += -mass * (c.x() * c.x()); - covariance[1] += -mass * (c.x() * c.y()); - covariance[2] += -mass * (c.y() * c.y()); + covariance[0] -= mass * (CGAL::square(c.x())); + covariance[1] -= mass * (c.x() * c.y()); + covariance[2] -= mass * (CGAL::square(c.y())); // solve for eigenvalues and eigenvectors. // eigen values are sorted in ascending order, diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_2.h index fc7dff5670a..384513fae0b 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_2.h @@ -69,9 +69,9 @@ linear_least_squares_fitting_2(InputIterator first, { const Point& p = *it; Vector d = p - c; // centered data point - covariance[0] += d.x() * d.x(); + covariance[0] += CGAL::square(d.x()); covariance[1] += d.x() * d.y(); - covariance[2] += d.y() * d.y(); + covariance[2] += CGAL::square(d.y()); } // solve for eigenvalues and eigenvectors. diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h index 3bec5e8d4d5..2edd0a69e89 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h @@ -93,7 +93,7 @@ linear_least_squares_fitting_2(InputIterator first, Matrix transformation = init_matrix(2,delta); FT area = (x1-x0)*(y2-y0); - CGAL_assertion(area != 0.0); + CGAL_assertion(!CGAL::is_zero(area)); // Find the 2nd order moment for the rectangle wrt to the origin by an affine transformation. @@ -104,20 +104,20 @@ linear_least_squares_fitting_2(InputIterator first, FT xav0 = (x1-x0)/FT(2); FT yav0 = (y2-y0)/FT(2); // and add to covariance matrix - covariance[0] += transformation[0][0] + area * (x0*xav0*2 + x0*x0); + covariance[0] += transformation[0][0] + area * (x0*xav0*2 + CGAL::square(x0)); covariance[1] += transformation[0][1] + area * (x0*yav0 + xav0*y0 + x0*y0); - covariance[2] += transformation[1][1] + area * (y0*yav0*2 + y0*y0); + covariance[2] += transformation[1][1] + area * (y0*yav0*2 + CGAL::square(y0)); mass += area; } - CGAL_assertion_msg (mass != FT(0), "Can't compute PCA of null measure."); + CGAL_assertion_msg (!CGAL::is_zero(mass), "Can't compute PCA of null measure."); // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += -mass * (c.x() * c.x()); - covariance[1] += -mass * (c.x() * c.y()); - covariance[2] += -mass * (c.y() * c.y()); + covariance[0] -= mass * (CGAL::square(c.x())); + covariance[1] -= mass * (c.x() * c.y()); + covariance[2] -= mass * (CGAL::square(c.y())); // solve for eigenvalues and eigenvectors. // eigen values are sorted in ascending order, diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h index a6d581d97df..8c0fbb8c7b3 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h @@ -85,7 +85,7 @@ linear_least_squares_fitting_2(InputIterator first, Matrix transformation = init_matrix(2,delta); using std::sqrt; FT length = CGAL::approximate_sqrt(t.squared_length()); - CGAL_assertion(length != 0.0); + CGAL_assertion(!CGAL::is_zero(length)); // Find the 2nd order moment for the segment wrt to the origin by an affine transformation. @@ -104,9 +104,9 @@ linear_least_squares_fitting_2(InputIterator first, // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += -mass * ( c.x() * c.x()); - covariance[1] += -mass * (c.x() * c.y()); - covariance[2] += -mass * (c.y() * c.y()); + covariance[0] -= mass * CGAL::square(c.x()); + covariance[1] -= mass * (c.x() * c.y()); + covariance[2] -= mass * (CGAL::square(c.y())); // solve for eigenvalues and eigenvectors. // eigen values are sorted in ascending order, diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h index ab96ad6d408..2b3d9a514b5 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h @@ -89,7 +89,7 @@ linear_least_squares_fitting_2(InputIterator first, Matrix transformation = init_matrix(2,delta); FT area = FT(0.5) * CGAL::abs(LA::determinant(transformation)); - CGAL_assertion(area!=0); + CGAL_assertion(!CGAL::is_zero(area)); // Find the 2nd order moment for the triangle wrt to the origin by an affine transformation. @@ -101,20 +101,20 @@ linear_least_squares_fitting_2(InputIterator first, FT yav0 = (delta[2]+delta[3])/FT(3); // and add to the covariance matrix - covariance[0] += transformation[0][0] + area * (x0*xav0*2 + x0*x0); + covariance[0] += transformation[0][0] + area * (x0*xav0*2 + CGAL::square(x0)); covariance[1] += transformation[0][1] + area * (x0*yav0 + xav0*y0 + x0*y0); - covariance[2] += transformation[1][1] + area * (y0*yav0*2 + y0*y0); + covariance[2] += transformation[1][1] + area * (y0*yav0*2 + CGAL::square(y0)); mass += area; } - CGAL_assertion_msg (mass != FT(0), "Can't compute PCA of null measure."); + CGAL_assertion_msg (!CGAL::is_zero(mass), "Can't compute PCA of null measure."); // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += -mass * (c.x() * c.x()); - covariance[1] += -mass * (c.x() * c.y()); - covariance[2] += -mass * (c.y() * c.y()); + covariance[0] -= mass * (CGAL::square(c.x())); + covariance[1] -= mass * (c.x() * c.y()); + covariance[2] -= mass * (CGAL::square(c.y())); // std::cout<<"cov: "< #include +#include typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point_3; @@ -224,9 +225,9 @@ void assert_quality (const std::vector& points, const Fitted& fitted) std::cerr << "mean distance = " << mean_dist << std::endl; - CGAL_assertion_code - (double limit = 1e-5 * std::sqrt (CGAL::squared_distance (points.front(), points.back()))); - CGAL_assertion (mean_dist < limit); + + double limit = 1e-5 * std::sqrt (CGAL::squared_distance (points.front(), points.back())); + assert (mean_dist < limit); } /* diff --git a/Property_map/include/CGAL/Dynamic_property_map.h b/Property_map/include/CGAL/Dynamic_property_map.h index 95463c807b1..de27dd668bc 100644 --- a/Property_map/include/CGAL/Dynamic_property_map.h +++ b/Property_map/include/CGAL/Dynamic_property_map.h @@ -19,10 +19,11 @@ #include #include -#include #include #include +#include + namespace CGAL { namespace internal { @@ -69,7 +70,7 @@ struct Dynamic_property_map { } - typedef boost::unordered_map Map; + typedef std::unordered_map Map; std::shared_ptr map_; V default_value_; }; diff --git a/Property_map/include/CGAL/property_map.h b/Property_map/include/CGAL/property_map.h index 0dddeefd626..302b194a5e9 100644 --- a/Property_map/include/CGAL/property_map.h +++ b/Property_map/include/CGAL/property_map.h @@ -39,15 +39,13 @@ namespace CGAL { /// A boolean property map return a const value at compile time template -class Static_boolean_property_map +struct Static_boolean_property_map { -public: typedef Key key_type; typedef bool value_type; typedef bool reference; typedef boost::read_write_property_map_tag category; -public: inline friend value_type get(Static_boolean_property_map, const key_type&) @@ -64,15 +62,16 @@ public: template class OR_property_map { + PM1 pm1; + PM2 pm2; + + public: + typedef typename PM1::key_type key_type; typedef typename PM1::value_type value_type; typedef typename PM1::reference reference; typedef boost::read_write_property_map_tag category; - PM1 pm1; - PM2 pm2; - - public: OR_property_map() {} // required by boost::connected_components OR_property_map(PM1 pm1, PM2 pm2) diff --git a/Property_map/test/Property_map/kernel_converter_properties_test.cpp b/Property_map/test/Property_map/kernel_converter_properties_test.cpp index ffa26724def..ebe871bc3e3 100644 --- a/Property_map/test/Property_map/kernel_converter_properties_test.cpp +++ b/Property_map/test/Property_map/kernel_converter_properties_test.cpp @@ -6,6 +6,8 @@ #include #include +#include + typedef CGAL::Simple_cartesian K1; typedef CGAL::Simple_cartesian > K2; typedef K1::Point_3 Point_3; @@ -21,9 +23,9 @@ test() VPMap vmap = get(CGAL::vertex_point, m); CGAL::Cartesian_converter_property_map kcmap =CGAL::make_cartesian_converter_property_map(vmap); - CGAL_assertion(get(kcmap, *vertices(m).begin()) == CGAL::Point_3(2,0,0)); + assert(get(kcmap, *vertices(m).begin()) == CGAL::Point_3(2,0,0)); put(kcmap, *vertices(m).begin(), CGAL::Point_3(0,2,3)); - CGAL_assertion(get(kcmap, *vertices(m).begin()) == CGAL::Point_3(0,2,3)); + assert(get(kcmap, *vertices(m).begin()) == CGAL::Point_3(0,2,3)); } @@ -34,4 +36,3 @@ int main() test(); return 0; } - diff --git a/STL_Extension/doc/STL_Extension/CGAL/Named_function_parameters.h b/STL_Extension/doc/STL_Extension/CGAL/Named_function_parameters.h new file mode 100644 index 00000000000..e48e624a37a --- /dev/null +++ b/STL_Extension/doc/STL_Extension/CGAL/Named_function_parameters.h @@ -0,0 +1,11 @@ +namespace CGAL{ +namespace parameters { +/// \ingroup PkgSTLExtensionRef +/// Type of the default named parameter pack +typedef unspecified_type Default_named_parameters; + +/// \ingroup PkgSTLExtensionRef +/// returns a default named parameter type indicating that default values should be used. +Default_named_parameters default_values(); + +} } diff --git a/STL_Extension/doc/STL_Extension/PackageDescription.txt b/STL_Extension/doc/STL_Extension/PackageDescription.txt index 8ac695b7c6c..a4df6c9b0bb 100644 --- a/STL_Extension/doc/STL_Extension/PackageDescription.txt +++ b/STL_Extension/doc/STL_Extension/PackageDescription.txt @@ -117,6 +117,8 @@ - `CGAL::Fast_location` - `CGAL::Compact_location` - `CGAL::value_type_traits` +- `CGAL::parameters::Default_named_parameters` +- `CGAL::parameters::default_values()` */ diff --git a/STL_Extension/include/CGAL/Compact_container.h b/STL_Extension/include/CGAL/Compact_container.h index 6e64790a239..5d1f91158b0 100644 --- a/STL_Extension/include/CGAL/Compact_container.h +++ b/STL_Extension/include/CGAL/Compact_container.h @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -480,7 +481,7 @@ public: // We use the block structure to provide an efficient version : // we check if the address is in the range of each block. - assert(cit != end()); + CGAL_assertion(cit != end()); const_pointer c = &*cit; size_type res=0; @@ -1050,7 +1051,7 @@ namespace internal { bool operator<(const CC_iterator& other) const { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP - assert( is_time_stamp_valid() ); + CGAL_assertion( is_time_stamp_valid() ); #endif return Time_stamper::less(m_ptr, other.m_ptr); } @@ -1058,7 +1059,7 @@ namespace internal { bool operator>(const CC_iterator& other) const { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP - assert( is_time_stamp_valid() ); + CGAL_assertion( is_time_stamp_valid() ); #endif return Time_stamper::less(other.m_ptr, m_ptr); } @@ -1066,7 +1067,7 @@ namespace internal { bool operator<=(const CC_iterator& other) const { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP - assert( is_time_stamp_valid() ); + CGAL_assertion( is_time_stamp_valid() ); #endif return Time_stamper::less(m_ptr, other.m_ptr) || (*this == other); @@ -1075,7 +1076,7 @@ namespace internal { bool operator>=(const CC_iterator& other) const { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP - assert( is_time_stamp_valid() ); + CGAL_assertion( is_time_stamp_valid() ); #endif return Time_stamper::less(other.m_ptr, m_ptr) || (*this == other); diff --git a/STL_Extension/include/CGAL/Concurrent_compact_container.h b/STL_Extension/include/CGAL/Concurrent_compact_container.h index 7ba9befa3a3..6bbdeee9176 100644 --- a/STL_Extension/include/CGAL/Concurrent_compact_container.h +++ b/STL_Extension/include/CGAL/Concurrent_compact_container.h @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -481,7 +482,7 @@ public: // We use the block structure to provide an efficient version : // we check if the address is in the range of each block. - assert(cit != end()); + CGAL_assertion(cit != end()); const_pointer c = &*cit; size_type res=0; diff --git a/STL_Extension/include/CGAL/Modifiable_priority_queue.h b/STL_Extension/include/CGAL/Modifiable_priority_queue.h index 9d932617274..270fe8250e2 100644 --- a/STL_Extension/include/CGAL/Modifiable_priority_queue.h +++ b/STL_Extension/include/CGAL/Modifiable_priority_queue.h @@ -11,55 +11,24 @@ #ifndef CGAL_MODIFIABLE_PRIORITY_QUEUE_H #define CGAL_MODIFIABLE_PRIORITY_QUEUE_H -#include // Neeeded by the following Boost header for CHAR_BIT. +#include // Needed by the following Boost header for CHAR_BIT. #include -#ifdef CGAL_SURFACE_MESH_SIMPLIFICATION_USE_RELAXED_HEAP -#include -#else + +#include #include +#include + +#include namespace CGAL { - namespace internal { -template , - class Comp = std::less, - class ID = ::boost::identity_property_map > -class mutable_queue_with_remove : public internal::boost_::mutable_queue -{ - typedef internal::boost_::mutable_queue Base; -public: - typedef typename Base::size_type size_type; - typedef typename Base::Node Node; - mutable_queue_with_remove(size_type n, const Comp& x=Comp(), const ID& _id=ID()) : Base(n,x,_id,true) - {} - - void remove(const IndexedType& x){ - //first place element at the top - size_type current_pos = this->index_array[ get(this->id, x) ]; - this->c[current_pos] = x; - - Node node(this->c.begin(), this->c.end(), this->c.begin()+current_pos, this->id); - while (node.has_parent()) - node.swap(node.parent(), this->index_array); - //then pop it - this->pop(); - } - - bool contains(const IndexedType& x) const { - return this->index_array[ get(this->id, x) ] !=this->index_array.size(); - } -}; - -} } //namespace CGAL::internal -#endif //CGAL_SURFACE_MESH_SIMPLIFICATION_USE_RELAXED_HEAP - -namespace CGAL { +enum Heap_type { CGAL_BOOST_PAIRING_HEAP, CGAL_BOOST_PENDING_MUTABLE_QUEUE, CGAL_BOOST_PENDING_RELAXED_HEAP }; template ,class ID_ = boost::identity_property_map + , Heap_type heap_type = CGAL_BOOST_PENDING_MUTABLE_QUEUE > class Modifiable_priority_queue { @@ -71,28 +40,24 @@ public: typedef Compare_ Compare; typedef ID_ ID ; - #ifdef CGAL_SURFACE_MESH_SIMPLIFICATION_USE_RELAXED_HEAP - typedef boost::relaxed_heap Heap; - #else - typedef internal::mutable_queue_with_remove,Compare,ID> Heap; - #endif //CGAL_SURFACE_MESH_SIMPLIFICATION_USE_RELAXED_HEAP + typedef std::conditional_t,Compare,ID>, + internal::boost_::relaxed_heap > Heap; + typedef typename Heap::value_type value_type; typedef typename Heap::size_type size_type; - typedef bool handle ; - public: - Modifiable_priority_queue( size_type largest_ID, Compare const& c, ID const& id ) : mHeap(largest_ID,c,id) {} + Modifiable_priority_queue( size_type largest_ID, Compare const& c = Compare(), ID const& id = ID() ) : mHeap(largest_ID,c,id) {} - handle push ( value_type const& v ) { mHeap.push(v) ; return handle(true) ; } + void push ( value_type const& v ) { mHeap.push(v) ; } - handle update ( value_type const& v, handle h ) { mHeap.update(v); return h ; } + void update ( value_type const& v ) { mHeap.update(v); } - handle erase ( value_type const& v, handle ) { mHeap.remove(v); return null_handle() ; } - handle erase ( value_type const& v ) { mHeap.remove(v); return null_handle() ; } + void erase ( value_type const& v ) { mHeap.remove(v); } - value_type top() const { return mHeap.top() ; } + value_type top() const { return mHeap.top(); } void pop() { mHeap.pop(); } @@ -112,7 +77,13 @@ public: return r ; } - static handle null_handle() { return handle(false); } + value_type top_and_pop() + { + CGAL_precondition(!empty()); + value_type v = top(); + pop(); + return v; + } private: @@ -120,6 +91,118 @@ private: } ; +template +struct Modifiable_priority_queue +{ + typedef Modifiable_priority_queue Self; + + typedef IndexedType_ IndexedType ; + typedef Compare_ Compare; + typedef ID_ ID ; + + struct Reverse_compare{ + Compare c; + Reverse_compare(const Compare& c):c(c){} + bool operator() (const IndexedType& a, const IndexedType& b) const + { + return !c(a,b); + } + }; + + // reference time (SMS Iphigenia, keeping 0.05% of edges, all default parameters + Surface_mesh): 12045ms + // -- + // boost::heap::priority_queue is ummutable and cannot be used + // -- + // typedef boost::heap::d_ary_heap, boost::heap::compare, boost::heap::mutable_ > Heap; //(15291ms) + // typedef boost::heap::d_ary_heap, boost::heap::compare, boost::heap::mutable_ > Heap; //(14351ms) + // typedef boost::heap::d_ary_heap, boost::heap::compare, boost::heap::mutable_ > Heap; //(13869ms) + // typedef boost::heap::d_ary_heap, boost::heap::compare, boost::heap::mutable_ > Heap; //(13879ms) + // typedef boost::heap::d_ary_heap, boost::heap::compare, boost::heap::mutable_ > Heap; //(13881ms) + // -- + //typedef boost::heap::binomial_heap> Heap; //(16216ms) + // -- + // typedef boost::heap::fibonacci_heap> Heap; // (13523ms) + // -- + typedef boost::heap::pairing_heap> Heap; // (12174ms) + // -- + // typedef boost::heap::skew_heap, boost::heap::mutable_> Heap; //(17957ms) + // -- + + typedef typename Heap::value_type value_type; + typedef typename Heap::size_type size_type; + +private: + void reserve_impl(size_type r, std::true_type) + { + mHeap.reserve(r); + } + + void reserve_impl(size_type, std::false_type) + {} + +public: + + Modifiable_priority_queue( size_type largest_ID, Compare const& c = Compare(), ID const& id = ID() ) + : mHeap(Reverse_compare(c)) + , mID(id) + , mHandles(largest_ID) + { + reserve(largest_ID); + } + + void push ( value_type const& v ) { mHandles[get(mID, v)]=mHeap.push(v) ; } + + void update ( value_type const& v ) { mHeap.update(mHandles[get(mID, v)]); } + + void erase ( value_type const& v ) { + auto vid = get(mID, v); + mHeap.erase(mHandles[vid]); + mHandles[vid]=typename Heap::handle_type(); + } + + value_type top() const { return mHeap.top(); } + + void pop() { mHeap.pop(); } + + bool empty() const { return mHeap.empty() ; } + + bool contains ( value_type const& v ) { return mHandles[get(mID, v)] != typename Heap::handle_type(); } + + boost::optional extract_top() + { + boost::optional r ; + if ( !empty() ) + { + value_type v = top(); + pop(); + r = boost::optional(v) ; + } + return r ; + } + + value_type top_and_pop() + { + CGAL_precondition(!empty()); + value_type v = top(); + pop(); + return v; + } + + void reserve(size_type r) + { + reserve_impl(r, std::integral_constant()); + } + + +private: + + Heap mHeap ; + ID mID; + std::vector mHandles; +} ; + } //namespace CGAL #endif diff --git a/BGL/include/CGAL/boost/graph/Named_function_parameters.h b/STL_Extension/include/CGAL/Named_function_parameters.h similarity index 86% rename from BGL/include/CGAL/boost/graph/Named_function_parameters.h rename to STL_Extension/include/CGAL/Named_function_parameters.h index 86f2f521496..3d3a2a463ee 100644 --- a/BGL/include/CGAL/boost/graph/Named_function_parameters.h +++ b/STL_Extension/include/CGAL/Named_function_parameters.h @@ -9,8 +9,8 @@ // // Author(s) : Sebastien Loriot -#ifndef CGAL_BOOST_GRAPH_NAMED_FUNCTION_PARAMS_H -#define CGAL_BOOST_GRAPH_NAMED_FUNCTION_PARAMS_H +#ifndef CGAL_NAMED_FUNCTION_PARAMETERS_H +#define CGAL_NAMED_FUNCTION_PARAMETERS_H #ifndef CGAL_NO_STATIC_ASSERTION_TESTS #include @@ -21,9 +21,14 @@ #include #include -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS T, typename Tag, typename Base -#define CGAL_BGL_NP_CLASS CGAL::Named_function_parameters +#define CGAL_NP_TEMPLATE_PARAMETERS NP_T=bool, typename NP_Tag=CGAL::internal_np::all_default_t, typename NP_Base=CGAL::internal_np::No_property +#define CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT NP_T, typename NP_Tag, typename NP_Base +#define CGAL_NP_CLASS CGAL::Named_function_parameters +#define CGAL_NP_TEMPLATE_PARAMETERS_1 NP_T1=bool, typename NP_Tag1=CGAL::internal_np::all_default_t, typename NP_Base1=CGAL::internal_np::No_property +#define CGAL_NP_CLASS_1 CGAL::Named_function_parameters +#define CGAL_NP_TEMPLATE_PARAMETERS_2 NP_T2=bool, typename NP_Tag2=CGAL::internal_np::all_default_t, typename NP_Base2=CGAL::internal_np::No_property +#define CGAL_NP_CLASS_2 CGAL::Named_function_parameters namespace CGAL { namespace internal_np{ @@ -36,7 +41,7 @@ enum all_default_t { all_default }; // define enum types and values for new named parameters #define CGAL_add_named_parameter(X, Y, Z) \ enum X { Y }; -#include +#include #undef CGAL_add_named_parameter template @@ -151,7 +156,7 @@ typename std::conditional::value, get_parameter_impl(const Named_params_impl& np, Tag) { return np.v; -}; +} template typename Get_param, Query_tag>::type @@ -199,7 +204,7 @@ typename std::conditional::value, get_parameter_reference_impl(const Named_params_impl& np, Tag) { return get_reference(np.v); -}; +} template T& @@ -213,7 +218,7 @@ T& get_parameter_reference_impl(const Named_params_impl, Tag, No_property>& np, Tag) { return np.v.get(); -}; +} template typename Get_param, Query_tag>::reference @@ -238,13 +243,6 @@ struct Named_function_parameters Named_function_parameters(const T& v) : base(v) {} Named_function_parameters(const T& v, const Base& b) : base(v, b) {} - Named_function_parameters - all_default() const - { - typedef Named_function_parameters Params; - return Params(*this); - } - // create the functions for new named parameters and the one imported boost // used to concatenate several parameters #define CGAL_add_named_parameter(X, Y, Z) \ @@ -255,17 +253,26 @@ struct Named_function_parameters typedef Named_function_parameters Params;\ return Params(k, *this); \ } -#include +#include #undef CGAL_add_named_parameter }; namespace parameters { -Named_function_parameters +typedef Named_function_parameters Default_named_parameters; + +#ifndef CGAL_NO_DEPRECATED_CODE +Default_named_parameters inline all_default() { - typedef Named_function_parameters Params; - return Params(); + return Default_named_parameters(); +} +#endif + +Default_named_parameters +inline default_values() +{ + return Default_named_parameters(); } template @@ -285,7 +292,7 @@ inline no_parameters(Named_function_parameters) typedef Named_function_parameters Params;\ return Params(p); \ } -#include +#include #undef CGAL_add_named_parameter // function to extract a parameter @@ -349,19 +356,23 @@ const T& choose_parameter(const T& t) return t; } -bool inline is_default_parameter(const internal_np::Param_not_found&) +template +constexpr bool is_default_parameter() { - return true; -} - -template -bool is_default_parameter(const T&) -{ - return false; + return std::is_same< typename internal_np::Get_param::type, + internal_np::Param_not_found> ::value; } } // end of parameters namespace +#ifndef CGAL_NO_DEPRECATED_CODE +namespace Polygon_mesh_processing { + +namespace parameters = CGAL::parameters; + +} +#endif + } //namespace CGAL #ifndef CGAL_NO_STATIC_ASSERTION_TESTS @@ -376,4 +387,4 @@ namespace boost } #endif -#endif // CGAL_BOOST_GRAPH_NAMED_FUNCTION_PARAMS_HPP +#endif // CGAL_BOOST_FUNCTION_PARAMS_HPP diff --git a/STL_Extension/include/CGAL/STL_Extension/internal/boost/mutable_queue.hpp b/STL_Extension/include/CGAL/STL_Extension/internal/boost/mutable_queue.hpp index 66fd3e6b8a0..aa19715136f 100644 --- a/STL_Extension/include/CGAL/STL_Extension/internal/boost/mutable_queue.hpp +++ b/STL_Extension/include/CGAL/STL_Extension/internal/boost/mutable_queue.hpp @@ -65,14 +65,10 @@ namespace boost_ { typedef Compare value_compare; typedef ID id_generator; - mutable_queue(size_type n, const Comp& x, const ID& _id) - : index_array(n), comp(x), id(_id) { - c.reserve(n); - } -//SL: added this constructor so that index_array is filled with +//SL: updated this constructor so that index_array is filled with // indices equals to n. Maintaining this property in pop allows // to have a method to detect if an element is in the queue - mutable_queue(size_type n, const Comp& x, const ID& _id,bool) + mutable_queue(size_type n, const Comp& x, const ID& _id) : index_array(n,n), comp(x), id(_id) { c.reserve(n); } @@ -134,6 +130,24 @@ namespace boost_ { void clear() { c.clear(); } +//SL: added remove and contains functions +// (historically in CGAL::internal::mutable_queue_with_remove with no good +// reason now that the present file is shipped with CGAL) + void remove(const IndexedType& x){ + //first place element at the top + size_type current_pos = index_array[ get(id, x) ]; + c[current_pos] = x; + + Node node(c.begin(), c.end(), c.begin()+current_pos, id); + while (node.has_parent()) + node.swap(node.parent(), index_array); + //then pop it + pop(); + } + + bool contains(const IndexedType& x) const { + return index_array[ get(id, x) ] != index_array.size(); + } #if 0 // dwa 2003/7/11 - I don't know what compiler is supposed to // be able to compile this, but is_heap is not standard!! diff --git a/STL_Extension/include/CGAL/STL_Extension/internal/boost/relaxed_heap.hpp b/STL_Extension/include/CGAL/STL_Extension/internal/boost/relaxed_heap.hpp new file mode 100644 index 00000000000..7996c1af5dd --- /dev/null +++ b/STL_Extension/include/CGAL/STL_Extension/internal/boost/relaxed_heap.hpp @@ -0,0 +1,754 @@ +// +//======================================================================= +// Copyright 2004 The Trustees of Indiana University. +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Authors: Douglas Gregor +// Andrew Lumsdaine +//======================================================================= +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: BSL-1.0 +// +// NOTE: this file has been taken from boost 1.77 to use +// with Modificable_priority_queue. +// The original file is +// + +#ifndef BOOST_RELAXED_HEAP_HEADER +#define BOOST_RELAXED_HEAP_HEADER + + +#include + +#include +#include +#include +#include +#include // for CHAR_BIT +#include + +#ifdef BOOST_RELAXED_HEAP_DEBUG +#include +#endif // BOOST_RELAXED_HEAP_DEBUG + +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable : 4355) // complaint about using 'this' to +#endif // initialize a member + +namespace CGAL { namespace internal { +namespace boost_ { + +template < typename IndexedType, typename Compare = std::less< IndexedType >, + typename ID = boost::identity_property_map > +class relaxed_heap +{ + struct group; + + typedef relaxed_heap self_type; + typedef std::size_t rank_type; + +public: + typedef IndexedType value_type; + typedef rank_type size_type; + +private: + /** + * The kind of key that a group has. The actual values are discussed + * in-depth in the documentation of the @c kind field of the @c group + * structure. Note that the order of the enumerators *IS* important + * and must not be changed. + */ + enum group_key_kind + { + smallest_key, + stored_key, + largest_key + }; + + struct group + { + explicit group(group_key_kind kind = largest_key) + : kind(kind), parent(this), rank(0) + { + } + + /** The value associated with this group. This value is only valid + * when @c kind!=largest_key (which indicates a deleted + * element). Note that the use of boost::optional increases the + * memory requirements slightly but does not result in extraneous + * memory allocations or deallocations. The optional could be + * eliminated when @c value_type is a model of + * DefaultConstructible. + */ + ::boost::optional< value_type > value; + + /** + * The kind of key stored at this group. This may be @c + * smallest_key, which indicates that the key is infinitely small; + * @c largest_key, which indicates that the key is infinitely + * large; or @c stored_key, which means that the key is unknown, + * but its relationship to other keys can be determined via the + * comparison function object. + */ + group_key_kind kind; + + /// The parent of this group. Will only be NULL for the dummy root group + group* parent; + + /// The rank of this group. Equivalent to the number of children in + /// the group. + rank_type rank; + + /** The children of this group. For the dummy root group, these are + * the roots. This is an array of length log n containing pointers + * to the child groups. + */ + group** children; + }; + + size_type log_base_2(size_type n) // log2 is a macro on some platforms + { + size_type leading_zeroes = 0; + do + { + size_type next = n << 1; + if (n == (next >> 1)) + { + ++leading_zeroes; + n = next; + } + else + { + break; + } + } while (true); + return sizeof(size_type) * CHAR_BIT - leading_zeroes - 1; + } + +public: + relaxed_heap( + size_type n, const Compare& compare = Compare(), const ID& id = ID()) + : compare(compare), id(id), root(smallest_key), groups(n), smallest_value(0) + { + if (n == 0) + { + root.children = new group*[1]; + return; + } + + log_n = log_base_2(n); + if (log_n == 0) + log_n = 1; + size_type g = n / log_n; + if (n % log_n > 0) + ++g; + size_type log_g = log_base_2(g); + size_type r = log_g; + + // Reserve an appropriate amount of space for data structures, so + // that we do not need to expand them. + index_to_group.resize(g); + A.resize(r + 1, 0); + root.rank = r + 1; + root.children = new group*[(log_g + 1) * (g + 1)]; + for (rank_type i = 0; i < r + 1; ++i) + root.children[i] = 0; + + // Build initial heap + size_type idx = 0; + while (idx < g) + { + root.children[r] = &index_to_group[idx]; + idx = build_tree(root, idx, r, log_g + 1); + if (idx != g) + r = static_cast< size_type >(log_base_2(g - idx)); + } + } + + ~relaxed_heap() { delete[] root.children; } + + void push(const value_type& x) + { + groups[get(id, x)] = x; + update(x); + } + + void update(const value_type& x) + { + group* a = &index_to_group[get(id, x) / log_n]; + if (!a->value || *a->value == x || compare(x, *a->value)) + { + if (a != smallest_value) + smallest_value = 0; + a->kind = stored_key; + a->value = x; + promote(a); + } + } + + void remove(const value_type& x) + { + group* a = &index_to_group[get(id, x) / log_n]; + CGAL_assertion(groups[get(id, x)]); + a->value = x; + a->kind = smallest_key; + promote(a); + smallest_value = a; + pop(); + } + + value_type& top() + { + find_smallest(); + CGAL_assertion(smallest_value->value != boost::none); + return *smallest_value->value; + } + + const value_type& top() const + { + find_smallest(); + CGAL_assertion(smallest_value->value != boost::none); + return *smallest_value->value; + } + + bool empty() const + { + find_smallest(); + return !smallest_value || (smallest_value->kind == largest_key); + } + + bool contains(const value_type& x) const + { + return static_cast< bool >(groups[get(id, x)]); + } + + void pop() + { + // Fill in smallest_value. This is the group x. + find_smallest(); + group* x = smallest_value; + smallest_value = 0; + + // Make x a leaf, giving it the smallest value within its group + rank_type r = x->rank; + group* p = x->parent; + { + CGAL_assertion(x->value != boost::none); + + // Find x's group + size_type start = get(id, *x->value) - get(id, *x->value) % log_n; + size_type end = start + log_n; + if (end > groups.size()) + end = groups.size(); + + // Remove the smallest value from the group, and find the new + // smallest value. + groups[get(id, *x->value)].reset(); + x->value.reset(); + x->kind = largest_key; + for (size_type i = start; i < end; ++i) + { + if (groups[i] && (!x->value || compare(*groups[i], *x->value))) + { + x->kind = stored_key; + x->value = groups[i]; + } + } + } + x->rank = 0; + + // Combine prior children of x with x + group* y = x; + for (size_type c = 0; c < r; ++c) + { + group* child = x->children[c]; + if (A[c] == child) + A[c] = 0; + y = combine(y, child); + } + + // If we got back something other than x, let y take x's place + if (y != x) + { + y->parent = p; + p->children[r] = y; + + CGAL_assertion(r == y->rank); + if (A[y->rank] == x) + A[y->rank] = do_compare(y, p) ? y : 0; + } + } + +#ifdef BOOST_RELAXED_HEAP_DEBUG + /************************************************************************* + * Debugging support * + *************************************************************************/ + void dump_tree() { dump_tree(std::cout); } + void dump_tree(std::ostream& out) { dump_tree(out, &root); } + + void dump_tree(std::ostream& out, group* p, bool in_progress = false) + { + if (!in_progress) + { + out << "digraph heap {\n" + << " edge[dir=\"back\"];\n"; + } + + size_type p_index = 0; + if (p != &root) + while (&index_to_group[p_index] != p) + ++p_index; + + for (size_type i = 0; i < p->rank; ++i) + { + group* c = p->children[i]; + if (c) + { + size_type c_index = 0; + if (c != &root) + while (&index_to_group[c_index] != c) + ++c_index; + + out << " "; + if (p == &root) + out << 'p'; + else + out << p_index; + out << " -> "; + if (c == &root) + out << 'p'; + else + out << c_index; + if (A[c->rank] == c) + out << " [style=\"dotted\"]"; + out << ";\n"; + dump_tree(out, c, true); + + // Emit node information + out << " "; + if (c == &root) + out << 'p'; + else + out << c_index; + out << " [label=\""; + if (c == &root) + out << 'p'; + else + out << c_index; + out << ":"; + size_type start = c_index * log_n; + size_type end = start + log_n; + if (end > groups.size()) + end = groups.size(); + while (start != end) + { + if (groups[start]) + { + out << " " << get(id, *groups[start]); + if (*groups[start] == *c->value) + out << "(*)"; + } + ++start; + } + out << '"'; + + if (do_compare(c, p)) + { + out << " "; + if (c == &root) + out << 'p'; + else + out << c_index; + out << ", style=\"filled\", fillcolor=\"gray\""; + } + out << "];\n"; + } + else + { + CGAL_assertion(p->parent == p); + } + } + if (!in_progress) + out << "}\n"; + } + + bool valid() + { + // Check that the ranks in the A array match the ranks of the + // groups stored there. Also, the active groups must be the last + // child of their parent. + for (size_type r = 0; r < A.size(); ++r) + { + if (A[r] && A[r]->rank != r) + return false; + + if (A[r] && A[r]->parent->children[A[r]->parent->rank - 1] != A[r]) + return false; + } + + // The root must have no value and a key of -Infinity + if (root.kind != smallest_key) + return false; + + return valid(&root); + } + + bool valid(group* p) + { + for (size_type i = 0; i < p->rank; ++i) + { + group* c = p->children[i]; + if (c) + { + // Check link structure + if (c->parent != p) + return false; + if (c->rank != i) + return false; + + // A bad group must be active + if (do_compare(c, p) && A[i] != c) + return false; + + // Check recursively + if (!valid(c)) + return false; + } + else + { + // Only the root may + if (p != &root) + return false; + } + } + return true; + } + +#endif // BOOST_RELAXED_HEAP_DEBUG + +private: + size_type build_tree( + group& parent, size_type idx, size_type r, size_type max_rank) + { + group& this_group = index_to_group[idx]; + this_group.parent = &parent; + ++idx; + + this_group.children = root.children + (idx * max_rank); + this_group.rank = r; + for (size_type i = 0; i < r; ++i) + { + this_group.children[i] = &index_to_group[idx]; + idx = build_tree(this_group, idx, i, max_rank); + } + return idx; + } + + void find_smallest() const + { + group** roots = root.children; + + if (!smallest_value) + { + std::size_t i; + for (i = 0; i < root.rank; ++i) + { + if (roots[i] + && (!smallest_value + || do_compare(roots[i], smallest_value))) + { + smallest_value = roots[i]; + } + } + for (i = 0; i < A.size(); ++i) + { + if (A[i] + && (!smallest_value || do_compare(A[i], smallest_value))) + smallest_value = A[i]; + } + } + } + + bool do_compare(group* x, group* y) const + { + return (x->kind < y->kind + || (x->kind == y->kind && x->kind == stored_key + && compare(*x->value, *y->value))); + } + + void promote(group* a) + { + CGAL_assertion(a != 0); + rank_type r = a->rank; + group* p = a->parent; + CGAL_assertion(p != 0); + if (do_compare(a, p)) + { + // s is the rank + 1 sibling + group* s = p->rank > r + 1 ? p->children[r + 1] : 0; + + // If a is the last child of p + if (r == p->rank - 1) + { + if (!A[r]) + A[r] = a; + else if (A[r] != a) + pair_transform(a); + } + else + { + CGAL_assertion(s != 0); + if (A[r + 1] == s) + active_sibling_transform(a, s); + else + good_sibling_transform(a, s); + } + } + } + + group* combine(group* a1, group* a2) + { + CGAL_assertion(a1->rank == a2->rank); + if (do_compare(a2, a1)) + do_swap(a1, a2); + a1->children[a1->rank++] = a2; + a2->parent = a1; + clean(a1); + return a1; + } + + void clean(group* q) + { + if (2 > q->rank) + return; + group* qp = q->children[q->rank - 1]; + rank_type s = q->rank - 2; + group* x = q->children[s]; + group* xp = qp->children[s]; + CGAL_assertion(s == x->rank); + + // If x is active, swap x and xp + if (A[s] == x) + { + q->children[s] = xp; + xp->parent = q; + qp->children[s] = x; + x->parent = qp; + } + } + + void pair_transform(group* a) + { +#if defined(BOOST_RELAXED_HEAP_DEBUG) && BOOST_RELAXED_HEAP_DEBUG > 1 + std::cerr << "- pair transform\n"; +#endif + rank_type r = a->rank; + + // p is a's parent + group* p = a->parent; + CGAL_assertion(p != 0); + + // g is p's parent (a's grandparent) + group* g = p->parent; + CGAL_assertion(g != 0); + + // a' <- A(r) + CGAL_assertion(A[r] != 0); + group* ap = A[r]; + CGAL_assertion(ap != 0); + + // A(r) <- nil + A[r] = 0; + + // let a' have parent p' + group* pp = ap->parent; + CGAL_assertion(pp != 0); + + // let a' have grandparent g' + group* gp = pp->parent; + CGAL_assertion(gp != 0); + + // Remove a and a' from their parents + CGAL_assertion(ap + == pp->children[pp->rank - 1]); // Guaranteed because ap is active + --pp->rank; + + // Guaranteed by caller + CGAL_assertion(a == p->children[p->rank - 1]); + --p->rank; + + // Note: a, ap, p, pp all have rank r + if (do_compare(pp, p)) + { + do_swap(a, ap); + do_swap(p, pp); + do_swap(g, gp); + } + + // Assuming k(p) <= k(p') + // make p' the rank r child of p + CGAL_assertion(r == p->rank); + p->children[p->rank++] = pp; + pp->parent = p; + + // Combine a, ap into a rank r+1 group c + group* c = combine(a, ap); + + // make c the rank r+1 child of g' + CGAL_assertion(gp->rank > r + 1); + gp->children[r + 1] = c; + c->parent = gp; + +#if defined(BOOST_RELAXED_HEAP_DEBUG) && BOOST_RELAXED_HEAP_DEBUG > 1 + std::cerr << "After pair transform...\n"; + dump_tree(); +#endif + + if (A[r + 1] == pp) + A[r + 1] = c; + else + promote(c); + } + + void active_sibling_transform(group* a, group* s) + { +#if defined(BOOST_RELAXED_HEAP_DEBUG) && BOOST_RELAXED_HEAP_DEBUG > 1 + std::cerr << "- active sibling transform\n"; +#endif + group* p = a->parent; + group* g = p->parent; + + // remove a, s from their parents + CGAL_assertion(s->parent == p); + CGAL_assertion(p->children[p->rank - 1] == s); + --p->rank; + CGAL_assertion(p->children[p->rank - 1] == a); + --p->rank; + + rank_type r = a->rank; + A[r + 1] = 0; + a = combine(p, a); + group* c = combine(a, s); + + // make c the rank r+2 child of g + CGAL_assertion(g->children[r + 2] == p); + g->children[r + 2] = c; + c->parent = g; + if (A[r + 2] == p) + A[r + 2] = c; + else + promote(c); + } + + void good_sibling_transform(group* a, group* s) + { +#if defined(BOOST_RELAXED_HEAP_DEBUG) && BOOST_RELAXED_HEAP_DEBUG > 1 + std::cerr << "- good sibling transform\n"; +#endif + rank_type r = a->rank; + group* c = s->children[s->rank - 1]; + CGAL_assertion(c->rank == r); + if (A[r] == c) + { +#if defined(BOOST_RELAXED_HEAP_DEBUG) && BOOST_RELAXED_HEAP_DEBUG > 1 + std::cerr << "- good sibling pair transform\n"; +#endif + A[r] = 0; + group* p = a->parent; + + // Remove c from its parent + --s->rank; + + // Make s the rank r child of p + s->parent = p; + p->children[r] = s; + + // combine a, c and let the result by the rank r+1 child of p + CGAL_assertion(p->rank > r + 1); + group* x = combine(a, c); + x->parent = p; + p->children[r + 1] = x; + + if (A[r + 1] == s) + A[r + 1] = x; + else + promote(x); + +#if defined(BOOST_RELAXED_HEAP_DEBUG) && BOOST_RELAXED_HEAP_DEBUG > 1 + dump_tree(std::cerr); +#endif + // pair_transform(a); + } + else + { + // Clean operation + group* p = a->parent; + s->children[r] = a; + a->parent = s; + p->children[r] = c; + c->parent = p; + + promote(a); + } + } + + static void do_swap(group*& x, group*& y) + { + group* tmp = x; + x = y; + y = tmp; + } + + /// Function object that compares two values in the heap + Compare compare; + + /// Mapping from values to indices in the range [0, n). + ID id; + + /** The root group of the queue. This group is special because it will + * never store a value, but it acts as a parent to all of the + * roots. Thus, its list of children is the list of roots. + */ + group root; + + /** Mapping from the group index of a value to the group associated + * with that value. If a value is not in the queue, then the "value" + * field will be empty. + */ + std::vector< group > index_to_group; + + /** Flat data structure containing the values in each of the + * groups. It will be indexed via the id of the values. The groups + * are each log_n long, with the last group potentially being + * smaller. + */ + std::vector< ::boost::optional< value_type > > groups; + + /** The list of active groups, indexed by rank. When A[r] is null, + * there is no active group of rank r. Otherwise, A[r] is the active + * group of rank r. + */ + std::vector< group* > A; + + /** The group containing the smallest value in the queue, which must + * be either a root or an active group. If this group is null, then we + * will need to search for this group when it is needed. + */ + mutable group* smallest_value; + + /// Cached value log_base_2(n) + size_type log_n; +}; + +} } } // end namespace CGAL::internal::boost_ + +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + +#endif // BOOST_RELAXED_HEAP_HEADER diff --git a/BGL/include/CGAL/boost/graph/parameters_interface.h b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h similarity index 97% rename from BGL/include/CGAL/boost/graph/parameters_interface.h rename to STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h index 1ce00a462e1..d597cf0b5d5 100644 --- a/BGL/include/CGAL/boost/graph/parameters_interface.h +++ b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h @@ -62,6 +62,7 @@ CGAL_add_named_parameter(geom_traits_t, geom_traits, geom_traits) CGAL_add_named_parameter(vertex_incident_patches_t, vertex_incident_patches, vertex_incident_patches_map) CGAL_add_named_parameter(density_control_factor_t, density_control_factor, density_control_factor) CGAL_add_named_parameter(use_delaunay_triangulation_t, use_delaunay_triangulation, use_delaunay_triangulation) +CGAL_add_named_parameter(do_not_use_cubic_algorithm_t, do_not_use_cubic_algorithm, do_not_use_cubic_algorithm) CGAL_add_named_parameter(use_2d_constrained_delaunay_triangulation_t, use_2d_constrained_delaunay_triangulation, use_2d_constrained_delaunay_triangulation) CGAL_add_named_parameter(fairing_continuity_t, fairing_continuity, fairing_continuity) CGAL_add_named_parameter(sparse_linear_solver_t, sparse_linear_solver, sparse_linear_solver) @@ -111,11 +112,11 @@ CGAL_add_named_parameter(error_codes_t, error_codes, error_codes) CGAL_add_named_parameter(volume_inclusions_t, volume_inclusions, volume_inclusions) CGAL_add_named_parameter(face_cc_map_t, face_connected_component_map, face_connected_component_map) CGAL_add_named_parameter(ccid_to_vid_vector_t, connected_component_id_to_volume_id, connected_component_id_to_volume_id) -CGAL_add_named_parameter(is_cc_outward_oriented_bs_t, is_cc_outward_oriented, is_cc_outward_oriented); -CGAL_add_named_parameter(intersecting_volume_pairs_t, intersecting_volume_pairs_output_iterator, intersecting_volume_pairs_output_iterator); -CGAL_add_named_parameter(i_used_as_a_predicate_t, i_used_as_a_predicate, i_used_as_a_predicate); -CGAL_add_named_parameter(nesting_levels_t, nesting_levels, nesting_levels); -CGAL_add_named_parameter(i_used_for_volume_orientation_t, i_used_for_volume_orientation, i_used_for_volume_orientation); +CGAL_add_named_parameter(is_cc_outward_oriented_bs_t, is_cc_outward_oriented, is_cc_outward_oriented) +CGAL_add_named_parameter(intersecting_volume_pairs_t, intersecting_volume_pairs_output_iterator, intersecting_volume_pairs_output_iterator) +CGAL_add_named_parameter(i_used_as_a_predicate_t, i_used_as_a_predicate, i_used_as_a_predicate) +CGAL_add_named_parameter(nesting_levels_t, nesting_levels, nesting_levels) +CGAL_add_named_parameter(i_used_for_volume_orientation_t, i_used_for_volume_orientation, i_used_for_volume_orientation) CGAL_add_named_parameter(area_threshold_t, area_threshold, area_threshold) CGAL_add_named_parameter(halfedges_keeper_t, halfedges_keeper, halfedges_keeper) CGAL_add_named_parameter(volume_threshold_t, volume_threshold, volume_threshold) @@ -133,6 +134,7 @@ CGAL_add_named_parameter(use_one_sided_hausdorff_t, use_one_sided_hausdorff, use CGAL_add_named_parameter(get_cost_policy_t, get_cost_policy, get_cost) CGAL_add_named_parameter(get_placement_policy_t, get_placement_policy, get_placement) CGAL_add_named_parameter(filter_t, filter, filter) +CGAL_add_named_parameter(use_relaxed_order_t, use_relaxed_order, use_relaxed_order) //to be documented CGAL_add_named_parameter(face_normal_t, face_normal, face_normal_map) @@ -180,6 +182,7 @@ CGAL_add_named_parameter(pointmatcher_config_t, pointmatcher_config, pointmatche CGAL_add_named_parameter(adjacencies_t, adjacencies, adjacencies) CGAL_add_named_parameter(scan_angle_t, scan_angle_map, scan_angle_map) CGAL_add_named_parameter(scanline_id_t, scanline_id_map, scanline_id_map) +CGAL_add_named_parameter(min_points_per_cell_t, min_points_per_cell, min_points_per_cell) CGAL_add_named_parameter(scalar_t, scalar_map, scalar_map) // List of named parameters used in Surface_mesh_approximation package diff --git a/STL_Extension/include/CGAL/utility.h b/STL_Extension/include/CGAL/utility.h index 4fa6bfacbad..277476c6079 100644 --- a/STL_Extension/include/CGAL/utility.h +++ b/STL_Extension/include/CGAL/utility.h @@ -325,4 +325,28 @@ inline P make_sorted_pair(T1&& t1, T2&& t2, Compare comp = Compare()) } //namespace CGAL +namespace std { + +#if defined(BOOST_MSVC) +# pragma warning(push) +# pragma warning(disable:4099) // For VC10 it is class hash +#endif + +#ifndef CGAL_CFG_NO_STD_HASH +template +struct hash> +{ + std::size_t operator()(const CGAL::Triple& t) const + { + return hash_value(t); + } +}; +#endif // CGAL_CFG_NO_STD_HASH + +#if defined(BOOST_MSVC) +# pragma warning(pop) +#endif + +} // std namespace + #endif // CGAL_UTILITY_H diff --git a/STL_Extension/test/STL_Extension/CMakeLists.txt b/STL_Extension/test/STL_Extension/CMakeLists.txt index 06f32e73106..2cec58eb9cb 100644 --- a/STL_Extension/test/STL_Extension/CMakeLists.txt +++ b/STL_Extension/test/STL_Extension/CMakeLists.txt @@ -39,6 +39,7 @@ create_single_source_cgal_program( "test_is_streamable.cpp" ) create_single_source_cgal_program( "test_lexcompare_outputrange.cpp" ) create_single_source_cgal_program( "test_Modifiable_priority_queue.cpp" ) create_single_source_cgal_program( "test_multiset.cpp" ) +create_single_source_cgal_program("test_cgal_named_params.cpp") add_executable( test_multiset_cc "test_multiset.cpp" ) target_link_libraries( test_multiset_cc PUBLIC CGAL::CGAL ) diff --git a/STL_Extension/test/STL_Extension/test_Modifiable_priority_queue.cpp b/STL_Extension/test/STL_Extension/test_Modifiable_priority_queue.cpp index 8b82ee3f486..2ebb51db3f8 100644 --- a/STL_Extension/test/STL_Extension/test_Modifiable_priority_queue.cpp +++ b/STL_Extension/test/STL_Extension/test_Modifiable_priority_queue.cpp @@ -41,7 +41,6 @@ int queue_size(Queue& q,int n){ int main() { - #ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_USE_RELAXED_HEAP //testing min-heap typedef CGAL::Modifiable_priority_queue Queue; Queue q(45,Queue::Compare(),Queue::ID()); @@ -73,7 +72,7 @@ int main() assert( q.top()->first == 4 ); assert( queue_size(q,45) == 4 ); - q.erase(&data[0]+4,false); + q.erase(&data[0]+4); assert( q.top()->first == 1 ); assert( queue_size(q,45) == 3 ); @@ -82,7 +81,7 @@ int main() assert( queue_size(q,45) == 4 ); data[5].second=43; - q.update(&data[0]+5,true); + q.update(&data[0]+5); assert( q.top()->first == 1 ); assert( queue_size(q,45) == 4 ); @@ -110,19 +109,19 @@ int main() assert( q.top()->first == 0 ); assert( queue_size(q,45) == 4 ); - q.erase(&data[0]+1,true); + q.erase(&data[0]+1); assert( q.top()->first == 0 ); assert( queue_size(q,45) == 3 ); - q.erase(&data[0]+2,true); + q.erase(&data[0]+2); assert( q.top()->first == 0 ); assert( queue_size(q,45) == 2 ); - q.erase(&data[0],true); + q.erase(&data[0]); assert( q.top()->first == 3 ); assert( queue_size(q,45) == 1 ); - q.erase(&data[0]+3,true); + q.erase(&data[0]+3); assert( queue_size(q,45) == 0 ); assert( q.empty() ); @@ -152,13 +151,13 @@ int main() for (unsigned int i=0;i<10;++i){ data[i].second=9-i; - q.update(&data[0]+i,true); + q.update(&data[0]+i); assert(q.top()->first==i); } //testing contains for (int i=0;i<10;++i){ - q.erase(&data[0]+i,true); + q.erase(&data[0]+i); assert(queue_size(q,45)==9-i); } @@ -172,20 +171,20 @@ int main() for (unsigned int i=0;i<9;++i){ data[i].second=10+i; - q.update(&data[0]+i,true); + q.update(&data[0]+i); assert(q.top()->first==i+1); } //revert order for (unsigned int i=0;i<10;++i){ data[9-i].second=i; - q.update(&data[0]+9-i,true); + q.update(&data[0]+9-i); assert(q.top()->first==9); } //testing remove (emulate pop) for (std::size_t i=0;i<10;++i){ assert(q.top()->first==9-i); - q.erase(&data[0]-i+9,true); + q.erase(&data[0]-i+9); } assert( q.empty() ); @@ -199,7 +198,7 @@ int main() for (std::size_t i=0;i<10;++i){ assert(q.top()->first==0); - q.erase(&data[0]-i+9,true); + q.erase(&data[0]-i+9); for (std::size_t k=0;k<9-i;++k) assert(q.contains(&data[0]+k)==true); for (std::size_t k=0;k #include -#include #include #include +#include void from_opt_var() { int i = 0; double j = 0.0; - CGAL_USE(i); CGAL_USE(j); + boost::optional< boost::variant > v(23); CGAL::Object o = v; - CGAL_assertion(!o.empty()); - CGAL_assertion(CGAL::assign(i, o)); - CGAL_assertion(i == 23); + assert(!o.empty()); + assert(CGAL::assign(i, o)); + assert(i == 23); //reassign the variant and assign it again v = 2.0; o = v; - CGAL_assertion(!CGAL::assign(i, o)); - CGAL_assertion(CGAL::assign(j, o)); - CGAL_assertion(j == 2.0); + assert(!CGAL::assign(i, o)); + assert(CGAL::assign(j, o)); + assert(j == 2.0); //empty optional boost::optional< boost::variant > v2; CGAL::Object o2 = v2; - CGAL_assertion(o2.empty()); + assert(o2.empty()); } void from_var() { int i = 0; - CGAL_USE(i); + boost::variant v(23); CGAL::Object o = v; - CGAL_assertion(!o.empty()); - CGAL_assertion(CGAL::assign(i, o)); - CGAL_assertion(i == 23); + assert(!o.empty()); + assert(CGAL::assign(i, o)); + assert(i == 23); } struct Foo { @@ -43,19 +43,19 @@ struct Foo { void make_object_and_assign() { int i = 23, j = 0; - CGAL_USE(j); + CGAL::Object o = CGAL::make_object(i); - CGAL_assertion(CGAL::assign(j, o)); - CGAL_assertion(j == i); - CGAL_assertion(CGAL::object_cast(&o) == nullptr); - CGAL_assertion(CGAL::object_cast(&o) != nullptr); + assert(CGAL::assign(j, o)); + assert(j == i); + assert(CGAL::object_cast(&o) == nullptr); + assert(CGAL::object_cast(&o) != nullptr); } void safe_bool() { CGAL::Object o; - CGAL_assertion(!o); + assert(!o); CGAL::Object o2 = CGAL::make_object(23); - CGAL_assertion(o2); + assert(o2); // dummy code, we want to bork on this // if(o == o2) ; diff --git a/STL_Extension/test/STL_Extension/test_Uncertain.cpp b/STL_Extension/test/STL_Extension/test_Uncertain.cpp index be6e67dd4ec..c8ab9867633 100644 --- a/STL_Extension/test/STL_Extension/test_Uncertain.cpp +++ b/STL_Extension/test/STL_Extension/test_Uncertain.cpp @@ -294,9 +294,7 @@ void test_bool() bool_assert(indet.is_same(CGAL_OR(indet, ufalse))); } catch (CGAL::Uncertain_conversion_exception&) { -#ifndef CGAL_CFG_NO_STATEMENT_EXPRESSIONS std::abort(); -#endif } // Test exceptions diff --git a/BGL/test/BGL/test_cgal_bgl_named_params.cpp b/STL_Extension/test/STL_Extension/test_cgal_named_params.cpp similarity index 82% rename from BGL/test/BGL/test_cgal_bgl_named_params.cpp rename to STL_Extension/test/STL_Extension/test_cgal_named_params.cpp index b7322b049f2..2ae445fbfd5 100644 --- a/BGL/test/BGL/test_cgal_bgl_named_params.cpp +++ b/STL_Extension/test/STL_Extension/test_cgal_named_params.cpp @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include @@ -23,7 +23,7 @@ struct B template void check_same_type(T) { - static const bool b = boost::is_same< A, T >::value; + static const bool b = std::is_same< A, T >::value; CGAL_static_assertion(b); assert(b); } @@ -46,7 +46,7 @@ template void test_no_copyable(const NamedParameters& np) { typedef typename inp::Get_param::type NP_type; - CGAL_static_assertion( (boost::is_same >::value) ); + CGAL_static_assertion( (std::is_same >::value) ); const A<4>& a = params::choose_parameter(params::get_parameter_reference(np, inp::edge_index), A<4>(4)); assert(a.v==4); @@ -102,5 +102,14 @@ int main() .face_index_map(std::reference_wrapper(b)) ); + auto d = CGAL::parameters::default_values(); + CGAL_static_assertion( (std::is_same::value) ); +#ifndef CGAL_NO_DEPRECATED_CODE + auto d1 = CGAL::parameters::all_default(); + CGAL_static_assertion( (std::is_same::value) ); + auto d2 = CGAL::Polygon_mesh_processing::parameters::all_default(); + CGAL_static_assertion( (std::is_same::value) ); +#endif + return EXIT_SUCCESS; } diff --git a/Scale_space_reconstruction_3/doc/Scale_space_reconstruction_3/PackageDescription.txt b/Scale_space_reconstruction_3/doc/Scale_space_reconstruction_3/PackageDescription.txt index 928bd81e75c..cbe16d9ac84 100644 --- a/Scale_space_reconstruction_3/doc/Scale_space_reconstruction_3/PackageDescription.txt +++ b/Scale_space_reconstruction_3/doc/Scale_space_reconstruction_3/PackageDescription.txt @@ -13,7 +13,7 @@ \cgalPkgPicture{knot_thumb.png} \cgalPkgSummaryBegin \cgalPkgAuthors{Thijs van Lankveld} -\cgalPkgDesc{This method allows to reconstruct a surface that interpolates a set of 3D points using either and alpha shape or the advancing front surface reconstruction method. The output interpolates the point set (as opposed to approximating the point set). How the surface connects the points depends on a scale variable, which can be estimated semi-automatically.} +\cgalPkgDesc{This method allows to reconstruct a surface that interpolates a set of 3D points using either an alpha shape or the advancing front surface reconstruction method. The output interpolates the point set (as opposed to approximating the point set). How the surface connects the points depends on a scale variable, which can be estimated semi-automatically.} \cgalPkgManuals{Chapter_Scale_space_reconstruction,PkgScaleSpaceReconstruction3Ref} \cgalPkgSummaryEnd \cgalPkgShortInfoBegin diff --git a/Scripts/developer_scripts/test_merge_of_branch b/Scripts/developer_scripts/test_merge_of_branch index 50e7f8c8c37..6021b9c988b 100755 --- a/Scripts/developer_scripts/test_merge_of_branch +++ b/Scripts/developer_scripts/test_merge_of_branch @@ -196,12 +196,12 @@ git_dir=`pwd` tmp_dir=`mktemp -d` cd $tmp_dir echo $tmp_dir -echo "#include \nstruct A{};\nint main(){" > main.cpp +echo "#include \nstruct A{};\nint main(){" > main.cpp for i in `echo $nps`; do echo " CGAL::parameters::${i}(A()).${i}(A());" >> main.cpp done echo "}" >> main.cpp -if ! g++ -DCGAL_NO_STATIC_ASSERTION_TESTS -I$git_dir/BGL/include main.cpp; then +if ! g++ -DCGAL_NO_STATIC_ASSERTION_TESTS -I$git_dir/STL_Extension/include main.cpp; then echo "ERROR: At least one documented named parameter does not exist" cd - rm -r $tmp_dir diff --git a/Scripts/developer_scripts/update_to_CGAL_np.sh b/Scripts/developer_scripts/update_to_CGAL_np.sh index c05347bb3b7..771d0d547d7 100644 --- a/Scripts/developer_scripts/update_to_CGAL_np.sh +++ b/Scripts/developer_scripts/update_to_CGAL_np.sh @@ -15,4 +15,4 @@ ack -l --cpp is_default_param | xargs sed -i -E 's/is_default_param[ ]*\(/is_def ack vertex_index_t | grep get_param git checkout BGL/include/CGAL/boost/graph/dijkstra_shortest_paths.hpp -git checkout BGL/include/CGAL/boost/graph/Named_function_parameters.h +git checkout STL_Extension/include/CGAL/Named_function_parameters.h diff --git a/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test.h b/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test.h index 3038ef5215c..14d2ec7152a 100644 --- a/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test.h +++ b/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test.h @@ -11,7 +11,7 @@ bool test_x(InputStream& is, const char* ifname, bool test_remove = true) { SDG2 sdg; std::cout << "Testing data from file: " << ifname << std::endl; - return test_base(is, sdg, ifname, "sdg.tmp", test_remove); + return test_base(is, sdg, ifname, test_remove); } @@ -20,7 +20,7 @@ bool test_no_x(InputStream& is, const char* ifname, bool test_remove = true) { SDG2_wi sdg; std::cout << "Testing data from file: " << ifname << std::endl; - return test_base(is, sdg, ifname, "sdg_wi.tmp", test_remove); + return test_base(is, sdg, ifname, test_remove); } //===================================================================== @@ -30,7 +30,7 @@ bool test_hierarchy_x(InputStream& is, const char* ifname, bool test_remove = tr { SDG2 sdg; std::cout << "Testing data from file: " << ifname << std::endl; - return test_base(is, sdg, ifname, "sdgh.tmp", test_remove); + return test_base(is, sdg, ifname, test_remove); } @@ -39,7 +39,7 @@ bool test_hierarchy_no_x(InputStream& is, const char* ifname, bool test_remove = { SDG2_wi sdg; std::cout << "Testing data from file: " << ifname << std::endl; - return test_base(is, sdg, ifname, "sdgh_wi.tmp", test_remove); + return test_base(is, sdg, ifname, test_remove); } @@ -47,12 +47,12 @@ bool test_hierarchy_no_x(InputStream& is, const char* ifname, bool test_remove = template -bool test_base(InputStream&, const SDG& sdg, const char* ifname, const char* ofname, +bool test_base(InputStream&, const SDG& sdg, const char* ifname, bool test_remove) { print_separator(); - bool types_ok = CGAL::test_sdg(std::cin, sdg, ifname, ofname, test_remove); + bool types_ok = CGAL::test_sdg(std::cin, sdg, ifname, test_remove); assert_no_warning( types_ok ); diff --git a/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h b/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h index 09ea811c3af..e124868718e 100644 --- a/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h +++ b/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "IO/Null_output_stream.h" #include "IO/io_aux.h" @@ -72,7 +73,7 @@ struct Level_finder< Segment_Delaunay_graph_2 > //======================================================================== template -bool test_sdg(InputStream&, const SDG&, const char* ifname, const char* ofname, +bool test_sdg(InputStream&, const SDG&, const char* ifname, bool test_remove) { typedef SDG SDG2; @@ -525,19 +526,17 @@ bool test_sdg(InputStream&, const SDG&, const char* ifname, const char* ofname, size_type npc1 = sdg.point_container().size(); size_type nv1 = sdg.number_of_vertices(); - std::ofstream ofs(ofname); - assert( ofs ); - sdg.file_output(ofs); + std::ostringstream oss; + sdg.file_output(oss); assert( sdg.is_valid() ); - ofs.close(); + oss.flush(); + std::string input = oss.str(); sdg.clear(); - std::ifstream ifs(ofname); - assert( ifs ); - sdg.file_input(ifs); + std::istringstream iss(input); + sdg.file_input(iss); assert( sdg.is_valid() ); - ifs.close(); size_type nisc2 = sdg.number_of_input_sites(); size_type npc2 = sdg.point_container().size(); diff --git a/Segment_Delaunay_graph_Linf_2/examples/Segment_Delaunay_graph_Linf_2/sdg-voronoi-edges-exact-linf.cpp b/Segment_Delaunay_graph_Linf_2/examples/Segment_Delaunay_graph_Linf_2/sdg-voronoi-edges-exact-linf.cpp index 99f740e5110..7259ddd553e 100644 --- a/Segment_Delaunay_graph_Linf_2/examples/Segment_Delaunay_graph_Linf_2/sdg-voronoi-edges-exact-linf.cpp +++ b/Segment_Delaunay_graph_Linf_2/examples/Segment_Delaunay_graph_Linf_2/sdg-voronoi-edges-exact-linf.cpp @@ -35,8 +35,6 @@ int main( int argc, char *argv[] ) { // read the sites from the stream and insert them in the diagram while ( ifs >> site ) { sdg.insert( site ); - CGAL_SDG_DEBUG( sdg.file_output_verbose(std::cout); ); - CGAL_assertion( sdg.is_valid(false, 1) ); } ifs.close(); diff --git a/Segment_Delaunay_graph_Linf_2/examples/Segment_Delaunay_graph_Linf_2/sdg-voronoi-edges-linf.cpp b/Segment_Delaunay_graph_Linf_2/examples/Segment_Delaunay_graph_Linf_2/sdg-voronoi-edges-linf.cpp index 576f3fe4d4c..9a6fc350e19 100644 --- a/Segment_Delaunay_graph_Linf_2/examples/Segment_Delaunay_graph_Linf_2/sdg-voronoi-edges-linf.cpp +++ b/Segment_Delaunay_graph_Linf_2/examples/Segment_Delaunay_graph_Linf_2/sdg-voronoi-edges-linf.cpp @@ -32,8 +32,6 @@ int main( int argc, char *argv[] ) { // read the sites from the stream and insert them in the diagram while ( ifs >> site ) { sdg.insert( site ); - CGAL_SDG_DEBUG( sdg.file_output_verbose(std::cout); ); - CGAL_assertion( sdg.is_valid(false, 1) ); } ifs.close(); diff --git a/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test.h b/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test.h index 3038ef5215c..14d2ec7152a 100644 --- a/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test.h +++ b/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test.h @@ -11,7 +11,7 @@ bool test_x(InputStream& is, const char* ifname, bool test_remove = true) { SDG2 sdg; std::cout << "Testing data from file: " << ifname << std::endl; - return test_base(is, sdg, ifname, "sdg.tmp", test_remove); + return test_base(is, sdg, ifname, test_remove); } @@ -20,7 +20,7 @@ bool test_no_x(InputStream& is, const char* ifname, bool test_remove = true) { SDG2_wi sdg; std::cout << "Testing data from file: " << ifname << std::endl; - return test_base(is, sdg, ifname, "sdg_wi.tmp", test_remove); + return test_base(is, sdg, ifname, test_remove); } //===================================================================== @@ -30,7 +30,7 @@ bool test_hierarchy_x(InputStream& is, const char* ifname, bool test_remove = tr { SDG2 sdg; std::cout << "Testing data from file: " << ifname << std::endl; - return test_base(is, sdg, ifname, "sdgh.tmp", test_remove); + return test_base(is, sdg, ifname, test_remove); } @@ -39,7 +39,7 @@ bool test_hierarchy_no_x(InputStream& is, const char* ifname, bool test_remove = { SDG2_wi sdg; std::cout << "Testing data from file: " << ifname << std::endl; - return test_base(is, sdg, ifname, "sdgh_wi.tmp", test_remove); + return test_base(is, sdg, ifname, test_remove); } @@ -47,12 +47,12 @@ bool test_hierarchy_no_x(InputStream& is, const char* ifname, bool test_remove = template -bool test_base(InputStream&, const SDG& sdg, const char* ifname, const char* ofname, +bool test_base(InputStream&, const SDG& sdg, const char* ifname, bool test_remove) { print_separator(); - bool types_ok = CGAL::test_sdg(std::cin, sdg, ifname, ofname, test_remove); + bool types_ok = CGAL::test_sdg(std::cin, sdg, ifname, test_remove); assert_no_warning( types_ok ); diff --git a/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test_types.h b/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test_types.h index 73e078423e4..ae24ecfe483 100644 --- a/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test_types.h +++ b/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test_types.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "IO/Null_output_stream.h" #include "IO/io_aux.h" @@ -72,7 +73,7 @@ struct Level_finder< Segment_Delaunay_graph_Linf_2 > //======================================================================== template -bool test_sdg(InputStream&, const SDG&, const char* ifname, const char* ofname, +bool test_sdg(InputStream&, const SDG&, const char* ifname, bool test_remove) { typedef SDG SDG2; @@ -524,19 +525,18 @@ bool test_sdg(InputStream&, const SDG&, const char* ifname, const char* ofname, size_type npc1 = sdg.point_container().size(); size_type nv1 = sdg.number_of_vertices(); - std::ofstream ofs(ofname); - assert( ofs ); - sdg.file_output(ofs); + std::ostringstream oss; + sdg.file_output(oss); assert( sdg.is_valid() ); - ofs.close(); + oss.flush(); + std::string input = oss.str(); sdg.clear(); - std::ifstream ifs(ofname); - assert( ifs ); - sdg.file_input(ifs); + std::istringstream iss(input); + + sdg.file_input(iss); assert( sdg.is_valid() ); - ifs.close(); size_type nisc2 = sdg.number_of_input_sites(); size_type npc2 = sdg.point_container().size(); diff --git a/Shape_regularization/doc/Shape_regularization/Doxyfile.in b/Shape_regularization/doc/Shape_regularization/Doxyfile.in index 455b5218ceb..58ec84a361a 100644 --- a/Shape_regularization/doc/Shape_regularization/Doxyfile.in +++ b/Shape_regularization/doc/Shape_regularization/Doxyfile.in @@ -3,8 +3,3 @@ PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - Shape Regularization" EXTRACT_ALL = false - -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = YES -EXPAND_AS_DEFINED = CGAL_BGL_NP_TEMPLATE_PARAMETERS \ - CGAL_BGL_NP_CLASS diff --git a/Shape_regularization/include/CGAL/Shape_regularization/Contours/Longest_direction_2.h b/Shape_regularization/include/CGAL/Shape_regularization/Contours/Longest_direction_2.h index 7b673cb7f9a..199417f31b1 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/Contours/Longest_direction_2.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/Contours/Longest_direction_2.h @@ -95,11 +95,11 @@ namespace Contours { \pre input_range.size() >= 3 for closed contours \pre input_range.size() >= 2 for open contours */ - template + template Longest_direction_2( const InputRange& input_range, const bool is_closed, - const NamedParameters& np) : + const NamedParameters& np = parameters::default_values()) : m_input_range(input_range), m_point_map(parameters::choose_parameter(parameters::get_parameter( np, internal_np::point_map), PointMap())) { @@ -121,15 +121,6 @@ namespace Contours { } } - /// \cond SKIP_IN_MANUAL - Longest_direction_2( - const InputRange& input_range, - const bool is_closed) : - Longest_direction_2( - input_range, is_closed, CGAL::parameters::all_default()) - { } - /// \endcond - /// @} /// \name Directions diff --git a/Shape_regularization/include/CGAL/Shape_regularization/Contours/Multiple_directions_2.h b/Shape_regularization/include/CGAL/Shape_regularization/Contours/Multiple_directions_2.h index c838405fa66..6d0ac4dca6f 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/Contours/Multiple_directions_2.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/Contours/Multiple_directions_2.h @@ -18,7 +18,7 @@ // Boost includes. #include -#include +#include // Internal includes. #include @@ -120,11 +120,11 @@ namespace Contours { \pre input_range.size() >= 3 for closed contours \pre input_range.size() >= 2 for open contours */ - template + template Multiple_directions_2( const InputRange& input_range, const bool is_closed, - const NamedParameters& np) : + const NamedParameters& np = parameters::default_values()) : m_input_range(input_range), m_point_map(parameters::choose_parameter(parameters::get_parameter( np, internal_np::point_map), PointMap())) { @@ -158,15 +158,6 @@ namespace Contours { } } - /// \cond SKIP_IN_MANUAL - Multiple_directions_2( - const InputRange& input_range, - const bool is_closed) : - Multiple_directions_2( - input_range, is_closed, CGAL::parameters::all_default()) - { } - /// \endcond - /// @} /// \name Directions diff --git a/Shape_regularization/include/CGAL/Shape_regularization/Contours/User_defined_directions_2.h b/Shape_regularization/include/CGAL/Shape_regularization/Contours/User_defined_directions_2.h index 7dc87ec436f..442efbe56a7 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/Contours/User_defined_directions_2.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/Contours/User_defined_directions_2.h @@ -108,12 +108,12 @@ namespace Contours { */ template< typename DirectionRange, - typename NamedParameters> + typename NamedParameters = parameters::Default_named_parameters> User_defined_directions_2( const InputRange& input_range, const bool is_closed, const DirectionRange& direction_range, - const NamedParameters& np) : + const NamedParameters& np = parameters::default_values()) : m_input_range(input_range), m_point_map(parameters::choose_parameter(parameters::get_parameter( np, internal_np::point_map), PointMap())), @@ -139,17 +139,6 @@ namespace Contours { } } - /// \cond SKIP_IN_MANUAL - template - User_defined_directions_2( - const InputRange& input_range, - const bool is_closed, - const DirectionRange& direction_range) : - User_defined_directions_2( - input_range, is_closed, direction_range, CGAL::parameters::all_default()) - { } - /// \endcond - /// @} /// \name Directions diff --git a/Shape_regularization/include/CGAL/Shape_regularization/QP_regularization.h b/Shape_regularization/include/CGAL/Shape_regularization/QP_regularization.h index 6875f93161d..95afdaf02ce 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/QP_regularization.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/QP_regularization.h @@ -139,13 +139,13 @@ namespace Shape_regularization { \pre input_range.size() >= 2 */ - template + template QP_regularization( const InputRange& input_range, NeighQuery& neighbor_query, RegType& regularization_type, QPSolver& quadratic_program, - const NamedParameters& np) : + const NamedParameters& np = parameters::default_values()) : m_input_range(input_range), m_neighbor_query(neighbor_query), m_regularization_type(regularization_type), @@ -157,18 +157,6 @@ namespace Shape_regularization { clear(); } - /// \cond SKIP_IN_MANUAL - QP_regularization( - const InputRange& input_range, - NeighQuery& neighbor_query, - RegType& regularization_type, - QPSolver& quadratic_program) : - QP_regularization( - input_range, neighbor_query, regularization_type, quadratic_program, - CGAL::parameters::all_default()) - { } - /// \endcond - /// @} /// \name Regularization diff --git a/Shape_regularization/include/CGAL/Shape_regularization/Segments/Angle_regularization_2.h b/Shape_regularization/include/CGAL/Shape_regularization/Segments/Angle_regularization_2.h index 64f850fa08c..4413dd3c133 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/Segments/Angle_regularization_2.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/Segments/Angle_regularization_2.h @@ -18,7 +18,7 @@ // Boost includes. #include -#include +#include // Internal includes. #include @@ -115,10 +115,10 @@ namespace Segments { \pre input_range.size() >= 2 \pre maximum_angle >= 0 && maximum_angle <= 90 */ - template + template Angle_regularization_2( InputRange& input_range, - const NamedParameters& np) : + const NamedParameters& np = parameters::default_values()) : m_input_range(input_range), m_segment_map(parameters::choose_parameter(parameters::get_parameter( np, internal_np::segment_map), SegmentMap())), @@ -138,14 +138,6 @@ namespace Segments { create_unique_group(); } - /// \cond SKIP_IN_MANUAL - Angle_regularization_2( - InputRange& input_range) : - Angle_regularization_2( - input_range, CGAL::parameters::all_default()) - { } - /// \endcond - /*! \brief inserts a group of segments from `input_range`. diff --git a/Shape_regularization/include/CGAL/Shape_regularization/Segments/Delaunay_neighbor_query_2.h b/Shape_regularization/include/CGAL/Shape_regularization/Segments/Delaunay_neighbor_query_2.h index 8de981cddd6..ef31b408965 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/Segments/Delaunay_neighbor_query_2.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/Segments/Delaunay_neighbor_query_2.h @@ -105,10 +105,10 @@ namespace Segments { \pre input_range.size() >= 2 */ - template + template Delaunay_neighbor_query_2( const InputRange& input_range, - const NamedParameters& np) : + const NamedParameters& np = parameters::default_values()) : m_input_range(input_range), m_segment_map(parameters::choose_parameter(parameters::get_parameter( np, internal_np::segment_map), SegmentMap())) { @@ -117,14 +117,6 @@ namespace Segments { create_unique_group(); } - /// \cond SKIP_IN_MANUAL - Delaunay_neighbor_query_2( - InputRange& input_range) : - Delaunay_neighbor_query_2( - input_range, CGAL::parameters::all_default()) - { } - /// \endcond - /*! \brief inserts a group of segments from `input_range` and finds their neighbors within the group. diff --git a/Shape_regularization/include/CGAL/Shape_regularization/Segments/Offset_regularization_2.h b/Shape_regularization/include/CGAL/Shape_regularization/Segments/Offset_regularization_2.h index e474bef5e2d..0ea5e7e1523 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/Segments/Offset_regularization_2.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/Segments/Offset_regularization_2.h @@ -18,7 +18,7 @@ // Boost includes. #include -#include +#include // Internal includes. #include @@ -119,10 +119,10 @@ namespace Segments { \pre input_range.size() >= 2 \pre maximum_offset >= 0 */ - template + template Offset_regularization_2( InputRange& input_range, - const NamedParameters& np) : + const NamedParameters& np = parameters::default_values()) : m_input_range(input_range), m_segment_map(parameters::choose_parameter(parameters::get_parameter( np, internal_np::segment_map), SegmentMap())), @@ -142,14 +142,6 @@ namespace Segments { create_unique_group(); } - /// \cond SKIP_IN_MANUAL - Offset_regularization_2( - InputRange& input_range) : - Offset_regularization_2( - input_range, CGAL::parameters::all_default()) - { } - /// \endcond - /*! \brief inserts a group of segments from `input_range`. diff --git a/Shape_regularization/include/CGAL/Shape_regularization/internal/Collinear_groups_2.h b/Shape_regularization/include/CGAL/Shape_regularization/internal/Collinear_groups_2.h index b2c48bd2b5d..c125a752dea 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/internal/Collinear_groups_2.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/internal/Collinear_groups_2.h @@ -18,7 +18,7 @@ // Boost includes. #include -#include +#include // Internal includes. #include diff --git a/Shape_regularization/include/CGAL/Shape_regularization/internal/Contour_regularization_2.h b/Shape_regularization/include/CGAL/Shape_regularization/internal/Contour_regularization_2.h index ed3c6689536..536ccd9f35b 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/internal/Contour_regularization_2.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/internal/Contour_regularization_2.h @@ -18,7 +18,7 @@ // Boost includes. #include -#include +#include // Internal includes. #include diff --git a/Shape_regularization/include/CGAL/Shape_regularization/internal/Orthogonal_groups_2.h b/Shape_regularization/include/CGAL/Shape_regularization/internal/Orthogonal_groups_2.h index 64c99fedf24..7bc3b48da33 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/internal/Orthogonal_groups_2.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/internal/Orthogonal_groups_2.h @@ -18,7 +18,7 @@ // Boost includes. #include -#include +#include // Internal includes. #include diff --git a/Shape_regularization/include/CGAL/Shape_regularization/internal/Parallel_groups_2.h b/Shape_regularization/include/CGAL/Shape_regularization/internal/Parallel_groups_2.h index 7823e52db0a..5c6f15957ac 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/internal/Parallel_groups_2.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/internal/Parallel_groups_2.h @@ -18,7 +18,7 @@ // Boost includes. #include -#include +#include // Internal includes. #include diff --git a/Shape_regularization/include/CGAL/Shape_regularization/internal/Unique_segments_2.h b/Shape_regularization/include/CGAL/Shape_regularization/internal/Unique_segments_2.h index 2be0e8a1b71..ba05ecba757 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/internal/Unique_segments_2.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/internal/Unique_segments_2.h @@ -18,7 +18,7 @@ // Boost includes. #include -#include +#include // Internal includes. #include diff --git a/Shape_regularization/include/CGAL/Shape_regularization/internal/utils.h b/Shape_regularization/include/CGAL/Shape_regularization/internal/utils.h index 751dbbb6714..00ef34e9f44 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/internal/utils.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/internal/utils.h @@ -41,7 +41,7 @@ #include // Named parameters. -#include +#include #include namespace CGAL { diff --git a/Shape_regularization/include/CGAL/Shape_regularization/regularize_contours.h b/Shape_regularization/include/CGAL/Shape_regularization/regularize_contours.h index ff19d8c4fed..1930fd31c06 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/regularize_contours.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/regularize_contours.h @@ -28,7 +28,7 @@ // Boost includes. /// \cond SKIP_IN_MANUAL #include -#include +#include /// \endcond // Internal includes. @@ -115,12 +115,12 @@ namespace Contours { typename InputRange, typename ContDirections, typename OutIterator, - typename NamedParameters> + typename NamedParameters = parameters::Default_named_parameters> OutIterator regularize_closed_contour( const InputRange& input_range, const ContDirections& directions, OutIterator contour, - const NamedParameters& np) { + const NamedParameters& np = parameters::default_values()) { using PointMap = typename CGAL::GetPointMap::type; using Point_2 = typename PointMap::value_type; @@ -141,22 +141,6 @@ namespace Contours { return regularizer.regularize(contour); } - /// \cond SKIP_IN_MANUAL - template< - typename InputRange, - typename ContDirections, - typename OutIterator> - OutIterator regularize_closed_contour( - const InputRange& input_range, - const ContDirections& directions, - OutIterator contour) { - - CGAL_precondition(input_range.size() >= 3); - return regularize_closed_contour( - input_range, directions, contour, CGAL::parameters::all_default()); - } - /// \endcond - /*! \ingroup PkgShapeRegularizationRefContours @@ -254,12 +238,12 @@ namespace Contours { typename InputRange, typename ContDirections, typename OutIterator, - typename NamedParameters> + typename NamedParameters = parameters::Default_named_parameters> OutIterator regularize_open_contour( const InputRange& input_range, const ContDirections& directions, OutIterator contour, - const NamedParameters& np) { + const NamedParameters& np = parameters::default_values()) { using PointMap = typename CGAL::GetPointMap::type; using Point_2 = typename PointMap::value_type; @@ -280,22 +264,6 @@ namespace Contours { return regularizer.regularize(contour); } - /// \cond SKIP_IN_MANUAL - template< - typename InputRange, - typename ContDirections, - typename OutIterator> - OutIterator regularize_open_contour( - const InputRange& input_range, - const ContDirections& directions, - OutIterator contour) { - - CGAL_precondition(input_range.size() >= 2); - return regularize_open_contour( - input_range, directions, contour, CGAL::parameters::all_default()); - } - /// \endcond - /*! \ingroup PkgShapeRegularizationRefContours diff --git a/Shape_regularization/include/CGAL/Shape_regularization/regularize_planes.h b/Shape_regularization/include/CGAL/Shape_regularization/regularize_planes.h index 0da06dd658a..b542efb012a 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/regularize_planes.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/regularize_planes.h @@ -28,7 +28,7 @@ // Boost includes. /// \cond SKIP_IN_MANUAL #include -#include +#include /// \endcond // Shape detection includes. @@ -282,23 +282,23 @@ namespace Planes { typename PlaneMap, typename PointRange, typename PointMap, - typename NamedParameters> + typename NamedParameters = parameters::Default_named_parameters> void regularize_planes( PlaneRange& planes, const PlaneMap plane_map, const PointRange& points, const PointMap point_map, - const NamedParameters& np) { + const NamedParameters& np = parameters::default_values()) { using parameters::get_parameter; using parameters::choose_parameter; + using parameters::is_default_parameter; using PlaneIndexMap = typename CGAL::Point_set_processing_3:: GetPlaneIndexMap::type; - CGAL_static_assertion_msg( - !(boost::is_same::NoMap>::value), - "Error: no index map found!"); + CGAL_static_assertion_msg((!is_default_parameter()), + "Error: no plane index map"); + const PlaneIndexMap index_map = choose_parameter(get_parameter(np, internal_np::plane_index_map), PlaneIndexMap()); @@ -337,21 +337,6 @@ namespace Planes { reg_prll, reg_orth, reg_copl, reg_symm, tol_angle, tol_copln, sym_dir); } - - template< - typename PlaneRange, - typename PlaneMap, - typename PointRange, - typename PointMap> - void regularize_planes( - PlaneRange& planes, - const PlaneMap plane_map, - const PointRange& points, - const PointMap point_map) { - - regularize_planes( - planes, plane_map, points, point_map, CGAL::parameters::all_default()); - } /// \endcond /*! @@ -391,9 +376,7 @@ namespace Planes { for more details \param np - an optional sequence of \ref bgl_namedparameters "Named Parameters" - among the ones listed below; this parameter can be omitted, - the default values are then used + a sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below: \cgalNamedParamsBegin \cgalParamNBegin{plane_map} @@ -411,7 +394,7 @@ namespace Planes { in the `points` range to the index of a plane in the `planes` range (-1 if point is not assigned to a plane)} \cgalParamType{a model of `ReadablePropertyMap` with `std::size_t` as key type and `int` as value type} - \cgalParamDefault{`PlaneIndexMap()`} + \cgalParamDefault{There is no default, this parameters is mandatory} \cgalParamNEnd \cgalParamNBegin{maximum_angle} \cgalParamDescription{maximum allowed angle in degrees between plane normals used @@ -477,18 +460,6 @@ namespace Planes { regularize_planes(planes, plane_map, points, point_map, np); } - /// \cond SKIP_IN_MANUAL - template< - typename PlaneRange, - typename PointRange> - void regularize_planes( - PlaneRange& planes, const PointRange& points) { - - regularize_planes( - planes, points, CGAL::parameters::all_default()); - } - /// \endcond - } // namespace Planes } // namespace Shape_regularization } // namespace CGAL diff --git a/Shape_regularization/include/CGAL/Shape_regularization/regularize_segments.h b/Shape_regularization/include/CGAL/Shape_regularization/regularize_segments.h index ae7af2c8465..2042cff97b5 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/regularize_segments.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/regularize_segments.h @@ -28,7 +28,7 @@ // Boost includes. /// \cond SKIP_IN_MANUAL #include -#include +#include /// \endcond // Internal includes. @@ -129,13 +129,13 @@ namespace Segments { typename NeighQuery, typename RegType, typename QPSolver, - typename NamedParameters> + typename NamedParameters = parameters::Default_named_parameters> void regularize_segments( InputRange& input_range, NeighQuery& neighbor_query, RegType& regularization_type, QPSolver& quadratic_program, - const NamedParameters& np) { + const NamedParameters& np = parameters::default_values()) { using SegmentMap = typename internal::GetSegmentMap::type; using Segment_2 = typename SegmentMap::value_type; @@ -150,25 +150,6 @@ namespace Segments { regularizer.regularize(); } - /// \cond SKIP_IN_MANUAL - template< - typename InputRange, - typename NeighQuery, - typename RegType, - typename QPSolver> - void regularize_segments( - InputRange& input_range, - NeighQuery& neighbor_query, - RegType& regularization_type, - QPSolver& quadratic_program) { - - CGAL_precondition(input_range.size() >= 2); - regularize_segments( - input_range, neighbor_query, regularization_type, quadratic_program, - CGAL::parameters::all_default()); - } - /// \endcond - #if defined(CGAL_USE_OSQP) || defined(DOXYGEN_RUNNING) /// \cond SKIP_IN_MANUAL @@ -385,11 +366,11 @@ namespace Segments { template< typename InputRange, typename OutIterator, - typename NamedParameters> + typename NamedParameters = parameters::Default_named_parameters> OutIterator parallel_groups( const InputRange& input_range, OutIterator groups, - const NamedParameters& np) { + const NamedParameters& np = parameters::default_values()) { using SegmentMap = typename internal::GetSegmentMap::type; using Segment_2 = typename SegmentMap::value_type; @@ -409,20 +390,6 @@ namespace Segments { return grouping.groups(groups); } - /// \cond SKIP_IN_MANUAL - template< - typename InputRange, - typename OutIterator> - OutIterator parallel_groups( - const InputRange& input_range, - OutIterator groups) { - - CGAL_precondition(input_range.size() >= 1); - return parallel_groups( - input_range, groups, CGAL::parameters::all_default()); - } - /// \endcond - /*! \ingroup PkgShapeRegularizationRefSegments @@ -492,11 +459,11 @@ namespace Segments { template< typename InputRange, typename OutIterator, - typename NamedParameters> + typename NamedParameters = parameters::Default_named_parameters> OutIterator collinear_groups( const InputRange& input_range, OutIterator groups, - const NamedParameters& np) { + const NamedParameters& np = parameters::default_values()) { using SegmentMap = typename internal::GetSegmentMap::type; using Segment_2 = typename SegmentMap::value_type; @@ -516,20 +483,6 @@ namespace Segments { return grouping.groups(groups); } - /// \cond SKIP_IN_MANUAL - template< - typename InputRange, - typename OutIterator> - OutIterator collinear_groups( - const InputRange& input_range, - OutIterator groups) { - - CGAL_precondition(input_range.size() >= 1); - return collinear_groups( - input_range, groups, CGAL::parameters::all_default()); - } - /// \endcond - /*! \ingroup PkgShapeRegularizationRefSegments @@ -599,11 +552,11 @@ namespace Segments { template< typename InputRange, typename OutIterator, - typename NamedParameters> + typename NamedParameters = parameters::Default_named_parameters> OutIterator orthogonal_groups( const InputRange& input_range, OutIterator groups, - const NamedParameters& np) { + const NamedParameters& np = parameters::default_values()) { using SegmentMap = typename internal::GetSegmentMap::type; using Segment_2 = typename SegmentMap::value_type; @@ -623,20 +576,6 @@ namespace Segments { return grouping.groups(groups); } - /// \cond SKIP_IN_MANUAL - template< - typename InputRange, - typename OutIterator> - OutIterator orthogonal_groups( - const InputRange& input_range, - OutIterator groups) { - - CGAL_precondition(input_range.size() >= 1); - return orthogonal_groups( - input_range, groups, CGAL::parameters::all_default()); - } - /// \endcond - /*! \ingroup PkgShapeRegularizationRefSegments @@ -705,11 +644,11 @@ namespace Segments { template< typename InputRange, typename OutIterator, - typename NamedParameters> + typename NamedParameters = parameters::Default_named_parameters> OutIterator unique_segments( const InputRange& input_range, OutIterator segments, - const NamedParameters& np) { + const NamedParameters& np = parameters::default_values()) { using SegmentMap = typename internal::GetSegmentMap::type; using Segment_2 = typename SegmentMap::value_type; @@ -729,20 +668,6 @@ namespace Segments { return unique.segments(segments); } - /// \cond SKIP_IN_MANUAL - template< - typename InputRange, - typename OutIterator> - OutIterator unique_segments( - const InputRange& input_range, - OutIterator segments) { - - CGAL_precondition(input_range.size() >= 1); - return unique_segments( - input_range, segments, CGAL::parameters::all_default()); - } - /// \endcond - } // namespace Segments } // namespace Shape_regularization } // namespace CGAL diff --git a/Shape_regularization/test/Shape_regularization/test_closed_contour_10_edges.cpp b/Shape_regularization/test/Shape_regularization/test_closed_contour_10_edges.cpp index 6fc744652c2..0b686d4c640 100644 --- a/Shape_regularization/test/Shape_regularization/test_closed_contour_10_edges.cpp +++ b/Shape_regularization/test/Shape_regularization/test_closed_contour_10_edges.cpp @@ -37,7 +37,7 @@ void test_closed_contour_10_edges() { std::vector regularized; SR::Contours::regularize_closed_contour( contour, directions, std::back_inserter(regularized), - CGAL::parameters::all_default()); + CGAL::parameters::default_values()); const std::size_t num_directions = directions.number_of_directions(); diff --git a/Shape_regularization/test/Shape_regularization/test_closed_contour_6_edges.cpp b/Shape_regularization/test/Shape_regularization/test_closed_contour_6_edges.cpp index cf85410bbc9..e56abd6d229 100644 --- a/Shape_regularization/test/Shape_regularization/test_closed_contour_6_edges.cpp +++ b/Shape_regularization/test/Shape_regularization/test_closed_contour_6_edges.cpp @@ -32,7 +32,7 @@ void test_closed_contour_6_edges() { std::vector regularized; SR::Contours::regularize_closed_contour( contour, directions, std::back_inserter(regularized), - CGAL::parameters::all_default()); + CGAL::parameters::default_values()); const std::size_t num_directions = directions.number_of_directions(); diff --git a/Shape_regularization/test/Shape_regularization/test_neighbor_query.cpp b/Shape_regularization/test/Shape_regularization/test_neighbor_query.cpp index 335e1f41e37..6dfa9a60ec3 100644 --- a/Shape_regularization/test/Shape_regularization/test_neighbor_query.cpp +++ b/Shape_regularization/test/Shape_regularization/test_neighbor_query.cpp @@ -38,7 +38,7 @@ void test_neighbor_query() { Indices neighbors; NQ neighbor_query( - segments, CGAL::parameters::all_default()); + segments, CGAL::parameters::default_values()); // Check unique group. Segments edges; diff --git a/Shape_regularization/test/Shape_regularization/test_open_contour_5_edges.cpp b/Shape_regularization/test/Shape_regularization/test_open_contour_5_edges.cpp index 68afefc9369..4ed7d06394f 100644 --- a/Shape_regularization/test/Shape_regularization/test_open_contour_5_edges.cpp +++ b/Shape_regularization/test/Shape_regularization/test_open_contour_5_edges.cpp @@ -32,7 +32,7 @@ void test_open_contour_5_edges() { std::vector regularized; SR::Contours::regularize_open_contour( contour, directions, std::back_inserter(regularized), - CGAL::parameters::all_default()); + CGAL::parameters::default_values()); const std::size_t num_directions = directions.number_of_directions(); diff --git a/Shape_regularization/test/Shape_regularization/test_open_contour_9_edges.cpp b/Shape_regularization/test/Shape_regularization/test_open_contour_9_edges.cpp index 297ef1e2798..9e8fa306c56 100644 --- a/Shape_regularization/test/Shape_regularization/test_open_contour_9_edges.cpp +++ b/Shape_regularization/test/Shape_regularization/test_open_contour_9_edges.cpp @@ -37,7 +37,7 @@ void test_open_contour_9_edges() { std::vector regularized; SR::Contours::regularize_open_contour( contour, directions, std::back_inserter(regularized), - CGAL::parameters::all_default()); + CGAL::parameters::default_values()); const std::size_t num_directions = directions.number_of_directions(); diff --git a/Shape_regularization/test/Shape_regularization/test_overloads.cpp b/Shape_regularization/test/Shape_regularization/test_overloads.cpp index 95f2f9b6d35..6900deeb143 100644 --- a/Shape_regularization/test/Shape_regularization/test_overloads.cpp +++ b/Shape_regularization/test/Shape_regularization/test_overloads.cpp @@ -52,7 +52,7 @@ void test_overloads() { CD odirections(points, false); SR::Segments::regularize_segments( - segments, neighbor_query, angle_regularization, quadratic_program, CGAL::parameters::all_default()); + segments, neighbor_query, angle_regularization, quadratic_program, CGAL::parameters::default_values()); SR::Segments::regularize_segments( segments, neighbor_query, angle_regularization, quadratic_program); SR::Segments::regularize_segments( @@ -66,34 +66,34 @@ void test_overloads() { segments); SR::Segments::parallel_groups( - segments, std::back_inserter(indices), CGAL::parameters::all_default()); + segments, std::back_inserter(indices), CGAL::parameters::default_values()); SR::Segments::parallel_groups( segments, std::back_inserter(indices)); SR::Segments::collinear_groups( - segments, std::back_inserter(indices), CGAL::parameters::all_default()); + segments, std::back_inserter(indices), CGAL::parameters::default_values()); SR::Segments::collinear_groups( segments, std::back_inserter(indices)); SR::Segments::orthogonal_groups( - segments, std::back_inserter(indices), CGAL::parameters::all_default()); + segments, std::back_inserter(indices), CGAL::parameters::default_values()); SR::Segments::orthogonal_groups( segments, std::back_inserter(indices)); SR::Segments::unique_segments( - segments, std::back_inserter(unique), CGAL::parameters::all_default()); + segments, std::back_inserter(unique), CGAL::parameters::default_values()); SR::Segments::unique_segments( segments, std::back_inserter(unique)); SR::Contours::regularize_closed_contour( - points, cdirections, std::back_inserter(contour), CGAL::parameters::all_default()); + points, cdirections, std::back_inserter(contour), CGAL::parameters::default_values()); SR::Contours::regularize_closed_contour( points, cdirections, std::back_inserter(contour)); SR::Contours::regularize_closed_contour( points, std::back_inserter(contour)); SR::Contours::regularize_open_contour( - points, odirections, std::back_inserter(contour), CGAL::parameters::all_default()); + points, odirections, std::back_inserter(contour), CGAL::parameters::default_values()); SR::Contours::regularize_open_contour( points, odirections, std::back_inserter(contour)); SR::Contours::regularize_open_contour( diff --git a/Spatial_searching/benchmark/Spatial_searching/CMakeLists.txt b/Spatial_searching/benchmark/Spatial_searching/CMakeLists.txt index 9feb16e2d30..087c6fb80aa 100644 --- a/Spatial_searching/benchmark/Spatial_searching/CMakeLists.txt +++ b/Spatial_searching/benchmark/Spatial_searching/CMakeLists.txt @@ -8,29 +8,28 @@ find_package(CGAL REQUIRED COMPONENTS Core) include(${CGAL_USE_FILE}) -find_package(Eigen3 3.1.91) #(requires 3.2.0 or greater) +find_package(Eigen3 3.1.91) # (requires 3.2.0 or greater) include(CGAL_Eigen3_support) include_directories(BEFORE "include") -create_single_source_cgal_program("Compare_ANN_STANN_CGAL.cpp") +# create_single_source_cgal_program("Compare_ANN_STANN_CGAL.cpp") # does not compile, missing dependency create_single_source_cgal_program("nanoflan.cpp") create_single_source_cgal_program("binary.cpp") create_single_source_cgal_program("nearest_neighbor_searching_50.cpp") create_single_source_cgal_program("nearest_neighbor_searching_inplace_50.cpp") create_single_source_cgal_program("Nearest_neighbor_searching.cpp") create_single_source_cgal_program("Nearest_neighbor_searching_2D.cpp") -create_single_source_cgal_program( - "Nearest_neighbor_searching_2D_user_defined.cpp") +create_single_source_cgal_program("Nearest_neighbor_searching_2D_user_defined.cpp") create_single_source_cgal_program("Split_data.cpp") create_single_source_cgal_program("nn3cgal.cpp") -create_single_source_cgal_program("nn4cgal.cpp") +# create_single_source_cgal_program("nn4cgal.cpp") # this file does not exist for some reason create_single_source_cgal_program("nn3nanoflan.cpp") create_single_source_cgal_program("sizeof.cpp") -create_single_source_cgal_program("deque.cpp") +# create_single_source_cgal_program("deque.cpp") # does not compile, lots of errors foreach( target - Compare_ANN_STANN_CGAL + # Compare_ANN_STANN_CGAL # see above nanoflan binary nearest_neighbor_searching_50 @@ -40,9 +39,10 @@ foreach( Nearest_neighbor_searching_2D_user_defined Split_data nn3cgal - nn4cgal + # nn4cgal # see above nn3nanoflan sizeof - deque) + # deque # see above + ) target_link_libraries(${target} PUBLIC CGAL::Eigen3_support) endforeach() diff --git a/Spatial_searching/benchmark/Spatial_searching/Compare_ANN_STANN_CGAL.cpp b/Spatial_searching/benchmark/Spatial_searching/Compare_ANN_STANN_CGAL.cpp index 776fe6240aa..c466b4e4c6d 100644 --- a/Spatial_searching/benchmark/Spatial_searching/Compare_ANN_STANN_CGAL.cpp +++ b/Spatial_searching/benchmark/Spatial_searching/Compare_ANN_STANN_CGAL.cpp @@ -5,7 +5,15 @@ #include #include #include + +#include +#if BOOST_VERSION < 107200 #include +using boost::progress_display; +#else +#include +using boost::timer::progress_display; +#endif #include #include @@ -115,7 +123,7 @@ int main(int argc,char** argv) double OK_tree=time.time(); time.reset(); -boost::progress_display show_progress( nb_queries ); + progress_display show_progress( nb_queries ); //running NN algorithms for (std::vector::const_iterator it=queries.begin();it!=queries.end();++it) diff --git a/Spatial_searching/benchmark/Spatial_searching/Distance.h b/Spatial_searching/benchmark/Spatial_searching/Distance.h index 56c03bd406e..18a02d600ff 100644 --- a/Spatial_searching/benchmark/Spatial_searching/Distance.h +++ b/Spatial_searching/benchmark/Spatial_searching/Distance.h @@ -34,7 +34,7 @@ struct Distance { } double new_distance(double& dist, double old_off, double new_off, - int cutting_dimension) const { + int /* cutting_dimension */) const { return dist + new_off*new_off - old_off*old_off; } diff --git a/Spatial_searching/benchmark/Spatial_searching/binary.cpp b/Spatial_searching/benchmark/Spatial_searching/binary.cpp index 262934b8cd2..f05e076a724 100644 --- a/Spatial_searching/benchmark/Spatial_searching/binary.cpp +++ b/Spatial_searching/benchmark/Spatial_searching/binary.cpp @@ -9,7 +9,7 @@ typedef CGAL::Simple_cartesian::Point_3 Point_3; -int main(int argc, char* argv[]) +int main(int /* argc */, char* argv[]) { #if 0 std::cerr << "ASCII to binary\n"; diff --git a/Spatial_searching/benchmark/Spatial_searching/include/nanoflann.hpp b/Spatial_searching/benchmark/Spatial_searching/include/nanoflann.hpp index bb6873c208d..766b41c77fc 100644 --- a/Spatial_searching/benchmark/Spatial_searching/include/nanoflann.hpp +++ b/Spatial_searching/benchmark/Spatial_searching/include/nanoflann.hpp @@ -485,6 +485,7 @@ namespace nanoflann */ PooledAllocator(const size_t blocksize_ = BLOCKSIZE) : blocksize(blocksize_) { internal_init(); + blocksize = blocksize_; } /** @@ -963,7 +964,7 @@ namespace nanoflann * \sa radiusSearch, findNeighbors * \note nChecks_IGNORED is ignored but kept for compatibility with the original FLANN interface. */ - inline void knnSearch(const ElementType *query_point, const size_t num_closest, IndexType *out_indices, DistanceType *out_distances_sq,const int nChecks_IGNORED = 10) const + inline void knnSearch(const ElementType *query_point, const size_t num_closest, IndexType *out_indices, DistanceType *out_distances_sq,const int /* nChecks_IGNORED = 10 */) const { nanoflann::KNNResultSet resultSet(num_closest); resultSet.init(out_indices, out_distances_sq); @@ -1412,7 +1413,7 @@ namespace nanoflann index_t* index; //! The kd-tree index for the user to call its methods as usual with any other FLANN index. /// Constructor: takes a const ref to the matrix object with the data points - KDTreeEigenMatrixAdaptor(const int dimensionality, const MatrixType &mat, const int leaf_max_size = 10) : m_data_matrix(mat) + KDTreeEigenMatrixAdaptor(const int /* dimensionality */, const MatrixType &mat, const int leaf_max_size = 10) : m_data_matrix(mat) { const size_t dims = mat.cols(); if (DIM>0 && static_cast(dims)!=DIM) @@ -1436,7 +1437,7 @@ namespace nanoflann * The user can also call index->... methods as desired. * \note nChecks_IGNORED is ignored but kept for compatibility with the original FLANN interface. */ - inline void query(const num_t *query_point, const size_t num_closest, IndexType *out_indices, num_t *out_distances_sq, const int nChecks_IGNORED = 10) const + inline void query(const num_t *query_point, const size_t num_closest, IndexType *out_indices, num_t *out_distances_sq, const int /* nChecks_IGNORED = 10 */) const { nanoflann::KNNResultSet resultSet(num_closest); resultSet.init(out_indices, out_distances_sq); @@ -1478,7 +1479,7 @@ namespace nanoflann // Return true if the BBOX was already computed by the class and returned in "bb" so it can be avoided to redo it again. // Look at bb.size() to find out the expected dimensionality (e.g. 2 or 3 for point clouds) template - bool kdtree_get_bbox(BBOX &bb) const { + bool kdtree_get_bbox(BBOX & /* bb */) const { return false; } diff --git a/Spatial_searching/benchmark/Spatial_searching/nanoflan.cpp b/Spatial_searching/benchmark/Spatial_searching/nanoflan.cpp index b415d86283b..db5f5c4a94d 100644 --- a/Spatial_searching/benchmark/Spatial_searching/nanoflan.cpp +++ b/Spatial_searching/benchmark/Spatial_searching/nanoflan.cpp @@ -39,7 +39,7 @@ struct PointCloud inline size_t kdtree_get_point_count() const { return pts.size(); } // Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class: - inline T kdtree_distance(const T *p1, const size_t idx_p2,size_t size) const + inline T kdtree_distance(const T *p1, const size_t idx_p2,size_t /* size */) const { const T d0=p1[0]-pts[idx_p2].x; const T d1=p1[1]-pts[idx_p2].y; @@ -61,7 +61,7 @@ struct PointCloud // Return true if the BBOX was already computed by the class and returned in "bb" so it can be avoided to redo it again. // Look at bb.size() to find out the expected dimensionality (e.g. 2 or 3 for point clouds) template - bool kdtree_get_bbox(BBOX &bb) const { return false; } + bool kdtree_get_bbox(BBOX & /* bb */) const { return false; } }; @@ -76,7 +76,7 @@ void generateRandomPointCloud(PointCloud &point, istream& is) } template -void kdtree_demo(const size_t N) +void kdtree_demo(const size_t /* N */) { PointCloud cloud; @@ -131,14 +131,14 @@ void kdtree_demo(const size_t N) //std::cout << "knnSearch(nn="<(100000); kdtree_demo(100000); diff --git a/Spatial_searching/benchmark/Spatial_searching/nearest_neighbor_searching_50.cpp b/Spatial_searching/benchmark/Spatial_searching/nearest_neighbor_searching_50.cpp index c526fa3f762..876898e5d81 100644 --- a/Spatial_searching/benchmark/Spatial_searching/nearest_neighbor_searching_50.cpp +++ b/Spatial_searching/benchmark/Spatial_searching/nearest_neighbor_searching_50.cpp @@ -15,7 +15,7 @@ typedef Neighbor_search::Tree Tree; int main() { - const unsigned int N = 50; + // const unsigned int N = 50; CGAL::Timer timer; timer.start(); @@ -51,7 +51,7 @@ int main() { double d = 0; timer.reset(); timer.start(); - for(int i = 0; i < queries.size(); i++){ + for(std::size_t i = 0; i < queries.size(); i++){ Neighbor_search search(tree, queries[i], 50, 0); // report the N nearest neighbors and their distance diff --git a/Spatial_searching/benchmark/Spatial_searching/nearest_neighbor_searching_inplace_50.cpp b/Spatial_searching/benchmark/Spatial_searching/nearest_neighbor_searching_inplace_50.cpp index 531ed1f585b..59e16509d32 100644 --- a/Spatial_searching/benchmark/Spatial_searching/nearest_neighbor_searching_inplace_50.cpp +++ b/Spatial_searching/benchmark/Spatial_searching/nearest_neighbor_searching_inplace_50.cpp @@ -41,7 +41,7 @@ typedef K_neighbor_search::Distance Distance; int main() { - const unsigned int N = 50; + // const unsigned int N = 50; CGAL::Timer timer; timer.start(); @@ -82,7 +82,7 @@ int main() { double d = 0; timer.reset(); timer.start(); - for(int i = 0; i < queries.size(); i++){ + for(std::size_t i = 0; i < queries.size(); i++){ K_neighbor_search search(tree, queries[i], 50, 0, true, tr_dist); // report the N nearest neighbors and their distance diff --git a/Spatial_searching/benchmark/Spatial_searching/nn3nanoflan.cpp b/Spatial_searching/benchmark/Spatial_searching/nn3nanoflan.cpp index 63da87f0128..8822bae9992 100644 --- a/Spatial_searching/benchmark/Spatial_searching/nn3nanoflan.cpp +++ b/Spatial_searching/benchmark/Spatial_searching/nn3nanoflan.cpp @@ -10,6 +10,7 @@ #include #include #include +#include using namespace std; using namespace nanoflann; @@ -42,7 +43,7 @@ struct PointCloud inline size_t kdtree_get_point_count() const { return pts.size(); } // Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class: - inline T kdtree_distance(const T *p1, const size_t idx_p2,size_t size) const + inline T kdtree_distance(const T *p1, const size_t idx_p2,size_t /* size */) const { const T d0=p1[0]-pts[idx_p2].x; const T d1=p1[1]-pts[idx_p2].y; @@ -64,7 +65,7 @@ struct PointCloud // Return true if the BBOX was already computed by the class and returned in "bb" so it can be avoided to redo it again. // Look at bb.size() to find out the expected dimensionality (e.g. 2 or 3 for point clouds) template - bool kdtree_get_bbox(BBOX &bb) const { return false; } + bool kdtree_get_bbox(BBOX & /* bb */) const { return false; } }; @@ -162,7 +163,7 @@ void kdtree_demo(int argc, char** argv) index.findNeighbors(resultSet, &query_pt[0], nanoflann::SearchParams(10,0)); timer.stop(); - for (int k=0; k`Graphviz` format +into the output stream `s`. +*/ +std::ostream& write_graphviz(std::ostream& s) const; + /// @} }; /* end Kd_tree */ diff --git a/Spatial_searching/include/CGAL/Incremental_neighbor_search.h b/Spatial_searching/include/CGAL/Incremental_neighbor_search.h index fb8f40c5e21..23c2d269d6c 100644 --- a/Spatial_searching/include/CGAL/Incremental_neighbor_search.h +++ b/Spatial_searching/include/CGAL/Incremental_neighbor_search.h @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -342,7 +343,8 @@ namespace CGAL { 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))); + const Point_d& p = *m_tree.begin(); + m_dim = static_cast(std::distance(construct_it(p), construct_it(p, 0))); multiplication_factor= distance.transformed_distance(FT(1)+Eps); diff --git a/Spatial_searching/include/CGAL/Kd_tree.h b/Spatial_searching/include/CGAL/Kd_tree.h index 0b765149fea..777a0dad29d 100644 --- a/Spatial_searching/include/CGAL/Kd_tree.h +++ b/Spatial_searching/include/CGAL/Kd_tree.h @@ -21,6 +21,9 @@ #include #include #include +#include +#include +#include #include #include @@ -377,6 +380,39 @@ public: return dim_; } + std::ostream& + write_graphviz(std::ostream& s) const + { + int counter = -1; + std::unordered_map node_to_index; + tree_root->get_indices(counter, node_to_index); + + const auto node_name = [&](const Node* node) { + const int index = node_to_index.at(node); + std::string node_name = "default_name"; + if (node->is_leaf()) { // leaf node + node_name = "L" + std::to_string(index); + } else { + if (index == 0) { // root node + node_name = "R" + std::to_string(index); + } else { // internal node + node_name = "N" + std::to_string(index); + } + } + CGAL_assertion(node_name != "default_name"); + return node_name; + }; + + s << "graph G" << std::endl; + s << "{" << std::endl << std::endl; + s << "label=\"Graph G. Num leaves: " << tree_root->num_nodes() << ". "; + s << "Num items: " << tree_root->num_items() << ".\"" << std::endl; + s << node_name(tree_root) + " ;"; + tree_root->print(s, node_name); + s << std::endl << "}" << std::endl << std::endl; + return s; + } + private: //any call to this function is for the moment not threadsafe void const_build() const { diff --git a/Spatial_searching/include/CGAL/Kd_tree_node.h b/Spatial_searching/include/CGAL/Kd_tree_node.h index 6e0e1b84698..02af0663d6a 100644 --- a/Spatial_searching/include/CGAL/Kd_tree_node.h +++ b/Spatial_searching/include/CGAL/Kd_tree_node.h @@ -15,7 +15,8 @@ #include - +#include +#include #include #include @@ -58,6 +59,55 @@ namespace CGAL { bool is_leaf() const { return leaf; } + void + get_indices(int& index, std::unordered_map& node_to_index) const + { + if (is_leaf()) { + Leaf_node_const_handle node = + static_cast(this); + ++index; + node_to_index[node] = index; + } else { + Internal_node_const_handle node = + static_cast(this); + ++index; + node_to_index[node] = index; + node->lower()->get_indices(index, node_to_index); + node->upper()->get_indices(index, node_to_index); + } + } + + template + void + print(std::ostream& s, const Node_name& node_name) const + { + if (is_leaf()) { // draw leaf nodes + + Leaf_node_const_handle node = + static_cast(this); + + s << std::endl; + if (node->size() > 0) { + s << node_name(node) << " [label=\"" << node_name(node) << ", Size: " + << node->size() << "\"] ;" << std::endl; + } else { + CGAL_assertion_msg(false, "ERROR: NODE SIZE IS ZERO!"); + } + + } else { // draw internal nodes + + Internal_node_const_handle node = + static_cast(this); + + s << std::endl; + s << node_name(node) << " [label=\"" << node_name(node) << "\"] ;" << std::endl; + s << node_name(node) << " -- " << node_name(node->lower()) << " ;"; + node->lower()->print(s, node_name); + s << node_name(node) << " -- " << node_name(node->upper()) << " ;"; + node->upper()->print(s, node_name); + } + } + std::size_t num_items() const { diff --git a/Spatial_searching/include/CGAL/Manhattan_distance_iso_box_point.h b/Spatial_searching/include/CGAL/Manhattan_distance_iso_box_point.h index 6a1708eab24..96b11788d5c 100644 --- a/Spatial_searching/include/CGAL/Manhattan_distance_iso_box_point.h +++ b/Spatial_searching/include/CGAL/Manhattan_distance_iso_box_point.h @@ -33,6 +33,7 @@ namespace CGAL { typedef typename SearchTraits::FT FT; typedef Iso_box_d Query_item; typedef typename internal::Get_dimension_tag::Dimension Dimension; + typedef typename CGAL::cpp11::result_of::type Min_vertex; typedef typename CGAL::cpp11::result_of::type Max_vertex; Manhattan_distance_iso_box_point(const SearchTraits& traits_=SearchTraits()):traits(traits_) {} @@ -46,9 +47,10 @@ namespace CGAL { traits.construct_cartesian_const_iterator_d_object(); typename SearchTraits::Construct_min_vertex_d construct_min_vertex; typename SearchTraits::Construct_max_vertex_d construct_max_vertex; + Min_vertex minv = construct_min_vertex(q); Max_vertex maxv = construct_max_vertex(q); typename SearchTraits::Cartesian_const_iterator_d qmaxit = construct_it(maxv), - qe = construct_it(maxv,1), qminit = construct_it(construct_min_vertex(q)), + qe = construct_it(maxv,1), qminit = construct_it(minv), pit = construct_it(p); for (; qmaxit != qe; ++pit,++qmaxit,++qminit) { if ((*pit)>(*qmaxit)) distance += @@ -67,9 +69,10 @@ namespace CGAL { traits.construct_cartesian_const_iterator_d_object(); typename SearchTraits::Construct_min_vertex_d construct_min_vertex; typename SearchTraits::Construct_max_vertex_d construct_max_vertex; + Min_vertex minv = construct_min_vertex(q); Max_vertex maxv = construct_max_vertex(q); typename SearchTraits::Cartesian_const_iterator_d qmaxit = construct_it(maxv), - qe = construct_it(maxv,1), qminit = construct_it(construct_min_vertex(q)); + qe = construct_it(maxv,1), qminit = construct_it(minv); for (unsigned int i = 0; qmaxit != qe; ++ qmaxit, ++qminit, ++i) { if (r.min_coord(i)>(*qmaxit)) distance +=(r.min_coord(i)-(*qmaxit)); @@ -86,9 +89,10 @@ namespace CGAL { traits.construct_cartesian_const_iterator_d_object(); typename SearchTraits::Construct_min_vertex_d construct_min_vertex; typename SearchTraits::Construct_max_vertex_d construct_max_vertex; + Min_vertex minv = construct_min_vertex(q); Max_vertex maxv = construct_max_vertex(q); typename SearchTraits::Cartesian_const_iterator_d qmaxit = construct_it(maxv), - qe = construct_it(maxv,1), qminit = construct_it(construct_min_vertex(q)); + qe = construct_it(maxv,1), qminit = construct_it(minv); for (unsigned int i = 0; qmaxit != qe; ++ qmaxit, ++qminit, ++i) { if (r.min_coord(i)>(*qmaxit)) { dists[i]=(r.min_coord(i)-(*qmaxit)); @@ -111,9 +115,10 @@ namespace CGAL { traits.construct_cartesian_const_iterator_d_object(); typename SearchTraits::Construct_min_vertex_d construct_min_vertex; typename SearchTraits::Construct_max_vertex_d construct_max_vertex; + Min_vertex minv = construct_min_vertex(q); Max_vertex maxv = construct_max_vertex(q); typename SearchTraits::Cartesian_const_iterator_d qmaxit = construct_it(maxv), - qe = construct_it(maxv,1), qminit = construct_it(construct_min_vertex(q)); + qe = construct_it(maxv,1), qminit = construct_it(minv); for (unsigned int i = 0; qmaxit != qe; ++ qmaxit, ++qminit, ++i) { if ( r.max_coord(i)-(*qminit) >(*qmaxit)-r.min_coord(i) ) distance += (r.max_coord(i)-(*qminit)); @@ -132,9 +137,10 @@ namespace CGAL { traits.construct_cartesian_const_iterator_d_object(); typename SearchTraits::Construct_min_vertex_d construct_min_vertex; typename SearchTraits::Construct_max_vertex_d construct_max_vertex; + Min_vertex minv = construct_min_vertex(q); Max_vertex maxv = construct_max_vertex(q); typename SearchTraits::Cartesian_const_iterator_d qmaxit = construct_it(maxv), - qe = construct_it(maxv,1), qminit = construct_it(construct_min_vertex(q)); + qe = construct_it(maxv,1), qminit = construct_it(minv); for (unsigned int i = 0; qmaxit != qe; ++ qmaxit, ++qminit, ++i) { if ( r.max_coord(i)-(*qminit) >(*qmaxit)-r.min_coord(i) ) { dists[i]=(r.max_coord(i)-(*qminit)); diff --git a/Spatial_searching/test/Spatial_searching/I_neighbor_search_manhattan_distance_isobox_point.cpp b/Spatial_searching/test/Spatial_searching/I_neighbor_search_manhattan_distance_isobox_point.cpp new file mode 100644 index 00000000000..7e81c4c7e6f --- /dev/null +++ b/Spatial_searching/test/Spatial_searching/I_neighbor_search_manhattan_distance_isobox_point.cpp @@ -0,0 +1,35 @@ + +#include + +#include +#include +#include +#include + + +using K = CGAL::Exact_predicates_inexact_constructions_kernel; +using Point = K::Point_2; +using TreeTraits = CGAL::Search_traits_2; +using Splitter = CGAL::Sliding_midpoint; +using Distance = CGAL::Manhattan_distance_iso_box_point; + +using IncrNN = CGAL::Incremental_neighbor_search; +using Tree = IncrNN::Tree; + +int main() { + + Tree tree; + tree.insert({1,1}); + tree.insert({2,2}); + + Point pQuery(0, 0); + + IncrNN nn(tree, {pQuery, pQuery}); + + for (IncrNN::iterator it = nn.begin(); it != nn.end(); ++it) { + std::cout << it->first << " dist: " << it->second << std::endl;; + } + + return 0; + +} diff --git a/Spatial_searching/test/Spatial_searching/data/balanced.xyz b/Spatial_searching/test/Spatial_searching/data/balanced.xyz new file mode 100644 index 00000000000..22f772d41b8 --- /dev/null +++ b/Spatial_searching/test/Spatial_searching/data/balanced.xyz @@ -0,0 +1,25 @@ +2 3 3 +5 4 2 +9 6 7 +4 7 9 +8 1 5 +7 2 6 +9 4 1 +8 4 2 +9 7 8 +6 3 1 +3 4 5 +1 6 8 +9 5 3 +2 1 3 +8 7 6 +5 4 2 +6 3 1 +8 7 6 +9 6 7 +2 1 3 +7 2 6 +4 7 9 +1 6 8 +3 4 5 +9 4 1 diff --git a/Spatial_searching/test/Spatial_searching/test_print.cpp b/Spatial_searching/test/Spatial_searching/test_print.cpp new file mode 100644 index 00000000000..eff527cef53 --- /dev/null +++ b/Spatial_searching/test/Spatial_searching/test_print.cpp @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; +using Point_3 = typename Kernel::Point_3; + +using Traits = CGAL::Search_traits_3; +using Splitter = CGAL::Sliding_midpoint; +using Kd_tree = CGAL::Kd_tree; + +using Timer = CGAL::Real_timer; + +void test_print(const std::string filename) { + + std::cout << std::endl; + std::cout << "- testing " << filename << " ... " << std::endl; + + std::vector points; + std::ifstream in(filename); + CGAL::IO::set_ascii_mode(in); + + Point_3 p; std::size_t count = 0; + while (in >> p) { + points.push_back(p); + ++count; + } + assert(points.size() > 0); + + std::cout << "* num points: " << points.size() << std::endl; + std::cout << "* building the tree ... " << std::endl; + + // Building the tree. + Splitter splitter(5); // bucket size = 5 + Kd_tree tree(points.begin(), points.end(), splitter); + + Timer timer; + timer.start(); + tree.build(); + timer.stop(); + std::cout << "* building done in " << timer.time() << " sec." << std::endl; + + tree.statistics(std::cout); + // Use this command to print in png: + // dot -Tpng tree.graphviz > tree.png + std::ofstream outfile("tree.graphviz"); + tree.write_graphviz(outfile); + + assert(tree.root()->num_items() == points.size()); + assert(tree.root()->num_nodes() == 8); + assert(tree.root()->depth() == 5); + std::cout << std::endl; +} + +int main() { + + std::cout.precision(20); + test_print("data/balanced.xyz"); + return EXIT_SUCCESS; +} diff --git a/Stream_support/doc/Stream_support/Doxyfile.in b/Stream_support/doc/Stream_support/Doxyfile.in index 290a4266fcd..f0c48c2e204 100644 --- a/Stream_support/doc/Stream_support/Doxyfile.in +++ b/Stream_support/doc/Stream_support/Doxyfile.in @@ -6,9 +6,3 @@ EXAMPLE_PATH = ${CGAL_PACKAGE_DIR}/examples EXTRACT_ALL = false HIDE_UNDOC_MEMBERS = true HIDE_UNDOC_CLASSES = true - -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = YES -EXPAND_AS_DEFINED = CGAL_BGL_NP_TEMPLATE_PARAMETERS \ - CGAL_BGL_NP_CLASS - diff --git a/Stream_support/doc/Stream_support/dependencies b/Stream_support/doc/Stream_support/dependencies index dadde6b839e..50dc362f947 100644 --- a/Stream_support/doc/Stream_support/dependencies +++ b/Stream_support/doc/Stream_support/dependencies @@ -1,7 +1,6 @@ Alpha_shapes_3 Arrangement_on_surface_2 BGL -Geomview Kernel_23 Manual Mesh_2 diff --git a/Stream_support/examples/Stream_support/Linestring_WKT.cpp b/Stream_support/examples/Stream_support/Linestring_WKT.cpp index c145680215e..e6ce9fe60d5 100644 --- a/Stream_support/examples/Stream_support/Linestring_WKT.cpp +++ b/Stream_support/examples/Stream_support/Linestring_WKT.cpp @@ -1,16 +1,10 @@ -#include #include - -#include -#include +#include #include #include #include -#include - -//typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; int main(int argc, char* argv[]) diff --git a/Stream_support/examples/Stream_support/Point_WKT.cpp b/Stream_support/examples/Stream_support/Point_WKT.cpp index 2bc1e94276c..54cadc48f8e 100644 --- a/Stream_support/examples/Stream_support/Point_WKT.cpp +++ b/Stream_support/examples/Stream_support/Point_WKT.cpp @@ -1,15 +1,10 @@ -#include #include - -#include -#include +#include #include #include #include -#include -//typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; int main(int argc, char* argv[]) diff --git a/Stream_support/examples/Stream_support/Polygon_WKT.cpp b/Stream_support/examples/Stream_support/Polygon_WKT.cpp index f7d4e31effe..f417e4a48ee 100644 --- a/Stream_support/examples/Stream_support/Polygon_WKT.cpp +++ b/Stream_support/examples/Stream_support/Polygon_WKT.cpp @@ -1,17 +1,10 @@ -#include #include - -#include -#include +#include #include #include -#include #include -#include - -//typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; int main(int argc, char* argv[]) diff --git a/Stream_support/examples/Stream_support/iv2off.cpp b/Stream_support/examples/Stream_support/iv2off.cpp index 231c7cff65d..676a6e56ac4 100644 --- a/Stream_support/examples/Stream_support/iv2off.cpp +++ b/Stream_support/examples/Stream_support/iv2off.cpp @@ -67,7 +67,6 @@ void iv_file_scanner( istream& in) // point coordinate list starts here offset = points.size(); in >> c; - CGAL_assertion( c == '['); in >> c; while ( in && ( c != ']')) { in.putback( c); @@ -99,7 +98,6 @@ void iv_file_scanner( istream& in) // indices start here std::size_t face_offset = facets.size(); in >> c; - CGAL_assertion( c == '['); facets.push_back( Facet()); Facet* facet = &facets.back(); in >> c; @@ -133,7 +131,6 @@ void iv_file_scanner( istream& in) // indices start here std::size_t face_offset = facets.size(); in >> c; - CGAL_assertion( c == '['); facets.push_back( Facet()); Facet* facet = &facets.back(); in >> c; diff --git a/Stream_support/examples/Stream_support/read_WKT.cpp b/Stream_support/examples/Stream_support/read_WKT.cpp index 2ead693e8ea..9c7ed82d578 100644 --- a/Stream_support/examples/Stream_support/read_WKT.cpp +++ b/Stream_support/examples/Stream_support/read_WKT.cpp @@ -1,16 +1,12 @@ -#include #include - -#include -#include +#include #include #include #include -#include -//typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; + int main(int argc, char* argv[]) { typedef CGAL::Point_2 Point; diff --git a/Stream_support/include/CGAL/IO/Color.h b/Stream_support/include/CGAL/IO/Color.h index 12bdd320e28..6cb2939fe49 100644 --- a/Stream_support/include/CGAL/IO/Color.h +++ b/Stream_support/include/CGAL/IO/Color.h @@ -41,8 +41,6 @@ namespace IO { left to its default value (255 = no transparency), which is why we often refer to the rgb-value of the color. - \sa `CGAL::Geomview_stream` - */ class Color @@ -134,6 +132,11 @@ public: return !( (*this) == c); } + bool operator<(const Color& c) const + { + return m_data < c.to_rgba(); + } + unsigned char r() const { return red(); } unsigned char g() const { return green(); } unsigned char b() const { return blue(); } @@ -208,7 +211,7 @@ public: /*! replaces the rgb values of the colors by the one given as parameters. */ - void set_rgb (unsigned char red, + Color& set_rgb (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = 255) @@ -217,13 +220,15 @@ public: m_data[1] = green; m_data[2] = blue; m_data[3] = alpha; + + return *this; } /*! replaces the rgb values of the colors by the conversion to rgb of the hsv values given as parameters. */ - void set_hsv (double hue, + Color& set_hsv (double hue, double saturation, double value, unsigned char alpha = 255) @@ -277,6 +282,8 @@ public: m_data[1] = (unsigned char)g; m_data[2] = (unsigned char)b; m_data[3] = alpha; + + return *this; } /// @} diff --git a/Stream_support/include/CGAL/IO/GOCAD.h b/Stream_support/include/CGAL/IO/GOCAD.h index fc8ab4a4d21..d0701c952e0 100644 --- a/Stream_support/include/CGAL/IO/GOCAD.h +++ b/Stream_support/include/CGAL/IO/GOCAD.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -40,12 +40,12 @@ namespace IO { /// \cond SKIP_IN_MANUAL -template +template bool read_GOCAD(std::istream& is, std::pair& name_and_color, PointRange& points, PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) { typedef typename boost::range_value::type Point; typedef typename boost::range_value::type Poly; @@ -156,6 +156,7 @@ bool read_GOCAD(std::istream& is, is.clear(std::ios::goodbit); return end_read && nb_gocad == nb_end && !is.bad(); } +/// \endcond /*! * \ingroup PkgStreamSupportIoFuncsGOCAD @@ -188,11 +189,11 @@ bool read_GOCAD(std::istream& is, * * \returns `true` if the reading was successful, `false` otherwise. */ -template +template bool read_GOCAD(std::istream& is, PointRange& points, PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -202,18 +203,6 @@ bool read_GOCAD(std::istream& is, return read_GOCAD(is, dummy, points, polygons, np); } -/// \cond SKIP_IN_MANUAL - -template -bool read_GOCAD(std::istream& is, PointRange& points, PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - std::pair dummy; - return read_GOCAD(is, dummy, points, polygons, parameters::all_default()); -} - -/// \endcond - /*! * \ingroup PkgStreamSupportIoFuncsGOCAD * @@ -245,11 +234,11 @@ bool read_GOCAD(std::istream& is, PointRange& points, PolygonRange& polygons, * * \returns `true` if the reading was successful, `false` otherwise. */ -template +template bool read_GOCAD(const std::string& fname, PointRange& points, PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -261,17 +250,6 @@ bool read_GOCAD(const std::string& fname, return read_GOCAD(is, dummy, points, polygons, np); } -/// \cond SKIP_IN_MANUAL - -template -bool read_GOCAD(const std::string& fname, PointRange& points, PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return read_GOCAD(fname, points, polygons, parameters::all_default()); -} - -/// \endcond - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // Write @@ -280,19 +258,19 @@ namespace internal { template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_GOCAD(std::ostream& os, const char* fname, const PointRange& points, const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) { typedef typename boost::range_value::type Poly; using parameters::choose_parameter; using parameters::get_parameter; - typedef typename CGAL::GetPointMap::type PointMap; + typedef typename CGAL::GetPointMap::type PointMap; PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); if(!os.good()) @@ -364,11 +342,11 @@ bool write_GOCAD(std::ostream& os, */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_GOCAD(std::ostream& os, const PointRange& points, const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -377,17 +355,6 @@ bool write_GOCAD(std::ostream& os, return internal::write_GOCAD(os, "anonymous", points, polygons, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_GOCAD(std::ostream& os, const PointRange& points, const PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return internal::write_GOCAD(os, "anonymous", points, polygons, parameters::all_default()); -} - -/// \endcond - /*! * \ingroup PkgStreamSupportIoFuncsGOCAD * @@ -417,11 +384,11 @@ bool write_GOCAD(std::ostream& os, const PointRange& points, const PolygonRange& */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_GOCAD(const std::string& fname, const PointRange& points, const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -432,18 +399,6 @@ bool write_GOCAD(const std::string& fname, return internal::write_GOCAD(os, fname.c_str(), points, polygons, np); } -/// \cond SKIP_IN_MANUAL - - -template -bool write_GOCAD(const std::string& fname, const PointRange& points, const PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return write_GOCAD(fname, points, polygons, parameters::all_default()); -} - -/// \endcond - } // namespace IO } // namespace CGAL diff --git a/Stream_support/include/CGAL/IO/Generic_writer.h b/Stream_support/include/CGAL/IO/Generic_writer.h index b3d46b4fb77..b91a8a5b7f7 100644 --- a/Stream_support/include/CGAL/IO/Generic_writer.h +++ b/Stream_support/include/CGAL/IO/Generic_writer.h @@ -17,7 +17,7 @@ #ifndef CGAL_IO_GENERIC_WRITER_H #define CGAL_IO_GENERIC_WRITER_H -#include +#include #include #include @@ -36,7 +36,7 @@ public: template bool operator()(const PointRange& points, const PolygonRange& polygons, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef typename boost::range_value::type Poly; @@ -74,13 +74,6 @@ public: return m_os.good(); } - template - bool operator()(const PointRange& points, - const PolygonRange& polygons) - { - return this->operator()(points, polygons, parameters::all_default()); - } - protected: Stream& m_os; FileWriter m_writer; diff --git a/Stream_support/include/CGAL/IO/OBJ.h b/Stream_support/include/CGAL/IO/OBJ.h index 9cdc507e3cc..1bbe0e264eb 100644 --- a/Stream_support/include/CGAL/IO/OBJ.h +++ b/Stream_support/include/CGAL/IO/OBJ.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -31,11 +31,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -211,11 +206,11 @@ bool read_OBJ(std::istream& is, /// \cgalNamedParamsEnd /// /// \returns `true` if the reading was successful, `false` otherwise. -template +template bool read_OBJ(std::istream& is, PointRange& points, PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -228,17 +223,6 @@ bool read_OBJ(std::istream& is, verbose); } -/// \cond SKIP_IN_MANUAL - -template -bool read_OBJ(std::istream& is, PointRange& points, PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return read_OBJ(is, points, polygons, parameters::all_default()); -} - -/// \endcond - /// \ingroup PkgStreamSupportIoFuncsOBJ /// /// \brief reads the content of the file `fname` into `points` and `polygons`, using the \ref IOStreamOBJ. @@ -267,11 +251,11 @@ bool read_OBJ(std::istream& is, PointRange& points, PolygonRange& polygons, /// \cgalNamedParamsEnd /// /// \returns `true` if the reading was successful, `false` otherwise. -template +template bool read_OBJ(const std::string& fname, PointRange& points, PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -282,17 +266,6 @@ bool read_OBJ(const std::string& fname, return read_OBJ(is, points, polygons, np); } -/// \cond SKIP_IN_MANUAL - -template -bool read_OBJ(const std::string& fname, PointRange& points, PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return read_OBJ(fname, points, polygons, parameters::all_default()); -} - -/// \endcond - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // Write @@ -326,11 +299,11 @@ bool read_OBJ(const std::string& fname, PointRange& points, PolygonRange& polygo */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_OBJ(std::ostream& os, const PointRange& points, const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -341,17 +314,6 @@ bool write_OBJ(std::ostream& os, return writer(points, polygons, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_OBJ(std::ostream& os, const PointRange& points, const PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return write_OBJ(os, points, polygons, parameters::all_default()); -} - -/// \endcond - /*! * \ingroup PkgStreamSupportIoFuncsOBJ * @@ -381,11 +343,11 @@ bool write_OBJ(std::ostream& os, const PointRange& points, const PolygonRange& p */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_OBJ(const std::string& fname, const PointRange& points, const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -397,17 +359,6 @@ bool write_OBJ(const std::string& fname, return write_OBJ(os, points, polygons, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_OBJ(const std::string& fname, const PointRange& points, const PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return write_OBJ(fname, points, polygons, parameters::all_default()); -} - -/// \endcond - } // namespace IO } // namespace CGAL diff --git a/Stream_support/include/CGAL/IO/OFF.h b/Stream_support/include/CGAL/IO/OFF.h index 3397a034959..4dc678064d1 100644 --- a/Stream_support/include/CGAL/IO/OFF.h +++ b/Stream_support/include/CGAL/IO/OFF.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include @@ -32,11 +32,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -183,11 +178,11 @@ bool read_OFF(std::istream& is, * * \returns `true` if the reading was successful, `false` otherwise. */ -template +template bool read_OFF(std::istream& is, PointRange& points, PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -208,17 +203,6 @@ bool read_OFF(std::istream& is, choose_parameter(get_parameter(np, internal_np::verbose), true)); } -/// \cond SKIP_IN_MANUAL - -template -bool read_OFF(std::istream& is, PointRange& points, PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return read_OFF(is, points, polygons, parameters::all_default()); -} - -/// \endcond - /*! * \ingroup PkgStreamSupportIoFuncsOFF * @@ -247,11 +231,11 @@ bool read_OFF(std::istream& is, PointRange& points, PolygonRange& polygons, * * \returns `true` if the reading was successful, `false` otherwise. */ -template +template bool read_OFF(const std::string& fname, PointRange& points, PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -261,17 +245,6 @@ bool read_OFF(const std::string& fname, return read_OFF(in, points, polygons, np); } -/// \cond SKIP_IN_MANUAL - -template -bool read_OFF(const std::string& fname, PointRange& points, PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return read_OFF(fname, points, polygons, parameters::all_default()); -} - -/// \endcond - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // Write @@ -303,11 +276,11 @@ bool read_OFF(const std::string& fname, PointRange& points, PolygonRange& polygo * * \return `true` if the writing was successful, `false` otherwise. */ -template +template bool write_OFF(std::ostream& os, const PointRange& points, const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -317,17 +290,6 @@ bool write_OFF(std::ostream& os, return writer(points, polygons, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_OFF(std::ostream& os, const PointRange& points, const PolygonRange& polygons - , typename boost::enable_if >::type* = nullptr) -{ - return write_OFF(os, points, polygons, parameters::all_default()); -} - -/// \endcond - /*! * \ingroup PkgStreamSupportIoFuncsOFF * @@ -355,11 +317,11 @@ bool write_OFF(std::ostream& os, const PointRange& points, const PolygonRange& p * * \return `true` if the writing was successful, `false` otherwise. */ -template +template bool write_OFF(const std::string& fname, const PointRange& points, const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -370,17 +332,6 @@ bool write_OFF(const std::string& fname, return writer(points, polygons, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_OFF(const std::string& fname, const PointRange& points, const PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return write_OFF(fname, points, polygons, parameters::all_default()); -} - -/// \endcond - } // namespace IO } // namespace CGAL diff --git a/Stream_support/include/CGAL/IO/OFF/File_scanner_OFF.h b/Stream_support/include/CGAL/IO/OFF/File_scanner_OFF.h index 90c1ed4305f..dd3d704b950 100644 --- a/Stream_support/include/CGAL/IO/OFF/File_scanner_OFF.h +++ b/Stream_support/include/CGAL/IO/OFF/File_scanner_OFF.h @@ -710,6 +710,7 @@ public: if(entries.empty()) { m_in.clear(std::ios::badbit); + size = 0; return; } size = static_cast(entries[0]); @@ -742,6 +743,7 @@ public: m_in.clear(std::ios::badbit); if(verbose()) std::cerr<<"error while reading facet. Missing index."<(entries[current_entry]); @@ -757,7 +759,7 @@ public: "cannot read OFF file beyond facet " << current_facet << "." << std::endl; } - + index=0; set_off_header(false); return; } @@ -777,7 +779,7 @@ public: << index + index_offset() << ": is out of range." << std::endl; } - + index = 0; set_off_header(false); return; } diff --git a/Stream_support/include/CGAL/IO/PLY.h b/Stream_support/include/CGAL/IO/PLY.h index dc11c16e873..672cefeaead 100644 --- a/Stream_support/include/CGAL/IO/PLY.h +++ b/Stream_support/include/CGAL/IO/PLY.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include #include @@ -32,11 +32,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -308,11 +303,11 @@ bool read_PLY(std::istream& is, * * \returns `true` if the reading was successful, `false` otherwise. */ -template +template bool read_PLY(std::istream& is, PointRange& points, PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -333,17 +328,6 @@ bool read_PLY(std::istream& is, choose_parameter(get_parameter(np, internal_np::verbose), true)); } -/// \cond SKIP_IN_MANUAL - -template -bool read_PLY(std::istream& is, PointRange& points, PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return read_PLY(is, points, polygons, parameters::all_default()); -} - -/// \endcond - /*! * \ingroup PkgStreamSupportIoFuncsPLY * @@ -379,11 +363,11 @@ bool read_PLY(std::istream& is, PointRange& points, PolygonRange& polygons, * * \returns `true` if the reading was successful, `false` otherwise. */ -template +template bool read_PLY(const std::string& fname, PointRange& points, PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -404,17 +388,6 @@ bool read_PLY(const std::string& fname, } } -/// \cond SKIP_IN_MANUAL - -template -bool read_PLY(const std::string& fname, PointRange& points, PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return read_PLY(fname, points, polygons, parameters::all_default()); -} - -/// \endcond - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // Write @@ -453,11 +426,11 @@ bool read_PLY(const std::string& fname, PointRange& points, PolygonRange& polygo * * \return `true` if the writing was successful, `false` otherwise. */ -template +template bool write_PLY(std::ostream& out, const PointRange& points, const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -498,17 +471,6 @@ bool write_PLY(std::ostream& out, return out.good(); } -/// \cond SKIP_IN_MANUAL - -template -bool write_PLY(std::ostream& out, const PointRange& points, const PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return write_PLY(out, points, polygons, parameters::all_default()); -} - -/// \endcond - /*! * \ingroup PkgStreamSupportIoFuncsPLY * @@ -543,11 +505,11 @@ bool write_PLY(std::ostream& out, const PointRange& points, const PolygonRange& * * \return `true` if the writing was successful, `false` otherwise. */ -template +template bool write_PLY(const std::string& fname, const PointRange& points, const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -568,17 +530,6 @@ bool write_PLY(const std::string& fname, } } -/// \cond SKIP_IN_MANUAL - -template -bool write_PLY(const std::string& fname, const PointRange& points, const PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return write_PLY(fname, points, polygons, parameters::all_default()); -} - -/// \endcond - } // namespace IO } // namespace CGAL diff --git a/Stream_support/include/CGAL/IO/STL.h b/Stream_support/include/CGAL/IO/STL.h index 530dd5035f9..a334fb81432 100644 --- a/Stream_support/include/CGAL/IO/STL.h +++ b/Stream_support/include/CGAL/IO/STL.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -29,11 +29,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { namespace IO { @@ -73,18 +68,17 @@ namespace IO { * * \returns `true` if the reading was successful, `false` otherwise. */ -template +template bool read_STL(std::istream& is, PointRange& points, TriangleRange& facets, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif ) { const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false); - const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true); if(!is.good()) { @@ -93,7 +87,6 @@ bool read_STL(std::istream& is, return false; } - int pos = 0; // Ignore all initial whitespace unsigned char c; @@ -104,23 +97,11 @@ bool read_STL(std::istream& is, is.unget(); // move back to the first interesting char break; } - ++pos; } if(!is.good()) // reached the end return true; - // If we have gone beyond 80 characters and have not read anything yet, - // then this must be an ASCII file. - if(pos > 80) - { - if(binary) - return false; - return internal::parse_ASCII_STL(is, points, facets, verbose); - } - - // We are within the first 80 characters, both ASCII and binary are possible - // Read the 5 first characters to check if the first word is "solid" std::string s; @@ -133,7 +114,6 @@ bool read_STL(std::istream& is, is.read(reinterpret_cast(&word[5]), sizeof(c))) { s = std::string(word, 5); - pos += 5; } else { @@ -172,17 +152,6 @@ bool read_STL(std::istream& is, } } -/// \cond SKIP_IN_MANUAL - -template -bool read_STL(std::istream& is, PointRange& points, TriangleRange& facets, - typename boost::enable_if >::type* = nullptr) -{ - return read_STL(is, points, facets, parameters::all_default()); -} - -/// \endcond - /*! * \ingroup PkgStreamSupportIoFuncsSTL * @@ -218,11 +187,11 @@ bool read_STL(std::istream& is, PointRange& points, TriangleRange& facets, * * \returns `true` if the reading was successful, `false` otherwise. */ -template +template bool read_STL(const std::string& fname, PointRange& points, TriangleRange& facets, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -249,17 +218,6 @@ bool read_STL(const std::string& fname, return read_STL(is, points, facets, CGAL::parameters::verbose(v).use_binary_mode(false)); } -/// \cond SKIP_IN_MANUAL - -template -bool read_STL(const std::string& fname, PointRange& points, TriangleRange& facets, - typename boost::enable_if >::type* = nullptr) -{ - return read_STL(fname, points, facets, parameters::all_default()); -} - -/// \endcond - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // Write @@ -295,11 +253,11 @@ bool read_STL(const std::string& fname, PointRange& points, TriangleRange& facet * * \return `true` if the writing was successful, `false` otherwise. */ -template +template bool write_STL(std::ostream& os, const PointRange& points, const TriangleRange& facets, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -310,7 +268,7 @@ bool write_STL(std::ostream& os, using parameters::choose_parameter; using parameters::get_parameter; - typedef typename CGAL::GetPointMap::type PointMap; + typedef typename CGAL::GetPointMap::type PointMap; PointMap point_map = choose_parameter(get_parameter(np, internal_np::point_map)); typedef typename boost::property_traits::value_type Point; @@ -368,17 +326,6 @@ bool write_STL(std::ostream& os, return !os.fail(); } -/// \cond SKIP_IN_MANUAL - -template -bool write_STL(std::ostream& os, const PointRange& points, const TriangleRange& facets, - typename boost::enable_if >::type* = nullptr) -{ - return write_STL(os, points, facets, parameters::all_default()); -} - -/// \endcond - /*! * \ingroup PkgStreamSupportIoFuncsSTL * @@ -414,11 +361,11 @@ bool write_STL(std::ostream& os, const PointRange& points, const TriangleRange& * * \return `true` if the writing was successful, `false` otherwise. */ -template +template bool write_STL(const std::string& fname, const PointRange& points, const TriangleRange& facets, - const CGAL_BGL_NP_CLASS& np + const CGAL_NP_CLASS& np = parameters::default_values() #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -439,17 +386,6 @@ bool write_STL(const std::string& fname, } } -/// \cond SKIP_IN_MANUAL - -template -bool write_STL(const std::string& fname, const PointRange& points, const TriangleRange& facets, - typename boost::enable_if >::type* = nullptr) -{ - return write_STL(fname, points, facets, parameters::all_default()); -} - -/// \endcond - } // namespace IO } // namespace CGAL diff --git a/Stream_support/include/CGAL/IO/VTK.h b/Stream_support/include/CGAL/IO/VTK.h index 34e31698fca..8878fde1523 100644 --- a/Stream_support/include/CGAL/IO/VTK.h +++ b/Stream_support/include/CGAL/IO/VTK.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #ifdef CGAL_USE_VTK @@ -32,11 +32,6 @@ #if defined(CGAL_USE_VTK) || defined(DOXYGEN_RUNNING) -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#endif - namespace CGAL { namespace IO { namespace internal { @@ -142,7 +137,7 @@ bool read_VTP(const std::string& fname, template bool read_VTP(const std::string& fname, PointRange& points, PolygonRange& polygons) { - return read_VTP(fname, points, polygons, parameters::all_default()); + return read_VTP(fname, points, polygons, parameters::default_values()); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -379,11 +374,11 @@ void write_soup_polys_points(std::ostream& os, */ template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_VTP(std::ostream& os, const PointRange& points, const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::get_parameter; using parameters::choose_parameter; @@ -432,16 +427,6 @@ bool write_VTP(std::ostream& os, os << "" << std::endl; } -/// \cond SKIP_IN_MANUAL - -template -bool write_VTP(std::ostream& os, const PointRange& points, const PolygonRange& polygons) -{ - return write_VTP(os, points, polygons, parameters::all_default()); -} - -/// \endcond - /*! * \ingroup PkgStreamSupportIoFuncsVTP * @@ -475,11 +460,11 @@ bool write_VTP(std::ostream& os, const PointRange& points, const PolygonRange& p * * \return `true` if the writing was successful, `false` otherwise. */ -template +template bool write_VTP(const std::string& fname, const PointRange& points, const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true); if(binary) @@ -496,16 +481,6 @@ bool write_VTP(const std::string& fname, } } -/// \cond SKIP_IN_MANUAL - -template -bool write_VTP(const std::string& fname, const PointRange& points, const PolygonRange& polygons) -{ - return write_VTP(fname, points, polygons, parameters::all_default()); -} - -/// \endcond - } // namespace IO } // namespace CGAL diff --git a/Stream_support/include/CGAL/IO/polygon_soup_io.h b/Stream_support/include/CGAL/IO/polygon_soup_io.h index 4934720e26a..098d088680b 100644 --- a/Stream_support/include/CGAL/IO/polygon_soup_io.h +++ b/Stream_support/include/CGAL/IO/polygon_soup_io.h @@ -52,8 +52,8 @@ namespace IO { * The format is detected from the filename extension (letter case is not important). * * \tparam PointRange a model of the concept `RandomAccessContainer` whose value type is the point type. - * \tparam PolygonRange a model of the concepts `SequenceContainer` and `BackInsertionSequence` - * whose `value_type` is itself a model of the concepts `SequenceContainer` + * \tparam PolygonRange a model of the concepts `RandomAccessContainer` and `BackInsertionSequence` + * whose `value_type` is itself a model of the concepts `RandomAccessContainer` * and `BackInsertionSequence` whose `value_type` is an unsigned integer type * convertible to `std::size_t` * \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @@ -73,11 +73,11 @@ namespace IO { * * \return `true` if reading was successful, `false` otherwise. */ -template +template bool read_polygon_soup(const std::string& fname, PointRange& points, PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false); @@ -113,16 +113,6 @@ bool read_polygon_soup(const std::string& fname, return false; } -/// \cond SKIP_IN_MANUAL - -template -bool read_polygon_soup(const std::string& fname, PointRange& points, PolygonRange& polygons) -{ - return read_polygon_soup(fname, points, polygons, parameters::all_default()); -} - -/// \endcond - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // Write @@ -163,11 +153,11 @@ bool read_polygon_soup(const std::string& fname, PointRange& points, PolygonRang * * \return `true` if writing was successful, `false` otherwise. */ -template +template bool write_polygon_soup(const std::string& fname, const PointRange& points, const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false); @@ -207,16 +197,6 @@ bool write_polygon_soup(const std::string& fname, return false; } -/// \cond SKIP_IN_MANUAL - -template -bool write_polygon_soup(const std::string& fname, PointRange& points, PolygonRange& polygons) -{ - return write_polygon_soup(fname, points, polygons, parameters::all_default()); -} - -/// \endcond - } // namespace IO } // namespace CGAL diff --git a/Stream_support/test/Stream_support/data/binary-issue-6374.stl b/Stream_support/test/Stream_support/data/binary-issue-6374.stl new file mode 100644 index 00000000000..82709ac4a42 Binary files /dev/null and b/Stream_support/test/Stream_support/data/binary-issue-6374.stl differ diff --git a/Stream_support/test/Stream_support/test_STL.cpp b/Stream_support/test/Stream_support/test_STL.cpp index 9fd3dffe5f0..705ea72f7e5 100644 --- a/Stream_support/test/Stream_support/test_STL.cpp +++ b/Stream_support/test/Stream_support/test_STL.cpp @@ -79,8 +79,8 @@ int main(int argc, char** argv) assert(ok); std::cout << points.size() << " points and " << polygons.size() << " polygons" << std::endl; - if(argc == 0) - assert(points.size() == 434 && polygons.size() == 864); + if(argc == 1) + assert(points.size() == 4 && polygons.size() == 4); points.clear(); polygons.clear(); @@ -129,6 +129,16 @@ int main(int argc, char** argv) further_tests(); + // issue 6374 + if(argc == 1) + { + points.clear(); + polygons.clear(); + bool ok = CGAL::IO::read_STL("data/binary-issue-6374.stl", points, polygons, CGAL::parameters::verbose(true)); + assert(ok); + assert(points.size()==8 && polygons.size()==12); + } + std::cout << "Done!" << std::endl; return EXIT_SUCCESS; } diff --git a/Stream_support/test/Stream_support/test_WKT.cpp b/Stream_support/test/Stream_support/test_WKT.cpp index 27ce052bd5e..90d9b8da4b2 100644 --- a/Stream_support/test/Stream_support/test_WKT.cpp +++ b/Stream_support/test/Stream_support/test_WKT.cpp @@ -4,11 +4,9 @@ #include -#include -#include - #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; @@ -30,42 +28,42 @@ bool test_read_WKT() std::ifstream in("data/point.wkt"); if(!CGAL::IO::read_point_WKT(in, p)) return false; - CGAL_assertion(p == Point(2,3)); + assert(p == Point(2,3)); } { std::ifstream in("data/linestring.wkt"); Linestring ls; if(!CGAL::IO::read_linestring_WKT(in, ls)) return false; - CGAL_assertion(ls.size() == 3); + assert(ls.size() == 3); } { Poly poly; std::ifstream in("data/polygon.wkt"); if(!CGAL::IO::read_polygon_WKT(in, poly)) return false; - CGAL_assertion(poly.outer_boundary().size() == 3); + assert(poly.outer_boundary().size() == 3); } { MultiPoint pees; std::ifstream in("data/multipoint.wkt"); if(!CGAL::IO::read_multi_point_WKT(in, pees)) return false; - CGAL_assertion(pees.size() == 4); + assert(pees.size() == 4); } { std::ifstream in("data/multilinestring.wkt"); MultiLinestring mls; if(!CGAL::IO::read_multi_linestring_WKT(in, mls)) return false; - CGAL_assertion(mls.size() == 2); + assert(mls.size() == 2); } { MultiPolygon polies; std::ifstream in("data/multipolygon.wkt"); if(!CGAL::IO::read_multi_polygon_WKT(in, polies)) return false; - CGAL_assertion(polies.size() == 2); + assert(polies.size() == 2); } std::cout << "WKT reading test passed." << std::endl; @@ -184,7 +182,7 @@ bool test_write_WKT() CGAL::IO::read_point_WKT(is, test_p); is.close(); } - CGAL_assertion(p == test_p); + assert(p == test_p); Linestring ls = generate_linestring(); { @@ -199,7 +197,7 @@ bool test_write_WKT() CGAL::IO::read_linestring_WKT(is, test_ls); is.close(); } - CGAL_assertion(ls == test_ls); + assert(ls == test_ls); Poly poly = generate_polygon(); { @@ -215,7 +213,7 @@ bool test_write_WKT() is.close(); } - CGAL_assertion(poly == test_poly); + assert(poly == test_poly); MultiPoint pees = generate_multipoint(); { @@ -230,7 +228,7 @@ bool test_write_WKT() CGAL::IO::read_multi_point_WKT(is, test_pees); is.close(); } - CGAL_assertion(pees== test_pees); + assert(pees== test_pees); MultiLinestring mls = generate_multilinestring(); { @@ -248,7 +246,7 @@ bool test_write_WKT() bool ok = true; for(size_t i=0; i #include -#include - +#include #include #include #include @@ -80,7 +79,7 @@ void PQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { Point* face_point_buffer = edge_point_buffer + num_e; int i=0; - boost::unordered_map v_index; + std::unordered_map v_index; for(vertex_descriptor vh : p_vertices){ v_index[vh]= i++; } @@ -200,7 +199,7 @@ void PTQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { Point* edge_point_buffer = vertex_point_buffer + num_v; int i=0; - boost::unordered_map v_index; + std::unordered_map v_index; for(vertex_descriptor vh : p_vertices){ v_index[vh]= i++; } diff --git a/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_hosts_3.h b/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_hosts_3.h index 3cb74375919..76cf48a912b 100644 --- a/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_hosts_3.h +++ b/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_hosts_3.h @@ -19,7 +19,7 @@ #include -#include +#include #include #include diff --git a/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_methods_3.h b/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_methods_3.h index 80b654de8d8..c84f688703b 100644 --- a/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_methods_3.h +++ b/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_methods_3.h @@ -17,7 +17,7 @@ #include -#include +#include #include #include @@ -123,8 +123,8 @@ void CatmullClark_subdivision(PolygonMesh& pmesh, int step) { * * \pre `pmesh` must be a triangle mesh. **/ -template -void CatmullClark_subdivision(PolygonMesh& pmesh, const NamedParameters& np) { +template +void CatmullClark_subdivision(PolygonMesh& pmesh, const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -138,12 +138,6 @@ void CatmullClark_subdivision(PolygonMesh& pmesh, const NamedParameters& np) { for(unsigned int i = 0; i < step; i++) internal::PQQ_1step(pmesh, vpm, mask); } - -template -void CatmullClark_subdivision(PolygonMesh& pmesh) -{ - CatmullClark_subdivision(pmesh, CGAL::parameters::all_default()); -} // ----------------------------------------------------------------------------- #ifndef DOXYGEN_RUNNING @@ -186,8 +180,8 @@ void Loop_subdivision(PolygonMesh& pmesh, int step) { * \cgalParamNEnd * \cgalNamedParamsEnd **/ -template -void Loop_subdivision(PolygonMesh& pmesh, const NamedParameters& np) { +template +void Loop_subdivision(PolygonMesh& pmesh, const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -201,12 +195,6 @@ void Loop_subdivision(PolygonMesh& pmesh, const NamedParameters& np) { for(unsigned int i = 0; i < step; i++) internal::PTQ_1step(pmesh, vpm, mask); } - -template -void Loop_subdivision(PolygonMesh& pmesh) -{ - Loop_subdivision(pmesh, CGAL::parameters::all_default()); -} // ----------------------------------------------------------------------------- #ifndef DOXYGEN_RUNNING @@ -249,8 +237,8 @@ void DooSabin_subdivision(PolygonMesh& pmesh, int step) { * \cgalParamNEnd * \cgalNamedParamsEnd **/ -template -void DooSabin_subdivision(PolygonMesh& pmesh, const NamedParameters& np) { +template +void DooSabin_subdivision(PolygonMesh& pmesh, const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -264,12 +252,6 @@ void DooSabin_subdivision(PolygonMesh& pmesh, const NamedParameters& np) { for(unsigned int i = 0; i < step; i++) internal::DQQ_1step(pmesh, vpm, mask); } - -template -void DooSabin_subdivision(PolygonMesh& pmesh) -{ - DooSabin_subdivision(pmesh, CGAL::parameters::all_default()); -} // ----------------------------------------------------------------------------- #ifndef DOXYGEN_RUNNING @@ -317,8 +299,8 @@ void Sqrt3_subdivision(PolygonMesh& pmesh, int step) { * * \pre `pmesh` must be a triangle mesh. **/ -template -void Sqrt3_subdivision(PolygonMesh& pmesh, const NamedParameters& np) { +template +void Sqrt3_subdivision(PolygonMesh& pmesh, const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -332,12 +314,6 @@ void Sqrt3_subdivision(PolygonMesh& pmesh, const NamedParameters& np) { for(unsigned int i = 0; i < step; i++) internal::Sqrt3_1step(pmesh, vpm, mask, (i%2==1)); } - -template -void Sqrt3_subdivision(PolygonMesh& pmesh) -{ - Sqrt3_subdivision(pmesh, CGAL::parameters::all_default()); -} /// @} } // namespace Subdivision_method_3 diff --git a/Subdivision_method_3/test/Subdivision_method_3/test_Subdivision_method_3.cpp b/Subdivision_method_3/test/Subdivision_method_3/test_Subdivision_method_3.cpp index 56b1d318765..c7c7757c49f 100644 --- a/Subdivision_method_3/test/Subdivision_method_3/test_Subdivision_method_3.cpp +++ b/Subdivision_method_3/test/Subdivision_method_3/test_Subdivision_method_3.cpp @@ -328,7 +328,7 @@ void test_Subdivision_surface_3_SM_NP() { typedef Kernel::Vector_3 Vector; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef boost::unordered_map Point_pmap; + typedef std::unordered_map Point_pmap; typedef boost::associative_property_map APM; typedef boost::property_map::type VPM; diff --git a/Subdivision_method_3/test/Subdivision_method_3/test_deprecated_Subdivision_method_3.cpp b/Subdivision_method_3/test/Subdivision_method_3/test_deprecated_Subdivision_method_3.cpp index bb453dfb918..14927d08b58 100644 --- a/Subdivision_method_3/test/Subdivision_method_3/test_deprecated_Subdivision_method_3.cpp +++ b/Subdivision_method_3/test/Subdivision_method_3/test_deprecated_Subdivision_method_3.cpp @@ -329,7 +329,7 @@ void test_Subdivision_surface_3_SM_NP() { typedef Kernel::Vector_3 Vector; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef boost::unordered_map Point_pmap; + typedef std::unordered_map Point_pmap; typedef boost::associative_property_map APM; typedef boost::property_map::type VPM; diff --git a/Surface_mesh/doc/Surface_mesh/Doxyfile.in b/Surface_mesh/doc/Surface_mesh/Doxyfile.in index 6ed62a12340..360259de0d4 100644 --- a/Surface_mesh/doc/Surface_mesh/Doxyfile.in +++ b/Surface_mesh/doc/Surface_mesh/Doxyfile.in @@ -1,9 +1,2 @@ @INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS} PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - Surface Mesh" - -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = YES -EXPAND_AS_DEFINED = CGAL_BGL_NP_TEMPLATE_PARAMETERS \ - CGAL_BGL_NP_CLASS \ - CGAL_DEPRECATED - diff --git a/Surface_mesh/examples/Surface_mesh/draw_surface_mesh_small_faces.h b/Surface_mesh/examples/Surface_mesh/draw_surface_mesh_small_faces.h index 0e5043c8f08..b8eeac5b008 100644 --- a/Surface_mesh/examples/Surface_mesh/draw_surface_mesh_small_faces.h +++ b/Surface_mesh/examples/Surface_mesh/draw_surface_mesh_small_faces.h @@ -20,6 +20,8 @@ #include #include +#include + template class SimpleSurfaceMeshWithSmallFacesViewerQt : public CGAL::Basic_viewer_qt { @@ -54,7 +56,7 @@ public: bool exist; typename SM::template Property_map faces_size; boost::tie(faces_size, exist)=sm.template property_map("f:size"); - CGAL_assertion(exist); + assert(exist); m_min_size=faces_size[*(sm.faces().begin())]; m_max_size=m_min_size; @@ -84,7 +86,7 @@ protected: bool exist; typename SM::template Property_map faces_size; boost::tie(faces_size, exist)=sm.template property_map("f:size"); - CGAL_assertion(exist); + assert(exist); // It it is smaller, color the face in red. if (get(faces_size, fh) #include #include +#include #include "draw_surface_mesh_small_faces.h" typedef CGAL::Simple_cartesian K; @@ -28,7 +29,7 @@ int main(int argc, char* argv[]) Mesh::Property_map faces_size; bool created; boost::tie(faces_size, created)=sm.add_property_map("f:size",0.); - CGAL_assertion(created); + assert(created); for(face_descriptor fd : sm.faces()) { faces_size[fd]=CGAL::Polygon_mesh_processing::face_area(fd, sm); } @@ -39,4 +40,3 @@ int main(int argc, char* argv[]) return EXIT_SUCCESS; } - diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/OFF.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/OFF.h index c1988eb2cca..fb4d3111a3e 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/OFF.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/OFF.h @@ -18,19 +18,13 @@ #include #include -#include +#include #include #include #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -40,7 +34,7 @@ namespace IO { namespace internal { template > + typename NamedParameters = parameters::Default_named_parameters > class GetVertexNormalMap { typedef typename PolygonMesh::template Property_map > + typename NamedParameters = parameters::Default_named_parameters > class GetVertexColorMap { typedef typename PolygonMesh::template Property_map > + typename NamedParameters = parameters::Default_named_parameters > class GetVertexTextureMap { typedef typename PolygonMesh::template Property_map > + typename NamedParameters = parameters::Default_named_parameters > class GetFaceColorMap { typedef typename PolygonMesh::template Property_map::type const_type; }; -template +template bool read_OFF_with_or_without_fcolors(std::istream& is, Surface_mesh& sm, const CGAL::File_scanner_OFF& scanner, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) { typedef Surface_mesh Mesh; typedef typename Mesh::Face_index Face_index; typedef CGAL::IO::Color Color; - typedef typename GetFaceColorMap::type FCM; + typedef typename GetFaceColorMap::type FCM; using parameters::choose_parameter; using parameters::is_default_parameter; @@ -116,7 +110,7 @@ bool read_OFF_with_or_without_fcolors(std::istream& is, typename Mesh::template Property_map fcm; - bool is_fcm_requested = !(is_default_parameter(get_parameter(np, internal_np::face_color_map))); + bool is_fcm_requested = !(is_default_parameter()); if(!is_fcm_requested && scanner.has_colors()) { bool created; @@ -136,18 +130,18 @@ bool read_OFF_with_or_without_fcolors(std::istream& is, } } -template +template bool read_OFF_with_or_without_vtextures(std::istream& is, Surface_mesh& sm, const CGAL::File_scanner_OFF& scanner, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) { typedef Surface_mesh Mesh; typedef typename Mesh::Vertex_index Vertex_index; - typedef typename GetK, CGAL_BGL_NP_CLASS>::Kernel K; + typedef typename GetK, CGAL_NP_CLASS>::Kernel K; typedef typename K::Point_2 Texture; - typedef typename GetVertexTextureMap::type VTM; + typedef typename GetVertexTextureMap::type VTM; using parameters::choose_parameter; using parameters::is_default_parameter; @@ -155,7 +149,7 @@ bool read_OFF_with_or_without_vtextures(std::istream& is, typename Mesh::template Property_map vtm; - bool is_vtm_requested = !(is_default_parameter(get_parameter(np, internal_np::vertex_texture_map))); + bool is_vtm_requested = !(is_default_parameter()); if(!is_vtm_requested && scanner.has_textures()) { bool created; @@ -175,17 +169,17 @@ bool read_OFF_with_or_without_vtextures(std::istream& is, } } -template +template bool read_OFF_with_or_without_vcolors(std::istream& is, Surface_mesh& sm, const CGAL::File_scanner_OFF& scanner, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) { typedef Surface_mesh Mesh; typedef typename Mesh::Vertex_index Vertex_index; typedef CGAL::IO::Color Color; - typedef typename GetVertexColorMap::type VCM; + typedef typename GetVertexColorMap::type VCM; using parameters::choose_parameter; using parameters::is_default_parameter; @@ -193,7 +187,7 @@ bool read_OFF_with_or_without_vcolors(std::istream& is, typename Mesh::template Property_map vcm; - bool is_vcm_requested = !(is_default_parameter(get_parameter(np, internal_np::vertex_color_map))); + bool is_vcm_requested = !(is_default_parameter()); if(!is_vcm_requested && scanner.has_colors()) { bool created; @@ -213,18 +207,18 @@ bool read_OFF_with_or_without_vcolors(std::istream& is, } } -template +template bool read_OFF_with_or_without_vnormals(std::istream& is, Surface_mesh& sm, const CGAL::File_scanner_OFF& scanner, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) { typedef Surface_mesh Mesh; typedef typename Mesh::Vertex_index Vertex_index; - typedef typename GetK, CGAL_BGL_NP_CLASS>::Kernel K; + typedef typename GetK, CGAL_NP_CLASS>::Kernel K; typedef typename K::Vector_3 Normal; - typedef typename GetVertexNormalMap::type VNM; + typedef typename GetVertexNormalMap::type VNM; using parameters::choose_parameter; using parameters::is_default_parameter; @@ -232,7 +226,7 @@ bool read_OFF_with_or_without_vnormals(std::istream& is, typename Mesh::template Property_map vnm; - bool is_vnm_requested = !(is_default_parameter(get_parameter(np, internal_np::vertex_normal_map))); + bool is_vnm_requested = !(is_default_parameter()); if(!is_vnm_requested && scanner.has_normals()) { bool created; @@ -325,10 +319,10 @@ bool read_OFF_with_or_without_vnormals(std::istream& is, /// the `failbit` of `is` is set and the mesh cleared. /// template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_OFF(std::istream& is, Surface_mesh& sm, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; @@ -345,31 +339,16 @@ bool read_OFF(std::istream& is, return res; } -template -bool read_OFF(std::istream& is, - Surface_mesh& sm) -{ - return read_OFF(is, sm, parameters::all_default()); -} - template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool read_OFF(const std::string& fname, Surface_mesh& sm, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { std::ifstream in(fname.c_str()); return read_OFF(in, sm, np); } -template -bool read_OFF(const std::string& fname, - Surface_mesh& sm) -{ - return read_OFF(fname, sm, parameters::all_default()); -} - } // namespace IO #ifndef CGAL_NO_DEPRECATED_CODE @@ -378,22 +357,12 @@ bool read_OFF(const std::string& fname, \ingroup PkgSurfaceMeshIOFuncDeprecated \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::read_OFF(std::istream&, const Surface_mesh&)` should be used instead. */ -template -CGAL_DEPRECATED bool read_off(std::istream& is, Surface_mesh& sm, const CGAL_BGL_NP_CLASS& np) +template +CGAL_DEPRECATED bool read_off(std::istream& is, Surface_mesh& sm, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::read_OFF(is, sm, np); } -/*! - \ingroup PkgSurfaceMeshIOFuncDeprecated - \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::read_OFF(std::istream&, const Surface_mesh&)` should be used instead. -*/ -template -CGAL_DEPRECATED bool read_off(std::istream& is, Surface_mesh& sm) -{ - return IO::read_OFF(is, sm, parameters::all_default()); -} - /*! \ingroup PkgSurfaceMeshIOFuncDeprecated \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::read_OFF(std::istream&, const Surface_mesh&)` should be used instead. @@ -401,9 +370,8 @@ CGAL_DEPRECATED bool read_off(std::istream& is, Surface_mesh& sm) template CGAL_DEPRECATED bool read_off(Surface_mesh& sm, const std::string& filename) { - return IO::read_OFF(filename, sm, parameters::all_default()); + return IO::read_OFF(filename, sm, parameters::default_values()); } - #endif // CGAL_NO_DEPRECATED_CODE //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -413,10 +381,10 @@ CGAL_DEPRECATED bool read_off(Surface_mesh& sm, const std::string& filena namespace IO { namespace internal { -template +template bool write_OFF_with_or_without_fcolors(std::ostream& os, const Surface_mesh& sm, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) { typedef Surface_mesh Mesh; typedef typename Mesh::Face_index Face_index; @@ -426,7 +394,7 @@ bool write_OFF_with_or_without_fcolors(std::ostream& os, using parameters::is_default_parameter; using parameters::get_parameter; - const bool has_fcolors = !(is_default_parameter(get_parameter(np, internal_np::face_color_map))); + const bool has_fcolors = !(is_default_parameter()); typename Mesh::template Property_map fcolors; bool has_internal_fcolors; @@ -438,22 +406,22 @@ bool write_OFF_with_or_without_fcolors(std::ostream& os, return write_OFF_BGL(os, sm, np); } -template +template bool write_OFF_with_or_without_vtextures(std::ostream& os, const Surface_mesh& sm, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) { typedef Surface_mesh Mesh; typedef typename Mesh::Vertex_index Vertex_index; - typedef typename GetK, CGAL_BGL_NP_CLASS>::Kernel K; + typedef typename GetK, CGAL_NP_CLASS>::Kernel K; typedef typename K::Point_2 Texture; using parameters::choose_parameter; using parameters::is_default_parameter; using parameters::get_parameter; - const bool has_vtextures = !(is_default_parameter(get_parameter(np, internal_np::vertex_texture_map))); + const bool has_vtextures = !(is_default_parameter()); typename Mesh::template Property_map vtextures; bool has_internal_vtextures; @@ -465,10 +433,10 @@ bool write_OFF_with_or_without_vtextures(std::ostream& os, return write_OFF_with_or_without_fcolors(os, sm, np); } -template +template bool write_OFF_with_or_without_vcolors(std::ostream& os, const Surface_mesh& sm, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) { typedef Surface_mesh Mesh; typedef typename Mesh::Vertex_index Vertex_index; @@ -478,7 +446,7 @@ bool write_OFF_with_or_without_vcolors(std::ostream& os, using parameters::is_default_parameter; using parameters::get_parameter; - const bool has_vcolors = !(is_default_parameter(get_parameter(np, internal_np::vertex_color_map))); + const bool has_vcolors = !(is_default_parameter()); typename Mesh::template Property_map vcolors; bool has_internal_vcolors; @@ -490,22 +458,22 @@ bool write_OFF_with_or_without_vcolors(std::ostream& os, return write_OFF_with_or_without_vtextures(os, sm, np); } -template +template bool write_OFF_with_or_without_vnormals(std::ostream& os, const Surface_mesh& sm, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np) { typedef Surface_mesh Mesh; typedef typename Mesh::Vertex_index Vertex_index; - typedef typename GetK, CGAL_BGL_NP_CLASS>::Kernel K; + typedef typename GetK, CGAL_NP_CLASS>::Kernel K; typedef typename K::Vector_3 Normal; using parameters::choose_parameter; using parameters::is_default_parameter; using parameters::get_parameter; - const bool has_vnormals = !(is_default_parameter(get_parameter(np, internal_np::vertex_normal_map))); + const bool has_vnormals = !(is_default_parameter()); typename Mesh::template Property_map vnormals; bool has_internal_vnormals; @@ -586,16 +554,16 @@ bool write_OFF_with_or_without_vnormals(std::ostream& os, /// /// \returns `true` if writing was successful, `false` otherwise. /// -template +template bool write_OFF(std::ostream& os, const Surface_mesh& sm, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::is_default_parameter; using parameters::get_parameter; - const bool has_vpoints = !(is_default_parameter(get_parameter(np, internal_np::vertex_point))); + const bool has_vpoints = !(is_default_parameter()); if(has_vpoints) return internal::write_OFF_with_or_without_vnormals(os, sm, np); @@ -610,22 +578,12 @@ bool write_OFF(std::ostream& os, \ingroup PkgSurfaceMeshIOFuncDeprecated \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::write_OFF(std::ostream&, const Surface_mesh&)` should be used instead. */ -template -CGAL_DEPRECATED bool write_off(std::ostream& os, const Surface_mesh& sm, const CGAL_BGL_NP_CLASS& np) +template +CGAL_DEPRECATED bool write_off(std::ostream& os, const Surface_mesh& sm, const CGAL_NP_CLASS& np = parameters::default_values()) { return IO::write_OFF(os, sm, np); } -/*! - \ingroup PkgSurfaceMeshIOFuncDeprecated - \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::write_OFF(std::ostream&, const Surface_mesh&)` should be used instead. -*/ -template -CGAL_DEPRECATED bool write_off(std::ostream& os, const Surface_mesh& sm) -{ - return IO::write_OFF(os, sm, parameters::all_default()); -} - /*! \ingroup PkgSurfaceMeshIOFuncDeprecated \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::write_OFF(std::ostream&, const Surface_mesh&)` should be used instead. @@ -633,7 +591,7 @@ CGAL_DEPRECATED bool write_off(std::ostream& os, const Surface_mesh& sm) template CGAL_DEPRECATED bool write_off(const Surface_mesh& sm, const std::string& filename) { - return IO::write_OFF(filename, sm, parameters::all_default()); + return IO::write_OFF(filename, sm, parameters::default_values()); } #endif // CGAL_NO_DEPRECATED_CODE diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h index d0edd60afcc..1e59286bd01 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h @@ -18,17 +18,11 @@ #include #include -#include +#include #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { namespace IO { namespace internal { @@ -913,11 +907,11 @@ namespace IO { /// /// \returns `true` if writing was successful, `false` otherwise. template + typename CGAL_NP_TEMPLATE_PARAMETERS> bool write_PLY(std::ostream& os, const Surface_mesh

      & sm, const std::string& comments, - const CGAL_BGL_NP_CLASS& np) + const CGAL_NP_CLASS& np = parameters::default_values()) { typedef Surface_mesh

      SMesh; typedef typename SMesh::Vertex_index VIndex; @@ -1112,26 +1106,13 @@ bool write_PLY(std::ostream& os, /// \cond SKIP_IN_MANUAL -template -bool write_PLY(std::ostream& os, const Surface_mesh

      & sm, const std::string& comments) -{ - return write_PLY(os, sm, comments, parameters::all_default()); -} - -template -bool write_PLY(std::ostream& os, const Surface_mesh

      & sm, const CGAL_BGL_NP_CLASS& np) +template +bool write_PLY(std::ostream& os, const Surface_mesh

      & sm, const CGAL_NP_CLASS& np = parameters::default_values()) { std::string unused_comment; return write_PLY(os, sm, unused_comment, np); } -template -bool write_PLY(std::ostream& os, const Surface_mesh

      & sm) -{ - std::string unused_comment; - return write_PLY(os, sm, unused_comment, parameters::all_default()); -} - /// \endcond } // namespace IO diff --git a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h index f6dd1d0e1c6..2127f3c8ed3 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -1529,6 +1529,9 @@ public: /// performs a validity check on a single vertex. bool is_valid(Vertex_index v) const { + if(!has_valid_index(v)) + return false; + Halfedge_index h = vconn_[v].halfedge_; if(h!= null_halfedge() && (!has_valid_index(h) || is_removed(h))) { std::cerr << "Vertex connectivity halfedge error in " << (size_type)v @@ -1540,6 +1543,9 @@ public: /// performs a validity check on a single halfedge. bool is_valid(Halfedge_index h) const { + if(!has_valid_index(h)) + return false; + Face_index f = hconn_[h].face_; Vertex_index v = hconn_[h].vertex_; Halfedge_index hn = hconn_[h].next_halfedge_; @@ -1581,6 +1587,9 @@ public: /// performs a validity check on a single edge. bool is_valid(Edge_index e) const { + if(!has_valid_index(e)) + return false; + Halfedge_index h = halfedge(e); return is_valid(h) && is_valid(opposite(h)); } @@ -1588,6 +1597,9 @@ public: /// performs a validity check on a single face. bool is_valid(Face_index f) const { + if(!has_valid_index(f)) + return false; + Halfedge_index h = fconn_[f].halfedge_; if(!has_valid_index(h) || is_removed(h)) { std::cerr << "Face connectivity halfedge error in " << (size_type)f diff --git a/Surface_mesh/include/CGAL/boost/graph/graph_traits_Surface_mesh.h b/Surface_mesh/include/CGAL/boost/graph/graph_traits_Surface_mesh.h index ebf511fe3a4..7c3ba16961a 100644 --- a/Surface_mesh/include/CGAL/boost/graph/graph_traits_Surface_mesh.h +++ b/Surface_mesh/include/CGAL/boost/graph/graph_traits_Surface_mesh.h @@ -17,7 +17,7 @@ #include // include this to avoid a VC15 warning -#include +#include #include #include diff --git a/Surface_mesh/test/Surface_mesh/sm_open_colored_off.cpp b/Surface_mesh/test/Surface_mesh/sm_open_colored_off.cpp index 3cca23fa666..2a925c7c325 100644 --- a/Surface_mesh/test/Surface_mesh/sm_open_colored_off.cpp +++ b/Surface_mesh/test/Surface_mesh/sm_open_colored_off.cpp @@ -3,6 +3,8 @@ #include #include #include +#include + typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef Kernel::Point_3 Point; typedef CGAL::Surface_mesh SMesh; @@ -28,7 +30,7 @@ void OpenOFF(int i) std::ifstream in(path.c_str()); SMesh surface_mesh; in >> surface_mesh; - CGAL_assertion(in && !surface_mesh.is_empty()); + assert(in && !surface_mesh.is_empty()); SMesh::Property_map fcolors = @@ -37,14 +39,14 @@ void OpenOFF(int i) SMesh::Property_map vcolors = surface_mesh.property_map("v:color").first; CGAL::IO::Color c = fcolors[*(surface_mesh.faces().begin())]; - CGAL_assertion(c== CGAL::IO::Color(229,0,0)); + assert(c== CGAL::IO::Color(229,0,0)); c = fcolors[*(--surface_mesh.faces().end())]; - CGAL_assertion(c== CGAL::IO::Color(0,0,229)); + assert(c== CGAL::IO::Color(0,0,229)); c = vcolors[*(surface_mesh.vertices().begin())]; - CGAL_assertion((c== CGAL::IO::Color(229,0,0))); + assert((c== CGAL::IO::Color(229,0,0))); c = vcolors[*(--surface_mesh.vertices().end())]; - CGAL_assertion((c== CGAL::IO::Color(0,0,229))); + assert((c== CGAL::IO::Color(0,0,229))); } diff --git a/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_timing_benchmark.cpp b/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_timing_benchmark.cpp index d7216de3739..5cc0554a11d 100644 --- a/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_timing_benchmark.cpp +++ b/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_timing_benchmark.cpp @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) t0.reset(); t0.start(); - approx.extract_mesh(CGAL::parameters::all_default()); + approx.extract_mesh(CGAL::parameters::default_values()); t0.stop(); std::cout << "meshing time " << t0.time() << " sec." << std::endl; diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_class_interface_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_class_interface_example.cpp index 965a56e30a9..1a3815ca911 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_class_interface_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_class_interface_example.cpp @@ -61,7 +61,7 @@ int main(int argc, char** argv) approx.run(10); // extract approximated mesh with default parameters - approx.extract_mesh(CGAL::parameters::all_default()); + approx.extract_mesh(CGAL::parameters::default_values()); // get approximated triangle soup std::vector anchors; diff --git a/Surface_mesh_approximation/include/CGAL/Surface_mesh_approximation/L21_metric_plane_proxy.h b/Surface_mesh_approximation/include/CGAL/Surface_mesh_approximation/L21_metric_plane_proxy.h index 4a38a9783da..7178bc68f33 100644 --- a/Surface_mesh_approximation/include/CGAL/Surface_mesh_approximation/L21_metric_plane_proxy.h +++ b/Surface_mesh_approximation/include/CGAL/Surface_mesh_approximation/L21_metric_plane_proxy.h @@ -22,7 +22,8 @@ #include #include -#include + +#include namespace CGAL { namespace Surface_mesh_approximation { diff --git a/Surface_mesh_approximation/include/CGAL/Surface_mesh_approximation/L2_metric_plane_proxy.h b/Surface_mesh_approximation/include/CGAL/Surface_mesh_approximation/L2_metric_plane_proxy.h index eee12468f63..1f3e012ce86 100644 --- a/Surface_mesh_approximation/include/CGAL/Surface_mesh_approximation/L2_metric_plane_proxy.h +++ b/Surface_mesh_approximation/include/CGAL/Surface_mesh_approximation/L2_metric_plane_proxy.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include diff --git a/Surface_mesh_approximation/include/CGAL/Surface_mesh_approximation/approximate_triangle_mesh.h b/Surface_mesh_approximation/include/CGAL/Surface_mesh_approximation/approximate_triangle_mesh.h index f7dbb84e459..37d8de708cd 100644 --- a/Surface_mesh_approximation/include/CGAL/Surface_mesh_approximation/approximate_triangle_mesh.h +++ b/Surface_mesh_approximation/include/CGAL/Surface_mesh_approximation/approximate_triangle_mesh.h @@ -18,7 +18,7 @@ #include -#include +#include #include #include @@ -43,18 +43,6 @@ enum Verbose_level { VERBOSE }; -// the named parameter header being not documented the doc is put here for now -#ifdef DOXYGEN_RUNNING -namespace parameters { - -/*! \ingroup bgl_namedparameters - * This function is used when default parameters are just fine for approximation or meshing. - */ -unspecified_type all_default(); - -} // namespace parameters -#endif - /*! * \ingroup PkgTSMARef * @brief approximates the input mesh with plane proxies. @@ -259,21 +247,21 @@ bool approximate_triangle_mesh(const TriangleMesh &tm, const NamedParameters &np // get proxy map approx.proxy_map( get_parameter(np, internal_np::face_proxy_map) ); - if (!parameters::is_default_parameter(get_parameter(np, internal_np::face_proxy_map)) + if (!parameters::is_default_parameter() && (vl == MAIN_STEPS || vl == VERBOSE)) std::cout << "Filling face proxy map done." << std::endl; // get proxies approx.proxies( get_parameter(np, internal_np::proxies) ); - if (!is_default_parameter( get_parameter(np, internal_np::proxies) ) + if (!is_default_parameter() && (vl == MAIN_STEPS || vl == VERBOSE)) std::cout << "Get proxies done." << std::endl; // meshing bool is_manifold = false; - if (!is_default_parameter( get_parameter(np, internal_np::anchors)) - || !is_default_parameter( get_parameter(np, internal_np::triangles) )) + if (!is_default_parameter() + || !is_default_parameter()) { if (vl == VERBOSE) { const FT subdivision_ratio = choose_parameter(get_parameter(np, internal_np::subdivision_ratio), FT(5.0)); @@ -299,14 +287,14 @@ bool approximate_triangle_mesh(const TriangleMesh &tm, const NamedParameters &np // get anchor points approx.anchor_points( get_parameter(np, internal_np::anchors) ); - if (!is_default_parameter( get_parameter(np, internal_np::anchors) ) + if (!is_default_parameter() && (vl == MAIN_STEPS || vl == VERBOSE)) std::cout << "Get anchors done." << std::endl; // get indexed triangles approx.indexed_triangles( get_parameter(np, internal_np::triangles) ); - if (!is_default_parameter( get_parameter(np, internal_np::triangles) ) + if (!is_default_parameter() && (vl == MAIN_STEPS || vl == VERBOSE)) std::cout << "Get indexed triangles done." << std::endl; diff --git a/Surface_mesh_approximation/include/CGAL/Variational_shape_approximation.h b/Surface_mesh_approximation/include/CGAL/Variational_shape_approximation.h index ef642b3e074..eba09b1b8c3 100644 --- a/Surface_mesh_approximation/include/CGAL/Variational_shape_approximation.h +++ b/Surface_mesh_approximation/include/CGAL/Variational_shape_approximation.h @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include @@ -1152,7 +1152,9 @@ private: target_px = max_nb_proxies; else target_px *= 2; - add_proxies_error_diffusion(target_px - m_proxies.size()); + // if no proxies could be added, stop + if( add_proxies_error_diffusion(target_px - m_proxies.size()) == 0) + break; const FT err = run(nb_relaxations); error_drop = err / initial_err; } @@ -1650,7 +1652,7 @@ private: typedef typename SubGraph::vertex_descriptor sg_vertex_descriptor; typedef std::vector VertexVector; - typedef boost::unordered_map VertexMap; + typedef std::unordered_map VertexMap; typedef boost::associative_property_map ToSGVertexMap; VertexMap vmap; ToSGVertexMap to_sgv_map(vmap); diff --git a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_approximation_test.cpp b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_approximation_test.cpp index bf31961af04..5d6461bb23d 100644 --- a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_approximation_test.cpp +++ b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_approximation_test.cpp @@ -35,7 +35,7 @@ int main() faces(mesh), target_edge_length, mesh, - PMP::parameters::number_of_iterations(nb_iter)); + CGAL::parameters::number_of_iterations(nb_iter)); std::cout << "Remeshing done. (" << std::distance(faces(mesh).first, faces(mesh).second) << " faces)..." << std::endl; diff --git a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_class_interface_test.cpp b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_class_interface_test.cpp index 845d4924e00..19714d0b9f0 100644 --- a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_class_interface_test.cpp +++ b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_class_interface_test.cpp @@ -45,7 +45,7 @@ int main() faces(mesh), target_edge_length, mesh, - PMP::parameters::number_of_iterations(nb_iter)); + CGAL::parameters::number_of_iterations(nb_iter)); std::cout << "Remeshing done. (" << std::distance(faces(mesh).first, faces(mesh).second) << " faces)..." << std::endl; diff --git a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_correctness_test.cpp b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_correctness_test.cpp index de23278b6d5..f30944b1ed0 100644 --- a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_correctness_test.cpp +++ b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_correctness_test.cpp @@ -40,7 +40,7 @@ bool load_mesh(const std::string file_name, Mesh &mesh) faces(mesh), target_edge_length, mesh, - PMP::parameters::number_of_iterations(nb_iter)); + CGAL::parameters::number_of_iterations(nb_iter)); std::cout << "Remeshing done. (" << std::distance(faces(mesh).first, faces(mesh).second) << " faces)..." << std::endl; std::cout << "Load mesh " << file_name << " done." << std::endl; diff --git a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_error_decrease_test.cpp b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_error_decrease_test.cpp index c691a750af1..d3687fea16c 100644 --- a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_error_decrease_test.cpp +++ b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_error_decrease_test.cpp @@ -54,7 +54,7 @@ int main() faces(mesh), target_edge_length, mesh, - PMP::parameters::number_of_iterations(nb_iter)); + CGAL::parameters::number_of_iterations(nb_iter)); std::cout << "Remeshing done. (" << std::distance(faces(mesh).first, faces(mesh).second) << " faces)..." << std::endl; diff --git a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_kernel_test.cpp b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_kernel_test.cpp index 3e7901e5dda..d6b34a0f1d3 100644 --- a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_kernel_test.cpp +++ b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_kernel_test.cpp @@ -36,7 +36,7 @@ int load_and_remesh_sm(TM &mesh) { faces(mesh), target_edge_length, mesh, - PMP::parameters::number_of_iterations(nb_iter)); + CGAL::parameters::number_of_iterations(nb_iter)); std::cout << "Remeshing done. (" << std::distance(faces(mesh).first, faces(mesh).second) << " faces)..." << std::endl; @@ -60,7 +60,7 @@ int load_and_remesh_poly(TM &mesh) { faces(mesh), target_edge_length, mesh, - PMP::parameters::number_of_iterations(nb_iter). + CGAL::parameters::number_of_iterations(nb_iter). face_index_map(get(boost::face_external_index, mesh))); std::cout << "Remeshing done. (" << std::distance(faces(mesh).first, faces(mesh).second) << " faces)..." << std::endl; diff --git a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_meshing_manifold_test.cpp b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_meshing_manifold_test.cpp index 125474a20c2..8b70f4ef53c 100644 --- a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_meshing_manifold_test.cpp +++ b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_meshing_manifold_test.cpp @@ -41,7 +41,7 @@ bool test_manifold(const std::string file_name, const FT drop = FT(1e-2)) faces(mesh), target_edge_length, mesh, - PMP::parameters::number_of_iterations(nb_iter)); + CGAL::parameters::number_of_iterations(nb_iter)); std::cout << "Remeshing done. (" << std::distance(faces(mesh).first, faces(mesh).second) << " faces)..." << std::endl; diff --git a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_metric_test.cpp b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_metric_test.cpp index ef36ed896fc..74e63634183 100644 --- a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_metric_test.cpp +++ b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_metric_test.cpp @@ -82,7 +82,7 @@ int main() faces(mesh), target_edge_length, mesh, - PMP::parameters::number_of_iterations(nb_iter)); + CGAL::parameters::number_of_iterations(nb_iter)); std::cout << "Remeshing done. (" << std::distance(faces(mesh).first, faces(mesh).second) << " faces)..." << std::endl; diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp index 4726357f23d..01954e162a8 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp @@ -76,7 +76,7 @@ int main(int argc, char** argv) UV_pmap uv_pm = sm.add_property_map("h:uv").first; // A halfedge on the (possibly virtual) border - halfedge_descriptor bhd = CGAL::Polygon_mesh_processing::longest_border(mesh, CGAL::Polygon_mesh_processing::parameters::all_default()).first; + halfedge_descriptor bhd = CGAL::Polygon_mesh_processing::longest_border(mesh).first; typedef SMP::Two_vertices_parameterizer_3 Border_parameterizer; typedef SMP::LSCM_parameterizer_3 Parameterizer; diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/orbifold.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/orbifold.cpp index 7ae125083dc..b16403a45ab 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/orbifold.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/orbifold.cpp @@ -11,8 +11,7 @@ #include -#include - +#include #include #include #include @@ -89,7 +88,7 @@ int main(int argc, char** argv) std::cout << mesh.number_of_seam_edges() << " seam edges in input" << std::endl; // Index map of the seam mesh (assuming a single connected component so far) - typedef boost::unordered_map Indices; + typedef std::unordered_map Indices; Indices indices; boost::associative_property_map vimap(indices); int counter = 0; @@ -98,7 +97,7 @@ int main(int argc, char** argv) } // Mark the cones in the seam mesh - boost::unordered_map cmap; + std::unordered_map cmap; SMP::locate_cones(mesh, cone_sm_vds.begin(), cone_sm_vds.end(), cmap); // The 2D points of the uv parametrisation will be written into this map @@ -112,8 +111,7 @@ int main(int argc, char** argv) // a halfedge on the (possibly virtual) border // only used in output (will also be used to handle multiple connected components in the future) - halfedge_descriptor bhd = CGAL::Polygon_mesh_processing::longest_border(mesh, - CGAL::Polygon_mesh_processing::parameters::all_default()).first; + halfedge_descriptor bhd = CGAL::Polygon_mesh_processing::longest_border(mesh).first; parameterizer.parameterize(mesh, bhd, cmap, uvmap, vimap); diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/square_border_parameterizer.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/square_border_parameterizer.cpp index 1261a9f5d76..5784d3a1fdb 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/square_border_parameterizer.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/square_border_parameterizer.cpp @@ -11,8 +11,8 @@ #include #include -#include +#include #include #include #include @@ -65,7 +65,7 @@ bool read_vertices(const PolyMesh& mesh, std::size_t counter = 0; std::istringstream point_line(line); std::size_t s; - boost::unordered_set indices; + std::unordered_set indices; while(point_line >> s) { if(s >= vds.size()) { diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/ARAP_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/ARAP_parameterizer_3.h index 33fef26c674..331fc3998af 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/ARAP_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/ARAP_parameterizer_3.h @@ -84,8 +84,8 @@ #include #include #include -#include +#include #include #include #include @@ -223,7 +223,7 @@ private: typedef CGAL::Halfedge_around_target_circulator halfedge_around_target_circulator; typedef CGAL::Halfedge_around_face_circulator halfedge_around_face_circulator; - typedef boost::unordered_set Vertex_set; + typedef std::unordered_set Vertex_set; typedef std::vector Faces_vector; // Traits subtypes: @@ -378,8 +378,8 @@ private: } // temporary vpmap since we do not need it in the future - boost::unordered_set vs; - internal::Bool_property_map > vpmap(vs); + std::unordered_set vs; + internal::Bool_property_map > vpmap(vs); // According to the paper, MVC is better for single border and LSCM is better // when there are multiple borders @@ -420,7 +420,7 @@ private: // A local uvmap (that is then discarded) is passed to avoid changing // the values of the real uvmap. Since we can't get VertexUVMap::C, // we build a map with the same key and value types - typedef boost::unordered_map Useless_map; typedef boost::associative_property_map Useless_pmap; diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Fixed_border_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Fixed_border_parameterizer_3.h index 4222d5f2244..e7bb9e073ff 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Fixed_border_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Fixed_border_parameterizer_3.h @@ -33,7 +33,8 @@ #include #include -#include + +#include /// \file Fixed_border_parameterizer_3.h @@ -212,7 +213,7 @@ public: Error_code status = OK; - typedef boost::unordered_set Vertex_set; + typedef std::unordered_set Vertex_set; Vertex_set vertices; internal::Containers_filler fc(mesh, vertices); @@ -248,7 +249,7 @@ public: // Fill the matrix for the inner vertices v_i: compute A's coefficient // w_ij for each neighbor j; then w_ii = - sum of w_ijs - boost::unordered_set main_border; + std::unordered_set main_border; for(vertex_descriptor v : vertices_around_face(bhd,mesh)){ main_border.insert(v); diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/IO/File_off.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/IO/File_off.h index 84fca87b11f..4916739836c 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/IO/File_off.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/IO/File_off.h @@ -25,9 +25,9 @@ #include #include -#include -#include +#include +#include #include #include #include @@ -96,11 +96,11 @@ void output_uvmap_to_off(const TriangleMesh& mesh, typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef boost::unordered_map Vertex_index_map; + typedef std::unordered_map Vertex_index_map; Vertex_index_map vium; boost::associative_property_map vimap(vium); - boost::unordered_set vertices; + std::unordered_set vertices; std::vector faces; internal::Containers_filler fc(mesh, vertices, &faces); diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/LSCM_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/LSCM_parameterizer_3.h index 109bfd46196..7e6b2aa9cbd 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/LSCM_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/LSCM_parameterizer_3.h @@ -32,8 +32,8 @@ #include #include -#include +#include #include /// \file LSCM_parameterizer_3.h @@ -201,7 +201,7 @@ public: CGAL_precondition(bhd != boost::graph_traits::null_halfedge() && is_border(bhd, mesh)); // Fill containers - boost::unordered_set ccvertices; + std::unordered_set ccvertices; std::vector ccfaces; internal::Containers_filler fc(mesh, ccvertices, &ccfaces); @@ -274,7 +274,7 @@ private: // \pre At least 2 border vertices must be parameterized. template void initialize_system_from_mesh_border(LeastSquaresSolver& solver, - const boost::unordered_set& ccvertices, + const std::unordered_set& ccvertices, UVmap uvmap, VertexIndexMap vimap, VertexParameterizedMap vpmap) const 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 a8053c2a9bd..a57a6031b83 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 @@ -34,8 +34,7 @@ #include -#include - +#include #include #include #include @@ -117,7 +116,7 @@ private: typedef typename boost::graph_traits::face_iterator face_iterator; typedef typename boost::graph_traits::vertex_iterator vertex_iterator; - typedef boost::unordered_set Vertex_set; + typedef std::unordered_set Vertex_set; typedef std::vector Faces_vector; // Traits subtypes: @@ -692,7 +691,9 @@ public: // Not sure how to handle non-simple yet @fixme if(!is_param_border_simple) { +#ifdef CGAL_SMP_ARAP_DEBUG std::cerr << "Border is not simple!" << std::endl; +#endif return ERROR_NON_CONVEX_BORDER; } @@ -702,8 +703,8 @@ public: // Prepare the constrained triangulation: collect exterior faces (faces in // the convex hull but not -- geometrically -- in 'mesh'). - boost::unordered_set vs; - internal::Bool_property_map > vpmap(vs); + std::unordered_set vs; + internal::Bool_property_map > vpmap(vs); prepare_CT_for_parameterization(ct, vpmap); // Run the MVC diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Orbifold_Tutte_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Orbifold_Tutte_parameterizer_3.h index 3f8337d0660..d304bcd52d7 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Orbifold_Tutte_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Orbifold_Tutte_parameterizer_3.h @@ -42,9 +42,9 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -152,7 +152,7 @@ Error_code read_cones(const TriangleMesh& tm, std::ifstream& in, ConeOutputItera typedef typename boost::graph_traits::vertex_descriptor TM_vertex_descriptor; typedef typename boost::graph_traits::vertex_iterator TM_vertex_iterator; - boost::unordered_map m; + std::unordered_map m; int counter = 0; TM_vertex_iterator vit, end; diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Square_border_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Square_border_parameterizer_3.h index e04f4055621..9c58d2a242f 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Square_border_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Square_border_parameterizer_3.h @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -23,6 +24,7 @@ #include + #include #include #include @@ -200,7 +202,7 @@ private: VertexParameterizedMap vpmap, Offset_map& offset) { - assert(offset.empty()); + CGAL_assertion(offset.empty()); put(vpmap, v0, true); put(vpmap, v1, true); @@ -234,7 +236,7 @@ private: if(get(vpmap, vt)) { // If both extremeties of a segment are corners, offsets are already correct if(!get(vpmap, vs)) { - assert(len != 0.0); + CGAL_assertion(len != 0.0); double ld = 1.0 / len; for(std::size_t i=index_of_previous_corner+1; i<=current_index; ++i) { // ld * offset[i] is in [0;1[ @@ -333,7 +335,7 @@ public: for(halfedge_descriptor hd : halfedges_around_face(start_hd, mesh)) { vertex_descriptor vd = source(hd, mesh); Point_2 uv; - assert(counter < offset.size()); + CGAL_assertion(counter < offset.size()); if(corners_encountered == 0) uv = Point_2(offset[counter++], 0.0); diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Two_vertices_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Two_vertices_parameterizer_3.h index 876babb7bc1..0cd827b34cf 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Two_vertices_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Two_vertices_parameterizer_3.h @@ -305,7 +305,7 @@ public: VertexParameterizedMap vpmap) { // Fill containers - boost::unordered_set vertices; + std::unordered_set vertices; internal::Containers_filler fc(mesh, vertices); Polygon_mesh_processing::connected_component( face(opposite(bhd, mesh), mesh), diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/Containers_filler.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/Containers_filler.h index 9e9d5422024..d9da2714623 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/Containers_filler.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/Containers_filler.h @@ -18,9 +18,9 @@ #include #include -#include #include +#include #include namespace CGAL { @@ -32,7 +32,7 @@ namespace internal { // Custom output iterator that fills 'faces' and 'vertices' containers from a mesh template::vertex_descriptor>, + std::unordered_set::vertex_descriptor>, typename Face_vector = std::vector::face_descriptor> > class Containers_filler diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/orbifold_cone_helper.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/orbifold_cone_helper.h index 2d819f3522a..480f8dd77a0 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/orbifold_cone_helper.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/orbifold_cone_helper.h @@ -21,8 +21,8 @@ #include #include -#include +#include #include #include #include @@ -93,7 +93,7 @@ bool are_cones_unique(const Cone_container& cones) } typedef typename Cone_container::value_type Cone; - boost::unordered_set unique_cones; + std::unordered_set unique_cones; unique_cones.insert(cones.begin(), cones.end()); @@ -221,7 +221,7 @@ bool check_cone_validity(const SeamMesh& mesh, CGAL_precondition(is_border(bhd, mesh)); // count how many times vertices on a seam appear - boost::unordered_map seam_vertices_counter; + std::unordered_map seam_vertices_counter; for(halfedge_descriptor hdaf : halfedges_around_face(bhd, mesh)) { CGAL_precondition(mesh.has_on_seam(hdaf)); @@ -229,7 +229,7 @@ bool check_cone_validity(const SeamMesh& mesh, TM_vertex_descriptor tm_vdt = target(hdaf, mesh.mesh()); // insert vds - std::pair::iterator, + std::pair::iterator, bool> is_insert_successful = seam_vertices_counter.insert(std::make_pair(tm_vds, 1)); if(!is_insert_successful.second) @@ -248,8 +248,8 @@ bool check_cone_validity(const SeamMesh& mesh, } // check for self intersections in the seam - typename boost::unordered_map::iterator sit = seam_vertices_counter.begin(), - send = seam_vertices_counter.end(); + typename std::unordered_map::iterator sit = seam_vertices_counter.begin(), + send = seam_vertices_counter.end(); for(; sit!=send; ++sit) { if(sit->second != 2 && sit->second != 4) { std::cerr << sit->second << std::endl; diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/validity.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/validity.h index e401c5273d8..6d5bdcb3ad0 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/validity.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/validity.h @@ -52,7 +52,7 @@ bool has_flips(const TriangleMesh& mesh, typedef typename Kernel::Vector_3 Vector_3; // Fill containers - boost::unordered_set vertices; + std::unordered_set vertices; std::vector faces; internal::Containers_filler fc(mesh, vertices, &faces); @@ -302,7 +302,7 @@ bool is_one_to_one_mapping(const TriangleMesh& mesh, typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - boost::unordered_set vertices; + std::unordered_set vertices; std::vector faces; internal::Containers_filler fc(mesh, vertices, &faces); diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/measure_distortion.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/measure_distortion.h index 12ec990202b..30a8b885b3e 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/measure_distortion.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/measure_distortion.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include #include diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/orbifold_shortest_path.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/orbifold_shortest_path.h index 4b1e4ab2cc0..3f8cdb0b93a 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/orbifold_shortest_path.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/orbifold_shortest_path.h @@ -20,8 +20,8 @@ #include #include -#include +#include #include #include #include @@ -54,7 +54,7 @@ void output_shortest_paths_to_selection_file(const TriangleMesh& mesh, typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::edge_descriptor edge_descriptor; - boost::unordered_map index_map; + std::unordered_map index_map; int counter = 0; for(vertex_descriptor vd : vertices(mesh)) { @@ -133,7 +133,7 @@ void compute_shortest_paths_between_two_cones(const TriangleMesh& mesh, typedef internal::Stop_at_target_Dijkstra_visitor Stop_visitor; - typedef boost::unordered_map Pred_umap; + typedef std::unordered_map Pred_umap; typedef boost::associative_property_map Pred_pmap; Pred_umap predecessor; diff --git a/Surface_mesh_parameterization/test/Surface_mesh_parameterization/extensive_parameterization_test.cpp b/Surface_mesh_parameterization/test/Surface_mesh_parameterization/extensive_parameterization_test.cpp index 51e9d38f718..ff97d007295 100644 --- a/Surface_mesh_parameterization/test/Surface_mesh_parameterization/extensive_parameterization_test.cpp +++ b/Surface_mesh_parameterization/test/Surface_mesh_parameterization/extensive_parameterization_test.cpp @@ -192,7 +192,7 @@ int main(int, char**) UV_pmap uvpm = sm.add_property_map("h:uv").first; // Indices map - typedef boost::unordered_map Indices; + typedef std::unordered_map Indices; Indices indices; PMP::connected_component(face(opposite(hd, sm), sm), sm, boost::make_function_output_iterator( @@ -200,8 +200,8 @@ int main(int, char**) boost::associative_property_map vipm(indices); // Vertex parameterized map - boost::unordered_set vs; - SMP::internal::Bool_property_map > vpm(vs); + std::unordered_set vs; + SMP::internal::Bool_property_map > vpm(vs); // Parameterizer SMP::Barycentric_mapping_parameterizer_3 parameterizer; @@ -246,7 +246,7 @@ int main(int, char**) boost::hash > > uv_pm(uvhm); // Indices map - typedef boost::unordered_map Indices; + typedef std::unordered_map Indices; Indices indices; PMP::connected_component(face(opposite(hd, sm), sm), sm, boost::make_function_output_iterator( @@ -254,8 +254,8 @@ int main(int, char**) boost::associative_property_map vipm(indices); // Parameterized bool pmap - boost::unordered_set vs; - SMP::internal::Bool_property_map< boost::unordered_set > vpm(vs); + std::unordered_set vs; + SMP::internal::Bool_property_map< std::unordered_set > vpm(vs); // Parameterizer SMP::ARAP_parameterizer_3 parameterizer; @@ -307,7 +307,7 @@ int main(int, char**) PM_SE_halfedge_descriptor hd = PMP::longest_border(mesh).first; // Indices - typedef boost::unordered_map Indices; + typedef std::unordered_map Indices; Indices indices; PMP::connected_component(face(opposite(hd, mesh), mesh), mesh, boost::make_function_output_iterator( @@ -315,8 +315,8 @@ int main(int, char**) boost::associative_property_map vipm(indices); // Parameterized - boost::unordered_set vs; - SMP::internal::Bool_property_map > vpm(vs); + std::unordered_set vs; + SMP::internal::Bool_property_map > vpm(vs); SMP::Discrete_conformal_map_parameterizer_3 parameterizer; @@ -372,7 +372,7 @@ int main(int, char**) SM_SE_halfedge_descriptor hd = PMP::longest_border(mesh).first; // Indices - typedef boost::unordered_map Indices; + typedef std::unordered_map Indices; Indices indices; PMP::connected_component(face(opposite(hd, mesh), mesh), mesh, boost::make_function_output_iterator( @@ -380,8 +380,8 @@ int main(int, char**) boost::associative_property_map vipm(indices); // Parameterized - boost::unordered_set vs; - SMP::internal::Bool_property_map > vpm(vs); + std::unordered_set vs; + SMP::internal::Bool_property_map > vpm(vs); SMP::Discrete_authalic_parameterizer_3 parameterizer; @@ -437,7 +437,7 @@ int main(int, char**) } // Index map of the seam mesh (assuming a single connected component so far) - typedef boost::unordered_map Indices; + typedef std::unordered_map Indices; Indices indices; boost::associative_property_map vimap(indices); int counter = 0; @@ -446,7 +446,7 @@ int main(int, char**) } // Mark the cones in the seam mesh - boost::unordered_map cmap; + std::unordered_map cmap; SMP::locate_cones(mesh, cone_sm_vds.begin(), cone_sm_vds.end(), cmap); // The 2D points of the uv parametrisation will be written into this map @@ -460,7 +460,7 @@ int main(int, char**) // a halfedge on the (possibly virtual) border // only used in output (will also be used to handle multiple connected components in the future) - SM_SE_halfedge_descriptor hd = PMP::longest_border(mesh, PMP::parameters::all_default()).first; + SM_SE_halfedge_descriptor hd = PMP::longest_border(mesh).first; SMP::Error_code status = parameterizer.parameterize(mesh, hd, cmap, uvmap, vimap); @@ -498,7 +498,7 @@ int main(int, char**) UV_pmap uvpm = sm.add_property_map("h:uv").first; // Indices map - typedef boost::unordered_map Indices; + typedef std::unordered_map Indices; Indices indices; PMP::connected_component(face(opposite(hd, sm), sm), sm, boost::make_function_output_iterator( @@ -506,8 +506,8 @@ int main(int, char**) boost::associative_property_map vipm(indices); // Vertex parameterized map - boost::unordered_set vs; - SMP::internal::Bool_property_map > vpm(vs); + std::unordered_set vs; + SMP::internal::Bool_property_map > vpm(vs); // Parameterizer SMP::Iterative_authalic_parameterizer_3 parameterizer; diff --git a/Surface_mesh_segmentation/test/Surface_mesh_segmentation/K_means_clustering_test_2.cpp b/Surface_mesh_segmentation/test/Surface_mesh_segmentation/K_means_clustering_test_2.cpp index a369afc311b..8aa901c1402 100644 --- a/Surface_mesh_segmentation/test/Surface_mesh_segmentation/K_means_clustering_test_2.cpp +++ b/Surface_mesh_segmentation/test/Surface_mesh_segmentation/K_means_clustering_test_2.cpp @@ -1,5 +1,7 @@ +#include #include #include + #include typedef CGAL::internal::K_means_clustering K_means; /** @@ -34,7 +36,7 @@ int main(void) std::string init_type_s = init_type_enum == K_means::RANDOM_INITIALIZATION ? "Random " : "Plus plus "; std::cerr << "Init type: " << init_type_s << "center size: " << center_size << std::endl; - CGAL_assertion(false); + assert(false); } } } 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 index 9780b8f8648..b984075eb2e 100644 --- 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 @@ -7,8 +7,6 @@ #include #include -#include - #include #include #include diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_multiple_sources.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_multiple_sources.cpp index c41c38c884c..4b1a99fabbd 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_multiple_sources.cpp +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_multiple_sources.cpp @@ -4,6 +4,9 @@ #include #include +#include + +#include #include #include #include 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 ef841dd6bb3..270f003af03 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 @@ -331,7 +331,7 @@ private: }; private: - const Traits& m_traits; + const Traits m_traits; const Triangle_mesh& m_graph; Vertex_index_map m_vertexIndexMap; diff --git a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_1.cpp b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_1.cpp index f420e43c1a3..22b1869274a 100644 --- a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_1.cpp +++ b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_1.cpp @@ -4,7 +4,6 @@ #include -#include #include #include diff --git a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_2.cpp b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_2.cpp index 06be126c91a..19bda236706 100644 --- a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_2.cpp +++ b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_2.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include "check.h" @@ -269,5 +268,3 @@ int main(int argc, char* argv[]) return 0; } - - diff --git a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_3.cpp b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_3.cpp index d9884ccb384..2f1c8790fd1 100644 --- a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_3.cpp +++ b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_3.cpp @@ -5,6 +5,7 @@ #include #include +#include #include @@ -104,6 +105,3 @@ int main(int argc, char* argv[]) return 0; } - - - diff --git a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_4.cpp b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_4.cpp index 9593de4bc43..2eb7248f38d 100644 --- a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_4.cpp +++ b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_4.cpp @@ -5,6 +5,7 @@ #include #include +#include #include @@ -152,5 +153,3 @@ int main(int argc, char* argv[]) return 0; } - - diff --git a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_5.cpp b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_5.cpp index ee5d2f15c81..54e3c49e4dd 100644 --- a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_5.cpp +++ b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_5.cpp @@ -5,7 +5,6 @@ #include -#include #include #include @@ -17,7 +16,6 @@ #include #include #include -#include #include #include "check.h" @@ -188,6 +186,3 @@ int main(int argc, char* argv[]) } return 0; } - - - diff --git a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_traits_test.cpp b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_traits_test.cpp index acd1502b060..784be8d0abd 100644 --- a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_traits_test.cpp +++ b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_traits_test.cpp @@ -1,4 +1,3 @@ -#include #include #include @@ -6,7 +5,6 @@ #include #include #include -#include #include diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/edge_collapse.h b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/edge_collapse.h index 62f99772792..bb0ed1c8ea6 100644 --- a/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/edge_collapse.h +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/edge_collapse.h @@ -87,6 +87,15 @@ the number of edges effectively removed. in case of non-constant complexity for index access.} \cgalParamExtra{This parameter is only used by debug functions and is usually not needed for users.} \cgalParamNEnd + + \cgalParamNBegin{use_relaxed_order} + \cgalParamDescription{a Boolean tag indicating if the ordering of elements to be collapsed in the priority queue can be relaxed} + \cgalParamType{Either `CGAL::Tag_true` or `CGAL::Tag_false`} + \cgalParamDefault{`CGAL::Tag_false()`} + \cgalParamExtra{Using a relaxed order will allow the algorithm to use a faster priority queue. + However, the ordering of the priority queue is no longer strict and there is a possibility + that some elements that ought to have been collapsed are not actually collapsed.} + \cgalParamNEnd \cgalNamedParamsEnd \cgalHeading{Semantics} @@ -101,10 +110,10 @@ and the remaining vertex is re-positioned. `visitor` is used to keep track of the simplification process. It has several member functions which are called at certain points in the simplification code. */ -template +template int edge_collapse(TriangleMesh& tmesh, const StopPolicy& should_stop, - const NamedParameters& np); + const NamedParameters& np = parameters::default_values()); } // namespace Surface_mesh_simplification } /* namespace CGAL */ diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/edge_collapse.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/edge_collapse.h index 37dcc4f65cf..aa7ff01d31e 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/edge_collapse.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/edge_collapse.h @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include @@ -25,7 +25,8 @@ namespace CGAL { namespace Surface_mesh_simplification { namespace internal { -template Algorithm; + GetCost, GetPlacement, ShouldIgnore, Visitor,use_relaxed_order> Algorithm; Algorithm algorithm(tmesh, traits, should_stop, vim, vpm, him, ecm, get_cost, get_placement, should_ignore, visitor); @@ -81,17 +82,20 @@ struct Dummy_visitor } // namespace internal -template +template int edge_collapse(TM& tmesh, const ShouldStop& should_stop, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; typedef typename GetGeomTraits::type Geom_traits; + typedef typename internal_np::Lookup_named_param_def < + internal_np::use_relaxed_order_t, NamedParameters, Tag_false> ::type Use_relaxed_order; - return internal::edge_collapse(tmesh, should_stop, + return internal::edge_collapse + (tmesh, should_stop, choose_parameter(get_parameter(np, internal_np::geom_traits)), CGAL::get_initialized_vertex_index_map(tmesh, np), choose_parameter(get_parameter(np, internal_np::vertex_point), @@ -105,12 +109,6 @@ int edge_collapse(TM& tmesh, } -template -int edge_collapse(TM& tmesh, const ShouldStop& should_stop) -{ - return edge_collapse(tmesh, should_stop, CGAL::parameters::all_default()); -} - } // namespace Surface_mesh_simplification } // namespace CGAL diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/internal/Edge_collapse.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/internal/Edge_collapse.h index e327e86be6e..59130d662dc 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/internal/Edge_collapse.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/internal/Edge_collapse.h @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -89,7 +90,8 @@ template + class VisitorT_, + bool use_relaxed_heap> class EdgeCollapse { typedef EdgeCollapse Self; @@ -173,28 +175,25 @@ public: const Self* m_algorithm; }; - typedef Modifiable_priority_queue PQ; - typedef typename PQ::handle PQ_handle; + static const Heap_type hp = use_relaxed_heap ? CGAL_BOOST_PENDING_RELAXED_HEAP + : CGAL_BOOST_PENDING_MUTABLE_QUEUE; + typedef Modifiable_priority_queue PQ; // An Edge_data is associated with EVERY _ edge in the mesh (collapsable or not). - // It relates the edge with the PQ-handle needed to update the priority queue + // It contains the edge status wrt the priority queue // It also relates the edge with a policy-based cache - class Edge_data + struct Edge_data { - public : - Edge_data() : m_PQ_h() {} - const Cost_type& cost() const { return m_cost; } Cost_type& cost() { return m_cost; } - PQ_handle queue_handle() const { return m_PQ_h;} - bool is_in_PQ() const { return m_PQ_h != PQ::null_handle(); } - void set_PQ_handle(PQ_handle h) { m_PQ_h = h; } - void reset_queue_handle() { m_PQ_h = PQ::null_handle(); } + bool is_in_PQ() const { return m_is_in_PQ; } + void set_is_in_PQ() { m_is_in_PQ=true; } + void reset_in_queue_status() { m_is_in_PQ = false; } private: Cost_type m_cost; - PQ_handle m_PQ_h; + bool m_is_in_PQ = false; }; typedef Edge_data* Edge_data_ptr; @@ -301,7 +300,8 @@ private: CGAL_expensive_assertion(!data.is_in_PQ()); CGAL_expensive_assertion(!mPQ->contains(h)); - data.set_PQ_handle(mPQ->push(h)); + mPQ->push(h); + data.set_is_in_PQ(); CGAL_expensive_assertion(data.is_in_PQ()); CGAL_expensive_assertion(mPQ->contains(h)); @@ -312,8 +312,9 @@ private: CGAL_assertion(is_primary_edge(h)); CGAL_expensive_assertion(data.is_in_PQ()); CGAL_expensive_assertion(mPQ->contains(h)); + CGAL_USE(data); - data.set_PQ_handle(mPQ->update(h, data.queue_handle())); + mPQ->update(h); CGAL_assertion(data.is_in_PQ()); CGAL_expensive_assertion(mPQ->contains(h)); @@ -325,7 +326,8 @@ private: CGAL_expensive_assertion(data.is_in_PQ()); CGAL_expensive_assertion(mPQ->contains(h)); - data.set_PQ_handle(mPQ->erase(h, data.queue_handle())); + mPQ->erase(h); + data.reset_in_queue_status(); CGAL_expensive_assertion(!data.is_in_PQ()); CGAL_expensive_assertion(!mPQ->contains(h)); @@ -339,7 +341,7 @@ private: CGAL_assertion(is_primary_edge(*opt_h)); CGAL_expensive_assertion(get_data(*opt_h).is_in_PQ()); - get_data(*opt_h).reset_queue_handle(); + get_data(*opt_h).reset_in_queue_status(); CGAL_expensive_assertion(!get_data(*opt_h).is_in_PQ()); CGAL_expensive_assertion(!mPQ->contains(*opt_h)); @@ -401,8 +403,8 @@ private: CGAL_SMS_DEBUG_CODE(unsigned m_step;) }; - template - EdgeCollapse:: +template +EdgeCollapse:: EdgeCollapse(Triangle_mesh& tmesh, const Geom_traits& traits, const Should_stop& should_stop, @@ -443,9 +445,9 @@ EdgeCollapse(Triangle_mesh& tmesh, #endif } -template +template int -EdgeCollapse:: +EdgeCollapse:: run() { CGAL_expensive_precondition(is_valid_polygon_mesh(m_tm) && CGAL::is_triangle_mesh(m_tm)); @@ -470,9 +472,9 @@ run() return r; } -template +template void -EdgeCollapse:: +EdgeCollapse:: collect() { CGAL_SMS_TRACE(0, "collecting edges..."); @@ -579,9 +581,9 @@ collect() CGAL_SMS_TRACE(0, "Initial edge count: " << m_initial_edge_count); } -template +template void -EdgeCollapse:: +EdgeCollapse:: loop() { CGAL_SMS_TRACE(0, "Collapsing edges..."); @@ -668,9 +670,9 @@ loop() } } -template +template bool -EdgeCollapse:: +EdgeCollapse:: is_border_or_constrained(const vertex_descriptor v) const { for(halfedge_descriptor h : halfedges_around_target(v, m_tm)) @@ -682,9 +684,9 @@ is_border_or_constrained(const vertex_descriptor v) const return false; } -template +template bool -EdgeCollapse:: +EdgeCollapse:: is_constrained(const vertex_descriptor v) const { for(halfedge_descriptor h : halfedges_around_target(v, m_tm)) @@ -703,9 +705,9 @@ is_constrained(const vertex_descriptor v) const // The link condition is as follows: for every vertex 'k' adjacent to both 'p and 'q', // "p,k,q" is a facet of the mesh. // - template +template bool - EdgeCollapse:: + EdgeCollapse:: is_collapse_topologically_valid(const Profile& profile) { bool res = true; @@ -871,17 +873,17 @@ is_collapse_topologically_valid(const Profile& profile) return res; } -template +template bool -EdgeCollapse:: +EdgeCollapse:: is_tetrahedron(const halfedge_descriptor h) { return CGAL::is_tetrahedron(h, m_tm); } -template +template bool -EdgeCollapse:: +EdgeCollapse:: is_open_triangle(const halfedge_descriptor h1) { bool res = false; @@ -910,9 +912,9 @@ is_open_triangle(const halfedge_descriptor h1) // respective areas is no greater than a max value and the internal // dihedral angle formed by their supporting planes is no greater than // a given threshold -template +template bool -EdgeCollapse:: +EdgeCollapse:: are_shared_triangles_valid(const Point& p0, const Point& p1, const Point& p2, const Point& p3) const { bool res = false; @@ -962,9 +964,9 @@ are_shared_triangles_valid(const Point& p0, const Point& p1, const Point& p2, co } // Returns the directed halfedge connecting v0 to v1, if exists. -template -typename EdgeCollapse::halfedge_descriptor -EdgeCollapse:: +template +typename EdgeCollapse::halfedge_descriptor +EdgeCollapse:: find_connection(const vertex_descriptor v0, const vertex_descriptor v1) const { @@ -979,9 +981,9 @@ find_connection(const vertex_descriptor v0, // Given the edge 'e' around the link for the collapsinge edge "v0-v1", finds the vertex that makes a triangle adjacent to 'e' but exterior to the link (i.e not containing v0 nor v1) // If 'e' is a null handle OR 'e' is a border edge, there is no such triangle and a null handle is returned. -template -typename EdgeCollapse::vertex_descriptor -EdgeCollapse:: +template +typename EdgeCollapse::vertex_descriptor +EdgeCollapse:: find_exterior_link_triangle_3rd_vertex(const halfedge_descriptor e, const vertex_descriptor v0, const vertex_descriptor v1) const @@ -1015,9 +1017,9 @@ find_exterior_link_triangle_3rd_vertex(const halfedge_descriptor e, // A collapse is geometrically valid if, in the resulting local mesh no two adjacent triangles form an internal dihedral angle // greater than a fixed threshold (i.e. triangles do not "fold" into each other) // -template +template bool -EdgeCollapse:: +EdgeCollapse:: is_collapse_geometrically_valid(const Profile& profile, Placement_type k0) { bool res = false; @@ -1114,9 +1116,9 @@ is_collapse_geometrically_valid(const Profile& profile, Placement_type k0) return res; } -template +template void -EdgeCollapse:: +EdgeCollapse:: collapse(const Profile& profile, Placement_type placement) { @@ -1217,9 +1219,9 @@ collapse(const Profile& profile, CGAL_SMS_DEBUG_CODE(++m_step;) } -template +template void -EdgeCollapse:: +EdgeCollapse:: update_neighbors(const vertex_descriptor v_kept) { CGAL_SMS_TRACE(3,"Updating cost of neighboring edges..."); diff --git a/Surface_mesh_skeletonization/include/CGAL/Mean_curvature_flow_skeletonization.h b/Surface_mesh_skeletonization/include/CGAL/Mean_curvature_flow_skeletonization.h index 3882180786a..9996979ad70 100644 --- a/Surface_mesh_skeletonization/include/CGAL/Mean_curvature_flow_skeletonization.h +++ b/Surface_mesh_skeletonization/include/CGAL/Mean_curvature_flow_skeletonization.h @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -68,6 +67,7 @@ #include #include +#include // for default parameters #if defined(CGAL_EIGEN3_ENABLED) @@ -728,7 +728,7 @@ public: MCFSKEL_DEBUG(print_edges();) MCFSKEL_INFO(double area = CGAL::Polygon_mesh_processing::area(m_tmesh, - CGAL::Polygon_mesh_processing::parameters::vertex_point_map(m_tmesh_point_pmap));) + CGAL::parameters::vertex_point_map(m_tmesh_point_pmap));) MCFSKEL_INFO(std::cout << "area " << area << "\n";) } @@ -752,7 +752,7 @@ public: detect_degeneracies(); double area = CGAL::Polygon_mesh_processing::area(m_tmesh, - CGAL::Polygon_mesh_processing::parameters::vertex_point_map(m_tmesh_point_pmap) + CGAL::parameters::vertex_point_map(m_tmesh_point_pmap) .geom_traits(m_traits)); double area_ratio = fabs(last_area - area) / m_original_area; @@ -857,7 +857,7 @@ private: m_are_poles_computed = false; m_original_area = CGAL::Polygon_mesh_processing::area(m_tmesh, - CGAL::Polygon_mesh_processing::parameters::vertex_point_map(m_tmesh_point_pmap) + CGAL::parameters::vertex_point_map(m_tmesh_point_pmap) .geom_traits(m_traits)); m_vertex_id_count = static_cast(num_vertices(m_tmesh)); @@ -1339,9 +1339,9 @@ private: { namespace PMP = CGAL::Polygon_mesh_processing; - boost::unordered_map normals; + std::unordered_map normals; boost::associative_property_map< - boost::unordered_map > normals_pmap(normals); + std::unordered_map > normals_pmap(normals); PMP::compute_face_normals(m_tmesh, normals_pmap); m_normals.resize(num_vertices(m_tmesh)); @@ -1351,7 +1351,7 @@ private: int vid = static_cast(get(m_vertex_id_pmap, v)); m_normals[vid] = PMP::compute_vertex_normal(v , m_tmesh - , PMP::parameters::geom_traits(m_traits) + , CGAL::parameters::geom_traits(m_traits) .face_normal_map(normals_pmap)); } } diff --git a/Surface_mesh_topology/examples/Surface_mesh_topology/unsew_edgewidth_repeatedly.cpp b/Surface_mesh_topology/examples/Surface_mesh_topology/unsew_edgewidth_repeatedly.cpp index 47c1d952004..5c18a4a0ec2 100644 --- a/Surface_mesh_topology/examples/Surface_mesh_topology/unsew_edgewidth_repeatedly.cpp +++ b/Surface_mesh_topology/examples/Surface_mesh_topology/unsew_edgewidth_repeatedly.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include using LCC_3 =CGAL::Linear_cell_complex_for_generalized_map<2, 3>; using Dart_handle =LCC_3::Dart_handle; @@ -97,7 +97,7 @@ int main(int argc, char* argv[]) CGAL::load_off(lccoriginal, inp); std::cout<<"File '"< origin_to_copy; + std::unordered_map origin_to_copy; lcccopy.copy(lccoriginal, &origin_to_copy, nullptr); LCC_3::size_type is_root=lccoriginal.get_new_mark(); diff --git a/Surface_mesh_topology/include/CGAL/Face_graph_wrapper.h b/Surface_mesh_topology/include/CGAL/Face_graph_wrapper.h index 547af360146..13eb031c1f0 100644 --- a/Surface_mesh_topology/include/CGAL/Face_graph_wrapper.h +++ b/Surface_mesh_topology/include/CGAL/Face_graph_wrapper.h @@ -13,6 +13,7 @@ #define CGAL_FACE_GRAPH_WRAPPER_H 1 #include +#include #include #include @@ -23,6 +24,7 @@ #include #include #include + #include namespace CGAL @@ -614,7 +616,7 @@ public: if (marks[acells[i]]==INVALID_MARK ) { marks[acells[i]]=get_new_mark(); - assert(is_whole_map_unmarked(marks[acells[i]])); + CGAL_assertion(is_whole_map_unmarked(marks[acells[i]])); } } diff --git a/Surface_mesh_topology/include/CGAL/Path_on_surface.h b/Surface_mesh_topology/include/CGAL/Path_on_surface.h index 3df8fa857d8..d0e5f9adb2f 100644 --- a/Surface_mesh_topology/include/CGAL/Path_on_surface.h +++ b/Surface_mesh_topology/include/CGAL/Path_on_surface.h @@ -70,7 +70,7 @@ public: { extend_straight_negative(-(it->length), false); } } update_is_closed(); - CGAL_assertion(is_valid(true)); + CGAL_expensive_assertion(is_valid(true)); } Path_on_surface(const Self& apath) : m_map(apath.m_map), @@ -1099,7 +1099,7 @@ public: /// @return the primitive root and the power of the path in the sense of string. /// use the linear Knuth-Morris-Pratt search std::pair factorize() { - CGAL_assertion(is_valid()); + CGAL_expensive_assertion(is_valid()); if (!is_closed()) { // if a path is not closed, it is already primitive return std::make_pair(Path_on_surface(*this), 1); diff --git a/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Generic_map_selector.h b/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Generic_map_selector.h index fcc5322c084..131570bdc98 100644 --- a/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Generic_map_selector.h +++ b/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Generic_map_selector.h @@ -44,9 +44,9 @@ namespace internal { using Mesh_original = Mesh_; using Generic_map = CGAL::Generalized_map<2, Items_>; using Dart_const_handle_original = typename Mesh_original::Dart_const_handle; - using Copy_to_origin_map = boost::unordered_map; - using Origin_to_copy_map = boost::unordered_map; static void copy(Generic_map& target, const Mesh_original& source, @@ -54,7 +54,7 @@ namespace internal { Copy_to_origin_map& copy_to_origin, typename Generic_map::size_type mark_perforated) { - target.copy_from_const(source, &origin_to_copy, ©_to_origin, true, mark_perforated); + target.copy_from_const(source, &origin_to_copy, ©_to_origin, false, true, mark_perforated); } }; @@ -64,16 +64,16 @@ namespace internal { using Mesh_original = Mesh_; using Generic_map = CGAL::Combinatorial_map<2, Items_>; using Dart_const_handle_original = typename Mesh_original::Dart_const_handle; - using Copy_to_origin_map = boost::unordered_map; - using Origin_to_copy_map = boost::unordered_map; static void copy(Generic_map& target, const Mesh_original& source, Origin_to_copy_map& origin_to_copy, Copy_to_origin_map& copy_to_origin, typename Generic_map::size_type mark_perforated) { - target.copy_from_const(source, &origin_to_copy, ©_to_origin, true, mark_perforated); + target.copy_from_const(source, &origin_to_copy, ©_to_origin, false, true, mark_perforated); } }; @@ -83,9 +83,9 @@ namespace internal { using Mesh_original = Mesh_; using Generic_map = CGAL::Combinatorial_map<2, Items_>; using Dart_const_handle_original = typename boost::graph_traits::halfedge_descriptor; - using Copy_to_origin_map = boost::unordered_map; - using Origin_to_copy_map = boost::unordered_map; static void copy(Generic_map& target, const Mesh_original& source, diff --git a/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Minimal_quadrangulation.h b/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Minimal_quadrangulation.h index 174ff1aec75..2c9b02a49d4 100644 --- a/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Minimal_quadrangulation.h +++ b/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Minimal_quadrangulation.h @@ -670,7 +670,7 @@ protected: } res.update_is_closed(); CGAL_assertion(res.is_empty() || res.is_closed()); - CGAL_assertion(res.is_valid()); + CGAL_expensive_assertion(res.is_valid()); return res; } @@ -702,7 +702,7 @@ protected: if (!res.is_empty()) { res.merge_last_flat_with_next_if_possible(); } CGAL_assertion(res.is_closed() || res.is_empty()); - CGAL_assertion(res.is_valid()); + CGAL_expensive_assertion(res.is_valid()); return res; } diff --git a/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Path_generators.h b/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Path_generators.h index 20cf61acd2a..824612fa702 100644 --- a/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Path_generators.h +++ b/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Path_generators.h @@ -13,6 +13,7 @@ #define CGAL_PATH_GENERATORS_H 1 #include +#include #include #include @@ -174,7 +175,7 @@ generate_random_connected_set_of_faces(const LCC& lcc, std::size_t nb, { return NULL; } } - assert (border_faces.size()!=0); + CGAL_assertion(border_faces.size()!=0); typename LCC::Dart_const_handle dhres=border_faces[0]; while(lcc.template is_free<2>(dhres) || lcc.is_marked(lcc.template beta<2>(dhres), amark)) diff --git a/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Path_on_surface_with_rle.h b/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Path_on_surface_with_rle.h index ea7392f758c..2de7aa1b047 100644 --- a/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Path_on_surface_with_rle.h +++ b/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Path_on_surface_with_rle.h @@ -185,7 +185,7 @@ public: (positive_flat?(static_cast(apath.length()-1)): -(static_cast(apath.length()-1))))); m_length=apath.length(); - CGAL_assertion(is_valid()); + CGAL_expensive_assertion(is_valid()); return; } } @@ -201,7 +201,7 @@ public: } while(i; // Associations between original darts and their copy. - using Origin_to_copy=boost::unordered_map; - using Copy_to_origin=boost::unordered_map; + using Origin_to_copy=std::unordered_map; + using Copy_to_origin=std::unordered_map; /// @return the local map const Local_map& get_local_map() const diff --git a/Surface_mesh_topology/include/CGAL/draw_face_graph_with_paths.h b/Surface_mesh_topology/include/CGAL/draw_face_graph_with_paths.h index 6b8ae90e6fa..4187cd5ccc9 100644 --- a/Surface_mesh_topology/include/CGAL/draw_face_graph_with_paths.h +++ b/Surface_mesh_topology/include/CGAL/draw_face_graph_with_paths.h @@ -18,6 +18,7 @@ #include #include #include +#include #ifdef CGAL_USE_BASIC_VIEWER @@ -52,7 +53,7 @@ struct LCC_geom_utils, Local_kernel, 3> } while(adart!=dh); - assert(nb>0); + CGAL_assertion(nb>0); return typename Get_traits::Kernel::Construct_scaled_vector_3() (normal, 1.0/nb); } diff --git a/Surface_mesh_topology/test/Surface_mesh_topology/fundamental_group_of_the_circle.cpp b/Surface_mesh_topology/test/Surface_mesh_topology/fundamental_group_of_the_circle.cpp index 54d9ff78634..1d725cc1fa6 100644 --- a/Surface_mesh_topology/test/Surface_mesh_topology/fundamental_group_of_the_circle.cpp +++ b/Surface_mesh_topology/test/Surface_mesh_topology/fundamental_group_of_the_circle.cpp @@ -17,6 +17,8 @@ Then it verify that #include #include +#include + // If you want to use a viewer, you can use qglviewer. #ifdef CGAL_USE_BASIC_VIEWER #include @@ -36,12 +38,12 @@ void create_positive_loop_88(Path_on_surface& p, unsigned int n) if (n==0) { p.push_back_by_index(88, true, true); - CGAL_assertion(p.is_closed()); + assert(p.is_closed()); } else { p.extend_straight_positive(10*n-1); - CGAL_assertion(p.is_closed()); + assert(p.is_closed()); } } /////////////////////////////////////////////////////////////////////////////// @@ -52,12 +54,12 @@ void create_negative_loop_88(Path_on_surface& p, unsigned int n) if (n==0) { p.push_back_by_index(88, false, true); - CGAL_assertion(p.is_closed()); + assert(p.is_closed()); } else { p.extend_straight_positive(10*n-1); - CGAL_assertion(p.is_closed()); + assert(p.is_closed()); } } /////////////////////////////////////////////////////////////////////////////// @@ -68,7 +70,7 @@ void create_positive_loop_24(Path_on_surface& p, unsigned int n) if (n==0) { p.push_back_by_index(24, true, true); - CGAL_assertion(p.is_closed()); + assert(p.is_closed()); } else { @@ -80,7 +82,7 @@ void create_positive_loop_24(Path_on_surface& p, unsigned int n) CGAL::draw(p.get_mesh(), v, "Title"); */ #endif // CGAL_USE_BASIC_VIEWER - CGAL_assertion(p.is_closed()); + assert(p.is_closed()); } } /////////////////////////////////////////////////////////////////////////////// @@ -91,12 +93,12 @@ void create_negative_loop_24(Path_on_surface& p, unsigned int n) if (n==0) { p.push_back_by_index(24, false, true); - CGAL_assertion(p.is_closed()); + assert(p.is_closed()); } else { p.extend_straight_negative((10*n)-1); - CGAL_assertion(p.is_closed()); + assert(p.is_closed()); } } /////////////////////////////////////////////////////////////////////////////// diff --git a/Surface_mesh_topology/test/Surface_mesh_topology/path_with_rle_deformation_tests.cpp b/Surface_mesh_topology/test/Surface_mesh_topology/path_with_rle_deformation_tests.cpp index fb6b32faba0..d0b3d4056ea 100644 --- a/Surface_mesh_topology/test/Surface_mesh_topology/path_with_rle_deformation_tests.cpp +++ b/Surface_mesh_topology/test/Surface_mesh_topology/path_with_rle_deformation_tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "Creation_of_test_cases_for_paths.h" @@ -120,7 +121,7 @@ void transform_path(Path_on_surface& path, Transformation t, #endif // CGAL_USE_BASIC_VIEWER path.swap(prevp); - CGAL_assertion(path.is_valid(true)); + assert(path.is_valid(true)); } /////////////////////////////////////////////////////////////////////////////// bool unit_test(Path_on_surface& path, Transformation t, diff --git a/Surface_mesh_topology/test/Surface_mesh_topology/test_homotopy_with_polygonal_schema.cpp b/Surface_mesh_topology/test/Surface_mesh_topology/test_homotopy_with_polygonal_schema.cpp index 64e829a88a6..0383e0a126c 100644 --- a/Surface_mesh_topology/test/Surface_mesh_topology/test_homotopy_with_polygonal_schema.cpp +++ b/Surface_mesh_topology/test/Surface_mesh_topology/test_homotopy_with_polygonal_schema.cpp @@ -4,6 +4,7 @@ #include #include #include +#include typedef CGAL::Surface_mesh_topology::Polygonal_schema_with_combinatorial_map<> PS; typedef typename PS::Dart_handle Dart_handle; @@ -20,7 +21,7 @@ bool test_two_random_paths(const PS& ps, int lmin=5, int lmax=20) { - CGAL_assertion(lmin>0 && lmin0 && lmin p1(ps), p2(ps); internal::generate_random_closed_path diff --git a/Surface_mesher/include/CGAL/IO/facets_in_complex_2_to_triangle_mesh.h b/Surface_mesher/include/CGAL/IO/facets_in_complex_2_to_triangle_mesh.h index db78a6bb947..80a3afaefe5 100644 --- a/Surface_mesher/include/CGAL/IO/facets_in_complex_2_to_triangle_mesh.h +++ b/Surface_mesher/include/CGAL/IO/facets_in_complex_2_to_triangle_mesh.h @@ -19,6 +19,7 @@ #include #include +#include #include namespace CGAL{ diff --git a/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher.h b/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher.h index ee59d6e91f6..e4bfadbdf72 100644 --- a/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher.h +++ b/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher.h @@ -39,6 +39,8 @@ #include #include +#include + namespace CGAL { namespace Surface_mesher { @@ -298,6 +300,7 @@ namespace CGAL { for(bool exit = false; ; exit = true) { + CGAL_USE(exit); // this for loop is a trick to pass in the following "if" once // with center="surface center", and once with // center="circumcenter" diff --git a/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher_edges_level.h b/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher_edges_level.h index 48721460e28..6466a188db9 100644 --- a/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher_edges_level.h +++ b/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher_edges_level.h @@ -591,7 +591,6 @@ namespace Surface_mesher { const Point_3&, const Zone& zone) { - CGAL_assertion_code(bool is_e_removed = false); CGAL_assertion_code(const Cell_handle& c = e.first); CGAL_assertion_code(Vertex_handle va = c->vertex(e.second)); CGAL_assertion_code(Vertex_handle vb = c->vertex(e.third)); @@ -614,7 +613,6 @@ namespace Surface_mesher { CGAL_assertion_code(Vertex_handle eit_va = eit->first->vertex(eit->second)); CGAL_assertion_code(Vertex_handle eit_vb = eit->first->vertex(eit->third)); CGAL_assertion_code(order_pair(eit_va, eit_vb)); - CGAL_assertion_code(if(va == eit_va && vb == eit_vb) is_e_removed = true); // c2t3.remove_from_complex(*eit); this->remove_element(make_pair_of_vertices(*eit)); #ifdef CGAL_SURFACE_MESHER_EDGES_DEBUG_INSERTIONS @@ -626,7 +624,6 @@ namespace Surface_mesher { boost::format(" before insertion: remove %1% edges\n") % number_of_edges_removed; #endif -// CGAL_assertion(is_e_removed == true); } // for visitors diff --git a/Surface_sweep_2/examples/Surface_sweep_2/plane_sweep.cpp b/Surface_sweep_2/examples/Surface_sweep_2/plane_sweep.cpp index d6d2fbbdfa8..28f894cd8bf 100644 --- a/Surface_sweep_2/examples/Surface_sweep_2/plane_sweep.cpp +++ b/Surface_sweep_2/examples/Surface_sweep_2/plane_sweep.cpp @@ -1,7 +1,8 @@ -//! \file examples/Arrangement_on_surface_2/plane_sweep.cpp +//! \file examples/Surface_sweep_2/plane_sweep.cpp // Computing intersection points among curves using the surface-sweep alg. #include +#include #include #include @@ -39,7 +40,7 @@ int main() std::cout << "Found " << sub_segs.size() << " interior-disjoint sub-segments." << std::endl; - CGAL_assertion(CGAL::do_curves_intersect (segments, segments + 4)); + assert(CGAL::do_curves_intersect (segments, segments + 4)); return 0; } diff --git a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Triangulation_data_structure_2.h b/TDS_2/include/CGAL/boost/graph/graph_traits_Triangulation_data_structure_2.h similarity index 96% rename from Triangulation_2/include/CGAL/boost/graph/graph_traits_Triangulation_data_structure_2.h rename to TDS_2/include/CGAL/boost/graph/graph_traits_Triangulation_data_structure_2.h index f52b8b2fb38..738013e2489 100644 --- a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Triangulation_data_structure_2.h +++ b/TDS_2/include/CGAL/boost/graph/graph_traits_Triangulation_data_structure_2.h @@ -12,11 +12,9 @@ #ifndef CGAL_GRAPH_TRAITS_TRIANGULATION_DATA_STRUCTURE_2_H #define CGAL_GRAPH_TRAITS_TRIANGULATION_DATA_STRUCTURE_2_H -#include - // include this to avoid a VC15 warning -#include -#include +#include +#include #include #include @@ -45,15 +43,15 @@ struct graph_traits > typedef CGAL::Triangulation_data_structure_2 Triangulation_data_structure; - typedef typename Triangulation_data_structure::Vertex_handle vertex_descriptor; - typedef CGAL::internal::T2_halfedge_descriptor halfedge_descriptor; - typedef CGAL::internal::T2_edge_descriptor edge_descriptor; - typedef typename Triangulation_data_structure::Face_handle face_descriptor; + typedef typename Triangulation_data_structure::Vertex_handle vertex_descriptor; + typedef CGAL::internal::TDS2_halfedge_descriptor halfedge_descriptor; + typedef CGAL::internal::TDS2_edge_descriptor edge_descriptor; + typedef typename Triangulation_data_structure::Face_handle face_descriptor; typedef CGAL::Prevent_deref vertex_iterator; - typedef CGAL::internal::T2_halfedge_iterator halfedge_iterator; - typedef CGAL::internal::T2_edge_iterator edge_iterator; typedef CGAL::Prevent_deref face_iterator; diff --git a/TDS_2/include/CGAL/boost/graph/internal/graph_traits_2D_TDS_helper.h b/TDS_2/include/CGAL/boost/graph/internal/graph_traits_2D_TDS_helper.h new file mode 100644 index 00000000000..d710a027cf2 --- /dev/null +++ b/TDS_2/include/CGAL/boost/graph/internal/graph_traits_2D_TDS_helper.h @@ -0,0 +1,322 @@ +// 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) : Mael Rouxel-Labbé + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#ifndef CGAL_GRAPH_TRAITS_2D_TDS_HELPERS +#define CGAL_GRAPH_TRAITS_2D_TDS_HELPERS + +namespace CGAL { +namespace internal { + +// A triangulation edge is a face handle + an int, and is thus actually a halfedge... +template +struct TDS2_halfedge_descriptor + : public TDS::Edge +{ + typedef typename TDS::Edge Base; + typedef typename TDS::Face_handle Face_handle; + + TDS2_halfedge_descriptor() {} + TDS2_halfedge_descriptor(Face_handle fh, int i) : Base(fh, i) { } + explicit TDS2_halfedge_descriptor(const Base& e) : Base(e) { } + TDS2_halfedge_descriptor(const TDS2_halfedge_descriptor& h) : Base(h) { } + + const Base& base() const { return static_cast(*this); } + + TDS2_halfedge_descriptor& operator=(const TDS2_halfedge_descriptor& h) + { + this->first = h.first; + this->second = h.second; + return *this; + } + + friend std::size_t hash_value(const TDS2_halfedge_descriptor& e) { + return hash_value(e.first); + } +}; + +// An edge is just a halfedge, but we give it a complete structure to distinguish it from Tr::Edge +template +struct TDS2_edge_descriptor +{ + typedef typename TDS::Face_handle Face_handle; + + TDS2_edge_descriptor() : first(), second(0) { } + explicit TDS2_edge_descriptor(const typename TDS::Edge& e) : first(e.first), second(e.second) { } + TDS2_edge_descriptor(Face_handle fd, int i) : first(fd), second(i) { } + + // so that we can still do stuff like tr.is_finite(edge_descriptor) without any hassle + operator std::pair() const { return std::make_pair(first, second); } + + friend std::size_t hash_value(const TDS2_edge_descriptor& h) + { + if(h.first == Face_handle()) + return 0; + + return hash_value(h.first < h.first->neighbor(h.second) ? h.first + : h.first->neighbor(h.second)); + } + + bool operator==(const TDS2_edge_descriptor& other) const + { + if((first == other.first) && (second == other.second)) + return true; + + Face_handle fh = first->neighbor(second); + if(other.first != fh) + return false; + + int i = fh->index(first); + return (other.second == i); + } + bool operator!=(TDS2_edge_descriptor& other) const { return ! (*this == other); } + + void get_canonical_edge_representation(Face_handle& fh, int& i) const + { + Face_handle neigh_fh = fh->neighbor(i); + Face_handle canonical_fh = (fh < neigh_fh) ? fh : neigh_fh; + + int canonical_i = (fh < neigh_fh) ? i : neigh_fh->index(fh); + + fh = canonical_fh; + i = canonical_i; + } + + bool operator<(const TDS2_edge_descriptor& other) const + { + if(*this == other) + return false; + + Face_handle tfh = first; + int ti = second; + get_canonical_edge_representation(tfh, ti); + + Face_handle ofh = other.first; + int oi = other.second; + get_canonical_edge_representation(ofh, oi); + + if(tfh < ofh) return true; + if(tfh > ofh) return false; + return ti < oi; + } + + Face_handle first; + int second; +}; + +// A halfedge iterator is just an edge iterator that duplicates everything twice, +// to see the edge from either side. +// Could probably be factorized with TDS2_edge_iterator, but it's clearer this way. +template +struct TDS2_halfedge_iterator +{ +private: + typedef TDS2_halfedge_iterator Self; + typedef EdgeIterator Edge_iterator; + typedef TDS2_halfedge_descriptor Descriptor; + typedef typename TDS::Face_handle Face_handle; + +public: + typedef Descriptor value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef std::bidirectional_iterator_tag iterator_category; + + TDS2_halfedge_iterator() { } + TDS2_halfedge_iterator(const Edge_iterator& feit) : it(feit), on_adjacent_face(false) { } + + Self& operator++() + { + // If we are on the first face, move to the opposite face. If we are already on the opposite face, + // then it's time to move on the next edge + if(on_adjacent_face) { + ++it; + on_adjacent_face = false; + } else { + on_adjacent_face = true; + } + + return *this; + } + + Self& operator--() + { + // Note that while decreasing, we start from the opposite face + if(on_adjacent_face) { + on_adjacent_face = false; + } else { + --it; + on_adjacent_face = true; + } + + return *this; + } + + Self operator++(int) { Self tmp = *this; operator++(); return tmp; } + Self operator--(int) { Self tmp = *this; operator--(); return tmp; } + + bool operator==(const Self& other) const { return it == other.it; } + bool operator!=(const Self& other) const { return !(*this == other); } + + reference operator*() const + { + if(on_adjacent_face) + { + Face_handle neigh_f = it->first->neighbor(it->second); + hd = Descriptor(neigh_f, neigh_f->index(it->first)); + return hd; + } else { + hd = Descriptor(it->first, it->second); + return hd; + } + } + +private: + Edge_iterator it; + bool on_adjacent_face; + mutable Descriptor hd; +}; + +template +struct TDS2_edge_iterator +{ +private: + typedef TDS2_edge_iterator Self; + typedef EdgeIterator Edge_iterator; + typedef TDS2_edge_descriptor Descriptor; + +public: + typedef Descriptor value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef std::bidirectional_iterator_tag iterator_category; + + TDS2_edge_iterator() { } + TDS2_edge_iterator(const Edge_iterator& feit) : it(feit) { } + + bool operator==(const Self& other) const { return it == other.it; } + bool operator!=(const Self& other) const { return !(*this == other); } + Self& operator++() { ++it; return *this; } + Self& operator--() { --it; return *this; } + Self operator++(int) { Self tmp = *this; operator++(); return tmp; } + Self operator--(int) { Self tmp = *this; operator--(); return tmp; } + + reference operator*() const + { + ed = Descriptor(*it); + return ed; + } + +private: + Edge_iterator it; + mutable Descriptor ed; +}; + +// Must distinguish TDS and triangulations circulators (later are filtered) +template +class TDS2_Out_edge_circulator + : public Circ +{ +private: + mutable E e; + +public: + typedef E value_type; + typedef E* pointer; + typedef E& reference; + + TDS2_Out_edge_circulator() : Circ() {} + TDS2_Out_edge_circulator(Circ c) : Circ(c) {} + + const E& operator*() const + { + E ed = static_cast(this)->operator*(); + e = E(ed.first->neighbor(ed.second), ed.first->neighbor(ed.second)->index(ed.first)); + return e; + } +}; + +template +class TDS2_In_edge_circulator + : public Circ +{ +private: + mutable E e; + +public: + typedef E value_type; + typedef E* pointer; + typedef E& reference; + + TDS2_In_edge_circulator() : Circ() {} + TDS2_In_edge_circulator(Circ c) : Circ(c) {} + + const E& operator*() const + { + typename Circ::value_type ed = static_cast(this)->operator*(); + e = E(ed); + return e; + } +}; + +} // namespace internal +} // namespace CGAL + +namespace std { + +// workaround a bug detected on at least g++ 4.4 where boost::next(Iterator) +// is picked as a candidate for next(h,g) +template +struct iterator_traits< CGAL::internal::TDS2_halfedge_descriptor > +{ + typedef void* iterator_category; + typedef void* difference_type; + typedef void* value_type; + typedef void* reference; +}; + +#if defined(BOOST_MSVC) +# pragma warning(push) +# pragma warning(disable:4099) // For VC10 it is class hash +#endif + +#ifndef CGAL_CFG_NO_STD_HASH + +template +struct hash > +{ + std::size_t operator()(const CGAL::internal::TDS2_halfedge_descriptor& e) const { + return hash_value(e); + } +}; + +#endif // CGAL_CFG_NO_STD_HASH + +#if defined(BOOST_MSVC) +# pragma warning(pop) +#endif + +} // namespace std + +#endif // CGAL_GRAPH_TRAITS_2D_TDS_HELPERS diff --git a/Triangulation_2/include/CGAL/boost/graph/properties_Triangulation_data_structure_2.h b/TDS_2/include/CGAL/boost/graph/properties_Triangulation_data_structure_2.h similarity index 97% rename from Triangulation_2/include/CGAL/boost/graph/properties_Triangulation_data_structure_2.h rename to TDS_2/include/CGAL/boost/graph/properties_Triangulation_data_structure_2.h index 6c3cb021bd6..0beda7ff5e2 100644 --- a/Triangulation_2/include/CGAL/boost/graph/properties_Triangulation_data_structure_2.h +++ b/TDS_2/include/CGAL/boost/graph/properties_Triangulation_data_structure_2.h @@ -12,10 +12,10 @@ #define CGAL_PROPERTIES_TRIANGULATION_DATA_STRUCTURE_2_H #include -#include +#include #include -#include +#include #include @@ -81,7 +81,7 @@ public: typedef boost::readable_property_map_tag category; typedef int value_type; typedef int reference; - typedef CGAL::internal::T2_halfedge_descriptor key_type; + typedef CGAL::internal::TDS2_halfedge_descriptor key_type; typedef typename TDS::Face_handle face_descriptor; @@ -112,7 +112,7 @@ public: typedef boost::readable_property_map_tag category; typedef int value_type; typedef int reference; - typedef CGAL::internal::T2_edge_descriptor key_type; + typedef CGAL::internal::TDS2_edge_descriptor key_type; typedef typename TDS::Face_handle Face_handle; diff --git a/Testsuite/test/parse-ctest-dashboard-xml.py b/Testsuite/test/parse-ctest-dashboard-xml.py index dc8524075ae..0df042fa1d5 100644 --- a/Testsuite/test/parse-ctest-dashboard-xml.py +++ b/Testsuite/test/parse-ctest-dashboard-xml.py @@ -56,7 +56,7 @@ for t in testing.findall('Test'): if 'encoding' in t_output.attrib and t_output.attrib['encoding'] == 'base64': t_output_value = base64.standard_b64decode(t_output_value) if 'compression' in t_output.attrib and t_output.attrib['compression'] == 'gzip': - t_output_value = zlib.decompress(t_output_value).decode("utf-8") + t_output_value = zlib.decompress(t_output_value).decode("utf-8", 'backslashreplace') tests[tests_ids[t.find('FullName').text]] = \ { \ "Name": t.find('Name').text, \ diff --git a/Tetrahedral_remeshing/doc/Tetrahedral_remeshing/Doxyfile.in b/Tetrahedral_remeshing/doc/Tetrahedral_remeshing/Doxyfile.in index a0a33b4553f..59dccb4ff04 100644 --- a/Tetrahedral_remeshing/doc/Tetrahedral_remeshing/Doxyfile.in +++ b/Tetrahedral_remeshing/doc/Tetrahedral_remeshing/Doxyfile.in @@ -9,8 +9,3 @@ WARN_IF_UNDOCUMENTED = false EXAMPLE_PATH += ${CGAL_Tetrahedral_remeshing_EXAMPLE_DIR} EXCLUDE = ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Tetrahedral_remeshing/internal - -#MACRO_EXPANSION = YES -#EXPAND_ONLY_PREDEF = YES -#EXPAND_AS_DEFINED = CGAL_PMP_NP_TEMPLATE_PARAMETERS \ -# CGAL_PMP_NP_CLASS diff --git a/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/tetrahedral_remeshing_generate_input.h b/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/tetrahedral_remeshing_generate_input.h index 7f020ae5c6a..a2dd90b0efc 100644 --- a/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/tetrahedral_remeshing_generate_input.h +++ b/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/tetrahedral_remeshing_generate_input.h @@ -12,8 +12,10 @@ #include -#include +#include +#include #include +#include namespace CGAL { @@ -42,7 +44,7 @@ namespace Tetrahedral_remeshing else c->set_subdomain_index(2); } - CGAL_assertion(tr.is_valid(true)); + assert(tr.is_valid(true)); } @@ -66,15 +68,17 @@ namespace Tetrahedral_remeshing for (typename Tr::Cell_handle c : tr.finite_cell_handles()) c->set_subdomain_index(1); - CGAL_assertion(tr.is_valid(true)); + assert(tr.is_valid(true)); } template void add_edge(typename Tr::Vertex_handle v1, typename Tr::Vertex_handle v2, const Tr& tr, - boost::unordered_set >& constraints) + std::unordered_set, + boost::hash>>& constraints) { typename Tr::Cell_handle c; int i, j; @@ -85,8 +89,11 @@ namespace Tetrahedral_remeshing template void make_constraints_from_cube_edges( Tr& tr, - boost::unordered_set >& constraints) + std::unordered_set, + boost::hash> + >& constraints) { typedef typename Tr::Point Point; typedef typename Tr::Vertex_handle Vertex_handle; @@ -143,8 +150,10 @@ namespace Tetrahedral_remeshing template void generate_input_cube(const std::size_t& n, Tr& tr, - boost::unordered_set >& constraints) + std::unordered_set, + boost::hash> >& constraints) { typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Point Point; @@ -185,7 +194,7 @@ namespace Tetrahedral_remeshing add_edge(v2, v6, tr, constraints); add_edge(v3, v7, tr, constraints); - CGAL_assertion(tr.is_valid(true)); + assert(tr.is_valid(true)); } } -} \ No newline at end of file +} diff --git a/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/tetrahedral_remeshing_with_features.cpp b/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/tetrahedral_remeshing_with_features.cpp index 26c967e5f63..9b39e266518 100644 --- a/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/tetrahedral_remeshing_with_features.cpp +++ b/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/tetrahedral_remeshing_with_features.cpp @@ -5,10 +5,10 @@ #include -#include - +#include #include #include +#include #include "tetrahedral_remeshing_generate_input.h" @@ -30,13 +30,13 @@ public: typedef boost::read_write_property_map_tag category; private: - boost::unordered_set* m_set_ptr; + std::unordered_set>* m_set_ptr; public: Constrained_edges_property_map() : m_set_ptr(nullptr) {} - Constrained_edges_property_map(boost::unordered_set* set_) + Constrained_edges_property_map(std::unordered_set>* set_) : m_set_ptr(set_) {} @@ -45,8 +45,8 @@ public: const key_type& k, const bool b) { - CGAL_assertion(map.m_set_ptr != nullptr); - CGAL_assertion(k.first < k.second); + assert(map.m_set_ptr != nullptr); + assert(k.first < k.second); if (b) map.m_set_ptr->insert(k); else map.m_set_ptr->erase(k); } @@ -54,8 +54,8 @@ public: friend value_type get(const Constrained_edges_property_map& map, const key_type& k) { - CGAL_assertion(map.m_set_ptr != nullptr); - CGAL_assertion(k.first < k.second); + assert(map.m_set_ptr != nullptr); + assert(k.first < k.second); return (map.m_set_ptr->count(k) > 0); } }; @@ -76,11 +76,11 @@ int main(int argc, char* argv[]) const int nbv = (argc > 3) ? atoi(argv[3]) : 500; Remeshing_triangulation t3; - boost::unordered_set > constraints; + typedef std::pair Vertex_pair; + std::unordered_set> constraints; CGAL::Tetrahedral_remeshing::generate_input_cube(nbv, t3, constraints); make_constraints_from_cube_edges(t3, constraints); - CGAL_assertion(t3.is_valid()); CGAL::tetrahedral_isotropic_remeshing(t3, target_edge_length, CGAL::parameters::edge_is_constrained_map( @@ -89,4 +89,3 @@ int main(int argc, char* argv[]) return EXIT_SUCCESS; } - diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/FMLS.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/FMLS.h index 354e2423674..c83946e592b 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/FMLS.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/FMLS.h @@ -562,7 +562,7 @@ void createMLSSurfaces(Subdomain__FMLS& subdomain_FMLS, subdomain_FMLS.clear(); subdomain_FMLS_indices.clear(); - typedef boost::unordered_map SurfaceIndexMap; + typedef std::unordered_map> SurfaceIndexMap; SurfaceIndexMap current_subdomain_FMLS_indices; SurfaceIndexMap subdomain_sample_numbers; diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h index 4ce1fe25af0..4923e35923d 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h @@ -19,12 +19,13 @@ #include #include #include -#include #include +#include #include #include #include +#include #include #include @@ -157,7 +158,7 @@ public: v0_new_pos = vec(point(vh1->point())); } - boost::unordered_set invalid_cells; + std::unordered_set invalid_cells; typedef typename Tr::Cell_circulator Cell_circulator; Cell_circulator circ = triangulation.incident_cells(edge); @@ -554,12 +555,12 @@ bool collapse_preserves_surface_star(const typename C3t3::Edge& edge, typename Tr::Geom_traits::Construct_normal_3 normal = gt.construct_normal_3_object(); - boost::unordered_set facets; + std::unordered_set> facets; tr.finite_incident_facets(v0, std::inserter(facets, facets.end())); tr.finite_incident_facets(v1, std::inserter(facets, facets.end())); // note : checking a 2nd ring of facets does not change the result -// boost::unordered_set ring2; +// std::unordered_set> ring2; // for (const Facet& f : facets) // { // for (int i = 1; i < 4; ++i) @@ -671,7 +672,7 @@ bool are_edge_lengths_valid(const typename C3t3::Edge& edge, const Vertex_handle v1 = edge.first->vertex(edge.second); const Vertex_handle v2 = edge.first->vertex(edge.third); - boost::unordered_map edges_sqlength_after_collapse; + std::unordered_map edges_sqlength_after_collapse; std::vector inc_edges; c3t3.triangulation().finite_incident_edges(v1, @@ -790,7 +791,7 @@ collapse(const typename C3t3::Cell_handle ch, bool valid = true; std::vector cells_to_remove; - boost::unordered_set invalid_cells; + std::unordered_set invalid_cells; for(const Cell_handle& c : inc_cells) { @@ -988,7 +989,7 @@ bool is_cells_set_manifold(const C3t3&, typedef std::array FV; typedef std::pair EV; - boost::unordered_map facets; + std::unordered_map> facets; for (Cell_handle c : cells) { for (int i = 0; i < 4; ++i) @@ -996,7 +997,7 @@ bool is_cells_set_manifold(const C3t3&, const FV fvi = make_vertex_array(c->vertex((i + 1) % 4), c->vertex((i + 2) % 4), c->vertex((i + 3) % 4)); - typename boost::unordered_map::iterator fit = facets.find(fvi); + typename std::unordered_map>::iterator fit = facets.find(fvi); if (fit == facets.end()) facets.insert(std::make_pair(fvi, 1)); else @@ -1004,7 +1005,7 @@ bool is_cells_set_manifold(const C3t3&, } } - boost::unordered_map edges; + std::unordered_map> edges; for (const auto& fvv : facets) { if (fvv.second != 1) @@ -1013,7 +1014,7 @@ bool is_cells_set_manifold(const C3t3&, for (int i = 0; i < 3; ++i) { const EV evi = make_vertex_pair(fvv.first[i], fvv.first[(i + 1) % 3]); - typename boost::unordered_map::iterator eit = edges.find(evi); + typename std::unordered_map>::iterator eit = edges.find(evi); if (eit == edges.end()) edges.insert(std::make_pair(evi, 1)); else diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/compute_c3t3_statistics.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/compute_c3t3_statistics.h index 36b93215109..1a6ecb15002 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/compute_c3t3_statistics.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/compute_c3t3_statistics.h @@ -19,8 +19,7 @@ #include #include #include - -#include +#include #include @@ -46,8 +45,6 @@ void compute_statistics(const Triangulation& tr, std::size_t nb_edges = 0; double total_edges = 0; - std::size_t nb_angle = 0; - double total_angle = 0; double min_edges_length = (std::numeric_limits::max)(); double max_edges_length = 0.; @@ -89,7 +86,7 @@ void compute_statistics(const Triangulation& tr, = tr.geom_traits().compute_approximate_dihedral_angle_3_object(); std::size_t nb_tets = 0; - boost::unordered_set selected_vertices; + std::unordered_set selected_vertices; std::vector sub_ids; for (Finite_cells_iterator cit = tr.finite_cells_begin(); cit != tr.finite_cells_end(); @@ -156,33 +153,27 @@ void compute_statistics(const Triangulation& tr, double a = CGAL::to_double(CGAL::abs(approx_dihedral_angle(p0, p1, p2, p3))); if (a < min_dihedral_angle) { min_dihedral_angle = a; } if (a > max_dihedral_angle) { max_dihedral_angle = a; } - total_angle += a; - ++nb_angle; + a = CGAL::to_double(CGAL::abs(approx_dihedral_angle(p0, p2, p1, p3))); if (a < min_dihedral_angle) { min_dihedral_angle = a; } if (a > max_dihedral_angle) { max_dihedral_angle = a; } - total_angle += a; - ++nb_angle; + a = CGAL::to_double(CGAL::abs(approx_dihedral_angle(p0, p3, p1, p2))); if (a < min_dihedral_angle) { min_dihedral_angle = a; } if (a > max_dihedral_angle) { max_dihedral_angle = a; } - total_angle += a; - ++nb_angle; + a = CGAL::to_double(CGAL::abs(approx_dihedral_angle(p1, p2, p0, p3))); if (a < min_dihedral_angle) { min_dihedral_angle = a; } if (a > max_dihedral_angle) { max_dihedral_angle = a; } - total_angle += a; - ++nb_angle; + a = CGAL::to_double(CGAL::abs(approx_dihedral_angle(p1, p3, p0, p2))); if (a < min_dihedral_angle) { min_dihedral_angle = a; } if (a > max_dihedral_angle) { max_dihedral_angle = a; } - total_angle += a; - ++nb_angle; + a = CGAL::to_double(CGAL::abs(approx_dihedral_angle(p2, p3, p0, p1))); if (a < min_dihedral_angle) { min_dihedral_angle = a; } if (a > max_dihedral_angle) { max_dihedral_angle = a; } - total_angle += a; - ++nb_angle; + } std::size_t nb_subdomains = sub_ids.size(); diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/flip_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/flip_edges.h index f849baea079..91a629ac875 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/flip_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/flip_edges.h @@ -20,11 +20,12 @@ #include -#include -#include #include #include +#include +#include +#include #include #include @@ -226,8 +227,8 @@ Sliver_removal_result flip_3_to_2(typename C3t3::Edge& edge, //Keep the facets typedef CGAL::Triple Facet_vvv; - typedef boost::unordered_map FaceMapIndex; - boost::unordered_set outer_mirror_facets; + typedef std::unordered_map FaceMapIndex; + std::unordered_set> outer_mirror_facets; FaceMapIndex facet_map_indices; std::vector mirror_facets; @@ -782,7 +783,7 @@ Sliver_removal_result flip_n_to_m(C3t3& c3t3, boost::container::small_vector to_remove; //Neighbors that will need to be updated after flip - boost::unordered_set neighbor_facets; + std::unordered_set> neighbor_facets; //Facets that will be used to create new cells // i.e. all the facets opposite to vh1 and don't have vh @@ -895,7 +896,7 @@ Sliver_removal_result flip_n_to_m(C3t3& c3t3, } typedef CGAL::Triple Facet_vvv; - typedef boost::unordered_map FaceMapIndex; + typedef std::unordered_map FaceMapIndex; FaceMapIndex facet_map_indices; std::vector facets; @@ -1092,12 +1093,12 @@ Sliver_removal_result find_best_flip(typename C3t3::Edge& edge, Facet_circulator done = circ; //Identify the vertices around this edge - boost::unordered_set vertices_around_edge; + std::unordered_set vertices_around_edge; bool boundary_edge = false; bool hull_edge = false; - boost::unordered_set boundary_vertices; -// boost::unordered_set hull_vertices; + std::unordered_set boundary_vertices; +// std::unordered_set hull_vertices; do { //Get the ids of the opposite vertices @@ -1242,7 +1243,7 @@ void flip_edges(C3T3& c3t3, //compute vertices normals map? // typedef typename C3T3::Surface_patch_index Surface_patch_index; - // typedef boost::unordered_map Spi_map; + // typedef std::unordered_map Spi_map; //if (!protect_boundaries) //{ // std::cout << "\tBoundary flips" << std::endl; diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/smooth_vertices.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/smooth_vertices.h index 7c784af9820..0b371947a6e 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/smooth_vertices.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/smooth_vertices.h @@ -20,10 +20,12 @@ #include #include -#include + #include #include +#include +#include #include #include #include @@ -50,7 +52,7 @@ class Tetrahedral_remeshing_smoother private: typedef CGAL::Tetrahedral_remeshing::internal::FMLS FMLS; std::vector subdomain_FMLS; - boost::unordered_map subdomain_FMLS_indices; + std::unordered_map> subdomain_FMLS_indices; bool m_smooth_constrained_edges; public: @@ -60,12 +62,12 @@ public: const bool smooth_constrained_edges) { //collect a map of vertices surface indices - boost::unordered_map > vertices_surface_indices; + std::unordered_map > vertices_surface_indices; collect_vertices_surface_indices(c3t3, vertices_surface_indices); //collect a map of normals at surface vertices - boost::unordered_map > vertices_normals; + std::unordered_map>> vertices_normals; compute_vertices_normals(c3t3, vertices_normals, cell_selector); // Build MLS Surfaces @@ -152,7 +154,7 @@ private: const Tr& tr = c3t3.triangulation(); //collect all facet normals - boost::unordered_map fnormals; + std::unordered_map> fnormals; for (const Facet& f : tr.finite_facets()) { if (is_boundary(c3t3, f, cell_selector)) @@ -246,8 +248,8 @@ private: #ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG osf.close(); std::ofstream os("dump_normals.polylines.txt"); - boost::unordered_map > ons_map; + std::unordered_map, boost::hash > ons_map; #endif //normalize the computed normals @@ -376,7 +378,7 @@ private: void collect_vertices_surface_indices( const C3t3& c3t3, - boost::unordered_map >& vertices_surface_indices) { for (typename C3t3::Facets_in_complex_iterator @@ -423,18 +425,18 @@ public: Tr& tr = c3t3.triangulation(); //collect a map of vertices surface indices - boost::unordered_map > vertices_surface_indices; + std::unordered_map > vertices_surface_indices; if(m_smooth_constrained_edges) collect_vertices_surface_indices(c3t3, vertices_surface_indices); //collect a map of normals at surface vertices - boost::unordered_map > vertices_normals; + std::unordered_map>> vertices_normals; compute_vertices_normals(c3t3, vertices_normals, cell_selector); //smooth() const std::size_t nbv = tr.number_of_vertices(); - boost::unordered_map vertex_id; + std::unordered_map vertex_id; std::vector smoothed_positions(nbv, CGAL::NULL_VECTOR); std::vector neighbors(nbv, -1); std::vector free_vertex(nbv, false);//are vertices free to move? indices are in `vertex_id` diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h index d0d3c12f442..76851bc76e9 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h @@ -18,11 +18,12 @@ #include #include #include -#include #include +#include #include +#include #include #include @@ -68,8 +69,8 @@ typename C3t3::Vertex_handle split_edge(const typename C3t3::Edge& e, } CGAL_assertion(dimension > 0); - boost::unordered_map cells_info; - boost::unordered_map > facets_info; + std::unordered_map> cells_info; + std::unordered_map, boost::hash> facets_info; // check orientation and collect incident cells to avoid circulating twice boost::container::small_vector inc_cells; diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h index 2b348e4574b..1be3eae9b0b 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -616,7 +617,7 @@ std::size_t nb_incident_subdomains(const typename C3t3::Vertex_handle v, { typedef typename C3t3::Subdomain_index Subdomain_index; - boost::unordered_set indices; + std::unordered_set indices; incident_subdomains(v, c3t3, std::inserter(indices, indices.begin())); return indices.size(); @@ -628,7 +629,7 @@ std::size_t nb_incident_subdomains(const typename C3t3::Edge& e, { typedef typename C3t3::Subdomain_index Subdomain_index; - boost::unordered_set indices; + std::unordered_set indices; incident_subdomains(e, c3t3, std::inserter(indices, indices.begin())); return indices.size(); @@ -640,7 +641,7 @@ std::size_t nb_incident_surface_patches(const typename C3t3::Edge& e, { typedef typename C3t3::Surface_patch_index Surface_patch_index; - boost::unordered_set indices; + std::unordered_set> indices; incident_surface_patches(e, c3t3, std::inserter(indices, indices.begin())); return indices.size(); @@ -651,7 +652,7 @@ std::size_t nb_incident_complex_edges(const typename C3t3::Vertex_handle v, const C3t3& c3t3) { typedef typename C3t3::Edge Edge; - boost::unordered_set edges; + std::unordered_set edges; c3t3.triangulation().finite_incident_edges(v, std::inserter(edges, edges.begin())); std::size_t count = 0; @@ -1309,7 +1310,7 @@ void dump_cells_off(const CellRange& cells, const Tr& /*tr*/, const char* filena Bimap_t vertices; int index = 0; - boost::unordered_set > facets; + std::unordered_set, boost::hash> > facets; for (Cell_handle c : cells) { diff --git a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h index b1818bbded1..581e459ab90 100644 --- a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h +++ b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #ifdef CGAL_DUMP_REMESHING_STEPS @@ -159,11 +159,11 @@ namespace CGAL * @todo implement non-uniform sizing field instead of uniform target edge length */ template + typename NamedParameters = parameters::Default_named_parameters> void tetrahedral_isotropic_remeshing( CGAL::Triangulation_3& tr, const double& target_edge_length, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef CGAL::Triangulation_3 Triangulation; tetrahedral_isotropic_remeshing( @@ -174,11 +174,11 @@ void tetrahedral_isotropic_remeshing( } template + typename NamedParameters = parameters::Default_named_parameters> void tetrahedral_isotropic_remeshing( CGAL::Triangulation_3& tr, const float& target_edge_length, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { typedef CGAL::Triangulation_3 Triangulation; tetrahedral_isotropic_remeshing( @@ -289,15 +289,6 @@ void tetrahedral_isotropic_remeshing( #endif } -template -void tetrahedral_isotropic_remeshing( - CGAL::Triangulation_3& tr, - const double& target_edge_length) -{ - tetrahedral_isotropic_remeshing(tr, target_edge_length, - CGAL::parameters::all_default()); -} - /*! * \ingroup PkgTetrahedralRemeshingRef * converts the triangulation contained in the input to a `Triangulation_3`. @@ -348,11 +339,11 @@ convert_to_triangulation_3( /////// template + typename NamedParameters = parameters::Default_named_parameters> void tetrahedral_isotropic_remeshing( CGAL::Mesh_complex_3_in_triangulation_3& c3t3, const double& target_edge_length, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { tetrahedral_isotropic_remeshing( c3t3, @@ -363,11 +354,11 @@ void tetrahedral_isotropic_remeshing( template + typename NamedParameters = parameters::Default_named_parameters> void tetrahedral_isotropic_remeshing( CGAL::Mesh_complex_3_in_triangulation_3& c3t3, const float& target_edge_length, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values) { tetrahedral_isotropic_remeshing( c3t3, @@ -376,24 +367,14 @@ void tetrahedral_isotropic_remeshing( np); } -template -void tetrahedral_isotropic_remeshing( - CGAL::Mesh_complex_3_in_triangulation_3& c3t3, - const double& target_edge_length) -{ - return tetrahedral_isotropic_remeshing(c3t3, target_edge_length, - CGAL::parameters::all_default()); -} - template + typename NamedParameters = parameters::Default_named_parameters> void tetrahedral_isotropic_remeshing( CGAL::Mesh_complex_3_in_triangulation_3& c3t3, const SizingFunction& sizing, - const NamedParameters& np) + const NamedParameters& np = parameters::default_values()) { CGAL_assertion(c3t3.triangulation().tds().is_valid(true)); diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing.cpp index 276227e2f9b..fffb560ac88 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing.cpp +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing.cpp @@ -13,6 +13,7 @@ #include #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -38,7 +39,7 @@ void generate_input_one_subdomain(const std::size_t nbv, T3& tr) for (typename T3::Cell_handle c : tr.finite_cell_handles()) c->set_subdomain_index(1); - CGAL_assertion(tr.is_valid(true)); + assert(tr.is_valid(true)); #ifdef CGAL_TETRAHEDRAL_REMESHING_GENERATE_INPUT_FILES std::ofstream out("data/triangulation_one_subdomain.binary.cgal", diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_io.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_io.cpp index c2cbe1406cc..fa3220b0635 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_io.cpp +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_io.cpp @@ -10,6 +10,7 @@ #include #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_of_one_subdomain.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_of_one_subdomain.cpp index 05f9add785e..0d90df4938b 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_of_one_subdomain.cpp +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_of_one_subdomain.cpp @@ -10,6 +10,7 @@ #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -37,7 +38,7 @@ void generate_input_two_subdomains(const std::size_t nbv, Remeshing_triangulatio else c->set_subdomain_index(2); } - CGAL_assertion(tr.is_valid(true)); + assert(tr.is_valid(true)); #ifdef CGAL_TETRAHEDRAL_REMESHING_GENERATE_INPUT_FILES std::ofstream os("data/triangulation_two_subdomains.binary.cgal", @@ -78,4 +79,3 @@ int main(int argc, char* argv[]) return EXIT_SUCCESS; } - diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_with_features.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_with_features.cpp index b80d66ce6b6..aee012397cb 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_with_features.cpp +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_with_features.cpp @@ -10,12 +10,14 @@ #include #include -#include +#include +#include #include #include #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -35,13 +37,13 @@ public: typedef boost::read_write_property_map_tag category; private: - boost::unordered_set* m_set_ptr; + std::unordered_set>* m_set_ptr; public: Constrained_edges_property_map() : m_set_ptr(nullptr) {} - Constrained_edges_property_map(boost::unordered_set* set_) + Constrained_edges_property_map(std::unordered_set>* set_) : m_set_ptr(set_) {} @@ -50,8 +52,8 @@ public: const key_type& k, const value_type b) { - CGAL_assertion(map.m_set_ptr != nullptr); - CGAL_assertion(k.first < k.second); + assert(map.m_set_ptr != nullptr); + assert(k.first < k.second); if (b) map.m_set_ptr->insert(k); else map.m_set_ptr->erase(k); } @@ -59,8 +61,8 @@ public: friend value_type get(const Constrained_edges_property_map& map, const key_type& k) { - CGAL_assertion(map.m_set_ptr != nullptr); - CGAL_assertion(k.first < k.second); + assert(map.m_set_ptr != nullptr); + assert(k.first < k.second); return map.m_set_ptr->count(k) > 0; } }; @@ -68,7 +70,8 @@ public: void add_edge(Vertex_handle v1, Vertex_handle v2, const Remeshing_triangulation& tr, - boost::unordered_set >& constraints) + std::unordered_set, + boost::hash>>& constraints) { Cell_handle c; int i, j; @@ -78,7 +81,8 @@ void add_edge(Vertex_handle v1, void generate_input_cube(const std::size_t& n, Remeshing_triangulation& tr, - boost::unordered_set >& constraints) + std::unordered_set, + boost::hash> >& constraints) { CGAL::Random rng; @@ -101,7 +105,7 @@ void generate_input_cube(const std::size_t& n, Vertex_handle v6 = tr.insert(Point( 2., 2., -2.)); Vertex_handle v7 = tr.insert(Point( 2., 2., 2.)); - CGAL_assertion(tr.is_valid(true)); + assert(tr.is_valid(true)); // writing file output #ifdef CGAL_TETRAHEDRAL_REMESHING_GENERATE_INPUT_FILES @@ -127,7 +131,7 @@ void generate_input_cube(const std::size_t& n, add_edge(v2, v6, tr, constraints); add_edge(v3, v7, tr, constraints); - CGAL_assertion(tr.is_valid(true)); + assert(tr.is_valid(true)); } void set_subdomain(Remeshing_triangulation& tr, const int index) @@ -142,7 +146,8 @@ int main(int argc, char* argv[]) std::cout << "CGAL Random seed = " << CGAL::get_default_random().get_seed() << std::endl; Remeshing_triangulation tr; - boost::unordered_set > constraints; + std::unordered_set, + boost::hash>> constraints; generate_input_cube(1000, tr, constraints); const double target_edge_length = (argc > 1) ? atof(argv[1]) : 0.02; @@ -158,4 +163,3 @@ int main(int argc, char* argv[]) return EXIT_SUCCESS; } - diff --git a/Triangulation/examples/Triangulation/barycentric_subdivision.cpp b/Triangulation/examples/Triangulation/barycentric_subdivision.cpp index 5e5e0a308b7..f76a2d8e1a4 100644 --- a/Triangulation/examples/Triangulation/barycentric_subdivision.cpp +++ b/Triangulation/examples/Triangulation/barycentric_subdivision.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include @@ -96,7 +96,7 @@ void find_face_from_vertices( const TDS & tds, } } std::cerr << "Could not build a face from vertices"< #include #include -#include +#include #include #include @@ -28,7 +28,7 @@ int main(int argc, char **argv) std::copy_n(rand_it, N, std::back_inserter(points)); T t(D); - CGAL_assertion(t.empty()); + assert(t.empty()); // insert the points in the triangulation, only if they are outside the // convex hull diff --git a/Triangulation/examples/Triangulation/regular_triangulation.cpp b/Triangulation/examples/Triangulation/regular_triangulation.cpp index 4dc0bf5e6c1..fb2b30ccf8c 100644 --- a/Triangulation/examples/Triangulation/regular_triangulation.cpp +++ b/Triangulation/examples/Triangulation/regular_triangulation.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include @@ -27,11 +27,11 @@ int main() points.push_back(Weighted_point(*rand_it++, rng.get_double(0., 10.))); T t(D); - CGAL_assertion(t.empty()); + assert(t.empty()); // Insert the points in the triangulation t.insert(points.begin(), points.end()); - CGAL_assertion( t.is_valid() ); + assert( t.is_valid() ); std::cout << "Regular triangulation successfully computed: " << t.number_of_vertices() << " vertices, " << t.number_of_finite_full_cells() << " finite cells." diff --git a/Triangulation/examples/Triangulation/triangulation.cpp b/Triangulation/examples/Triangulation/triangulation.cpp index 966b771cbdb..0044bc1da77 100644 --- a/Triangulation/examples/Triangulation/triangulation.cpp +++ b/Triangulation/examples/Triangulation/triangulation.cpp @@ -4,11 +4,11 @@ #include #include #include -#include #include #include #include +#include typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > K; typedef CGAL::Triangulation Triangulation; @@ -23,9 +23,9 @@ int main() std::copy_n(rand_it, N, std::back_inserter(points)); Triangulation t(D); // create triangulation - CGAL_assertion(t.empty()); + assert(t.empty()); t.insert(points.begin(), points.end()); // compute triangulation - CGAL_assertion( t.is_valid() ); + assert( t.is_valid() ); // - - - - - - - - - - - - - - - - - - - - - - - - STEP 2 typedef Triangulation::Face Face; typedef std::vector Faces; @@ -41,4 +41,3 @@ int main() return 0; } - diff --git a/Triangulation/examples/Triangulation/triangulation_data_structure_dynamic.cpp b/Triangulation/examples/Triangulation/triangulation_data_structure_dynamic.cpp index f8fc86dff17..3d06d01ccda 100644 --- a/Triangulation/examples/Triangulation/triangulation_data_structure_dynamic.cpp +++ b/Triangulation/examples/Triangulation/triangulation_data_structure_dynamic.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include @@ -11,17 +11,17 @@ int main() typedef TDS::Vertex_handle Vertex_handle; TDS D(ddim); // the argument is taken into account. - CGAL_assertion( ddim == D.maximal_dimension() ); - CGAL_assertion( -2 == D.current_dimension() ); - CGAL_assertion( D.is_valid() ); + assert( ddim == D.maximal_dimension() ); + assert( -2 == D.current_dimension() ); + assert( D.is_valid() ); std::vector V(5); V[0] = D.insert_increase_dimension(); V[1] = D.insert_increase_dimension(V[0]); V[2] = D.insert_increase_dimension(V[0]); V[3] = D.insert_increase_dimension(V[0]); V[4] = D.insert_in_full_cell(V[3]->full_cell()); - CGAL_assertion( 6 == D.number_of_full_cells() ); - CGAL_assertion( 2 == D.current_dimension() ); - CGAL_assertion( D.is_valid() ); + assert( 6 == D.number_of_full_cells() ); + assert( 2 == D.current_dimension() ); + assert( D.is_valid() ); return 0; } diff --git a/Triangulation/examples/Triangulation/triangulation_data_structure_static.cpp b/Triangulation/examples/Triangulation/triangulation_data_structure_static.cpp index c56ae7390ca..19c22790805 100644 --- a/Triangulation/examples/Triangulation/triangulation_data_structure_static.cpp +++ b/Triangulation/examples/Triangulation/triangulation_data_structure_static.cpp @@ -1,42 +1,42 @@ #include -#include #include +#include int main() { typedef CGAL::Triangulation_data_structure > TDS; TDS S; - CGAL_assertion( 7 == S.maximal_dimension() ); - CGAL_assertion( -2 == S.current_dimension() ); - CGAL_assertion( S.is_valid() ); + assert( 7 == S.maximal_dimension() ); + assert( -2 == S.current_dimension() ); + assert( S.is_valid() ); std::vector V(10); V[0] = S.insert_increase_dimension(); //insert first vertex - CGAL_assertion( -1 == S.current_dimension() ); + assert( -1 == S.current_dimension() ); for( int i = 1; i <= 5; ++i ) V[i] = S.insert_increase_dimension(V[0]); // the first 6 vertices have created a triangulation // of the 4-dimensional topological sphere // (the boundary of a five dimensional simplex). - CGAL_assertion( 4 == S.current_dimension() ); - CGAL_assertion( 6 == S.number_of_vertices() ); - CGAL_assertion( 6 == S.number_of_full_cells() ); + assert( 4 == S.current_dimension() ); + assert( 6 == S.number_of_vertices() ); + assert( 6 == S.number_of_full_cells() ); TDS::Full_cell_handle c = V[5]->full_cell(); V[6] = S.insert_in_full_cell(c); // full cell c is split in 5 - CGAL_assertion( 7 == S.number_of_vertices() ); - CGAL_assertion( 10 == S.number_of_full_cells() ); + assert( 7 == S.number_of_vertices() ); + assert( 10 == S.number_of_full_cells() ); c = V[3]->full_cell(); TDS::Facet ft(c, 2); // the Facet opposite to vertex 2 in c V[7] = S.insert_in_facet(ft); // facet ft is split in 4 and the two incident cells are split accordingly - CGAL_assertion( 8 == S.number_of_vertices() ); - CGAL_assertion( 16 == S.number_of_full_cells() ); + assert( 8 == S.number_of_vertices() ); + assert( 16 == S.number_of_full_cells() ); c = V[3]->full_cell(); TDS::Face face(c); @@ -45,7 +45,7 @@ int main() face.set_index(1, 4); // and vertex 4 V[8] = S.insert_in_face(face); // face is split in 2, and all incident full cells also - CGAL_assertion( S.is_valid() ); + assert( S.is_valid() ); TDS::Full_cell_handle hole[2]; hole[0] = V[8]->full_cell(); @@ -54,6 +54,6 @@ int main() ft = TDS::Facet(hole[0], 1); // a face on the boundary of hole[0] V[9] = S.insert_in_hole(hole, hole+2, ft); // the hole is triangulated by linking a new vertex to its boundary - CGAL_assertion( S.is_valid() ); + assert( S.is_valid() ); return 0; } diff --git a/Triangulation/test/Triangulation/test_delaunay.cpp b/Triangulation/test/Triangulation/test_delaunay.cpp index 0af45e570e6..bd31a2c7582 100644 --- a/Triangulation/test/Triangulation/test_delaunay.cpp +++ b/Triangulation/test/Triangulation/test_delaunay.cpp @@ -10,6 +10,7 @@ #include #include #include +#include using namespace std; @@ -58,7 +59,7 @@ void test(const int d, const string & type, const int N) cerr << nbis << " = " << (nbis+nbfs) << " = " << dt.number_of_full_cells(); cerr << "\nThe triangulation has current dimension " << dt.current_dimension(); - CGAL_assertion( dt.number_of_full_cells() == nbis+nbfs); + assert( dt.number_of_full_cells() == nbis+nbfs); cerr << "\nTraversing finite vertices... "; size_t nbfv(0); diff --git a/Triangulation/test/Triangulation/test_regular.cpp b/Triangulation/test/Triangulation/test_regular.cpp index a4d2030e249..1ad6e7a151a 100644 --- a/Triangulation/test/Triangulation/test_regular.cpp +++ b/Triangulation/test/Triangulation/test_regular.cpp @@ -10,6 +10,7 @@ #include #include #include +#include using namespace std; @@ -54,7 +55,7 @@ void test(const int d, const string & type, const int N) cerr << nbis << " = " << (nbis+nbfs) << " = " << rt.number_of_full_cells(); cerr << "\nThe triangulation has current dimension " << rt.current_dimension(); - CGAL_assertion( rt.number_of_full_cells() == nbis+nbfs); + assert( rt.number_of_full_cells() == nbis+nbfs); cerr << "\nTraversing finite vertices... "; size_t nbfv(0); diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h index bafd2be5272..f1471a76acb 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h @@ -109,6 +109,11 @@ constraint. The value type of this iterator is `Vertex_handle`. */ typedef unspecified_type Vertices_in_constraint_iterator; +/*! +A range type for iterating over the vertices of the constraint. +*/ +typedef unspecified_type Vertices_in_constraint; + /*! A context enables the access to the vertices of a constraint that pass through a subconstraint. @@ -341,7 +346,7 @@ Constraint_iterator constraints_end() const; /*! returns a range of constraints. */ -Subconstraints constraints() const; +Constraints constraints() const; /*! returns a `Subconstraint_iterator` pointing at the first diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Delaunay_triangulation_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Delaunay_triangulation_2.h index 911caf7983c..45a4fe12c20 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Delaunay_triangulation_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Delaunay_triangulation_2.h @@ -236,7 +236,7 @@ std::pair get_conflicts_and_boundary(const Point &p, OutputItFaces fit, OutputItBoundaryEdges eit, -Face_handle start) const; +Face_handle start = Face_handle()) const; /*! outputs the faces of the conflict zone of point `p` into an output iterator. @@ -248,7 +248,7 @@ template OutputItFaces get_conflicts (const Point &p, OutputItFaces fit, -Face_handle start) const; +Face_handle start = Face_handle()) const; /*! outputs the boundary edges of the conflict zone of point `p` into an output iterator. @@ -266,7 +266,7 @@ template OutputItBoundaryEdges get_boundary_of_conflicts(const Point &p, OutputItBoundaryEdges eit, -Face_handle start) const; +Face_handle start = Face_handle()) const; /// @} diff --git a/Triangulation_2/doc/Triangulation_2/Concepts/ConstrainedTriangulationTraits_2.h b/Triangulation_2/doc/Triangulation_2/Concepts/ConstrainedTriangulationTraits_2.h index 257c77b0a58..a9dd8effbb9 100644 --- a/Triangulation_2/doc/Triangulation_2/Concepts/ConstrainedTriangulationTraits_2.h +++ b/Triangulation_2/doc/Triangulation_2/Concepts/ConstrainedTriangulationTraits_2.h @@ -20,6 +20,7 @@ to compute the squared distance between a point and a line \cgalRefines `TriangulationTraits_2` \cgalHasModel All \cgal Kernels +\cgalHasModel `CGAL::Projection_traits_3` \cgalHasModel `CGAL::Projection_traits_xy_3` \cgalHasModel `CGAL::Projection_traits_yz_3` \cgalHasModel `CGAL::Projection_traits_xz_3` diff --git a/Triangulation_2/doc/Triangulation_2/Concepts/DelaunayTriangulationTraits_2.h b/Triangulation_2/doc/Triangulation_2/Concepts/DelaunayTriangulationTraits_2.h index 83c9bb6126b..5eaf3c65fbb 100644 --- a/Triangulation_2/doc/Triangulation_2/Concepts/DelaunayTriangulationTraits_2.h +++ b/Triangulation_2/doc/Triangulation_2/Concepts/DelaunayTriangulationTraits_2.h @@ -23,6 +23,8 @@ required if the method `nearest_vertex()` is used. \cgalHasModel \cgal kernels +\cgalHasModel `CGAL::Projection_traits_3` (not for dual Voronoi functions) +\cgalHasModel `CGAL::Projection_traits_xy_3` (not for dual Voronoi functions) \cgalHasModel `CGAL::Projection_traits_xy_3` (not for dual Voronoi functions) \cgalHasModel `CGAL::Projection_traits_yz_3` (not for dual Voronoi functions) \cgalHasModel `CGAL::Projection_traits_xz_3` (not for dual Voronoi functions) @@ -169,4 +171,3 @@ Construct_ray_2 construct_ray_2_object(); /// @} }; /* end DelaunayTriangulationTraits_2 */ - diff --git a/Triangulation_2/doc/Triangulation_2/Concepts/TriangulationTraits_2.h b/Triangulation_2/doc/Triangulation_2/Concepts/TriangulationTraits_2.h index 0329639d1aa..82340f339f1 100644 --- a/Triangulation_2/doc/Triangulation_2/Concepts/TriangulationTraits_2.h +++ b/Triangulation_2/doc/Triangulation_2/Concepts/TriangulationTraits_2.h @@ -13,6 +13,7 @@ triangulation and some function object types for the required predicates on those primitives. \cgalHasModel All models of `Kernel`. +\cgalHasModel `CGAL::Projection_traits_3` \cgalHasModel `CGAL::Projection_traits_xy_3` \cgalHasModel `CGAL::Projection_traits_yz_3` \cgalHasModel `CGAL::Projection_traits_xz_3` @@ -261,4 +262,3 @@ Construct_circumcenter_2 construct_circumcenter_2_object(); /// @} }; /* end TriangulationTraits_2 */ - diff --git a/Triangulation_2/doc/Triangulation_2/examples.txt b/Triangulation_2/doc/Triangulation_2/examples.txt index 459982e56a2..688a58665ae 100644 --- a/Triangulation_2/doc/Triangulation_2/examples.txt +++ b/Triangulation_2/doc/Triangulation_2/examples.txt @@ -22,4 +22,5 @@ \example Triangulation_2/segment_soup_to_polylines.cpp \example Triangulation_2/draw_triangulation_2.cpp \example Triangulation_2/low_dimensional.cpp +\example Triangulation_2/star_conflict_zone.cpp */ diff --git a/Triangulation_2/examples/Triangulation_2/CMakeLists.txt b/Triangulation_2/examples/Triangulation_2/CMakeLists.txt index f5af1d45f31..3c56e972268 100644 --- a/Triangulation_2/examples/Triangulation_2/CMakeLists.txt +++ b/Triangulation_2/examples/Triangulation_2/CMakeLists.txt @@ -17,6 +17,7 @@ endforeach() if(CGAL_Qt5_FOUND) target_link_libraries(draw_triangulation_2 PUBLIC CGAL::CGAL_Basic_viewer) + target_link_libraries(star_conflict_zone PUBLIC CGAL::CGAL_Basic_viewer) else() message( STATUS diff --git a/Triangulation_2/examples/Triangulation_2/copy_triangulation_2.cpp b/Triangulation_2/examples/Triangulation_2/copy_triangulation_2.cpp index db1bd13ea3a..e757b35c7fb 100644 --- a/Triangulation_2/examples/Triangulation_2/copy_triangulation_2.cpp +++ b/Triangulation_2/examples/Triangulation_2/copy_triangulation_2.cpp @@ -3,6 +3,7 @@ #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel EPIC; typedef CGAL::Exact_predicates_exact_constructions_kernel EPEC; @@ -44,5 +45,5 @@ int main() dt2_epec.set_infinite_vertex( dt2_epec.tds().copy_tds( dt2_epic.tds(),dt2_epic.infinite_vertex(), Convert_vertex(), Convert_face() ) ); - CGAL_assertion( dt2_epec.is_valid() ); + assert( dt2_epec.is_valid() ); } diff --git a/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_2.cpp b/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_2.cpp index 5d5f3620366..21d0df6bebd 100644 --- a/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_2.cpp +++ b/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_2.cpp @@ -24,8 +24,6 @@ int main() Delaunay T; T.insert( points.begin(),points.end() ); - CGAL_assertion( T.number_of_vertices() == 6 ); - // check that the info was correctly set. Delaunay::Finite_vertices_iterator vit; for (Vertex_handle v : T.finite_vertex_handles()) diff --git a/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_regular_2.cpp b/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_regular_2.cpp index 27b51dba0db..468b386d888 100644 --- a/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_regular_2.cpp +++ b/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_regular_2.cpp @@ -28,8 +28,6 @@ int main() Regular rt; rt.insert( points.begin(),points.end() ); - CGAL_assertion( rt.number_of_vertices() == 6 ); - // check that the info was correctly set. for (Vertex_handle v : rt.finite_vertex_handles()) if( points[ v->info() ].first != v->point() ){ diff --git a/Triangulation_2/examples/Triangulation_2/info_insert_with_transform_iterator_2.cpp b/Triangulation_2/examples/Triangulation_2/info_insert_with_transform_iterator_2.cpp index 5cf0f395c7a..13de245d23d 100644 --- a/Triangulation_2/examples/Triangulation_2/info_insert_with_transform_iterator_2.cpp +++ b/Triangulation_2/examples/Triangulation_2/info_insert_with_transform_iterator_2.cpp @@ -37,8 +37,6 @@ int main() T.insert( boost::make_transform_iterator(points.begin(),Auto_count()), boost::make_transform_iterator(points.end(), Auto_count() ) ); - CGAL_assertion( T.number_of_vertices() == 6 ); - // check that the info was correctly set. Delaunay::Finite_vertices_iterator vit; for (Vertex_handle v : T.finite_vertex_handles()) diff --git a/Triangulation_2/examples/Triangulation_2/info_insert_with_zip_iterator_2.cpp b/Triangulation_2/examples/Triangulation_2/info_insert_with_zip_iterator_2.cpp index 27b0855a8c9..94059abb6f7 100644 --- a/Triangulation_2/examples/Triangulation_2/info_insert_with_zip_iterator_2.cpp +++ b/Triangulation_2/examples/Triangulation_2/info_insert_with_zip_iterator_2.cpp @@ -36,9 +36,6 @@ int main() T.insert( boost::make_zip_iterator(boost::make_tuple( points.begin(),indices.begin() )), boost::make_zip_iterator(boost::make_tuple( points.end(),indices.end() ) ) ); - CGAL_assertion( T.number_of_vertices() == 6 ); - - // check that the info was correctly set. for (Vertex_handle v : T.finite_vertex_handles()) diff --git a/Triangulation_2/examples/Triangulation_2/star_conflict_zone.cpp b/Triangulation_2/examples/Triangulation_2/star_conflict_zone.cpp new file mode 100644 index 00000000000..c16f662e081 --- /dev/null +++ b/Triangulation_2/examples/Triangulation_2/star_conflict_zone.cpp @@ -0,0 +1,62 @@ +#include +#include +#include +#include +#include +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef K::Point_2 Point_2; +typedef CGAL::Delaunay_triangulation_2 Dt2; +typedef Dt2::Edge Edge; +typedef Dt2::Face_handle Face_handle; +typedef Dt2::Face_circulator Face_circulator; +typedef Dt2::Vertex_handle Vertex_handle; + +int main( ) +{ + Dt2 dt2; + + dt2.insert(Point_2(0,0)); + dt2.insert(Point_2(10,0)); + dt2.insert(Point_2(0,10)); + + std::array points = { Point_2(2,2), Point_2(1,0), Point_2(2,2) }; + + CGAL::spatial_sort(points.begin(), points.end()); + + Face_handle hint; + + std::vector faces; + std::vector edges; + + assert(dt2.dimension() == 2); // precondition of get_conflicts_and_boundary + for(const Point_2 p : points){ + faces.clear(); // faster than variables in the scope + edges.clear(); + dt2.get_conflicts_and_boundary(p, + std::back_inserter(faces), + std::back_inserter(edges), + hint); + + if(faces.empty()){ + std::cout << "point " << p << " already in the triangulation" << std::endl; + }else{ + // Do something with the faces before the insertion + + Vertex_handle vh = dt2.star_hole(p, + edges.begin(), edges.end(), + faces.begin(), faces.end()); + hint = vh->face(); // we could also take any element of faces + + // Do something with the faces after the insertion + Face_circulator fc = dt2.incident_faces(vh), done(fc); + do { + fc++; + } while (fc != done); + } + draw(dt2); + } + return 0; +} diff --git a/Triangulation_2/examples/Triangulation_2/terr_trian.cpp b/Triangulation_2/examples/Triangulation_2/terr_trian.cpp index 9b86dd3c331..8b18765cac5 100644 --- a/Triangulation_2/examples/Triangulation_2/terr_trian.cpp +++ b/Triangulation_2/examples/Triangulation_2/terr_trian.cpp @@ -5,9 +5,12 @@ #include #include +#include #include #include #include +#include +#include #include #include @@ -15,159 +18,159 @@ #include #include -#include "triangulation_print_OFF.h" - -using namespace std; - -template -class Indexed_point: public CGAL::Point_3 { - typedef CGAL::Point_3 Point_3; -public: - int* index; - Indexed_point() {} - Indexed_point( Point_3 p) : Point_3(p) {} - Indexed_point( double x, double y, double z, int* i) - : Point_3(x,y,z), index(i) {} -}; - typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef CGAL::Point_3 Point_3; -typedef Indexed_point IPoint; -typedef CGAL::Projection_traits_xy_3 Gtraits; - -struct Gt : public Gtraits { - typedef IPoint Point; -}; +typedef CGAL::Projection_traits_xy_3 Gt; typedef CGAL::Triangulation_2 Triangulation; typedef CGAL::Delaunay_triangulation_2 Delaunay_triangulation; bool verbose = false; -bool binary = false; -bool noc = false; bool delaunay = false; bool incr = false; // main function with standard unix commandline arguments // ------------------------------------------------------ int main( int argc, char **argv) { - int n = 0; // number of filenames - char *filename[2]; - bool help = false; - for (int i = 1; i < argc; i++) { // check commandline options - if ( strcmp( "-v", argv[i]) == 0) - verbose = true; - else if ( strcmp( "-b", argv[i]) == 0) - binary = true; - else if ( strcmp( "-noc", argv[i]) == 0) - noc = true; - else if ( strcmp( "-delaunay", argv[i]) == 0) - delaunay = true; - else if ( strcmp( "-incr", argv[i]) == 0) - incr = true; - else if ( (strcmp( "-h", argv[i]) == 0) || - (strcmp( "-help", argv[i]) == 0)) - help = true; - else if ( n < 2 ) { - filename[ n++] = argv[i]; - } else { - ++n; - break; - } - } - if ((n > 2) || help) { - if ( ! help) - cerr << "Error: in parameter list" << endl; - cerr << "Usage: " << argv[0] << " [] [ []]" - << endl; - cerr << " Terrain triangulation in the xy-plane." << endl; - cerr << " -delaunay Delaunay triangulation (default)." << endl; - cerr << " -incr Incremental insertion (no flips)." << endl; - cerr << " -b binary output (default is ASCII)." << endl; - cerr << " -noc no comments in file." << endl; - cerr << " -v verbose." << endl; - exit( ! help); - } - - CGAL::Verbose_ostream vout( verbose); - vout << argv[0] << ": verbosity on." << endl; - - const char* iname = "cin"; - istream* p_in = &cin; - ifstream in; - if ( n > 0) { - in.open( filename[0]); - p_in = ∈ - iname = filename[0]; - } - if ( !*p_in) { - cerr << argv[0] << ": error: cannot open file '" << iname - << "' for reading." < 1) { - out.open( filename[1]); - p_out = &out; - oname = filename[1]; - } - if ( !*p_out) { - cerr << argv[0] << ": error: cannot open file '"<< oname - << "' for writing." < 2) || help) { + if ( ! help) + std::cerr << "Error: in parameter list" << std::endl; + std::cerr << "Usage: " << argv[0] << " [] [ []]" + << std::endl; + std::cerr << " Terrain triangulation in the xy-plane." << std::endl; + std::cerr << " -delaunay Delaunay triangulation (triangulation otherwise)." << std::endl; + std::cerr << " -incr Incremental insertion (no flips)." << std::endl; + std::cerr << " -v verbose." << std::endl; + exit( ! help); + } + + CGAL::Verbose_ostream vout( verbose); + vout << argv[0] << ": verbosity on." << std::endl; + + const char* iname = "cin"; + std::istream* p_in = &std::cin; + std::ifstream in; + if ( n > 0) { + in.open( filename[0]); + p_in = ∈ + iname = filename[0]; + } + if ( !*p_in) { + std::cerr << argv[0] << ": error: cannot open file '" << iname + << "' for reading." << std::endl; + exit(1); + } + + CGAL::File_scanner_OFF scanner( * p_in, true); + if ( !*p_in) + exit(1); + + const char* oname = "cout"; + std::ostream* p_out = &std::cout; + std::ofstream out; + if ( n > 1) { + out.open( filename[1]); + p_out = &out; + oname = filename[1]; + } + if ( !*p_out) { + std::cerr << argv[0] << ": error: cannot open file '"<< oname + << "' for writing." << std::endl; + exit(1); + } + + if ( delaunay) + { + Delaunay_triangulation triang; + if (incr) + { + vout << "Scanning and triangulating ... " << std::flush; + for ( std::size_t j = 0; j < scanner.size_of_vertices(); j++) { + double x, y, z; + scanner.scan_vertex( x, y, z); + Point_3 p( x, y, z); + triang.insert( p); + } } - if ( !*p_out) { - cerr << argv[0] << " write error: while writing file '"<< oname << "'." - << endl; - exit( 1); + else + { + vout << "Scanning ... " << std::flush; + std::vector points; + for ( std::size_t j = 0; j < scanner.size_of_vertices(); j++) { + double x, y, z; + scanner.scan_vertex( x, y, z); + points.push_back(Point_3(x, y, z)); + } + vout << "done." << std::endl; + vout << "Triangulating ... " << std::flush; + triang.insert(points.begin(), points.end()); } - delete[] indices; - return 0; + vout << " done." << std::endl; + vout << "write_triangulation(" << oname << ") ... " << std::flush; + CGAL::IO::write_OFF(*p_out, triang); + vout << "done." << std::endl; + + } else { + Triangulation triang; + if(incr) + { + vout << "Scanning and triangulating ... " << std::flush; + for ( std::size_t j = 0; j < scanner.size_of_vertices(); j++) { + double x, y, z; + scanner.scan_vertex( x, y, z); + Point_3 p( x, y, z); + triang.insert( p); + } + } + else + { + vout << "Scanning ... " << std::flush; + std::vector points; + for ( std::size_t j = 0; j < scanner.size_of_vertices(); j++) { + double x, y, z; + scanner.scan_vertex( x, y, z); + points.push_back(Point_3( x, y, z)); + } + vout << "done." << std::endl; + vout << "Triangulating ... " << std::flush; + triang.insert(points.begin(), points.end()); + } + vout << "done." << std::endl; + vout << "write_triangulation(" << oname << ") ... " << std::flush; + CGAL::IO::write_OFF(*p_out, triang); + vout << "done." << std::endl; + } + if ( !*p_in) { + std::cerr << argv[0] << " read error: while reading file '"<< iname << "'." + << std::endl; + std::exit(1); + } + if ( !*p_out) { + std::cerr << argv[0] << " write error: while writing file '"<< oname << "'." + << std::endl; + exit(1); + } + + return 0; } diff --git a/Triangulation_2/examples/Triangulation_2/triangulation_print_OFF.h b/Triangulation_2/examples/Triangulation_2/triangulation_print_OFF.h deleted file mode 100644 index 255f93d4e3c..00000000000 --- a/Triangulation_2/examples/Triangulation_2/triangulation_print_OFF.h +++ /dev/null @@ -1,73 +0,0 @@ -// Print a Triangulation with 3d points in object file format (OFF). - -#ifndef CGAL_TRIANGULATION_PRINT_OFF_H -#define CGAL_TRIANGULATION_PRINT_OFF_H 1 - -#include - -namespace CGAL { - -template < class Triang > -void -triangulation_print_OFF( std::ostream& out, - const Triang& triang, - bool binary = false, - bool noc = false, - bool verbose = false) { - CGAL_precondition( triang.is_valid()); - typedef typename Triang::Vertex Vertex; - typedef typename Triang::Vertex_iterator Vertex_iterator; - typedef typename Triang::Face_iterator Face_iterator; - // Build a map from vertex pointers to vertex indices. - std::map > mapping; - std::size_t vn = 0; - Vertex_iterator vi = triang.vertices_begin(); - for ( ; vi != triang.vertices_end(); ++vi) { - CGAL_assertion( ! triang.is_infinite( vi)); - mapping[ &*vi] = vn; - vn++; - } - CGAL_assertion( vn == std::size_t( triang.number_of_vertices())); - - // Count finite and infinite faces. - std::size_t fn = 0; - Face_iterator fi = triang.faces_begin(); - for ( ; fi != triang.faces_end(); ++fi) { - CGAL_assertion( ! triang.is_infinite( fi)); - fn++; - } - std::size_t fin = triang.number_of_faces() - fn; - - File_header_OFF header( binary, noc, false, verbose); - File_writer_OFF writer( header); - writer.write_header( out, vn, 3 * fn + fin, fn); - - vi = triang.vertices_begin(); - for ( ; vi != triang.vertices_end(); ++vi) { - CGAL_assertion( ! triang.is_infinite( vi)); - writer.write_vertex( to_double(vi->point().x()), - to_double(vi->point().y()), - to_double(vi->point().z())); - } - writer.write_facet_header(); - - fi = triang.faces_begin(); - while ( fn --) { - writer.write_facet_begin( 3); - CGAL_assertion( mapping.find(&*(fi->vertex(0))) != mapping.end()); - CGAL_assertion( mapping.find(&*(fi->vertex(1))) != mapping.end()); - CGAL_assertion( mapping.find(&*(fi->vertex(2))) != mapping.end()); - writer.write_facet_vertex_index( mapping[ &*(fi->vertex(0))]); - writer.write_facet_vertex_index( mapping[ &*(fi->vertex(1))]); - writer.write_facet_vertex_index( mapping[ &*(fi->vertex(2))]); - writer.write_facet_end(); - ++fi; - } - CGAL_assertion( fi == triang.faces_end()); - writer.write_footer(); -} - -} //namespace CGAL - -#endif // CGAL_TRIANGULATION_PRINT_OFF_H // -// EOF // diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h index c6c79d6bae1..95e0b4befc7 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h @@ -1186,7 +1186,8 @@ intersect(Face_handle f, int i, << " , #" << vd->time_stamp() << "= " << vd->point() << " , Exact_intersections_tag)\n"; #endif // CGAL_CDT_2_DEBUG_INTERSECTIONS - Point pi; + Point pi(ORIGIN); // initialize although we are sure that it will be + // set by the intersection, but to quiet a warning Intersection_tag itag = Intersection_tag(); CGAL_triangulation_assertion_code( bool ok = ) intersection(geom_traits(), pa, pb, pc, pd, pi, itag ); diff --git a/Triangulation_2/include/CGAL/IO/Triangulation_geomview_ostream_2.h b/Triangulation_2/include/CGAL/IO/Triangulation_geomview_ostream_2.h deleted file mode 100644 index 5391db69404..00000000000 --- a/Triangulation_2/include/CGAL/IO/Triangulation_geomview_ostream_2.h +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) 2000 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) : Sylvain Pion - -#ifndef CGAL_IO_TRIANGULATION_GEOMVIEW_OSTREAM_2_H -#define CGAL_IO_TRIANGULATION_GEOMVIEW_OSTREAM_2_H - -#include - - -#include -#include - -namespace CGAL { - -// There are 2 drawing functions for triangulations : depending on the wired -// mode of the Geomview_stream, we draw either the edges or the faces. - -// TODO : -// - Check the correctness when dimension < 2. -// - Use the current stream color instead of built-in constant. - -template < class GT, class TDS > -void -show_triangulation_edges(Geomview_stream &gv, const Triangulation_2 &T) -{ - // Header. - gv.set_ascii_mode(); - gv << "(geometry " << gv.get_new_id("triangulationedge") - << " {appearance {}{ SKEL \n" - << T.number_of_vertices() - << T.number_of_vertices() + T.number_of_faces()-1 << "\n"; - - // Finite vertices coordinates. - std::map::Vertex_handle, int> V; - int inum = 0; - for( typename Triangulation_2::Vertex_iterator - vit = T.vertices_begin(); vit != T.vertices_end(); ++vit) { - V[vit] = inum++; - gv << vit->point() << "\n"; - } - - // Finite edges indices. - for( typename Triangulation_2::Edge_iterator - eit = T.edges_begin(); eit != T.edges_end(); ++eit) { - gv << 2 - << V[(*eit).first->vertex(T.ccw((*eit).second))] - << V[(*eit).first->vertex(T. cw((*eit).second))] - << "\n"; // without color. - // << 4 << drand48() << drand48() << drand48() << 1.0; // random color - } -} - -template < class GT, class TDS > -void -show_triangulation_faces(Geomview_stream &gv, const Triangulation_2 &T) -{ - // Header. - gv.set_binary_mode(); - gv << "(geometry " << gv.get_new_id("triangulation") - << " {appearance {}{ OFF BINARY\n" - << T.number_of_vertices() << T.number_of_faces() << 0; - - // Finite vertices coordinates. - std::map::Vertex_handle, int> V; - int inum = 0; - for( typename Triangulation_2::Vertex_iterator - vit = T.vertices_begin(); vit != T.vertices_end(); ++vit) { - V[vit] = inum++; - gv << vit->point(); - } - - // Finite faces indices. - for( typename Triangulation_2::Face_iterator - fit = T.faces_begin(); fit != T.faces_end(); ++fit) { - gv << 3; - for (int i=0; i<3; i++) - gv << V[fit->vertex(i)]; - gv << 0; // without color. - // gv << 4 << drand48() << drand48() << drand48() << 1.0; // random color - } -} - -template < class GT, class TDS > -Geomview_stream& -operator<<( Geomview_stream &gv, const Triangulation_2 &T) -{ - bool ascii_bak = gv.get_ascii_mode(); - bool raw_bak = gv.set_raw(true); - - if (gv.get_wired()) - show_triangulation_edges(gv, T); - else - show_triangulation_faces(gv, T); - - // Footer. - gv << "}})"; - - gv.set_raw(raw_bak); - gv.set_ascii_mode(ascii_bak); - return gv; -} - -} //namespace CGAL - -#endif // CGAL_IO_TRIANGULATION_GEOMVIEW_OSTREAM_2_H diff --git a/Triangulation_2/include/CGAL/boost/graph/internal/graph_traits_2D_triangulation_helper.h b/Triangulation_2/include/CGAL/boost/graph/internal/graph_traits_2D_triangulation_helper.h index 5d94f0dc6b2..8585bc33db1 100644 --- a/Triangulation_2/include/CGAL/boost/graph/internal/graph_traits_2D_triangulation_helper.h +++ b/Triangulation_2/include/CGAL/boost/graph/internal/graph_traits_2D_triangulation_helper.h @@ -8,12 +8,11 @@ // // Author(s) : Mael Rouxel-Labbé +#include #include #include #include -#include -#include #include #include @@ -24,260 +23,19 @@ namespace CGAL { namespace internal { -// A triangulation edge is a face handle + an int, and is thus actually a halfedge... -template -struct T2_halfedge_descriptor - : public Tr::Edge -{ - typedef typename Tr::Edge Base; - typedef typename Tr::Face_handle Face_handle; +// just for clarity +template +using T2_halfedge_descriptor = TDS2_halfedge_descriptor; - T2_halfedge_descriptor() {} - T2_halfedge_descriptor(Face_handle fh, int i) : Base(fh, i) { } - explicit T2_halfedge_descriptor(const Base& e) : Base(e) { } - T2_halfedge_descriptor(const T2_halfedge_descriptor& h) : Base(h) { } +template +using T2_halfedge_iterator = TDS2_halfedge_iterator; - const Base& base() const { return static_cast(*this); } +template +using T2_edge_descriptor = TDS2_edge_descriptor; - T2_halfedge_descriptor& operator=(const T2_halfedge_descriptor& h) - { - this->first = h.first; - this->second = h.second; - return *this; - } +template +using T2_edge_iterator = TDS2_edge_iterator; - friend std::size_t hash_value(const T2_halfedge_descriptor& e) { - return hash_value(e.first); - } -}; - -// An edge is just a halfedge, but we give it a complete structure to distinguish it from Tr::Edge -template -struct T2_edge_descriptor -{ - typedef typename Tr::Face_handle Face_handle; - - T2_edge_descriptor() : first(), second(0) { } - explicit T2_edge_descriptor(const typename Tr::Edge& e) : first(e.first), second(e.second) { } - T2_edge_descriptor(Face_handle fd, int i) : first(fd), second(i) { } - - // so that we can still do stuff like tr.is_finite(edge_descriptor) without any hassle - operator std::pair() const { return std::make_pair(first, second); } - - friend std::size_t hash_value(const T2_edge_descriptor& h) - { - if(h.first == Face_handle()) - return 0; - - return hash_value(h.first < h.first->neighbor(h.second) ? h.first - : h.first->neighbor(h.second)); - } - - bool operator==(const T2_edge_descriptor& other) const - { - if((first == other.first) && (second == other.second)) - return true; - - Face_handle fh = first->neighbor(second); - if(other.first != fh) - return false; - - int i = fh->index(first); - return (other.second == i); - } - bool operator!=(T2_edge_descriptor& other) const { return ! (*this == other); } - - void get_canonical_edge_representation(Face_handle& fh, int& i) const - { - Face_handle neigh_fh = fh->neighbor(i); - Face_handle canonical_fh = (fh < neigh_fh) ? fh : neigh_fh; - - int canonical_i = (fh < neigh_fh) ? i : neigh_fh->index(fh); - - fh = canonical_fh; - i = canonical_i; - } - - bool operator<(const T2_edge_descriptor& other) const - { - if(*this == other) - return false; - - Face_handle tfh = first; - int ti = second; - get_canonical_edge_representation(tfh, ti); - - Face_handle ofh = other.first; - int oi = other.second; - get_canonical_edge_representation(ofh, oi); - - if(tfh < ofh) return true; - if(tfh > ofh) return false; - return ti < oi; - } - - Face_handle first; - int second; -}; - -// A halfedge iterator is just an edge iterator that duplicates everything twice, -// to see the edge from either side. -// Could probably be factorized with T2_edge_iterator, but it's clearer this way. -template -struct T2_halfedge_iterator -{ -private: - typedef T2_halfedge_iterator Self; - typedef EdgeIterator Edge_iterator; - typedef T2_halfedge_descriptor Descriptor; - typedef typename Tr::Face_handle Face_handle; - -public: - typedef Descriptor value_type; - typedef value_type* pointer; - typedef value_type& reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef std::bidirectional_iterator_tag iterator_category; - - T2_halfedge_iterator() { } - T2_halfedge_iterator(const Edge_iterator& feit) : it(feit), on_adjacent_face(false) { } - - Self& operator++() - { - // If we are on the first face, move to the opposite face. If we are already on the opposite face, - // then it's time to move on the next edge - if(on_adjacent_face) { - ++it; - on_adjacent_face = false; - } else { - on_adjacent_face = true; - } - - return *this; - } - - Self& operator--() - { - // Note that while decreasing, we start from the opposite face - if(on_adjacent_face) { - on_adjacent_face = false; - } else { - --it; - on_adjacent_face = true; - } - - return *this; - } - - Self operator++(int) { Self tmp = *this; operator++(); return tmp; } - Self operator--(int) { Self tmp = *this; operator--(); return tmp; } - - bool operator==(const Self& other) const { return it == other.it; } - bool operator!=(const Self& other) const { return !(*this == other); } - - reference operator*() const - { - if(on_adjacent_face) - { - Face_handle neigh_f = it->first->neighbor(it->second); - hd = Descriptor(neigh_f, neigh_f->index(it->first)); - return hd; - } else { - hd = Descriptor(it->first, it->second); - return hd; - } - } - -private: - Edge_iterator it; - bool on_adjacent_face; - mutable Descriptor hd; -}; - -template -struct T2_edge_iterator -{ -private: - typedef T2_edge_iterator Self; - typedef EdgeIterator Edge_iterator; - typedef T2_edge_descriptor Descriptor; - -public: - typedef Descriptor value_type; - typedef value_type* pointer; - typedef value_type& reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef std::bidirectional_iterator_tag iterator_category; - - T2_edge_iterator() { } - T2_edge_iterator(const Edge_iterator& feit) : it(feit) { } - - bool operator==(const Self& other) const { return it == other.it; } - bool operator!=(const Self& other) const { return !(*this == other); } - Self& operator++() { ++it; return *this; } - Self& operator--() { --it; return *this; } - Self operator++(int) { Self tmp = *this; operator++(); return tmp; } - Self operator--(int) { Self tmp = *this; operator--(); return tmp; } - - reference operator*() const - { - ed = Descriptor(*it); - return ed; - } - -private: - Edge_iterator it; - mutable Descriptor ed; -}; - -// Must distinguish TDS and triangulations circulators (later are filtered) -template -class TDS2_Out_edge_circulator - : public Circ -{ -private: - mutable E e; - -public: - typedef E value_type; - typedef E* pointer; - typedef E& reference; - - TDS2_Out_edge_circulator() : Circ() {} - TDS2_Out_edge_circulator(Circ c) : Circ(c) {} - - const E& operator*() const - { - E ed = static_cast(this)->operator*(); - e = E(ed.first->neighbor(ed.second), ed.first->neighbor(ed.second)->index(ed.first)); - return e; - } -}; - -template -class TDS2_In_edge_circulator - : public Circ -{ -private: - mutable E e; - -public: - typedef E value_type; - typedef E* pointer; - typedef E& reference; - - TDS2_In_edge_circulator() : Circ() {} - TDS2_In_edge_circulator(Circ c) : Circ(c) {} - - const E& operator*() const - { - typename Circ::value_type ed = static_cast(this)->operator*(); - e = E(ed); - return e; - } -}; template struct T2_edge_circulator @@ -422,40 +180,4 @@ private: } // namespace internal } // namespace CGAL -namespace std { - -// workaround a bug detected on at least g++ 4.4 where boost::next(Iterator) -// is picked as a candidate for next(h,g) -template -struct iterator_traits< CGAL::internal::T2_halfedge_descriptor > -{ - typedef void* iterator_category; - typedef void* difference_type; - typedef void* value_type; - typedef void* reference; -}; - -#if defined(BOOST_MSVC) -# pragma warning(push) -# pragma warning(disable:4099) // For VC10 it is class hash -#endif - -#ifndef CGAL_CFG_NO_STD_HASH - -template < class Tr> -struct hash > -{ - std::size_t operator()(const CGAL::internal::T2_halfedge_descriptor& e) const { - return hash_value(e); - } -}; - -#endif // CGAL_CFG_NO_STD_HASH - -#if defined(BOOST_MSVC) -# pragma warning(pop) -#endif - -} // namespace std - #endif // CGAL_GRAPH_TRAITS_2D_TRIANGULATION_HELPERS diff --git a/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h b/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h index 5cdde7ec8f8..7111e237ef6 100644 --- a/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h +++ b/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h @@ -9,6 +9,7 @@ // Author(s) : Mael Rouxel-Labbé #include +#include #include #include @@ -20,7 +21,7 @@ #error CGAL_2D_TRIANGULATION is not defined #endif -// note only the properties below are protected by the macro, +// note that only the properties below are protected by the macro, // the rest of the file is the shared implementation of properties for all 2D triangulations #ifndef CGAL_BOOST_GRAPH_PROPERTIES_2D_TRIANGULATION_H #define CGAL_BOOST_GRAPH_PROPERTIES_2D_TRIANGULATION_H @@ -28,12 +29,6 @@ namespace CGAL { namespace internal { -template -struct T2_halfedge_descriptor; - -template -struct T2_edge_descriptor; - template class T2_vertex_point_map { diff --git a/Triangulation_2/test/Triangulation_2/test_constrained_triangulation_with_info_2.cpp b/Triangulation_2/test/Triangulation_2/test_constrained_triangulation_with_info_2.cpp index 217f3e4f0ec..d86f08e55b8 100644 --- a/Triangulation_2/test/Triangulation_2/test_constrained_triangulation_with_info_2.cpp +++ b/Triangulation_2/test/Triangulation_2/test_constrained_triangulation_with_info_2.cpp @@ -2,6 +2,7 @@ #include #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -27,7 +28,7 @@ int main() CDT T; T.insert( points.begin(),points.end() ); - CGAL_assertion( T.number_of_vertices() == 6 ); + assert( T.number_of_vertices() == 6 ); // check that the info was correctly set. CDT::Finite_vertices_iterator vit; @@ -63,7 +64,7 @@ int main() T.insert( boost::make_zip_iterator(boost::make_tuple( points.begin(),indices.begin() )), boost::make_zip_iterator(boost::make_tuple( points.end(),indices.end() ) ) ); - CGAL_assertion( T.number_of_vertices() == 6 ); + assert( T.number_of_vertices() == 6 ); // check that the info was correctly set. diff --git a/Triangulation_2/test/Triangulation_2/test_triangulation_with_zip_iterator_2.cpp b/Triangulation_2/test/Triangulation_2/test_triangulation_with_zip_iterator_2.cpp index ae0dd96779a..c3e0a5a081c 100644 --- a/Triangulation_2/test/Triangulation_2/test_triangulation_with_zip_iterator_2.cpp +++ b/Triangulation_2/test/Triangulation_2/test_triangulation_with_zip_iterator_2.cpp @@ -3,6 +3,7 @@ #include #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; @@ -34,7 +35,7 @@ int main() Triangulation T( boost::make_zip_iterator(boost::make_tuple( points.begin(),indices.begin() )), boost::make_zip_iterator(boost::make_tuple( points.end(),indices.end() ) ) ); - CGAL_assertion( T.number_of_vertices() == 6 ); + assert( T.number_of_vertices() == 6 ); // check that the info was correctly set. diff --git a/Triangulation_3/demo/Triangulation_3_Geomview_demos/CMakeLists.txt b/Triangulation_3/demo/Triangulation_3_Geomview_demos/CMakeLists.txt deleted file mode 100644 index 5cf9ceab015..00000000000 --- a/Triangulation_3/demo/Triangulation_3_Geomview_demos/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# Created by the script cgal_create_cmake_script -# This is the CMake script for compiling a CGAL application. - -cmake_minimum_required(VERSION 3.1...3.20) -project(Triangulation_3_Geomview_demos_Demo) - -if(NOT POLICY CMP0070 AND POLICY CMP0053) - # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. - cmake_policy(SET CMP0053 OLD) -endif() - -set_directory_properties(PROPERTIES CGAL_NO_TESTING TRUE) - -find_package(CGAL REQUIRED) - -create_single_source_cgal_program("Triangulation_3_demo.cpp") -create_single_source_cgal_program("Triangulation_3_color_demo.cpp") -create_single_source_cgal_program("Triangulation_3_remove_demo.cpp") -create_single_source_cgal_program("Triangulation_3_voronoi_demo.cpp") diff --git a/Triangulation_3/demo/Triangulation_3_Geomview_demos/README b/Triangulation_3/demo/Triangulation_3_Geomview_demos/README deleted file mode 100644 index 2a2042cfc89..00000000000 --- a/Triangulation_3/demo/Triangulation_3_Geomview_demos/README +++ /dev/null @@ -1,39 +0,0 @@ -The demos use Geomview -[see the chapter Geomview in the cgal manual - support library: -Geomview 1.8.1 is required. The geomview command must be in the user's $PATH, -otherwise the program will not be able to execute.] - -------- demo ------------------------------------------------- -Construction of a Delaunay triangulation. - -Needs an input file "data/points" containing points (given by x y z) - -Draws the triangulation (vertices and edges) in geomview - -Locates a point a shows the cell containing it - -Draws the triangulation (edges and cells) in geomview, -then the user can move one of the two displayed versions -of the triangulation. --------------------------------------------------------------- - -------- demo_color ------------------------------------------- -Constructs a Delaunay triangulation with a special Vertex base class -containing a color (white by default). - -Sets the color of degree 6 vertices to red. - -Displays the triangulation where each vertex has its own color. --------------------------------------------------------------- - -------- demo_voronoi ------------------------------------------ -Constructs a Delaunay triangulation for points on a grid. - -Displays the Voronoi edges of the set of points --------------------------------------------------------------- - -------- demo_remove ------------------------------------------ -Constructs a Delaunay triangulation for points on a grid. - -Then removes all the vertices in random order --------------------------------------------------------------- diff --git a/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_color_demo.cpp b/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_color_demo.cpp deleted file mode 100644 index 010bf0465d8..00000000000 --- a/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_color_demo.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 2001, 2002, 2003, 2004, 2005 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) : Monique Teillaud - -#include - -#ifndef CGAL_USE_GEOMVIEW -#include -int main() -{ - std::cerr << "Geomview doesn't work on this platform," - " so this demo doesn't work" << std::endl; - return 0; -} -#else - -#include - -#include -#include - -#include - -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; - -typedef CGAL::Triangulation_vertex_base_with_info_3 Vb; -typedef CGAL::Delaunay_triangulation_cell_base_3 Cb; -typedef CGAL::Triangulation_data_structure_3 Tds; -typedef CGAL::Delaunay_triangulation_3 Delaunay; - -typedef Delaunay::Point Point; - -int main() -{ - CGAL::Geomview_stream gv(CGAL::Bbox_3(0,0,0, 2, 2, 2)); - gv.set_bg_color(CGAL::IO::Color(0, 200, 200)); - gv.clear(); - - Delaunay T; - - T.insert(Point(0,0,0)); - T.insert(Point(1,0,0)); - T.insert(Point(0,1,0)); - T.insert(Point(0,0,1)); - T.insert(Point(2,2,2)); - T.insert(Point(-1,0,1)); - - // Set the color of finite vertices of degree 6 to red. - Delaunay::Finite_vertices_iterator vit; - for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) - if (T.degree(vit) == 6) - vit->info() = CGAL::IO::red(); - - std::cout << " Visualization of T" << std::endl; - gv.set_wired(true); - gv << T; - - std::cout << " Vertices of T with their own color" << std::endl - << " red for degree 6 (counting infinite vertex)" - << std::endl - << " white otherwise" << std::endl; - for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) - gv << vit->info() << vit->point(); - - std::cout << "Enter any character to quit" << std::endl; - char ch; - std::cin >> ch; - - return 0; -} - -#endif // CGAL_USE_GEOMVIEW diff --git a/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_demo.cpp b/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_demo.cpp deleted file mode 100644 index b34b666422d..00000000000 --- a/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_demo.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// Copyright (c) 1999, 2000, 2001, 2002, 2003, 2004, 2005 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) : Monique Teillaud - -#include - -#ifndef CGAL_USE_GEOMVIEW -#include -int main() -{ - std::cerr << "Geomview doesn't work on this platform," - " so this demo doesn't work" << std::endl; - return 0; -} -#else - -#include - -#include - -#include - -#include -#include -#include -#include - -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; - -typedef CGAL::Delaunay_triangulation_3 Triangulation; - -typedef Triangulation::Finite_vertices_iterator Finite_vertices_iterator; -typedef Triangulation::Cell_handle Cell_handle; -typedef Triangulation::Locate_type Locate_type; -typedef Triangulation::Point Point; - -////////////////////// -// VISU GEOMVIEW -////////////////////// -template -void visu_cell(CGAL::Geomview_stream & os, const TRIANGULATION & T, - Cell_handle c) -{ - if ( ! T.is_infinite(c) ) - os << T.tetrahedron(c); - else - os << T.triangle(c,c->index(T.infinite_vertex())); -} -template -void visu_facet(CGAL::Geomview_stream & os, const TRIANGULATION & T, - Cell_handle c, int i) -{ - if ( ! T.is_infinite(c,i) ) - os << T.triangle(c,i); -} -template -void visu_edge(CGAL::Geomview_stream & os, const TRIANGULATION & T, - Cell_handle c, int i, int j) -{ - if ( ! T.is_infinite(c,i,j) ) - os << T.segment(c,i,j); -} -template -void visu_vertices(CGAL::Geomview_stream & os, const TRIANGULATION & T) -{ - Finite_vertices_iterator vit = T.finite_vertices_begin(); - Finite_vertices_iterator vdone = T.finite_vertices_end(); - - if ( vit == vdone ) { std::cout << "no vertex" << std::endl ;} - else { - while(vit != vdone) { - os << vit->point(); - ++vit; - } - } -} -template -void visu_vertex(CGAL::Geomview_stream & os, const TRIANGULATION & T, - Cell_handle c, int i) -{ - if ( ! T.is_infinite(c->vertex(i)) ) - os << c->vertex(i)->point(); -} - -////////////////////// - -int main() -{ - CGAL::Geomview_stream gv(CGAL::Bbox_3(0,0,0, 2, 2, 2)); - gv.set_bg_color(CGAL::IO::Color(0, 200, 200)); - gv.clear(); - - Triangulation T; - - std::ifstream iFile("data/points",std::ios::in); - - if (! iFile) { - std::cout <<"A file named points in directory data" - <<" containing points should be provided," << std::endl - <<"see README"< begin (iFile), end; - T.insert (begin, end); - } - - T.is_valid(true); - - std::cout <<" Visualizing vertices and edges" << std::endl; - visu_vertices(gv,T); - gv.set_wired(true); - gv << T; - gv.set_wired(false); - - sleep(3); - - std::cout <<" Locating point (1,1,1) :" << std::endl; - Point p(1,1,1); - gv.set_vertex_color(CGAL::orange()); - gv << p; - Locate_type lt; - int li, lj; - Cell_handle c = T.locate(p,lt,li,lj); - - sleep(3); - - gv << CGAL::violet(); - if ( lt == Triangulation::CELL ) { - std::cout <<" CELL" << std::endl; - visu_cell(gv,T,c); - } - if ( lt == Triangulation::FACET ) { - std::cout <<" FACET" << std::endl; - visu_facet(gv,T,c,li); - } - if ( lt == Triangulation::EDGE ) { - std::cout <<" EDGE" << std::endl; - visu_edge(gv,T,c,li,lj); - } - if ( lt == Triangulation::VERTEX ) { - std::cout <<" VERTEX" << std::endl; - visu_vertex(gv,T,c,li); - } - if ( lt == Triangulation::OUTSIDE_CONVEX_HULL ) - std::cout <<" OUTSIDE_CONVEX_HULL" << std::endl; - if ( lt == Triangulation::OUTSIDE_AFFINE_HULL ) - std::cout <<" OUTSIDE_AFFINE_HULL" << std::endl; - - sleep(6); - - std::cout <<" Visualizing T" << std::endl; - gv.clear(); - std::cout <<" - facets" << std::endl; - gv << T; - std::cout <<" - edges only" << std::endl; - gv.set_wired(true); - gv << T; - gv.set_wired(false); - std::cout <<" You can move one of the" <> ch; - - return 0; -} - -#endif // CGAL_USE_GEOMVIEW diff --git a/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_remove_demo.cpp b/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_remove_demo.cpp deleted file mode 100644 index 4b1ab9e2f08..00000000000 --- a/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_remove_demo.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) 2001, 2002, 2003, 2004, 2005 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) : Monique Teillaud - -#include - -#ifndef CGAL_USE_GEOMVIEW -#include -int main() -{ - std::cerr << "Geomview doesn't work on this platform," - " so this demo doesn't work" << std::endl; - return 0; -} -#else - -#include - -#include - -#include - -#include -#include -#include -#include - -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Delaunay_triangulation_3 Dt; - -typedef Dt::Vertex_iterator Vertex_iterator; -typedef Dt::Vertex_handle Vertex_handle; -typedef Dt::Cell_handle Cell_handle; -typedef Dt::Point Point; - -////////////////////// -// VISU GEOMVIEW -////////////////////// -template -void visu_cell(CGAL::Geomview_stream & os, const TRIANGULATION & T, - Cell_handle c) -{ - if ( ! T.is_infinite(c) ) - os << T.tetrahedron(c); - else - os << T.triangle(c,c->index(T.infinite_vertex())); -} -template -void visu_facet(CGAL::Geomview_stream & os, const TRIANGULATION & T, - Cell_handle c, int i) -{ - if ( ! T.is_infinite(c,i) ) - os << T.triangle(c,i); -} -template -void visu_edge(CGAL::Geomview_stream & os, const TRIANGULATION & T, - Cell_handle c, int i, int j) -{ - if ( ! T.is_infinite(c,i,j) ) - os << T.segment(c,i,j); -} -template -void visu_vertices(CGAL::Geomview_stream & os, const TRIANGULATION & T) -{ - Vertex_iterator vit = T.finite_vertices_begin(); - Vertex_iterator vdone = T.vertices_end(); - - if ( vit == vdone ) { std::cout << "no vertex" << std::endl ;} - else { - while(vit != vdone) { - os << vit->point(); - ++vit; - } - } -} -template -void visu_vertex(CGAL::Geomview_stream & os, const TRIANGULATION & T, - Cell_handle c, int i) -{ - if ( ! T.is_infinite(c->vertex(i)) ) - os << c->vertex(i)->point(); -} - -////////////////////// - -int main() -{ - CGAL::Geomview_stream gv(CGAL::Bbox_3(0,0,0, 5, 5, 5)); - gv.set_bg_color(CGAL::IO::Color(0, 200, 200)); - gv.set_wired(true); - gv.clear(); - - Dt T; - - std::cout <<" Inserting points" << std::endl ; - int x,y,z; - std::vector V(125); - int i=0; - - for (z=0 ; z<5 ; z++) - for (y=0 ; y<5 ; y++) - for (x=0 ; x<5 ; x++) - V[i++] = T.insert(Point(x,y,z)); - - assert( T.is_valid() ); - assert( T.number_of_vertices() == 125 ); - assert( T.dimension() == 3 ); - - std::cout <<" Visualizing edges" << std::endl; - gv << T; - - sleep(3); - - std::cout <<" Removing vertices in random order" << std::endl; - - CGAL::cpp98::random_shuffle(V.begin(), V.end()); - - for (i=0; i<125; ++i) { - T.remove(V[i]); - gv.clear(); - gv << T; - } - - char ch; - std::cout << "Enter any character to quit" << std::endl; - std::cin >> ch; - - return 0; -} - -#endif // CGAL_USE_GEOMVIEW diff --git a/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_voronoi_demo.cpp b/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_voronoi_demo.cpp deleted file mode 100644 index 3fccb43099e..00000000000 --- a/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_voronoi_demo.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2001, 2002, 2003, 2004, 2005 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) : Monique Teillaud - -#include - -#ifndef CGAL_USE_GEOMVIEW -#include -int main() -{ - std::cerr << "Geomview doesn't work on this platform," - " so this demo doesn't work" - << std::endl; - return 0; -} -#else - -#include - -#include -#include - -#include - -#include - -// exact constructions (circumcenter computations) are needed in this -// demo, not only predicates -typedef CGAL::Exact_predicates_exact_constructions_kernel K; - -typedef CGAL::Triangulation_vertex_base_3 Vb; -typedef CGAL::Delaunay_triangulation_cell_base_with_circumcenter_3 Cb; -typedef CGAL::Triangulation_data_structure_3 TDS; -typedef CGAL::Delaunay_triangulation_3 Triangulation; -// typedef CGAL::Delaunay_triangulation_3 Triangulation; - -typedef Triangulation::Point Point; - -int main() -{ - CGAL::Geomview_stream gv(CGAL::Bbox_3(0,0,0, 3, 3, 3)); - gv.set_bg_color(CGAL::IO::Color(0, 200, 200)); - gv.clear(); - - Triangulation T; - - std::cout <<" Inserting points" << std::endl ; - for (int z=0 ; z<3 ; z++) - for (int y=0 ; y<3 ; y++) - for (int x=0 ; x<3 ; x++) - T.insert(Point(x, y, z)); - - T.is_valid(true); - - std::cout <<" Visualizing T" << std::endl; - gv.set_wired(true); - gv << T; - - std::cout <<" Visualizing the Voronoi edges" << std::endl; - gv << CGAL::IO::red(); - T.draw_dual(gv); - - char ch; - std::cout << "Enter any character to quit" << std::endl; - std::cin >> ch; - - return 0; -} - -#endif // CGAL_USE_GEOMVIEW diff --git a/Triangulation_3/demo/Triangulation_3_Geomview_demos/data/points b/Triangulation_3/demo/Triangulation_3_Geomview_demos/data/points deleted file mode 100644 index b50bfb6eee4..00000000000 --- a/Triangulation_3/demo/Triangulation_3_Geomview_demos/data/points +++ /dev/null @@ -1,7 +0,0 @@ -0 0 0 -1 0 0 -0 1 0 -0 0 1 -2 2 2 --1 0 1 - diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h index aaa27b22d4e..70a2830c48c 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h @@ -1720,12 +1720,6 @@ is_valid(Cell_handle c, bool verbose = false) const; /*! \name I/O -\cgal provides an interface to Geomview for a 3D-triangulation, -see Chapter \ref Chapter_Geomview on `Geomview_stream`. - -\code -#include -\endcode The information in the `iostream` is: the dimension, the number of finite vertices, the non-combinatorial information about vertices diff --git a/Triangulation_3/doc/Triangulation_3/dependencies b/Triangulation_3/doc/Triangulation_3/dependencies index 90cf16912e5..ab8f6c69aa5 100644 --- a/Triangulation_3/doc/Triangulation_3/dependencies +++ b/Triangulation_3/doc/Triangulation_3/dependencies @@ -8,5 +8,4 @@ Spatial_sorting Stream_support Triangulation_2 TDS_3 -Geomview BGL diff --git a/Triangulation_3/examples/Triangulation_3/copy_triangulation_3.cpp b/Triangulation_3/examples/Triangulation_3/copy_triangulation_3.cpp index 2915dc1ef6c..ab7e2c42458 100644 --- a/Triangulation_3/examples/Triangulation_3/copy_triangulation_3.cpp +++ b/Triangulation_3/examples/Triangulation_3/copy_triangulation_3.cpp @@ -3,6 +3,7 @@ #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel EPIC; typedef CGAL::Exact_predicates_exact_constructions_kernel EPEC; @@ -43,5 +44,5 @@ int main() dt3_epec.set_infinite_vertex( dt3_epec.tds().copy_tds( dt3_epic.tds(),dt3_epic.infinite_vertex(), Convert_vertex(), Convert_cell() ) ); - CGAL_assertion( dt3_epec.is_valid() ); + assert( dt3_epec.is_valid() ); } diff --git a/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator.cpp b/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator.cpp index 0b9c8a44100..8e089f0c368 100644 --- a/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator.cpp +++ b/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator.cpp @@ -26,8 +26,6 @@ int main() Delaunay T( points.begin(),points.end() ); - CGAL_assertion( T.number_of_vertices() == 6 ); - // check that the info was correctly set. for (Delaunay::Vertex_handle v : T.finite_vertex_handles()) if( points[ v->info() ].first != v->point() ){ diff --git a/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator_regular.cpp b/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator_regular.cpp index 63d68a3e20a..ec51d80a277 100644 --- a/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator_regular.cpp +++ b/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator_regular.cpp @@ -26,8 +26,6 @@ int main() Regular rt( points.begin(),points.end() ); - CGAL_assertion( rt.number_of_vertices() == 6 ); - // check that the info was correctly set. for (Regular::Vertex_handle v : rt.finite_vertex_handles()) if( points[ v->info() ].first != v->point() ){ diff --git a/Triangulation_3/examples/Triangulation_3/info_insert_with_transform_iterator.cpp b/Triangulation_3/examples/Triangulation_3/info_insert_with_transform_iterator.cpp index b28d792f3d4..9c673471bc9 100644 --- a/Triangulation_3/examples/Triangulation_3/info_insert_with_transform_iterator.cpp +++ b/Triangulation_3/examples/Triangulation_3/info_insert_with_transform_iterator.cpp @@ -38,8 +38,6 @@ int main() Delaunay T( boost::make_transform_iterator(points.begin(),Auto_count()), boost::make_transform_iterator(points.end(), Auto_count() ) ); - CGAL_assertion( T.number_of_vertices() == 6 ); - // check that the info was correctly set. for (Delaunay::Vertex_handle v : T.finite_vertex_handles()) if( points[ v->info() ] != v->point() ){ diff --git a/Triangulation_3/examples/Triangulation_3/info_insert_with_zip_iterator.cpp b/Triangulation_3/examples/Triangulation_3/info_insert_with_zip_iterator.cpp index bf3a5988f30..ba8eb60b2f8 100644 --- a/Triangulation_3/examples/Triangulation_3/info_insert_with_zip_iterator.cpp +++ b/Triangulation_3/examples/Triangulation_3/info_insert_with_zip_iterator.cpp @@ -37,8 +37,6 @@ int main() Delaunay T( boost::make_zip_iterator(boost::make_tuple( points.begin(),indices.begin() )), boost::make_zip_iterator(boost::make_tuple( points.end(),indices.end() ) ) ); - CGAL_assertion( T.number_of_vertices() == 6 ); - // check that the info was correctly set. for (Delaunay::Vertex_handle v : T.finite_vertex_handles() ) if( points[ v->info() ] != v->point() ){ diff --git a/Triangulation_3/include/CGAL/IO/Triangulation_geomview_ostream_3.h b/Triangulation_3/include/CGAL/IO/Triangulation_geomview_ostream_3.h deleted file mode 100644 index 655143e76a7..00000000000 --- a/Triangulation_3/include/CGAL/IO/Triangulation_geomview_ostream_3.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2000 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) : Sylvain Pion - -#ifndef CGAL_IO_TRIANGULATION_GEOMVIEW_OSTREAM_3_H -#define CGAL_IO_TRIANGULATION_GEOMVIEW_OSTREAM_3_H - -#include - - -#include -#include - -// TODO : -// - Check the correctness when dimension < 3. -// - Use the stream color instead of built-in constant/random. -// - If interfaces were more similar, we could think of sharing 2d and 3d ? - -namespace CGAL { - -// This one is to show the edges of a 3D triangulation. -template < class GT, class TDS > -void -show_triangulation_edges(Geomview_stream &gv, const Triangulation_3 &T) -{ - // Header. - gv.set_ascii_mode(); - gv << "(geometry " << gv.get_new_id("triangulationedge") - << " {appearance {}{ SKEL \n" - << T.number_of_vertices() << T.number_of_finite_edges() << "\n"; - - // Finite vertices coordinates. - std::map::Vertex_handle, int> V; - int inum = 0; - for( typename Triangulation_3::Finite_vertices_iterator - vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) { - V[vit] = inum++; - gv << vit->point() << "\n"; - } - - // Finite edges indices. - for( typename Triangulation_3::Finite_edges_iterator - eit = T.finite_edges_begin(); eit != T.finite_edges_end(); ++eit) { - gv << 2 - << V[(*eit).first->vertex((*eit).second)] - << V[(*eit).first->vertex((*eit).third)] - << "\n"; // without color. - // << 4 << drand48() << drand48() << drand48() << 1.0; // random color. - } -} - -template < class GT, class TDS > -Geomview_stream& -operator<<( Geomview_stream &gv, const Triangulation_3 &T) -{ - if (gv.get_wired()) { - // We draw the edges. - bool ascii_bak = gv.get_ascii_mode(); - bool raw_bak = gv.set_raw(true); - - show_triangulation_edges(gv, T); - - // Footer. - gv << "}})"; - - gv.set_raw(raw_bak); - gv.set_ascii_mode(ascii_bak); - } - else { - // We draw the facets. - std::vector triangles; - - for (typename Triangulation_3::Finite_facets_iterator - fit = T.finite_facets_begin(); fit != T.finite_facets_end(); - ++fit) - triangles.push_back(T.triangle(*fit)); - - gv.draw_triangles(triangles.begin(), triangles.end()); - } - return gv; -} - -} //namespace CGAL - -#endif // CGAL_IO_TRIANGULATION_GEOMVIEW_OSTREAM_3_H diff --git a/Triangulation_3/test/Triangulation_3/test_Triangulation_with_transform_iterator.cpp b/Triangulation_3/test/Triangulation_3/test_Triangulation_with_transform_iterator.cpp index e39c87c2408..be15a44fd76 100644 --- a/Triangulation_3/test/Triangulation_3/test_Triangulation_with_transform_iterator.cpp +++ b/Triangulation_3/test/Triangulation_3/test_Triangulation_with_transform_iterator.cpp @@ -5,6 +5,7 @@ #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Triangulation_vertex_base_with_info_3 Vb; @@ -37,7 +38,7 @@ int main() Triangulation T( boost::make_transform_iterator(points.begin(),Auto_count()), boost::make_transform_iterator(points.end(), Auto_count() ) ); - CGAL_assertion( T.number_of_vertices() == 6 ); + assert( T.number_of_vertices() == 6 ); // check that the info was correctly set. Triangulation::Finite_vertices_iterator vit; diff --git a/Triangulation_3/test/Triangulation_3/test_Triangulation_with_zip_iterator.cpp b/Triangulation_3/test/Triangulation_3/test_Triangulation_with_zip_iterator.cpp index 06479948507..c0bb6abba75 100644 --- a/Triangulation_3/test/Triangulation_3/test_Triangulation_with_zip_iterator.cpp +++ b/Triangulation_3/test/Triangulation_3/test_Triangulation_with_zip_iterator.cpp @@ -7,6 +7,7 @@ #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Triangulation_vertex_base_with_info_3 Vb; @@ -36,7 +37,7 @@ int main() Triangulation T(boost::make_zip_iterator(boost::make_tuple( points.begin(),indices.begin() )), boost::make_zip_iterator(boost::make_tuple( points.end(),indices.end() ) ) ); - CGAL_assertion( T.number_of_vertices() == 6 ); + assert( T.number_of_vertices() == 6 ); // check that the info was correctly set. Triangulation::Finite_vertices_iterator vit; diff --git a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2/IO/OFF.h b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2/IO/OFF.h index b939db6e843..fb5ba3d6605 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2/IO/OFF.h +++ b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2/IO/OFF.h @@ -16,7 +16,7 @@ #include -#include +#include #include #include @@ -24,12 +24,6 @@ #include #include -#ifdef DOXYGEN_RUNNING -#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters -#define CGAL_BGL_NP_CLASS NamedParameters -#define CGAL_DEPRECATED -#endif - namespace CGAL { template @@ -68,10 +62,10 @@ namespace IO { \return `true` if the writing was successful, `false` otherwise. */ -template +template bool write_OFF(std::ostream& os, const CGAL::Triangulation_on_sphere_2& dt, - const CGAL_BGL_NP_CLASS& np) + const NamedParameters& np = parameters::default_values()) { typedef Triangulation_on_sphere_2 Tr; typedef typename Tr::Vertex_handle Vertex_handle; @@ -136,16 +130,6 @@ bool write_OFF(std::ostream& os, return !os.fail(); } -/// \cond SKIP_IN_MANUAL - -template -bool write_OFF(std::ostream& os, const CGAL::Triangulation_on_sphere_2& dt) -{ - return write_OFF(os, dt, parameters::all_default()); -} - -/// \endcond - /*! \ingroup PkgPointSet3IOOFF @@ -169,26 +153,15 @@ bool write_OFF(std::ostream& os, const CGAL::Triangulation_on_sphere_2& \return `true` if the writing was successful, `false` otherwise. */ -template +template bool write_OFF(const std::string& fname, const CGAL::Triangulation_on_sphere_2& dt, - const CGAL_BGL_NP_CLASS& np) + const NamedParameters& np = parameters::default_values()) { std::ofstream os(fname); // stream precision will be set in the ostream overload return write_OFF(os, dt, np); } -/// \cond SKIP_IN_MANUAL - -template -bool write_OFF(const std::string& fname, const CGAL::Triangulation_on_sphere_2& dt) -{ - std::ofstream os(fname); - return write_OFF(os, dt, parameters::all_default()); -} - -/// \endcond - } } // namespace CGAL::IO #endif // CGAL_TOS2_IO_OFF_H diff --git a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/test_dtos_traits.cpp b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/test_dtos_traits.cpp index a6a0d02ced8..b39f08587c4 100644 --- a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/test_dtos_traits.cpp +++ b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/test_dtos_traits.cpp @@ -74,7 +74,7 @@ int main(int, char**) // result = traits.power_test_2_object()(P2, P1, P10); // assert(result == CGAL::ON_NEGATIVE_SIDE); - // power_test_2(p,q) where p, q, and the center of the sphere are colinear + // power_test_2(p,q) where p, q, and the center of the sphere are collinear // result = traits.power_test_2_object()(P1, P7); // assert(result == CGAL::ON_POSITIVE_SIDE); // result = traits.power_test_2_object()(P1, P1); @@ -101,7 +101,7 @@ int main(int, char**) // result = traits_6.power_test_2_object()(P14, P1, P11); // assert(result == CGAL::ON_NEGATIVE_SIDE); - // power_test_2(p,q) where p, q and sphere are colinear + // power_test_2(p,q) where p, q and sphere are collinear // result = traits_6.power_test_2_object()(P13, P0); // assert(result == CGAL::ON_POSITIVE_SIDE); // result = traits_6.power_test_2_object()(P13, P13); diff --git a/Visibility_2/include/CGAL/Rotational_sweep_visibility_2.h b/Visibility_2/include/CGAL/Rotational_sweep_visibility_2.h index 2ee98969576..fd7bfd719a8 100644 --- a/Visibility_2/include/CGAL/Rotational_sweep_visibility_2.h +++ b/Visibility_2/include/CGAL/Rotational_sweep_visibility_2.h @@ -22,7 +22,6 @@ #include #include #include -#include #include diff --git a/Voronoi_diagram_2/test/Voronoi_diagram_2/include/vda_test_vda.h b/Voronoi_diagram_2/test/Voronoi_diagram_2/include/vda_test_vda.h index 877f0fa117b..2b2974ae273 100644 --- a/Voronoi_diagram_2/test/Voronoi_diagram_2/include/vda_test_vda.h +++ b/Voronoi_diagram_2/test/Voronoi_diagram_2/include/vda_test_vda.h @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include "helper_functions.h" #include @@ -499,15 +501,15 @@ void test_vda(const VDA& vda) #ifndef VDA_TEST_RT // testing file I/O - std::ofstream ofs("tmp.vd.cgal"); - assert( ofs ); - ofs << vda; - ofs.close(); + std::ostringstream oss; + oss << vda; + oss.flush(); - std::ifstream ifs("tmp.vd.cgal"); - assert( ifs ); - ifs >> vda_copy; - ifs.close(); + std::string input = oss.str(); + + std::istringstream iss(input); + + iss >> vda_copy; assert( vda_copy.number_of_vertices() == nv ); assert( vda_copy.number_of_halfedges() == ne ); diff --git a/Voronoi_diagram_2/test/Voronoi_diagram_2/vda_tos2.cpp b/Voronoi_diagram_2/test/Voronoi_diagram_2/vda_tos2.cpp index 18dd6ec5700..bbe4f086b4c 100644 --- a/Voronoi_diagram_2/test/Voronoi_diagram_2/vda_tos2.cpp +++ b/Voronoi_diagram_2/test/Voronoi_diagram_2/vda_tos2.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -170,6 +171,10 @@ int main(int argc, char** argv) std::cout << vd.number_of_faces() << " faces" << std::endl; std::cout << "dimension = " << vd.dual().dimension() << std::endl; + // redirect std::cout to cout_output + std::stringstream cout_output; + std::streambuf* old_cout_buf = std::cout.rdbuf(cout_output.rdbuf()); + VD::Vertex_iterator vit = vd.vertices_begin(), vend = vd.vertices_end(); for(; vit!=vend; ++vit) { @@ -197,5 +202,29 @@ int main(int argc, char** argv) CGAL_USE(opposite_h); } + // now restore std::cout and display the output + std::cout.rdbuf(old_cout_buf); + const auto output = cout_output.str(); + const auto str_size = output.size(); + const auto str_begin = output.data(); + const auto str_end = str_begin + str_size; + constexpr auto nb = static_cast>(10000); + auto pos1 = str_begin + (std::min)(nb, str_size); + assert(pos1 <= str_end); + const auto pos2 = str_end - (std::min)(nb, str_size); + assert(pos2 >= str_begin); + if (pos2 <= pos1) { + pos1 = str_end; + } + std::cout << "NOW THE FIRST AND LAST 10k CHARACTERS OF THE COUT OUTPUT:\n"; + std::cout << "-----\n" << std::string(str_begin, pos1) << "\n-----\n"; + if (pos1 != str_end) { + std::cout << "[...]\n-----\n" << std::string(pos2, str_end) << "\n-----\n"; + } + const auto file_name = "vda_tos2_test_output.txt"; + std::ofstream file_output(file_name); + file_output << output; + std::cout << "Full log is output to " << file_name << "\n"; + return EXIT_SUCCESS; } diff --git a/Weights/test/Weights/include/utils.h b/Weights/test/Weights/include/utils.h index bfbc8d78086..89b9beb0911 100644 --- a/Weights/test/Weights/include/utils.h +++ b/Weights/test/Weights/include/utils.h @@ -124,20 +124,20 @@ bool test_query( const auto a2 = wrapper.weight_a(t2, r2, p2, q2); const auto b2 = wrapper.weight_b(t2, r2, p2, q2); - CGAL_assertion(a2 >= FT(0) && b2 >= FT(0)); + assert(a2 >= FT(0) && b2 >= FT(0)); if (a2 < FT(0) || b2 < FT(0)) return false; - CGAL_assertion(CGAL::abs(a2 - b2) < tol); + assert(CGAL::abs(a2 - b2) < tol); if (CGAL::abs(a2 - b2) >= tol) return false; if (wrapper.supports_3d()) { const auto a3 = wrapper.weight_a(t3, r3, p3, q3); const auto b3 = wrapper.weight_b(t3, r3, p3, q3); - CGAL_assertion(a3 >= FT(0) && b3 >= FT(0)); + assert(a3 >= FT(0) && b3 >= FT(0)); if (a3 < FT(0) || b3 < FT(0)) return false; - CGAL_assertion(CGAL::abs(a3 - b3) < tol); + assert(CGAL::abs(a3 - b3) < tol); if (CGAL::abs(a3 - b3) >= tol) return false; - CGAL_assertion(CGAL::abs(a2 - a3) < tol); - CGAL_assertion(CGAL::abs(b2 - b3) < tol); + assert(CGAL::abs(a2 - a3) < tol); + assert(CGAL::abs(b2 - b3) < tol); if (CGAL::abs(a2 - a3) >= tol) return false; if (CGAL::abs(b2 - b3) >= tol) return false; } @@ -169,20 +169,20 @@ bool test_symmetry_x( const auto a2 = wrapper.weight_a(t2, r2, p2, Point_2(-x, 0)); const auto b2 = wrapper.weight_a(t2, r2, p2, Point_2(+x, 0)); - CGAL_assertion(a2 >= FT(0) && b2 >= FT(0)); + assert(a2 >= FT(0) && b2 >= FT(0)); if (a2 < FT(0) || b2 < FT(0)) return false; - CGAL_assertion(CGAL::abs(a2 - b2) < tol); + assert(CGAL::abs(a2 - b2) < tol); if (CGAL::abs(a2 - b2) >= tol) return false; if (wrapper.supports_3d()) { const auto a3 = wrapper.weight_a(t3, r3, p3, Point_3(-x, 0, 1)); const auto b3 = wrapper.weight_a(t3, r3, p3, Point_3(+x, 0, 1)); - CGAL_assertion(a3 >= FT(0) && b3 >= FT(0)); + assert(a3 >= FT(0) && b3 >= FT(0)); if (a3 < FT(0) || b3 < FT(0)) return false; - CGAL_assertion(CGAL::abs(a3 - b3) < tol); + assert(CGAL::abs(a3 - b3) < tol); if (CGAL::abs(a3 - b3) >= tol) return false; - CGAL_assertion(CGAL::abs(a2 - a3) < tol); - CGAL_assertion(CGAL::abs(b2 - b3) < tol); + assert(CGAL::abs(a2 - a3) < tol); + assert(CGAL::abs(b2 - b3) < tol); if (CGAL::abs(a2 - a3) >= tol) return false; if (CGAL::abs(b2 - b3) >= tol) return false; } @@ -218,17 +218,17 @@ bool test_compare( const auto a2 = wrapper1.weight_a(t2, r2, p2, q2); const auto b2 = wrapper2.weight_a(t2, r2, p2, q2); - CGAL_assertion(a2 >= FT(0) && b2 >= FT(0)); + assert(a2 >= FT(0) && b2 >= FT(0)); if (a2 < FT(0) || b2 < FT(0)) return false; - CGAL_assertion(CGAL::abs(a2 - b2) < tol); + assert(CGAL::abs(a2 - b2) < tol); if (CGAL::abs(a2 - b2) >= tol) return false; if (wrapper1.supports_3d() && wrapper2.supports_3d()) { const auto a3 = wrapper1.weight_a(t3, r3, p3, q3); const auto b3 = wrapper2.weight_a(t3, r3, p3, q3); - CGAL_assertion(a3 >= FT(0) && b3 >= FT(0)); + assert(a3 >= FT(0) && b3 >= FT(0)); if (a3 < FT(0) || b3 < FT(0)) return false; - CGAL_assertion(CGAL::abs(a3 - b3) < tol); + assert(CGAL::abs(a3 - b3) < tol); if (CGAL::abs(a3 - b3) >= tol) return false; } return true; @@ -258,9 +258,9 @@ bool test_neighbors( const auto a2 = wrapper.weight(p2, q2, r2); const auto a3 = wrapper.weight(p3, q3, r3); - CGAL_assertion(a2 >= FT(0) && a3 >= FT(0)); + assert(a2 >= FT(0) && a3 >= FT(0)); if (a2 < FT(0) || a3 < FT(0)) return false; - CGAL_assertion(CGAL::abs(a2 - a3) < tol); + assert(CGAL::abs(a2 - a3) < tol); if (CGAL::abs(a2 - a3) >= tol) return false; return true; } @@ -288,12 +288,12 @@ bool test_area( const auto a2 = wrapper.weight(p2, q2, r2); const auto a3 = wrapper.weight(p3, q3, r3); - CGAL_assertion(a2 <= CGAL::Weights::area(p2, q2, r2)); - CGAL_assertion(a3 <= CGAL::Weights::area(p3, q3, r3)); + assert(a2 <= CGAL::Weights::area(p2, q2, r2)); + assert(a3 <= CGAL::Weights::area(p3, q3, r3)); if (a2 > CGAL::Weights::area(p2, q2, r2)) return false; if (a3 > CGAL::Weights::area(p3, q3, r3)) return false; - CGAL_assertion(a2 >= FT(0)); - CGAL_assertion(a3 >= FT(0)); + assert(a2 >= FT(0)); + assert(a3 >= FT(0)); if (a2 < FT(0)) return false; if (a3 < FT(0)) return false; return true; @@ -305,7 +305,7 @@ bool test_coordinates( const std::vector& polygon, const std::vector& weights) { - CGAL_assertion(weights.size() > 0); + assert(weights.size() > 0); if (weights.size() == 0) return false; // Compute the sum of weights. @@ -314,7 +314,7 @@ bool test_coordinates( for (const FT& weight : weights) { sum += weight; } - CGAL_assertion(sum >= tol); + assert(sum >= tol); if (sum < tol) return false; // Compute coordinates. @@ -323,7 +323,7 @@ bool test_coordinates( for (const FT& weight : weights) { coordinates.push_back(weight / sum); } - CGAL_assertion(coordinates.size() == weights.size()); + assert(coordinates.size() == weights.size()); if (coordinates.size() != weights.size()) return false; // Test partition of unity. @@ -331,7 +331,7 @@ bool test_coordinates( for (const FT& coordinate : coordinates) { sum += coordinate; } - CGAL_assertion(CGAL::abs(FT(1) - sum) < tol); + assert(CGAL::abs(FT(1) - sum) < tol); if (CGAL::abs(FT(1) - sum) >= tol) return false; // Test linear precision. @@ -340,8 +340,8 @@ bool test_coordinates( x += coordinates[i] * polygon[i].x(); y += coordinates[i] * polygon[i].y(); } - CGAL_assertion(CGAL::abs(query.x() - x) < tol); - CGAL_assertion(CGAL::abs(query.y() - y) < tol); + assert(CGAL::abs(query.x() - x) < tol); + assert(CGAL::abs(query.y() - y) < tol); if (CGAL::abs(query.x() - x) >= tol) return false; if (CGAL::abs(query.y() - y) >= tol) return false; return true; @@ -357,7 +357,7 @@ bool test_on_polygon( // Get weights. using FT = typename Kernel::FT; - CGAL_assertion(polygon_2.size() >= 3); + assert(polygon_2.size() >= 3); if (polygon_2.size() < 3) return false; // 2D version. @@ -365,7 +365,7 @@ bool test_on_polygon( weights_2.reserve(polygon_2.size()); wrapper.compute_on_polygon( polygon_2, query_2, Kernel(), std::back_inserter(weights_2)); - CGAL_assertion(weights_2.size() == polygon_2.size()); + assert(weights_2.size() == polygon_2.size()); if (weights_2.size() != polygon_2.size()) return false; if (!test_coordinates(query_2, polygon_2, weights_2)) return false; @@ -377,7 +377,7 @@ bool test_on_polygon( for (const auto& vertex_2 : polygon_2) { polygon_3.push_back(Point_3(vertex_2.x(), vertex_2.y(), 1)); } - CGAL_assertion(polygon_3.size() == polygon_2.size()); + assert(polygon_3.size() == polygon_2.size()); if (polygon_3.size() != polygon_2.size()) return false; const CGAL::Projection_traits_xy_3 ptraits; @@ -385,7 +385,7 @@ bool test_on_polygon( weights_3.reserve(polygon_3.size()); wrapper.compute_on_polygon( polygon_3, query_3, ptraits, std::back_inserter(weights_3)); - CGAL_assertion(weights_3.size() == polygon_3.size()); + assert(weights_3.size() == polygon_3.size()); if (weights_3.size() != polygon_3.size()) return false; if (!test_coordinates(query_3, polygon_3, weights_3)) return false; return true; @@ -402,7 +402,7 @@ bool test_barycentric_properties( // Get weights. using FT = typename Kernel::FT; const std::size_t n = polygon.size(); - CGAL_assertion(n >= 3); + assert(n >= 3); if (n < 3) return false; // Check properties. @@ -418,7 +418,7 @@ bool test_barycentric_properties( const FT weight = wrapper.weight_a(t, r, p, q); weights.push_back(weight); } - CGAL_assertion(weights.size() == n); + assert(weights.size() == n); if (weights.size() != n) return false; if (!test_coordinates(query, polygon, weights)) return false; return true;